Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrong volume button palette #507

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 9 additions & 23 deletions src/widgets/toolbox_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1495,8 +1495,12 @@ void ToolboxProxy::slotThemeTypeChanged()
// 取消阴影
pa.setColor(DPalette::Shadow, btnframecolor);
DApplicationHelper::instance()->setPalette(m_pFullScreenBtn, pa);
DApplicationHelper::instance()->setPalette(m_pVolBtn, pa);
DApplicationHelper::instance()->setPalette(m_pListBtn, pa);

// 音量按钮取消边框背景
pa.setColor(DPalette::Light, QColor(Qt::transparent));
pa.setColor(DPalette::Dark, QColor(Qt::transparent));
DApplicationHelper::instance()->setPalette(m_pVolBtn, pa);
} else {
textPalette.setColor(QPalette::WindowText, QColor(255, 255, 255, 40)); // 深色背景下时长显示置灰
textPalette.setColor(QPalette::Text, QColor(255, 255, 255, 40));
Expand All @@ -1516,8 +1520,11 @@ void ToolboxProxy::slotThemeTypeChanged()
// 取消阴影
pa.setColor(DPalette::Shadow, framecolor);
DApplicationHelper::instance()->setPalette(m_pFullScreenBtn, pa);
DApplicationHelper::instance()->setPalette(m_pVolBtn, pa);
DApplicationHelper::instance()->setPalette(m_pListBtn, pa);

pa.setColor(DPalette::Light, QColor(Qt::transparent));
pa.setColor(DPalette::Dark, QColor(Qt::transparent));
DApplicationHelper::instance()->setPalette(m_pVolBtn, pa);
}

if(m_pEngine->state() != PlayerEngine::CoreState::Idle) {
Expand Down Expand Up @@ -2060,11 +2067,6 @@ void ToolboxProxy::updatePlayState()
if (DGuiApplicationHelper::LightType == DGuiApplicationHelper::instance()->themeType()) {
DPalette pa;

pa = m_pVolBtn->palette();
pa.setColor(DPalette::Light, QColor(255, 255, 255, 255));
pa.setColor(DPalette::Dark, QColor(255, 255, 255, 255));
m_pVolBtn->setPalette(pa);

pa = m_pFullScreenBtn->palette();
pa.setColor(DPalette::Light, QColor(255, 255, 255, 255));
pa.setColor(DPalette::Dark, QColor(255, 255, 255, 255));
Expand All @@ -2083,11 +2085,6 @@ void ToolboxProxy::updatePlayState()
} else {
DPalette pa;

pa = m_pVolBtn->palette();
pa.setColor(DPalette::Light, QColor(0, 0, 0, 255));
pa.setColor(DPalette::Dark, QColor(0, 0, 0, 255));
m_pVolBtn->setPalette(pa);

pa = m_pFullScreenBtn->palette();
pa.setColor(DPalette::Light, QColor(0, 0, 0, 255));
pa.setColor(DPalette::Dark, QColor(0, 0, 0, 255));
Expand All @@ -2114,12 +2111,6 @@ void ToolboxProxy::updatePlayState()
if (DGuiApplicationHelper::LightType == DGuiApplicationHelper::instance()->themeType()) {
DPalette pa;


pa = m_pVolBtn->palette();
pa.setColor(DPalette::Light, QColor(255, 255, 255, 255));
pa.setColor(DPalette::Dark, QColor(255, 255, 255, 255));
m_pVolBtn->setPalette(pa);

pa = m_pFullScreenBtn->palette();
pa.setColor(DPalette::Light, QColor(255, 255, 255, 255));
pa.setColor(DPalette::Dark, QColor(255, 255, 255, 255));
Expand All @@ -2138,11 +2129,6 @@ void ToolboxProxy::updatePlayState()
} else {
DPalette pa;

pa = m_pVolBtn->palette();
pa.setColor(DPalette::Light, QColor(0, 0, 0, 255));
pa.setColor(DPalette::Dark, QColor(0, 0, 0, 255));
m_pVolBtn->setPalette(pa);

pa = m_pFullScreenBtn->palette();
pa.setColor(DPalette::Light, QColor(0, 0, 0, 255));
pa.setColor(DPalette::Dark, QColor(0, 0, 0, 255));
Expand Down
11 changes: 5 additions & 6 deletions src/widgets/toolbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace dmr {
VolumeButton::VolumeButton(QWidget *parent)
: QPushButton(parent), m_nVolume(100), m_bMute(false)
{
setFlat(true);
setIconSize(QSize(36, 36));
setIcon(QIcon::fromTheme("dcc_volume"));
installEventFilter(this);
}
Expand Down Expand Up @@ -46,6 +48,9 @@ void VolumeButton::setIcon(const QIcon &icon)
{
if (!icon.isNull()) {
m_icon = icon;

// 使用 PushButon 绘制图标
QPushButton::setIcon(m_icon);
}
}

Expand Down Expand Up @@ -77,12 +82,6 @@ void VolumeButton::leaveEvent(QEvent *ev)
QPushButton::leaveEvent(ev);
}

void VolumeButton::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.drawPixmap(rect(), m_icon.pixmap(rect().size()));
}

void VolumeButton::wheelEvent(QWheelEvent *we)
{
//qInfo() << we->angleDelta() << we->modifiers() << we->buttons();
Expand Down
1 change: 0 additions & 1 deletion src/widgets/toolbutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ class VolumeButton: public QPushButton
protected:
void enterEvent(QEvent *ev) override;
void leaveEvent(QEvent *ev) override;
void paintEvent(QPaintEvent *) override;
void wheelEvent(QWheelEvent *wev) override;
void focusOutEvent(QFocusEvent *ev) override;
bool eventFilter(QObject *obj, QEvent *e) override;
Expand Down
Loading