Skip to content

Commit

Permalink
Merge pull request #7563 from nextcloud/backport/7561/stable-3.15
Browse files Browse the repository at this point in the history
[stable-3.15] Bugfix/dark mode switch
  • Loading branch information
mgallien authored Nov 25, 2024
2 parents 500b18a + 91ffccb commit 6ff2c15
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/gui/tray/ActivityItemContent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ RowLayout {

cache: true
fillMode: Image.PreserveAspectFit
source: Theme.darkMode ? model.darkIcon : model.lightIcon
source: Style.darkMode ? model.darkIcon : model.lightIcon
sourceSize.height: 64
sourceSize.width: 64
mipmap: true // Addresses grainy downscale
Expand Down
2 changes: 1 addition & 1 deletion src/gui/tray/CallNotificationDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ ApplicationWindow {
cache: true

source: root.usingUserAvatar ? root.talkNotificationData.userAvatar :
Theme.darkMode ? root.talkIcon + palette.windowText : root.talkIcon + Style.ncBlue
Style.darkMode ? root.talkIcon + palette.windowText : root.talkIcon + Style.ncBlue
sourceSize.width: Style.accountAvatarSize
sourceSize.height: Style.accountAvatarSize

Expand Down
6 changes: 3 additions & 3 deletions src/gui/tray/UnifiedSearchResultListItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ MouseArea {
anchors.fill: parent
title: model.resultTitle
subline: model.subline
icons: Theme.darkMode ? model.darkIcons : model.lightIcons
iconsIsThumbnail: Theme.darkMode ? model.darkIconsIsThumbnail : model.lightIconsIsThumbnail
iconPlaceholder: Theme.darkMode ? model.darkImagePlaceholder : model.lightImagePlaceholder
icons: Style.darkMode ? model.darkIcons : model.lightIcons
iconsIsThumbnail: Style.darkMode ? model.darkIconsIsThumbnail : model.lightIconsIsThumbnail
iconPlaceholder: Style.darkMode ? model.darkImagePlaceholder : model.lightImagePlaceholder
isRounded: model.isRounded && iconsIsThumbnail
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/tray/UserLine.qml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ AbstractButton {
Layout.leftMargin: Style.accountIconsMenuMargin
verticalAlignment: Qt.AlignCenter
cache: false
source: model.avatar !== "" ? model.avatar : Theme.darkMode ? "image://avatars/fallbackWhite" : "image://avatars/fallbackBlack"
source: model.avatar !== "" ? model.avatar : Style.darkMode ? "image://avatars/fallbackWhite" : "image://avatars/fallbackBlack"
Layout.preferredHeight: Style.accountAvatarSize
Layout.preferredWidth: Style.accountAvatarSize

Expand Down
13 changes: 6 additions & 7 deletions src/libsync/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,10 @@ Theme::Theme()
QColor(127, 127, 127));
reserveDarkPalette.setColor(QPalette::Disabled, QPalette::WindowText,
QColor(127, 127, 127));
connectToPaletteSignal();
#endif

connectToPaletteSignal();

#ifdef APPLICATION_SERVER_URL_ENFORCE
_forceOverrideServerUrl = true;
#endif
Expand Down Expand Up @@ -964,13 +965,10 @@ QColor Theme::defaultColor()
return QColor{NEXTCLOUD_BACKGROUND_COLOR};
}

void Theme::connectToPaletteSignal()
void Theme::connectToPaletteSignal() const
{
if (!_paletteSignalsConnected) {
if (const auto ptr = qobject_cast<QGuiApplication*>(qApp)) {
connect(ptr->styleHints(), &QStyleHints::colorSchemeChanged, this, &Theme::darkModeChanged);
_paletteSignalsConnected = true;
}
if (const auto ptr = qobject_cast<QGuiApplication*>(qApp)) {
connect(ptr->styleHints(), &QStyleHints::colorSchemeChanged, this, &Theme::darkModeChanged, Qt::UniqueConnection);
}
}

Expand Down Expand Up @@ -1012,6 +1010,7 @@ QVariantMap Theme::systemPalette() const

bool Theme::darkMode() const
{
connectToPaletteSignal();
const auto isDarkFromStyle = [] {
switch (qGuiApp->styleHints()->colorScheme())
{
Expand Down
3 changes: 1 addition & 2 deletions src/libsync/theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -639,14 +639,13 @@ public slots:
Theme &operator=(Theme const &);

void updateMultipleOverrideServers();
void connectToPaletteSignal();
void connectToPaletteSignal() const;
#if defined(Q_OS_WIN)
QPalette reserveDarkPalette; // Windows 11 button and window dark colours
#endif

static Theme *_instance;
bool _mono = false;
bool _paletteSignalsConnected = false;

QString _overrideServerUrl;
bool _forceOverrideServerUrl = false;
Expand Down

0 comments on commit 6ff2c15

Please sign in to comment.