Skip to content

Commit 6ff2c15

Browse files
authored
Merge pull request #7563 from nextcloud/backport/7561/stable-3.15
[stable-3.15] Bugfix/dark mode switch
2 parents 500b18a + 91ffccb commit 6ff2c15

6 files changed

+13
-15
lines changed

src/gui/tray/ActivityItemContent.qml

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ RowLayout {
104104

105105
cache: true
106106
fillMode: Image.PreserveAspectFit
107-
source: Theme.darkMode ? model.darkIcon : model.lightIcon
107+
source: Style.darkMode ? model.darkIcon : model.lightIcon
108108
sourceSize.height: 64
109109
sourceSize.width: 64
110110
mipmap: true // Addresses grainy downscale

src/gui/tray/CallNotificationDialog.qml

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ ApplicationWindow {
163163
cache: true
164164

165165
source: root.usingUserAvatar ? root.talkNotificationData.userAvatar :
166-
Theme.darkMode ? root.talkIcon + palette.windowText : root.talkIcon + Style.ncBlue
166+
Style.darkMode ? root.talkIcon + palette.windowText : root.talkIcon + Style.ncBlue
167167
sourceSize.width: Style.accountAvatarSize
168168
sourceSize.height: Style.accountAvatarSize
169169

src/gui/tray/UnifiedSearchResultListItem.qml

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ MouseArea {
5656
anchors.fill: parent
5757
title: model.resultTitle
5858
subline: model.subline
59-
icons: Theme.darkMode ? model.darkIcons : model.lightIcons
60-
iconsIsThumbnail: Theme.darkMode ? model.darkIconsIsThumbnail : model.lightIconsIsThumbnail
61-
iconPlaceholder: Theme.darkMode ? model.darkImagePlaceholder : model.lightImagePlaceholder
59+
icons: Style.darkMode ? model.darkIcons : model.lightIcons
60+
iconsIsThumbnail: Style.darkMode ? model.darkIconsIsThumbnail : model.lightIconsIsThumbnail
61+
iconPlaceholder: Style.darkMode ? model.darkImagePlaceholder : model.lightImagePlaceholder
6262
isRounded: model.isRounded && iconsIsThumbnail
6363
}
6464
}

src/gui/tray/UserLine.qml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ AbstractButton {
4141
Layout.leftMargin: Style.accountIconsMenuMargin
4242
verticalAlignment: Qt.AlignCenter
4343
cache: false
44-
source: model.avatar !== "" ? model.avatar : Theme.darkMode ? "image://avatars/fallbackWhite" : "image://avatars/fallbackBlack"
44+
source: model.avatar !== "" ? model.avatar : Style.darkMode ? "image://avatars/fallbackWhite" : "image://avatars/fallbackBlack"
4545
Layout.preferredHeight: Style.accountAvatarSize
4646
Layout.preferredWidth: Style.accountAvatarSize
4747

src/libsync/theme.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,10 @@ Theme::Theme()
398398
QColor(127, 127, 127));
399399
reserveDarkPalette.setColor(QPalette::Disabled, QPalette::WindowText,
400400
QColor(127, 127, 127));
401-
connectToPaletteSignal();
402401
#endif
403402

403+
connectToPaletteSignal();
404+
404405
#ifdef APPLICATION_SERVER_URL_ENFORCE
405406
_forceOverrideServerUrl = true;
406407
#endif
@@ -964,13 +965,10 @@ QColor Theme::defaultColor()
964965
return QColor{NEXTCLOUD_BACKGROUND_COLOR};
965966
}
966967

967-
void Theme::connectToPaletteSignal()
968+
void Theme::connectToPaletteSignal() const
968969
{
969-
if (!_paletteSignalsConnected) {
970-
if (const auto ptr = qobject_cast<QGuiApplication*>(qApp)) {
971-
connect(ptr->styleHints(), &QStyleHints::colorSchemeChanged, this, &Theme::darkModeChanged);
972-
_paletteSignalsConnected = true;
973-
}
970+
if (const auto ptr = qobject_cast<QGuiApplication*>(qApp)) {
971+
connect(ptr->styleHints(), &QStyleHints::colorSchemeChanged, this, &Theme::darkModeChanged, Qt::UniqueConnection);
974972
}
975973
}
976974

@@ -1012,6 +1010,7 @@ QVariantMap Theme::systemPalette() const
10121010

10131011
bool Theme::darkMode() const
10141012
{
1013+
connectToPaletteSignal();
10151014
const auto isDarkFromStyle = [] {
10161015
switch (qGuiApp->styleHints()->colorScheme())
10171016
{

src/libsync/theme.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -639,14 +639,13 @@ public slots:
639639
Theme &operator=(Theme const &);
640640

641641
void updateMultipleOverrideServers();
642-
void connectToPaletteSignal();
642+
void connectToPaletteSignal() const;
643643
#if defined(Q_OS_WIN)
644644
QPalette reserveDarkPalette; // Windows 11 button and window dark colours
645645
#endif
646646

647647
static Theme *_instance;
648648
bool _mono = false;
649-
bool _paletteSignalsConnected = false;
650649

651650
QString _overrideServerUrl;
652651
bool _forceOverrideServerUrl = false;

0 commit comments

Comments
 (0)