Skip to content
This repository has been archived by the owner. It is now read-only.
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
34 changes: 8 additions & 26 deletions src/qt6ct-qtplugin/qt6ctplatformtheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ QPlatformDialogHelper *Qt6CTPlatformTheme::createPlatformDialogHelper(DialogType

const QPalette *Qt6CTPlatformTheme::palette(QPlatformTheme::Palette type) const
{
qDebug() << Q_FUNC_INFO << type;
return (m_usePalette && m_palette) ? m_palette.get() : QGenericUnixTheme::palette(type);
if (type == QPlatformTheme::SystemPalette && !m_isIgnored)
return &m_palette;
return QPlatformTheme::palette(type);
}

const QFont *Qt6CTPlatformTheme::font(QPlatformTheme::Font type) const
Expand Down Expand Up @@ -152,21 +153,10 @@ void Qt6CTPlatformTheme::applySettings()
{
if(!QGuiApplication::desktopSettingsAware() || m_isIgnored)
{
m_usePalette = false;
m_update = true;
return;
}

if(!m_update)
{
//do not override application palette
if(QCoreApplication::testAttribute(Qt::AA_SetPalette))
{
m_usePalette = false;
qCDebug(lqt6ct) << "palette support is disabled";
}
}

QGuiApplication::setFont(m_generalFont); //apply font

#ifdef QT_WIDGETS_LIB
Expand All @@ -182,12 +172,6 @@ void Qt6CTPlatformTheme::applySettings()
Qt6CT::reloadStyleInstanceSettings();
}

if(!m_palette)
m_palette = std::make_unique<QPalette>(qApp->style()->standardPalette());

if(m_update && m_usePalette)
qApp->setPalette(*m_palette);

if(m_userStyleSheet != m_prevStyleSheet)
{
// prepend our stylesheet to that of the application
Expand All @@ -209,7 +193,10 @@ void Qt6CTPlatformTheme::applySettings()
#endif

if(m_update)
{
QIconLoader::instance()->updateSystemTheme(); //apply icons
QGuiApplication::setPalette(QGuiApplication::palette()); //apply palette
}

#ifdef QT_WIDGETS_LIB
if(hasWidgets() && m_update)
Expand All @@ -218,8 +205,6 @@ void Qt6CTPlatformTheme::applySettings()
{
QEvent e(QEvent::ThemeChange);
QApplication::sendEvent(w, &e);
if(m_palette && m_usePalette)
w->setPalette(*m_palette);
}
}
#endif
Expand Down Expand Up @@ -250,17 +235,16 @@ void Qt6CTPlatformTheme::updateSettings()

void Qt6CTPlatformTheme::readSettings()
{
m_palette.reset();

QSettings settings(Qt6CT::configFile(), QSettings::IniFormat);

settings.beginGroup("Appearance");
m_style = settings.value("style", "Fusion").toString();
m_palette = *QPlatformTheme::palette(SystemPalette);
QString schemePath = settings.value("color_scheme_path").toString();
if(!schemePath.isEmpty() && settings.value("custom_palette", false).toBool())
{
schemePath = Qt6CT::resolvePath(schemePath); //replace environment variables
m_palette = std::make_unique<QPalette>(Qt6CT::loadColorScheme(schemePath, *QPlatformTheme::palette(SystemPalette)));
m_palette = Qt6CT::loadColorScheme(schemePath, m_palette);
}
m_iconTheme = settings.value("icon_theme").toString();
//load dialogs
Expand Down Expand Up @@ -338,8 +322,6 @@ void Qt6CTPlatformTheme::readSettings()
QCoreApplication::setAttribute(Qt::AA_ForceRasterWidgets, true);
else if(!m_isIgnored && forceRasterWidgets == Qt::Unchecked)
QCoreApplication::setAttribute(Qt::AA_ForceRasterWidgets, false);
if(m_isIgnored)
m_usePalette = false;
settings.endGroup();
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/qt6ct-qtplugin/qt6ctplatformtheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,14 @@ private slots:
#endif
QString loadStyleSheets(const QStringList &paths);
QString m_style, m_iconTheme, m_userStyleSheet, m_prevStyleSheet;
std::unique_ptr<QPalette> m_palette;
QPalette m_palette;
QFont m_generalFont, m_fixedFont;
int m_doubleClickInterval;
int m_cursorFlashTime;
int m_uiEffects;
int m_buttonBoxLayout;
int m_keyboardScheme;
bool m_update = false;
bool m_usePalette = true;
int m_toolButtonStyle = Qt::ToolButtonFollowStyle;
int m_wheelScrollLines = 3;
bool m_showShortcutsInContextMenus = false;
Expand Down