Skip to content

Commit

Permalink
Avoid use of deprecated signal QGuiApplication::paletteChanged
Browse files Browse the repository at this point in the history
Simply use `QEvent::PaletteChange` which is handled in the Qt Widgets GUI
and the Qt Quick GUI anyway. The Plasmoid doesn't need to be changed as it
passes a palette to the icon manager explicitly (to deduce the palette from
the Plasma theme).
  • Loading branch information
Martchus committed Jan 18, 2025
1 parent 724037b commit 8f2cb51
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
10 changes: 0 additions & 10 deletions syncthingmodel/syncthingicons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,16 +347,6 @@ IconManager::IconManager(const QPalette *palette)
, m_distinguishTrayIcons(false)
{
m_forkAwesomeRenderer.warnIfInvalid();
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
if (!palette) {
QObject::connect(qGuiApp, &QGuiApplication::paletteChanged, this, &IconManager::setPalette);
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
}

void IconManager::applySettings(
Expand Down
10 changes: 7 additions & 3 deletions tray/gui/quick/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,14 @@ bool App::eventFilter(QObject *object, QEvent *event)
}
switch (event->type()) {
case QEvent::ApplicationPaletteChange:
if (m_app && m_imageProvider) {
m_imageProvider->setDefaultColor(m_app->palette().color(QPalette::Normal, QPalette::Text));
}
qDebug() << "Application palette has changed";
if (m_app) {
const auto palette = m_app->palette();
IconManager::instance(&palette).setPalette(palette);
if (m_imageProvider) {
m_imageProvider->setDefaultColor(palette.color(QPalette::Normal, QPalette::Text));
}
}
applyDarkmodeChange(m_darkColorScheme, QtUtilities::isPaletteDark());
break;
default:;
Expand Down
5 changes: 4 additions & 1 deletion tray/gui/traywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,11 +630,14 @@ bool TrayWidget::event(QEvent *event)
{
const auto res = QWidget::event(event);
switch (event->type()) {
case QEvent::PaletteChange:
case QEvent::PaletteChange: {
const auto palette = QPalette();
IconManager::instance(&palette).setPalette(palette);
setBrightColorsOfModelsAccordingToPalette();
setLabelPixmaps();
setTrafficPixmaps(true);
break;
}
case QEvent::LanguageChange:
m_ui->retranslateUi(this);
applyLauncherSettings(false, true, false);
Expand Down

0 comments on commit 8f2cb51

Please sign in to comment.