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