mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 21:46:03 +03:00
Revert "remove broken system paellete detection within our custom style"
This reverts commit 2d08cdb503
.
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
c1f9861265
commit
1f4f7c7d0f
3 changed files with 43 additions and 6 deletions
|
@ -947,12 +947,49 @@ void Theme::connectToPaletteSignal()
|
||||||
{
|
{
|
||||||
if (!_paletteSignalsConnected) {
|
if (!_paletteSignalsConnected) {
|
||||||
if (const auto ptr = qobject_cast<QGuiApplication *>(QGuiApplication::instance())) {
|
if (const auto ptr = qobject_cast<QGuiApplication *>(QGuiApplication::instance())) {
|
||||||
|
connect(ptr, &QGuiApplication::paletteChanged, this, &Theme::systemPaletteChanged);
|
||||||
connect(ptr->styleHints(), &QStyleHints::colorSchemeChanged, this, &Theme::darkModeChanged);
|
connect(ptr->styleHints(), &QStyleHints::colorSchemeChanged, this, &Theme::darkModeChanged);
|
||||||
_paletteSignalsConnected = true;
|
_paletteSignalsConnected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantMap Theme::systemPalette()
|
||||||
|
{
|
||||||
|
connectToPaletteSignal();
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
auto systemPalette = QGuiApplication::palette();
|
||||||
|
if(darkMode()) {
|
||||||
|
systemPalette = reserveDarkPalette;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
const auto systemPalette = QGuiApplication::palette();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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()
|
bool Theme::darkMode()
|
||||||
{
|
{
|
||||||
connectToPaletteSignal();
|
connectToPaletteSignal();
|
||||||
|
|
|
@ -67,6 +67,7 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject
|
||||||
|
|
||||||
Q_PROPERTY(QColor defaultColor READ defaultColor CONSTANT)
|
Q_PROPERTY(QColor defaultColor READ defaultColor CONSTANT)
|
||||||
|
|
||||||
|
Q_PROPERTY(QVariantMap systemPalette READ systemPalette NOTIFY systemPaletteChanged)
|
||||||
Q_PROPERTY(bool darkMode READ darkMode NOTIFY darkModeChanged)
|
Q_PROPERTY(bool darkMode READ darkMode NOTIFY darkModeChanged)
|
||||||
public:
|
public:
|
||||||
enum CustomMediaType {
|
enum CustomMediaType {
|
||||||
|
@ -600,6 +601,7 @@ public:
|
||||||
|
|
||||||
static constexpr const char *themePrefix = ":/client/theme/";
|
static constexpr const char *themePrefix = ":/client/theme/";
|
||||||
|
|
||||||
|
QVariantMap systemPalette();
|
||||||
bool darkMode();
|
bool darkMode();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -624,6 +626,7 @@ protected:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void systrayUseMonoIconsChanged(bool);
|
void systrayUseMonoIconsChanged(bool);
|
||||||
|
void systemPaletteChanged(const QPalette &palette);
|
||||||
void darkModeChanged();
|
void darkModeChanged();
|
||||||
void overrideServerUrlChanged();
|
void overrideServerUrlChanged();
|
||||||
void forceOverrideServerUrlChanged();
|
void forceOverrideServerUrlChanged();
|
||||||
|
|
|
@ -8,20 +8,17 @@ QtObject {
|
||||||
readonly property int pixelSize: fontMetrics.font.pixelSize
|
readonly property int pixelSize: fontMetrics.font.pixelSize
|
||||||
readonly property bool darkMode: Theme.darkMode
|
readonly property bool darkMode: Theme.darkMode
|
||||||
|
|
||||||
property SystemPalette nativePalette: SystemPalette {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Colors
|
// Colors
|
||||||
readonly property color ncBlue: Theme.wizardHeaderBackgroundColor
|
readonly property color ncBlue: Theme.wizardHeaderBackgroundColor
|
||||||
readonly property color ncHeaderTextColor: Theme.wizardHeaderTitleColor
|
readonly property color ncHeaderTextColor: Theme.wizardHeaderTitleColor
|
||||||
readonly property color ncTextColor: nativePalette.text
|
readonly property color ncTextColor: Theme.systemPalette.windowText
|
||||||
readonly property color ncTextBrightColor: "white"
|
readonly property color ncTextBrightColor: "white"
|
||||||
readonly property color ncSecondaryTextColor: "#808080"
|
readonly property color ncSecondaryTextColor: "#808080"
|
||||||
readonly property color lightHover: Theme.darkMode ? Qt.lighter(backgroundColor, 2) : Qt.darker(backgroundColor, 1.05)
|
readonly property color lightHover: Theme.darkMode ? Qt.lighter(backgroundColor, 2) : Qt.darker(backgroundColor, 1.05)
|
||||||
readonly property color darkerHover: Theme.darkMode ? Qt.lighter(backgroundColor, 2.35) : Qt.darker(backgroundColor, 1.25)
|
readonly property color darkerHover: Theme.darkMode ? Qt.lighter(backgroundColor, 2.35) : Qt.darker(backgroundColor, 1.25)
|
||||||
readonly property color menuBorder: Theme.darkMode ? Qt.lighter(backgroundColor, 2.5) : Qt.darker(backgroundColor, 1.5)
|
readonly property color menuBorder: Theme.darkMode ? Qt.lighter(backgroundColor, 2.5) : Qt.darker(backgroundColor, 1.5)
|
||||||
readonly property color backgroundColor: nativePalette.window
|
readonly property color backgroundColor: Theme.systemPalette.window
|
||||||
readonly property color buttonBackgroundColor: nativePalette.button
|
readonly property color buttonBackgroundColor: Theme.systemPalette.button
|
||||||
readonly property color positiveColor: Qt.rgba(0.38, 0.74, 0.38, 1)
|
readonly property color positiveColor: Qt.rgba(0.38, 0.74, 0.38, 1)
|
||||||
|
|
||||||
readonly property color currentUserHeaderColor: UserModel.currentUser ? UserModel.currentUser.headerColor : ncBlue
|
readonly property color currentUserHeaderColor: UserModel.currentUser ? UserModel.currentUser.headerColor : ncBlue
|
||||||
|
|
Loading…
Reference in a new issue