Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>2020-01-02 10:43:34 +0300
committerDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>2020-01-02 10:43:34 +0300
commit7653c5fa605718618cd769526b40e5a6164dd969 (patch)
tree37071fdf1a6867ca71f8736793193aa705e74c38 /src/gui/settingsdialog.cpp
parent44bfc79caac1bbd8e1187fc84435219ea2af2a9b (diff)
parentbd61cd3142fcc7bad365c4d96616bafb1e88feda (diff)
Fix merge conflict
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Diffstat (limited to 'src/gui/settingsdialog.cpp')
-rw-r--r--src/gui/settingsdialog.cpp56
1 files changed, 20 insertions, 36 deletions
diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp
index da40ffff1..a80de4da5 100644
--- a/src/gui/settingsdialog.cpp
+++ b/src/gui/settingsdialog.cpp
@@ -56,10 +56,6 @@ namespace OCC {
#include "settingsdialogcommon.cpp"
-//
-// Whenever you change something here check both settingsdialog.cpp and settingsdialogmac.cpp !
-//
-
SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent)
: QDialog(parent)
, _ui(new Ui::SettingsDialog)
@@ -108,6 +104,9 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent)
GeneralSettings *generalSettings = new GeneralSettings;
_ui->stack->addWidget(generalSettings);
+ // Connect styleChanged events to our widgets, so they can adapt (Dark-/Light-Mode switching)
+ connect(this, &SettingsDialog::styleChanged, generalSettings, &GeneralSettings::slotStyleChanged);
+
QAction *networkAction = createColorAwareAction(QLatin1String(":/client/resources/network.png"), tr("Network"));
_actionGroup->addAction(networkAction);
_toolBar->addAction(networkAction);
@@ -128,6 +127,8 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent)
connect(showLogWindow, &QAction::triggered, gui, &ownCloudGui::slotToggleLogBrowser);
addAction(showLogWindow);
+ connect(this, &SettingsDialog::onActivate, gui, &ownCloudGui::slotSettingsDialogActivated);
+
customizeStyle();
cfg.restoreGeometry(this);
@@ -160,6 +161,13 @@ void SettingsDialog::changeEvent(QEvent *e)
case QEvent::PaletteChange:
case QEvent::ThemeChange:
customizeStyle();
+
+ // Notify the other widgets (Dark-/Light-Mode switching)
+ emit styleChanged();
+ break;
+ case QEvent::ActivationChange:
+ if(isActiveWindow())
+ emit onActivate();
break;
default:
break;
@@ -265,6 +273,10 @@ void SettingsDialog::accountAdded(AccountState *s)
// Refresh immediatly when getting online
connect(s, &AccountState::isConnectedChanged, this, &SettingsDialog::slotRefreshActivityAccountStateSender);
+ // Connect styleChanged event, to adapt (Dark-/Light-Mode switching)
+ connect(this, &SettingsDialog::styleChanged, accountSettings, &AccountSettings::slotStyleChanged);
+ connect(this, &SettingsDialog::styleChanged, _activitySettings[s], &ActivitySettings::slotStyleChanged);
+
activityAdded(s);
slotRefreshActivity(s);
}
@@ -346,13 +358,13 @@ void SettingsDialog::accountRemoved(AccountState *s)
void SettingsDialog::customizeStyle()
{
QString highlightColor(palette().highlight().color().name());
- QString altBase(palette().alternateBase().color().name());
+ QString highlightTextColor(palette().highlightedText().color().name());
QString dark(palette().dark().color().name());
QString background(palette().base().color().name());
- _toolBar->setStyleSheet(QString::fromLatin1(TOOLBAR_CSS).arg(background, dark, highlightColor, altBase));
+ _toolBar->setStyleSheet(QString::fromLatin1(TOOLBAR_CSS).arg(background, dark, highlightColor, highlightTextColor));
Q_FOREACH (QAction *a, _actionGroup->actions()) {
- QIcon icon = createColorAwareIcon(a->property("iconPath").toString());
+ QIcon icon = Theme::createColorAwareIcon(a->property("iconPath").toString(), palette());
a->setIcon(icon);
QToolButton *btn = qobject_cast<QToolButton *>(_toolBar->widgetForAction(a));
if (btn)
@@ -360,34 +372,6 @@ void SettingsDialog::customizeStyle()
}
}
-static bool isDarkColor(const QColor &color)
-{
- // account for different sensitivity of the human eye to certain colors
- double treshold = 1.0 - (0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue()) / 255.0;
- return treshold > 0.5;
-}
-
-QIcon SettingsDialog::createColorAwareIcon(const QString &name)
-{
- QPalette pal = palette();
- QImage img(name);
- QImage inverted(img);
- inverted.invertPixels(QImage::InvertRgb);
-
- QIcon icon;
- if (isDarkColor(pal.color(QPalette::Base))) {
- icon.addPixmap(QPixmap::fromImage(inverted));
- } else {
- icon.addPixmap(QPixmap::fromImage(img));
- }
- if (isDarkColor(pal.color(QPalette::HighlightedText))) {
- icon.addPixmap(QPixmap::fromImage(img), QIcon::Normal, QIcon::On);
- } else {
- icon.addPixmap(QPixmap::fromImage(inverted), QIcon::Normal, QIcon::On);
- }
- return icon;
-}
-
class ToolButtonAction : public QWidgetAction
{
public:
@@ -428,7 +412,7 @@ QAction *SettingsDialog::createActionWithIcon(const QIcon &icon, const QString &
QAction *SettingsDialog::createColorAwareAction(const QString &iconPath, const QString &text)
{
// all buttons must have the same size in order to keep a good layout
- QIcon coloredIcon = createColorAwareIcon(iconPath);
+ QIcon coloredIcon = Theme::createColorAwareIcon(iconPath, palette());
return createActionWithIcon(coloredIcon, text, iconPath);
}