diff --git a/src/gui/nmcgui/nmcsettingsdialog.cpp b/src/gui/nmcgui/nmcsettingsdialog.cpp new file mode 100644 index 0000000000000..060776fa763b4 --- /dev/null +++ b/src/gui/nmcgui/nmcsettingsdialog.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (C) by Eugen Fischer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "nmcsettingsdialog.h" +#include "QtWidgets/qboxlayout.h" +#include "QtWidgets/qlabel.h" +#include "QtWidgets/qtoolbar.h" +#include "settingsdialog.h" + +namespace OCC { + +NMCSettingsDialog::NMCSettingsDialog(ownCloudGui *gui, QWidget *parent) + : SettingsDialog(gui, parent) +{ + setLayout(); + + //The window has no background widget, use palette + QPalette palette; + palette.setColor(QPalette::Window, QColor("#F3f3f3")); + setPalette(palette); + + setFixedSize(750,760); + + getToolBar()->setFixedHeight(91); ///75px button height + 8 + 8 margin top and bottom + getToolBar()->setStyleSheet("QToolBar{background: #f3f3f3; background-color: #f3f3f3; border-width: 0px; border-color: none;}"); + getToolBar()->setContentsMargins(8,0,8,0); //Left margin not accepted, Qt bug? +} + +void NMCSettingsDialog::slotAccountAvatarChanged() +{ + //Intercept the base class slot, so the round avatar is not set. (dont pass to base class) + //Fix Account button size, for ech new created account + fixAccountButton(); +} + +void OCC::NMCSettingsDialog::setLayout() const +{ + //Fix network and general settings button size + const auto actions = getToolBar()->actions(); + for(auto *action : actions) + { + if((action->text() == QCoreApplication::translate("OCC::SettingsDialog","General") || action->text() == QCoreApplication::tr("General")) || + (action->text() == QCoreApplication::translate("OCC::SettingsDialog","Network") || action->text() == QCoreApplication::tr("Network")) || + (action->text() == QCoreApplication::translate("OCC::SettingsDialog","Account") || action->text() == QCoreApplication::tr("Account"))) + { + auto *widget = getToolBar()->widgetForAction(action); + if(widget) + { + widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + widget->setFixedSize(75, 75); + widget->setStyleSheet( + "QToolButton { border: none; background-color: #f3f3f3; border-radius: 4px; font-size: 13px; padding: 8px;}" + "QToolButton:hover { background-color: #e5e5e5; }" + ); + } + } + } + + //Fix initial account button size and stylesheet + fixAccountButton(); +} + +void NMCSettingsDialog::fixAccountButton() const +{ + auto action = getToolBar()->actions().at(0); + auto *widget = getToolBar()->widgetForAction(action); + if(widget) + { + widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + widget->setFixedSize(128, 75); + widget->setStyleSheet( + "QToolButton { border: none; background-color: #f3f3f3; border-radius: 4px; font-size: 13px; padding: 8px;}" + "QToolButton:hover { background-color: #e5e5e5; }" + ); + } +} + +} // namespace OCC diff --git a/src/gui/nmcgui/nmcsettingsdialog.h b/src/gui/nmcgui/nmcsettingsdialog.h new file mode 100644 index 0000000000000..2e917e809d8f6 --- /dev/null +++ b/src/gui/nmcgui/nmcsettingsdialog.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) by Eugen Fischer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#ifndef MIRALL_SETTINGSDIALOGMAGENTA_H +#define MIRALL_SETTINGSDIALOGMAGENTA_H + +#include + +namespace OCC { + +/** + * @brief The NMCSettingsDialog class + * + * This class represents the settings dialog specific to the Magenta theme. + * It inherits from SettingsDialog and provides additional functionalities + * or customizations related to the Magenta theme. + * + * @ingroup gui + */ +class NMCSettingsDialog : public SettingsDialog +{ + Q_OBJECT + +public: + /** + * @brief Constructor for NMCSettingsDialog + * + * @param gui Pointer to the ownCloudGui instance. + * @param parent Pointer to the parent QWidget (default is nullptr). + */ + explicit NMCSettingsDialog(ownCloudGui *gui, QWidget *parent = nullptr); + + /** + * @brief Destructor for NMCSettingsDialog + */ + ~NMCSettingsDialog() = default; + +public slots: + /** + * @brief Slot for handling changes in the account avatar + */ + void slotAccountAvatarChanged(); + + // NMCGuiInterface interface +protected: + /** + * @brief Sets the layout for the NMCSettingsDialog + */ + void setLayout() const; + +private: + /** + * @brief Fixes the appearance of the account button + */ + void fixAccountButton() const; +}; + +} // namespace OCC +#endif // MIRALL_SETTINGSDIALOGMAGENTA_H diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 60138a494943b..113cd74d69b11 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -25,6 +25,7 @@ #include "guiutility.h" #include "logbrowser.h" #include "logger.h" +#include "nmcgui/nmcsettingsdialog.h" #include "openfilemanager.h" #include "owncloudsetupwizard.h" #include "progressdispatcher.h" @@ -600,7 +601,8 @@ void ownCloudGui::slotShowGuiMessage(const QString &title, const QString &messag void ownCloudGui::slotShowSettings() { if (_settingsDialog.isNull()) { - _settingsDialog = new SettingsDialog(this); + // _settingsDialog = new SettingsDialog(this); + _settingsDialog = new NMCSettingsDialog(this); _settingsDialog->setAttribute(Qt::WA_DeleteOnClose, true); #ifdef Q_OS_MAC auto *fgbg = new ForegroundBackground(); diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index 5e37b2b170dbf..1b1805c60d8d7 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -13,6 +13,7 @@ */ #include "settingsdialog.h" +#include "QtWidgets/qmainwindow.h" #include "ui_settingsdialog.h" #include "folderman.h" @@ -75,7 +76,8 @@ QString shortDisplayNameForSettings(OCC::Account *account, int width) host = fm.elidedText(host, Qt::ElideMiddle, width); user = fm.elidedText(user, Qt::ElideRight, width); } - return QStringLiteral("%1\n%2").arg(user, host); + // return QStringLiteral("%1\n%2").arg(user, host); + return QStringLiteral("%1").arg(user); } } @@ -129,6 +131,12 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) auto *generalSettings = new NMCGeneralSettings; _ui->stack->addWidget(generalSettings); + // Adds space between general and network actions + auto *spacer2 = new QWidget(); + spacer2->setFixedWidth(8); + spacer2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + _toolBar->addWidget(spacer2); + // Connect styleChanged events to our widgets, so they can adapt (Dark-/Light-Mode switching) connect(this, &SettingsDialog::styleChanged, generalSettings, &GeneralSettings::slotStyleChanged); @@ -243,7 +251,8 @@ void SettingsDialog::accountAdded(AccountState *s) const auto accountAction = createColorAwareAction(QLatin1String(":/client/theme/account.svg"), actionText); if (!brandingSingleAccount) { - accountAction->setToolTip(s->account()->displayName()); + // accountAction->setToolTip(s->account()->displayName()); + accountAction->setToolTip(shortDisplayNameForSettings(s->account().data(), static_cast(height * buttonSizeRatio))); accountAction->setIconText(shortDisplayNameForSettings(s->account().data(), static_cast(height * buttonSizeRatio))); } @@ -304,6 +313,7 @@ void SettingsDialog::slotAccountDisplayNameChanged() action->setText(displayName); auto height = _toolBar->sizeHint().height(); action->setIconText(shortDisplayNameForSettings(account, static_cast(height * buttonSizeRatio))); + action->setToolTip(shortDisplayNameForSettings(account, static_cast(height * buttonSizeRatio))); } } } @@ -350,13 +360,13 @@ void SettingsDialog::customizeStyle() QString background(palette().base().color().name()); _toolBar->setStyleSheet(TOOLBAR_CSS().arg(background, dark, highlightColor, highlightTextColor)); - Q_FOREACH (QAction *a, _actionGroup->actions()) { - QIcon icon = Theme::createColorAwareIcon(a->property("iconPath").toString(), palette()); - a->setIcon(icon); - auto *btn = qobject_cast(_toolBar->widgetForAction(a)); - if (btn) - btn->setIcon(icon); - } + // Q_FOREACH (QAction *a, _actionGroup->actions()) { + // QIcon icon = Theme::createColorAwareIcon(a->property("iconPath").toString(), palette()); + // a->setIcon(icon); + // auto *btn = qobject_cast(_toolBar->widgetForAction(a)); + // if (btn) + // btn->setIcon(icon); + // } } class ToolButtonAction : public QWidgetAction @@ -403,8 +413,9 @@ 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 = Theme::createColorAwareIcon(iconPath, palette()); - return createActionWithIcon(coloredIcon, text, iconPath); + // QIcon coloredIcon = Theme::createColorAwareIcon(iconPath, palette()); + // return createActionWithIcon(coloredIcon, text, iconPath); + return createActionWithIcon(QIcon(iconPath), text, iconPath); } } // namespace OCC diff --git a/src/gui/settingsdialog.h b/src/gui/settingsdialog.h index f992d50ea7b36..2ea272f4a798c 100644 --- a/src/gui/settingsdialog.h +++ b/src/gui/settingsdialog.h @@ -53,11 +53,16 @@ class SettingsDialog : public QDialog QWidget* currentPage(); + QToolBar *getToolBar() const + { + return _toolBar; + } + public slots: void showFirstPage(); void showIssuesList(OCC::AccountState *account); void slotSwitchPage(QAction *action); - void slotAccountAvatarChanged(); + virtual void slotAccountAvatarChanged(); void slotAccountDisplayNameChanged(); signals: @@ -74,9 +79,10 @@ private slots: void accountAdded(OCC::AccountState *); void accountRemoved(OCC::AccountState *); -private: +protected: void customizeStyle(); +private: QAction *createColorAwareAction(const QString &iconName, const QString &fileName); QAction *createActionWithIcon(const QIcon &icon, const QString &text, const QString &iconPath = QString()); diff --git a/theme/account.svg b/theme/account.svg index 2e22c019a5a90..5e7e9e798fe4c 100644 --- a/theme/account.svg +++ b/theme/account.svg @@ -1 +1,13 @@ - \ No newline at end of file + + + + + + + + diff --git a/theme/network.svg b/theme/network.svg index ca6455df5b41e..2f9e7bdf3cc61 100644 --- a/theme/network.svg +++ b/theme/network.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + /svg/icon/home/wifi/default + + + + \ No newline at end of file diff --git a/theme/settings.svg b/theme/settings.svg index 85597a0c0d835..434caf275d458 100644 --- a/theme/settings.svg +++ b/theme/settings.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + /svg/icon/service/settings/default + + + + \ No newline at end of file