mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
fix: 修复任务栏适应不同的主题
1、不同的主题变化的时候,音乐播放,声音调节和亮度调整面板颜色发生变化 2、切换任务栏的位置,弹出窗口的箭头方向显示正确 Log: 任务栏插件适配不同的主题 Influence: 从控制中心修改主题颜色,观察任务栏快捷面板的主题颜色是否发生变化 Bug: https://pms.uniontech.com/bug-view-179377.html Change-Id: Ic77858124d55dce149d8bd78fb8831038caed265
This commit is contained in:
parent
c6b2257f15
commit
b337d88dd4
@ -136,6 +136,20 @@ void QuickPluginWindow::setPositon(Position position)
|
||||
} else {
|
||||
m_mainLayout->setDirection(QBoxLayout::BottomToTop);
|
||||
}
|
||||
switch(m_position) {
|
||||
case Dock::Position::Top:
|
||||
getPopWindow()->setArrowDirection(DArrowRectangle::ArrowDirection::ArrowTop);
|
||||
break;
|
||||
case Dock::Position::Right:
|
||||
getPopWindow()->setArrowDirection(DArrowRectangle::ArrowDirection::ArrowRight);
|
||||
break;
|
||||
case Dock::Position::Bottom:
|
||||
getPopWindow()->setArrowDirection(DArrowRectangle::ArrowDirection::ArrowBottom);
|
||||
break;
|
||||
case Dock::Position::Left:
|
||||
getPopWindow()->setArrowDirection(DArrowRectangle::ArrowDirection::ArrowLeft);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void QuickPluginWindow::dragPlugin(PluginsItemInterface *item)
|
||||
|
@ -23,12 +23,16 @@
|
||||
#include "imageutil.h"
|
||||
#include "slidercontainer.h"
|
||||
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
|
||||
#define BACKSIZE 36
|
||||
#define IMAGESIZE 18
|
||||
|
||||
DGUI_USE_NAMESPACE
|
||||
|
||||
BrightnessWidget::BrightnessWidget(BrightnessModel *model, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_sliderContainer(new SliderContainer(this))
|
||||
@ -55,11 +59,7 @@ void BrightnessWidget::initUi()
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout(this);
|
||||
mainLayout->setContentsMargins(15, 0, 12, 0);
|
||||
|
||||
QPixmap leftPixmap = ImageUtil::loadSvg(":/brightness.svg", QSize(IMAGESIZE, IMAGESIZE));
|
||||
QPixmap rightPixmap = ImageUtil::loadSvg(":/ICON_Device_Laptop.svg", QSize(IMAGESIZE, IMAGESIZE));
|
||||
m_sliderContainer->setIcon(SliderContainer::IconPosition::LeftIcon, leftPixmap, QSize(), 10);
|
||||
m_sliderContainer->setIcon(SliderContainer::IconPosition::RightIcon, rightPixmap, QSize(BACKSIZE, BACKSIZE), 12);
|
||||
|
||||
onThemeTypeChanged();
|
||||
// 需求要求调节范围是10%-100%,且调节幅度为1%
|
||||
m_sliderContainer->setRange(10, 100);
|
||||
m_sliderContainer->setPageStep(1);
|
||||
@ -83,6 +83,7 @@ void BrightnessWidget::initConnection()
|
||||
Q_EMIT brightClicked();
|
||||
});
|
||||
|
||||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &BrightnessWidget::onThemeTypeChanged);
|
||||
updateSliderValue();
|
||||
}
|
||||
|
||||
@ -93,3 +94,26 @@ void BrightnessWidget::updateSliderValue()
|
||||
m_sliderContainer->updateSliderValue(monitor->brightness());
|
||||
}
|
||||
}
|
||||
|
||||
void BrightnessWidget::convertThemePixmap(QPixmap &pixmap)
|
||||
{
|
||||
// 图片是黑色的,如果当前主题为白色主题,则无需转换
|
||||
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::LightType)
|
||||
return;
|
||||
|
||||
// 如果是黑色主题,则转换成白色图像
|
||||
QPainter painter(&pixmap);
|
||||
painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||
painter.fillRect(pixmap.rect(), Qt::white);
|
||||
painter.end();
|
||||
}
|
||||
|
||||
void BrightnessWidget::onThemeTypeChanged()
|
||||
{
|
||||
QPixmap leftPixmap = ImageUtil::loadSvg(":/brightness.svg", QSize(IMAGESIZE, IMAGESIZE));
|
||||
QPixmap rightPixmap = ImageUtil::loadSvg(":/ICON_Device_Laptop.svg", QSize(IMAGESIZE, IMAGESIZE));
|
||||
convertThemePixmap(leftPixmap);
|
||||
convertThemePixmap(rightPixmap);
|
||||
m_sliderContainer->setIcon(SliderContainer::IconPosition::LeftIcon, leftPixmap, QSize(), 10);
|
||||
m_sliderContainer->setIcon(SliderContainer::IconPosition::RightIcon, rightPixmap, QSize(BACKSIZE, BACKSIZE), 12);
|
||||
}
|
||||
|
@ -47,6 +47,10 @@ private:
|
||||
void initUi();
|
||||
void initConnection();
|
||||
void updateSliderValue();
|
||||
void convertThemePixmap(QPixmap &pixmap);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onThemeTypeChanged();
|
||||
|
||||
private:
|
||||
SliderContainer *m_sliderContainer;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "mediawidget.h"
|
||||
|
||||
#include <DFontSizeManager>
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
@ -31,6 +32,7 @@
|
||||
#include <QPainterPath>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
DGUI_USE_NAMESPACE
|
||||
|
||||
#define PAUSEHEIGHT 21
|
||||
#define PLAYHEIGHT 18
|
||||
@ -175,11 +177,12 @@ void MusicButton::paintEvent(QPaintEvent *event)
|
||||
int height = this->height();
|
||||
int startX = 2;
|
||||
int startY = (height - ctrlHeight) / 2;
|
||||
QColor color = DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::LightType ? Qt::black : Qt::white;
|
||||
QPainter painter(this);
|
||||
painter.save();
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setPen(Qt::black);
|
||||
painter.setBrush(Qt::black);
|
||||
painter.setPen(color);
|
||||
painter.setBrush(color);
|
||||
if (m_buttonType == ButtonType::Pause) {
|
||||
painter.drawRect(QRect(startX, startY, ICOMMARGIN, ctrlHeight));
|
||||
painter.drawRect(QRect(width - ICOMMARGIN - ICONSPACE, startY, ICOMMARGIN, ctrlHeight));
|
||||
|
@ -34,6 +34,7 @@ LineQuickItem::LineQuickItem(PluginsItemInterface *const pluginInter, const QStr
|
||||
, m_effectWidget(new DBlurEffectWidget(this))
|
||||
{
|
||||
initUi();
|
||||
initConnection();
|
||||
QMetaObject::invokeMethod(this, &LineQuickItem::resizeSelf, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
@ -70,11 +71,9 @@ bool LineQuickItem::eventFilter(QObject *obj, QEvent *event)
|
||||
|
||||
void LineQuickItem::initUi()
|
||||
{
|
||||
QColor maskColor(Qt::white);
|
||||
maskColor.setAlphaF(0.8);
|
||||
m_effectWidget->setMaskColor(maskColor);
|
||||
m_effectWidget->setBlurRectXRadius(8);
|
||||
m_effectWidget->setBlurRectYRadius(8);
|
||||
onThemeTypeChanged(DGuiApplicationHelper::instance()->themeType());
|
||||
|
||||
// 如果图标不为空
|
||||
if (!m_centerWidget)
|
||||
@ -95,6 +94,11 @@ void LineQuickItem::initUi()
|
||||
m_centerWidget->installEventFilter(this);
|
||||
}
|
||||
|
||||
void LineQuickItem::initConnection()
|
||||
{
|
||||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &LineQuickItem::onThemeTypeChanged);
|
||||
}
|
||||
|
||||
void LineQuickItem::resizeSelf()
|
||||
{
|
||||
if (!m_centerWidget)
|
||||
@ -103,3 +107,10 @@ void LineQuickItem::resizeSelf()
|
||||
m_effectWidget->setFixedHeight(m_centerWidget->height());
|
||||
setFixedHeight(m_centerWidget->height());
|
||||
}
|
||||
|
||||
void LineQuickItem::onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType)
|
||||
{
|
||||
QColor maskColor = themeType == DGuiApplicationHelper::ColorType::LightType ? Qt::white : Qt::black;
|
||||
maskColor.setAlphaF(themeType == DGuiApplicationHelper::ColorType::LightType ? 0.8 : 0.5);
|
||||
m_effectWidget->setMaskColor(maskColor);
|
||||
}
|
||||
|
@ -23,12 +23,16 @@
|
||||
|
||||
#include "quicksettingitem.h"
|
||||
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
namespace Dtk {
|
||||
namespace Widget {
|
||||
class DBlurEffectWidget;
|
||||
}
|
||||
}
|
||||
|
||||
DGUI_USE_NAMESPACE
|
||||
|
||||
// 插件在快捷面板中的展示的样式,这个为整行显示的插件,例如声音,亮度调整和音乐播放等
|
||||
class LineQuickItem : public QuickSettingItem
|
||||
{
|
||||
@ -47,8 +51,12 @@ protected:
|
||||
|
||||
private:
|
||||
void initUi();
|
||||
void initConnection();
|
||||
void resizeSelf();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType);
|
||||
|
||||
private:
|
||||
QWidget *m_centerWidget;
|
||||
QWidget *m_centerParentWidget;
|
||||
|
15
plugins/sound/resources/broadcast.svg
Normal file
15
plugins/sound/resources/broadcast.svg
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="18px" height="20px" viewBox="0 0 18 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>ICON / MenuItem / Broadcast</title>
|
||||
<g id="任务栏" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="任务栏-时尚" transform="translate(-993.000000, -844.000000)" fill="#000000" fill-rule="nonzero">
|
||||
<g id="UDE-/-ControlPanel" transform="translate(712.000000, 534.000000)">
|
||||
<g id="编组-4" transform="translate(10.000000, 290.000000)">
|
||||
<g id="形状结合" transform="translate(268.000000, 18.000000)">
|
||||
<path d="M12,14 L20,22 L4,22 L12,14 Z M12,2 C16.9705627,2 21,6.02943725 21,11 C21,13.8342485 19.6898859,16.3625035 17.642214,18.0122085 L16.8031599,17.146139 C18.6274776,15.7184347 19.8,13.496146 19.8,11 C19.8,6.69217895 16.307821,3.2 12,3.2 C7.69217895,3.2 4.2,6.69217895 4.2,11 C4.2,13.4965987 5.37294772,15.7192407 7.19783267,17.1469157 L6.35879863,18.0130242 C4.31054605,16.3633369 3,13.8347157 3,11 C3,6.02943725 7.02943725,2 12,2 Z M12,5 C15.3137085,5 18,7.6862915 18,11 C18,12.9892946 17.0318944,14.752476 15.541118,15.8441093 L14.6955445,14.9722251 C15.9657118,14.1086147 16.8,12.6517366 16.8,11 C16.8,8.3490332 14.6509668,6.2 12,6.2 C9.3490332,6.2 7.2,8.3490332 7.2,11 C7.2,12.652163 8.03471909,14.109367 9.30543941,14.9728939 L8.4598839,15.8448429 C6.96853942,14.753266 6,12.9897402 6,11 C6,7.6862915 8.6862915,5 12,5 Z M12,8 C13.6568542,8 15,9.34314575 15,11 C15,12.1468362 14.356487,13.1433719 13.4108513,13.6482168 L12,12.1937608 L10.5901445,13.6487482 C9.6439648,13.1440714 9,12.1472387 9,11 C9,9.34314575 10.3431458,8 12,8 Z"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.8 KiB |
@ -37,6 +37,7 @@
|
||||
#include <QEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMetaMethod>
|
||||
#include <QPainter>
|
||||
|
||||
DGUI_USE_NAMESPACE
|
||||
|
||||
@ -66,10 +67,7 @@ void SoundWidget::initUi()
|
||||
mainLayout->setContentsMargins(17, 0, 12, 0);
|
||||
mainLayout->addWidget(m_sliderContainer);
|
||||
|
||||
QPixmap leftPixmap = ImageUtil::loadSvg(leftIcon(), QSize(ICON_SIZE, ICON_SIZE));
|
||||
QPixmap rightPixmap = ImageUtil::loadSvg(rightIcon(), QSize(ICON_SIZE, ICON_SIZE));
|
||||
m_sliderContainer->setIcon(SliderContainer::IconPosition::LeftIcon, leftPixmap, QSize(), 10);
|
||||
m_sliderContainer->setIcon(SliderContainer::IconPosition::RightIcon, rightPixmap, QSize(BACKSIZE, BACKSIZE), 12);
|
||||
onThemeTypeChanged();
|
||||
m_sliderContainer->setRange(0, std::round(m_dbusAudio->maxUIVolume() * 100.00));
|
||||
m_sliderContainer->setPageStep(2);
|
||||
|
||||
@ -107,6 +105,8 @@ void SoundWidget::initConnection()
|
||||
m_sliderContainer->setIcon(SliderContainer::IconPosition::LeftIcon, QIcon(leftIcon()));
|
||||
});
|
||||
|
||||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &SoundWidget::onThemeTypeChanged);
|
||||
|
||||
connect(m_sliderContainer, &SliderContainer::iconClicked, this, [ this ](const SliderContainer::IconPosition icon) {
|
||||
switch (icon) {
|
||||
case SliderContainer::IconPosition::LeftIcon: {
|
||||
@ -126,10 +126,17 @@ void SoundWidget::initConnection()
|
||||
const QString SoundWidget::leftIcon()
|
||||
{
|
||||
const bool mute = existActiveOutputDevice() ? m_defaultSink->mute() : true;
|
||||
if (mute)
|
||||
return QString(":/icons/resources/audio-volume-muted-dark.svg");
|
||||
if (mute) {
|
||||
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::LightType)
|
||||
return QString(":/audio-volume-muted-symbolic-dark.svg");
|
||||
|
||||
return QString(":/icons/resources/volume.svg");
|
||||
return QString(":/audio-volume-muted-symbolic.svg");
|
||||
}
|
||||
|
||||
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::LightType)
|
||||
return QString(":/audio-volume-medium-symbolic-dark.svg");
|
||||
|
||||
return QString(":/audio-volume-medium-symbolic.svg");
|
||||
}
|
||||
|
||||
const QString SoundWidget::rightIcon()
|
||||
@ -137,6 +144,19 @@ const QString SoundWidget::rightIcon()
|
||||
return QString(":/icons/resources/broadcast.svg");
|
||||
}
|
||||
|
||||
void SoundWidget::convertThemePixmap(QPixmap &pixmap)
|
||||
{
|
||||
// 图片是黑色的,如果当前主题为白色主题,则无需转换
|
||||
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::LightType)
|
||||
return;
|
||||
|
||||
// 如果是黑色主题,则转换成白色图像
|
||||
QPainter painter(&pixmap);
|
||||
painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||
painter.fillRect(pixmap.rect(), Qt::white);
|
||||
painter.end();
|
||||
}
|
||||
|
||||
/** 判断是否存在未禁用的声音输出设备
|
||||
* @brief SoundApplet::existActiveOutputDevice
|
||||
* @return 存在返回true,否则返回false
|
||||
@ -160,3 +180,12 @@ bool SoundWidget::existActiveOutputDevice() const
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void SoundWidget::onThemeTypeChanged()
|
||||
{
|
||||
QPixmap leftPixmap = ImageUtil::loadSvg(leftIcon(), QSize(ICON_SIZE, ICON_SIZE));
|
||||
QPixmap rightPixmap = ImageUtil::loadSvg(rightIcon(), QSize(ICON_SIZE, ICON_SIZE));
|
||||
convertThemePixmap(rightPixmap);
|
||||
m_sliderContainer->setIcon(SliderContainer::IconPosition::LeftIcon, leftPixmap, QSize(), 10);
|
||||
m_sliderContainer->setIcon(SliderContainer::IconPosition::RightIcon, rightPixmap, QSize(BACKSIZE, BACKSIZE), 12);
|
||||
}
|
||||
|
@ -55,8 +55,12 @@ protected:
|
||||
private:
|
||||
const QString leftIcon();
|
||||
const QString rightIcon();
|
||||
void convertThemePixmap(QPixmap &pixmap);
|
||||
bool existActiveOutputDevice() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onThemeTypeChanged();
|
||||
|
||||
private:
|
||||
DBusAudio *m_dbusAudio;
|
||||
SliderContainer *m_sliderContainer;
|
||||
|
Loading…
x
Reference in New Issue
Block a user