Skip to content

Commit

Permalink
Use Qt's default platformtheme palette
Browse files Browse the repository at this point in the history
This may result into some wrong colors, but it's better than no colors when using empty palette
  • Loading branch information
grulja committed Apr 19, 2020
1 parent 2f48414 commit d4277c9
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 37 deletions.
23 changes: 0 additions & 23 deletions common/gnomehintssettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ GnomeHintsSettings::GnomeHintsSettings()
cursorSizeChanged();

loadFonts();
loadPalette();
loadStaticHints();
loadTheme();
loadTitlebar();
Expand All @@ -148,7 +147,6 @@ GnomeHintsSettings::GnomeHintsSettings()
GnomeHintsSettings::~GnomeHintsSettings()
{
qDeleteAll(m_fonts);
delete m_palette;
if (m_cinnamonSettings) {
g_object_unref(m_cinnamonSettings);
}
Expand Down Expand Up @@ -263,18 +261,7 @@ void GnomeHintsSettings::iconsChanged()

void GnomeHintsSettings::themeChanged()
{
loadPalette();
loadTheme();

// QApplication::setPalette and QGuiApplication::setPalette are different functions
// and non virtual. Call the correct one
if (qobject_cast<QApplication *>(QCoreApplication::instance())) {
QApplication::setPalette(*m_palette);
if (QStyleFactory::keys().contains(m_gtkTheme, Qt::CaseInsensitive))
QApplication::setStyle(m_gtkTheme);
} else if (qobject_cast<QGuiApplication *>(QCoreApplication::instance())) {
QGuiApplication::setPalette(*m_palette);
}
}

void GnomeHintsSettings::loadTitlebar()
Expand Down Expand Up @@ -409,16 +396,6 @@ void GnomeHintsSettings::loadFonts()
}
}

void GnomeHintsSettings::loadPalette()
{
if (m_palette) {
delete m_palette;
m_palette = nullptr;
}

m_palette = new QPalette();
}

void GnomeHintsSettings::loadStaticHints() {
int cursorBlinkTime = getSettingsProperty<int>(QStringLiteral("cursor-blink-time"));
if (cursorBlinkTime >= 100) {
Expand Down
8 changes: 0 additions & 8 deletions common/gnomehintssettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

#include <qpa/qplatformtheme.h>

class QPalette;

class GnomeHintsSettings : public QObject
{
Expand Down Expand Up @@ -84,11 +83,6 @@ class GnomeHintsSettings : public QObject
return m_hints[hint];
}

inline QPalette *palette() const
{
return m_palette;
}

inline TitlebarButtons titlebarButtons() const
{
return m_titlebarButtons;
Expand All @@ -110,7 +104,6 @@ private Q_SLOTS:
void loadFonts();
void loadTheme();
void loadTitlebar();
void loadPalette();
void loadStaticHints();
void portalSettingChanged(const QString &group, const QString &key, const QDBusVariant &value);

Expand Down Expand Up @@ -169,7 +162,6 @@ private Q_SLOTS:
TitlebarButtons m_titlebarButtons = TitlebarButton::CloseButton;
TitlebarButtonsPlacement m_titlebarButtonPlacement = TitlebarButtonsPlacement::RightPlacement;
QString m_gtkTheme = nullptr;
QPalette *m_palette = nullptr;
GSettings *m_cinnamonSettings = nullptr;
GSettings *m_gnomeDesktopSettings = nullptr;
GSettings *m_settings = nullptr;
Expand Down
7 changes: 1 addition & 6 deletions theme/qgnomeplatformtheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,7 @@ const QFont *QGnomePlatformTheme::font(Font type) const

const QPalette *QGnomePlatformTheme::palette(Palette type) const
{
QPalette *palette = m_hints->palette();
if (palette && type == QPlatformTheme::SystemPalette) {
return palette;
} else {
return QPlatformTheme::palette(type);
}
return QPlatformTheme::palette(type);
}

bool QGnomePlatformTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) const
Expand Down

0 comments on commit d4277c9

Please sign in to comment.