Fix QML coloring issues

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2022-11-23 20:08:52 +01:00 committed by Matthieu Gallien
parent 5087d5142a
commit 52758a00b8
2 changed files with 27 additions and 4 deletions

View File

@ -929,7 +929,7 @@ void Theme::connectToPaletteSignal()
}
}
QPalette Theme::systemPalette()
QVariantMap Theme::systemPalette()
{
connectToPaletteSignal();
#if defined(Q_OS_WIN)
@ -937,7 +937,30 @@ QPalette Theme::systemPalette()
return reserveDarkPalette;
}
#endif
return QGuiApplication::palette();
const auto systemPalette = QGuiApplication::palette();
return QVariantMap {
{ QStringLiteral("base"), systemPalette.base().color() },
{ QStringLiteral("alternateBase"), systemPalette.alternateBase().color() },
{ QStringLiteral("text"), systemPalette.text().color() },
{ QStringLiteral("toolTipBase"), systemPalette.toolTipBase().color() },
{ QStringLiteral("toolTipText"), systemPalette.toolTipText().color() },
{ QStringLiteral("brightText"), systemPalette.brightText().color() },
{ QStringLiteral("buttonText"), systemPalette.buttonText().color() },
{ QStringLiteral("button"), systemPalette.button().color() },
{ QStringLiteral("highlightedText"), systemPalette.highlightedText().color() },
{ QStringLiteral("placeholderText"), systemPalette.placeholderText().color() },
{ QStringLiteral("windowText"), systemPalette.windowText().color() },
{ QStringLiteral("window"), systemPalette.window().color() },
{ QStringLiteral("dark"), systemPalette.dark().color() },
{ QStringLiteral("highlight"), systemPalette.highlight().color() },
{ QStringLiteral("light"), systemPalette.light().color() },
{ QStringLiteral("link"), systemPalette.link().color() },
{ QStringLiteral("midlight"), systemPalette.midlight().color() },
{ QStringLiteral("mid"), systemPalette.mid().color() },
{ QStringLiteral("linkVisited"), systemPalette.linkVisited().color() },
{ QStringLiteral("shadow"), systemPalette.shadow().color() },
};
}
bool Theme::darkMode()

View File

@ -67,7 +67,7 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject
Q_PROPERTY(QColor defaultColor READ defaultColor CONSTANT)
Q_PROPERTY(QPalette systemPalette READ systemPalette NOTIFY systemPaletteChanged)
Q_PROPERTY(QVariantMap systemPalette READ systemPalette NOTIFY systemPaletteChanged)
Q_PROPERTY(bool darkMode READ darkMode NOTIFY darkModeChanged)
public:
enum CustomMediaType {
@ -593,7 +593,7 @@ public:
static constexpr const char *themePrefix = ":/client/theme/";
QPalette systemPalette();
QVariantMap systemPalette();
bool darkMode();
public slots: