Skip to content

Commit 61ab2fa

Browse files
authored
Merge pull request #9703 from nextcloud/bugfix/9683/settings-colours
fix(gui/settings): use different palette colour for backgrounds
2 parents 3d76dae + 75c8ace commit 61ab2fa

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

src/gui/accountsettings.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@
6060

6161
using namespace Qt::StringLiterals;
6262

63+
#ifdef Q_OS_WIN
64+
// "light" looks too bright on dark mode on Windows only
65+
#define BACKGROUND_PALETTE "alternate-base"
66+
#else
67+
// ...and "alternate-base" looks too bright on macOS only. On Linux/Plasma either one looked fine ...
68+
#define BACKGROUND_PALETTE "light"
69+
#endif
70+
6371
#ifdef BUILD_FILE_PROVIDER_MODULE
6472
#include "macOS/fileprovider.h"
6573
#endif
@@ -182,7 +190,7 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
182190
const auto delegate = new FolderStatusDelegate;
183191
delegate->setParent(this);
184192

185-
setStyleSheet("QWidget#syncFoldersPanelContents, QWidget#connectionSettingsPanelContents, QWidget#fileProviderPanelContents { background: palette(alternate-base); }"_L1);
193+
setStyleSheet("QWidget#syncFoldersPanelContents, QWidget#connectionSettingsPanelContents, QWidget#fileProviderPanelContents { background: palette(" BACKGROUND_PALETTE "); }"_L1);
186194
_ui->syncFoldersPanelContents->setAutoFillBackground(true);
187195
_ui->syncFoldersPanelContents->setAttribute(Qt::WA_StyledBackground, true);
188196
_ui->syncFoldersPanelContents->setContentsMargins(0, 0, 0, 0);
@@ -199,7 +207,7 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
199207
_ui->_folderList->header()->hide();
200208
_ui->_folderList->setAutoFillBackground(true);
201209
_ui->_folderList->setAttribute(Qt::WA_StyledBackground, true);
202-
_ui->_folderList->setStyleSheet(QStringLiteral("QTreeView { background: palette(alternate-base); }"));
210+
_ui->_folderList->setStyleSheet(QStringLiteral("QTreeView { background: palette(" BACKGROUND_PALETTE "); }"));
203211
_ui->_folderList->setItemDelegate(delegate);
204212
_ui->_folderList->setModel(_model);
205213
_ui->_folderList->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);

src/gui/macOS/ui/FileProviderSettings.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Page {
2323
title: qsTr("Virtual files settings")
2424

2525
background: Rectangle {
26-
color: palette.alternateBase
26+
color: palette.light
2727
border.width: root.showBorder ? Style.normalBorderWidth : 0
2828
border.color: palette.mid
2929
}

src/gui/networksettings.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@
2121
#include <QPalette>
2222
#include <type_traits>
2323

24+
constexpr auto BACKGROUND_ROLE =
25+
#ifdef Q_OS_WIN
26+
// "light" looks too bright on dark mode on Windows only
27+
QPalette::AlternateBase;
28+
#else
29+
// ...and "alternate-base" looks too bright on macOS only. On Linux/Plasma either one looked fine ...
30+
QPalette::Light;
31+
#endif
32+
2433
namespace OCC {
2534

2635
NetworkSettings::NetworkSettings(const AccountPtr &account, QWidget *parent)
@@ -30,13 +39,13 @@ NetworkSettings::NetworkSettings(const AccountPtr &account, QWidget *parent)
3039
{
3140
_ui->setupUi(this);
3241
setAutoFillBackground(true);
33-
setBackgroundRole(QPalette::AlternateBase);
42+
setBackgroundRole(BACKGROUND_ROLE);
3443
_ui->proxyGroupBox->setAutoFillBackground(true);
35-
_ui->proxyGroupBox->setBackgroundRole(QPalette::AlternateBase);
44+
_ui->proxyGroupBox->setBackgroundRole(BACKGROUND_ROLE);
3645
_ui->downloadBox->setAutoFillBackground(true);
37-
_ui->downloadBox->setBackgroundRole(QPalette::AlternateBase);
46+
_ui->downloadBox->setBackgroundRole(BACKGROUND_ROLE);
3847
_ui->uploadBox->setAutoFillBackground(true);
39-
_ui->uploadBox->setBackgroundRole(QPalette::AlternateBase);
48+
_ui->uploadBox->setBackgroundRole(BACKGROUND_ROLE);
4049

4150
_ui->manualSettings->setVisible(_ui->manualProxyRadioButton->isChecked());
4251

src/gui/settingsdialog.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242

4343
using namespace Qt::StringLiterals;
4444

45+
#ifdef Q_OS_WIN
46+
// "light" looks too bright on dark mode on Windows only
47+
#define BACKGROUND_PALETTE "alternate-base"
48+
#else
49+
// ...and "alternate-base" looks too bright on macOS only. On Linux/Plasma either one looked fine ...
50+
#define BACKGROUND_PALETTE "light"
51+
#endif
52+
4553
namespace {
4654
class CurrentPageSizeStackedWidget : public QStackedWidget
4755
{
@@ -434,15 +442,15 @@ void SettingsDialog::customizeStyle()
434442
"#Settings { background: palette(window); border-radius: 0; }"
435443

436444
/* Navigation */
437-
"#settings_navigation, #settings_navigation_scroll { background: palette(alternate-base); border-radius: 12px; padding: 4px; }"
445+
"#settings_navigation, #settings_navigation_scroll { background: palette(" BACKGROUND_PALETTE "); border-radius: 12px; padding: 4px; }"
438446

439447
/* Content area */
440448
"#settings_content, #settings_content_scroll { background: palette(window); border-radius: 12px; }"
441449

442450
/* Panels */
443451
"#generalGroupBox, #advancedGroupBox, #aboutAndUpdatesGroupBox,"
444452
"#accountStatusPanel, #connectionSettingsPanel, #fileProviderPanel, #syncFoldersPanel {"
445-
" background: palette(alternate-base);"
453+
" background: palette(" BACKGROUND_PALETTE ");"
446454
" border-radius: 10px;"
447455
" margin: 0px;"
448456
" padding: 6px;"

0 commit comments

Comments
 (0)