mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
fix: tray background color not set alpha
as title
This commit is contained in:
parent
b2efe239b6
commit
430e92adbc
@ -16,10 +16,8 @@ LineQuickItem::LineQuickItem(PluginsItemInterface *const pluginInter, const QStr
|
|||||||
: QuickSettingItem(pluginInter, itemKey, parent)
|
: QuickSettingItem(pluginInter, itemKey, parent)
|
||||||
, m_centerWidget(pluginInter->itemWidget(QUICK_ITEM_KEY))
|
, m_centerWidget(pluginInter->itemWidget(QUICK_ITEM_KEY))
|
||||||
, m_centerParentWidget(nullptr)
|
, m_centerParentWidget(nullptr)
|
||||||
, m_effectWidget(new DBlurEffectWidget(this))
|
|
||||||
{
|
{
|
||||||
initUi();
|
initUi();
|
||||||
initConnection();
|
|
||||||
QMetaObject::invokeMethod(this, &LineQuickItem::resizeSelf, Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, &LineQuickItem::resizeSelf, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,10 +54,6 @@ bool LineQuickItem::eventFilter(QObject *obj, QEvent *event)
|
|||||||
|
|
||||||
void LineQuickItem::initUi()
|
void LineQuickItem::initUi()
|
||||||
{
|
{
|
||||||
m_effectWidget->setBlurRectXRadius(8);
|
|
||||||
m_effectWidget->setBlurRectYRadius(8);
|
|
||||||
onThemeTypeChanged(DGuiApplicationHelper::instance()->themeType());
|
|
||||||
|
|
||||||
// 如果图标不为空
|
// 如果图标不为空
|
||||||
if (!m_centerWidget)
|
if (!m_centerWidget)
|
||||||
return;
|
return;
|
||||||
@ -67,35 +61,22 @@ void LineQuickItem::initUi()
|
|||||||
m_centerWidget->setVisible(true);
|
m_centerWidget->setVisible(true);
|
||||||
m_centerParentWidget = m_centerWidget->parentWidget();
|
m_centerParentWidget = m_centerWidget->parentWidget();
|
||||||
|
|
||||||
QHBoxLayout *layout = new QHBoxLayout(m_effectWidget);
|
QHBoxLayout *layout = new QHBoxLayout;
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
layout->setAlignment(Qt::AlignHCenter);
|
layout->setAlignment(Qt::AlignHCenter);
|
||||||
layout->addWidget(m_centerWidget);
|
layout->addWidget(m_centerWidget);
|
||||||
|
|
||||||
QHBoxLayout *mainLayout = new QHBoxLayout(this);
|
QHBoxLayout *mainLayout = new QHBoxLayout(this);
|
||||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
mainLayout->addWidget(m_effectWidget);
|
mainLayout->addWidget(m_centerWidget);
|
||||||
|
|
||||||
m_centerWidget->installEventFilter(this);
|
m_centerWidget->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineQuickItem::initConnection()
|
|
||||||
{
|
|
||||||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &LineQuickItem::onThemeTypeChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LineQuickItem::resizeSelf()
|
void LineQuickItem::resizeSelf()
|
||||||
{
|
{
|
||||||
if (!m_centerWidget)
|
if (!m_centerWidget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_effectWidget->setFixedHeight(m_centerWidget->height());
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
@ -8,16 +8,6 @@
|
|||||||
|
|
||||||
#include "quicksettingitem.h"
|
#include "quicksettingitem.h"
|
||||||
|
|
||||||
#include <DGuiApplicationHelper>
|
|
||||||
|
|
||||||
namespace Dtk {
|
|
||||||
namespace Widget {
|
|
||||||
class DBlurEffectWidget;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DGUI_USE_NAMESPACE
|
|
||||||
|
|
||||||
// 插件在快捷面板中的展示的样式,这个为整行显示的插件,例如声音,亮度调整和音乐播放等
|
// 插件在快捷面板中的展示的样式,这个为整行显示的插件,例如声音,亮度调整和音乐播放等
|
||||||
class LineQuickItem : public QuickSettingItem
|
class LineQuickItem : public QuickSettingItem
|
||||||
{
|
{
|
||||||
@ -36,16 +26,11 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void initUi();
|
void initUi();
|
||||||
void initConnection();
|
|
||||||
void resizeSelf();
|
void resizeSelf();
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *m_centerWidget;
|
QWidget *m_centerWidget;
|
||||||
QWidget *m_centerParentWidget;
|
QWidget *m_centerParentWidget;
|
||||||
Dtk::Widget::DBlurEffectWidget *m_effectWidget;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FULLQUICKITEM_H
|
#endif // FULLQUICKITEM_H
|
||||||
|
@ -94,8 +94,8 @@ void QuickSettingItem::paintEvent(QPaintEvent *e)
|
|||||||
QColor backColor(Qt::white);
|
QColor backColor(Qt::white);
|
||||||
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::DarkType) {
|
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::DarkType) {
|
||||||
backColor = Qt::black;
|
backColor = Qt::black;
|
||||||
backColor.setAlphaF(0.5);
|
|
||||||
}
|
}
|
||||||
|
backColor.setAlphaF(0.5);
|
||||||
DPalette dpa = DPaletteHelper::instance()->palette(this);
|
DPalette dpa = DPaletteHelper::instance()->palette(this);
|
||||||
painter.fillRect(rect(), backColor);
|
painter.fillRect(rect(), backColor);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user