Skip to content

Commit

Permalink
fix: update record time color while theme change
Browse files Browse the repository at this point in the history
As title.

Log: Update record time color while theme change
  • Loading branch information
rb-union authored and deepin-bot[bot] committed Dec 17, 2024
1 parent d84a27e commit c88985a
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/dde-dock-plugins/recordtime/timewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,19 @@ TimeWidget::TimeWidget(DWidget *parent):

m_textLabel->setFont(RECORDER_TIME_FONT);
m_textLabel->setText("00:00:00");
QPalette textPalette = m_textLabel->palette();
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) {
textPalette.setColor(QPalette::WindowText, Qt::black);
}else{
textPalette.setColor(QPalette::WindowText, Qt::white);
}
m_textLabel->setPalette(textPalette);

auto updatePalette = [this](){
QPalette textPalette = m_textLabel->palette();
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) {
textPalette.setColor(QPalette::WindowText, Qt::black);
}else{
textPalette.setColor(QPalette::WindowText, Qt::white);
}
m_textLabel->setPalette(textPalette);
};
updatePalette();
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, updatePalette);

m_textLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);

m_timer = new QTimer(this);
Expand Down

0 comments on commit c88985a

Please sign in to comment.