Commit c2483427 authored by Alessandro Portale's avatar Alessandro Portale
Browse files

Utils: Keep correct palette for dark themers after suspend



Sleep, hibernation and user sign-in can cause a ThemeChange event. That
event resets the application palette, discarding a palette that may have
been previously set.

Dark themes in Qt Creator want to set and keep their custom application
palettes. So, this change sets the custom application palette on each
ThemeChange event that is send to the main window.

Task-number: QTCREATORBUG-14929
Change-Id: Ic9fb0111cfa0e8171b819d687f280c3db6cc8f2c
Reviewed-by: David Schulz's avatarDavid Schulz <david.schulz@qt.io>
parent 5cf8fbab
......@@ -24,6 +24,7 @@
****************************************************************************/
#include "appmainwindow.h"
#include "theme/theme_p.h"
#ifdef Q_OS_WIN
#include <windows.h>
......@@ -60,11 +61,14 @@ void AppMainWindow::raiseWindow()
#ifdef Q_OS_WIN
bool AppMainWindow::event(QEvent *event)
{
if (event->type() == m_deviceEventId) {
const QEvent::Type type = event->type();
if (type == m_deviceEventId) {
event->accept();
emit deviceChange();
return true;
}
if (type == QEvent::ThemeChange)
setThemeApplicationPalette();
return QMainWindow::event(event);
}
......
......@@ -57,14 +57,19 @@ Theme *proxyTheme()
return new Theme(m_creatorTheme);
}
void setThemeApplicationPalette()
{
if (m_creatorTheme && m_creatorTheme->flag(Theme::ApplyThemePaletteGlobally))
QApplication::setPalette(m_creatorTheme->palette());
}
void setCreatorTheme(Theme *theme)
{
if (m_creatorTheme == theme)
return;
delete m_creatorTheme;
m_creatorTheme = theme;
if (theme && theme->flag(Theme::ApplyThemePaletteGlobally))
QApplication::setPalette(theme->palette());
setThemeApplicationPalette();
}
Theme::Theme(const QString &id, QObject *parent)
......
......@@ -51,5 +51,6 @@ public:
};
QTCREATOR_UTILS_EXPORT void setCreatorTheme(Theme *theme);
QTCREATOR_UTILS_EXPORT void setThemeApplicationPalette();
} // namespace Utils
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment