From 6400db059f21c43ddb4c9c33e8e6edd17160c25f Mon Sep 17 00:00:00 2001 From: Sharma Date: Mon, 5 Jun 2023 19:32:09 +0530 Subject: [PATCH 1/2] Add style sheet file globally style.qss Signed-off-by: Camila --- resources.qrc | 3 +++ src/gui/application.cpp | 10 ++++++++++ src/gui/settingsdialog.cpp | 20 +++++++++++--------- theme/Style/style.qss | 7 +++++++ 4 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 theme/Style/style.qss diff --git a/resources.qrc b/resources.qrc index fdd4bcf570e6..3f2d0851c0fe 100644 --- a/resources.qrc +++ b/resources.qrc @@ -60,4 +60,7 @@ src/gui/ConflictDelegate.qml src/gui/ConflictItemFileInfo.qml + + theme/Style/style.qss + diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 18b01f6c2df7..b624e927f12a 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -245,6 +245,16 @@ Application::Application(int &argc, char **argv) setApplicationName(_theme->appName()); setWindowIcon(_theme->applicationIcon()); + QString highlightColor(palette().highlight().color().name()); + QString highlightTextColor(palette().highlightedText().color().name()); + QString dark(palette().dark().color().name()); + QString background(palette().base().color().name()); + + QFile file(":/qss/theme/Style/style.qss"); + file.open(QFile::ReadOnly); + QString styleSheet = QLatin1String(file.readAll()); + app.setStyleSheet(styleSheet.arg(background, dark, highlightColor, highlightTextColor)); + if (!ConfigFile().exists()) { // Migrate from version <= 2.4 setApplicationName(_theme->appNameGUI()); diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index 130e5deac1c7..0e2446c14ef6 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -41,13 +41,11 @@ #include namespace { -const QString TOOLBAR_CSS() -{ - return QStringLiteral("QToolBar { background: %1; margin: 0; padding: 0; border: none; border-bottom: 1px solid %2; spacing: 0; } " - "QToolBar QToolButton { background: %1; border: none; border-bottom: 1px solid %2; margin: 0; padding: 5px; } " - "QToolBar QToolBarExtension { padding:0; } " - "QToolBar QToolButton:checked { background: %3; color: %4; }"); -} + +constexpr auto highlightColor = "color"; +constexpr auto highlightTextColor = "color"; +constexpr auto dark = "color"; +constexpr auto background = "color"; const float buttonSizeRatio = 1.618f; // golden ratio @@ -88,6 +86,10 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) _toolBar = new QToolBar; _toolBar->setIconSize(QSize(32, 32)); _toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + //_toolBar->setProperty(highlightColor, palette().highlight().color().name()); + //_toolBar->setProperty(highlightTextColor, Theme::defaultColor().name()); + //_toolBar->setProperty(dark, palette().dark().color().name()); + //_toolBar->setProperty(background, palette().base().color().name()); layout()->setMenuBar(_toolBar); // People perceive this as a Window, so also make Ctrl+W work @@ -337,11 +339,11 @@ void SettingsDialog::accountRemoved(AccountState *s) void SettingsDialog::customizeStyle() { - QString highlightColor(palette().highlight().color().name()); + /* QString highlightColor(palette().highlight().color().name()); QString highlightTextColor(palette().highlightedText().color().name()); QString dark(palette().dark().color().name()); QString background(palette().base().color().name()); - _toolBar->setStyleSheet(TOOLBAR_CSS().arg(background, dark, highlightColor, highlightTextColor)); + _toolBar->setStyleSheet(TOOLBAR_CSS().arg(background, dark, highlightColor, highlightTextColor));*/ Q_FOREACH (QAction *a, _actionGroup->actions()) { QIcon icon = Theme::createColorAwareIcon(a->property("iconPath").toString(), palette()); diff --git a/theme/Style/style.qss b/theme/Style/style.qss new file mode 100644 index 000000000000..e7d6ec71ed8c --- /dev/null +++ b/theme/Style/style.qss @@ -0,0 +1,7 @@ + +QToolBar { background: %1; margin: 0; padding: 0; border: none; border-bottom: 1px solid %2; spacing: 0; } +QToolBar QToolButton { background: %1; border: none; border-bottom: 1px solid %2; margin: 0; padding: 5px; } +QToolBar QToolBarExtension { padding:0; } +QToolBar QToolButton:checked { background: %3; color: %4; } + + From cd966ad04f85cf08df09cb713ee4bf583e1653a2 Mon Sep 17 00:00:00 2001 From: Sharma Date: Wed, 7 Jun 2023 12:06:16 +0530 Subject: [PATCH 2/2] Remove stylesheet from cpp files and add objectname - Separated the set style sheet changes - Removed progress bar stylesheet from accountsettings.cpp Signed-off-by: Camila --- resources.qrc | 2 +- src/gui/accountsettings.cpp | 18 ------------------ src/gui/application.cpp | 25 ++++++++++++++++--------- src/gui/application.h | 2 ++ src/gui/folderwizard.cpp | 1 + src/gui/settingsdialog.cpp | 16 ---------------- src/gui/wizard/owncloudwizard.cpp | 9 +++++++-- theme/Style/style.qss | 2 ++ 8 files changed, 29 insertions(+), 46 deletions(-) diff --git a/resources.qrc b/resources.qrc index 3f2d0851c0fe..f99ce6aacc71 100644 --- a/resources.qrc +++ b/resources.qrc @@ -60,7 +60,7 @@ src/gui/ConflictDelegate.qml src/gui/ConflictItemFileInfo.qml - + theme/Style/style.qss diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index b4ca6b3b7808..781c52b98a3c 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -76,16 +76,6 @@ class AccountSettings; Q_LOGGING_CATEGORY(lcAccountSettings, "nextcloud.gui.account.settings", QtInfoMsg) -static const char progressBarStyleC[] = - "QProgressBar {" - "border: 1px solid grey;" - "border-radius: 5px;" - "text-align: center;" - "}" - "QProgressBar::chunk {" - "background-color: %1; width: 1px;" - "}"; - void showEnableE2eeWithVirtualFilesWarningDialog(std::function onAccept) { const auto messageBox = new QMessageBox; @@ -220,11 +210,6 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) connect(FolderMan::instance(), &FolderMan::folderListChanged, _model, &FolderStatusModel::resetFolders); connect(this, &AccountSettings::folderChanged, _model, &FolderStatusModel::resetFolders); - - // quotaProgressBar style now set in customizeStyle() - /*QColor color = palette().highlight().color(); - _ui->quotaProgressBar->setStyleSheet(QString::fromLatin1(progressBarStyleC).arg(color.name()));*/ - // Connect E2E stuff initializeE2eEncryption(); _ui->encryptionMessage->setCloseButtonVisible(false); @@ -1552,9 +1537,6 @@ void AccountSettings::customizeStyle() auto msg = _ui->connectLabel->text(); Theme::replaceLinkColorStringBackgroundAware(msg); _ui->connectLabel->setText(msg); - - const auto color = palette().highlight().color(); - _ui->quotaProgressBar->setStyleSheet(QString::fromLatin1(progressBarStyleC).arg(color.name())); } void AccountSettings::initializeE2eEncryption() diff --git a/src/gui/application.cpp b/src/gui/application.cpp index b624e927f12a..12080fea63b3 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -245,15 +245,7 @@ Application::Application(int &argc, char **argv) setApplicationName(_theme->appName()); setWindowIcon(_theme->applicationIcon()); - QString highlightColor(palette().highlight().color().name()); - QString highlightTextColor(palette().highlightedText().color().name()); - QString dark(palette().dark().color().name()); - QString background(palette().base().color().name()); - - QFile file(":/qss/theme/Style/style.qss"); - file.open(QFile::ReadOnly); - QString styleSheet = QLatin1String(file.readAll()); - app.setStyleSheet(styleSheet.arg(background, dark, highlightColor, highlightTextColor)); + addCustomStyleSheet(); if (!ConfigFile().exists()) { // Migrate from version <= 2.4 @@ -1023,4 +1015,19 @@ bool Application::event(QEvent *event) return SharedTools::QtSingleApplication::event(event); } +void Application::addCustomStyleSheet() +{ + const auto wizardPalette = palette(); + const auto highlightColor = wizardPalette.highlight().color().name(); + const auto highlightTextColor = wizardPalette.highlightedText().color().name(); + const auto dark = wizardPalette.dark().color().name(); + const auto background = wizardPalette.base().color().name(); + + QFile file(QStringLiteral(":/qss/theme/Style/style.qss")); + if (file.open(QFile::ReadOnly)) { + const auto &styleSheet = QString::fromLatin1(file.readAll()); + setStyleSheet(styleSheet.arg(background, dark, highlightColor, highlightTextColor)); + } +} + } // namespace OCC diff --git a/src/gui/application.h b/src/gui/application.h index bb9f97bef0b5..c7c13f0e53b2 100644 --- a/src/gui/application.h +++ b/src/gui/application.h @@ -124,6 +124,8 @@ protected slots: */ bool configVersionMigration(); + void addCustomStyleSheet(); + QPointer _gui; Theme *_theme; diff --git a/src/gui/folderwizard.cpp b/src/gui/folderwizard.cpp index 1c82938cb1bb..be7181019f08 100644 --- a/src/gui/folderwizard.cpp +++ b/src/gui/folderwizard.cpp @@ -645,6 +645,7 @@ FolderWizard::FolderWizard(AccountPtr account, QWidget *parent) setPage(Page_SelectiveSync, _folderWizardSelectiveSyncPage); setWindowTitle(tr("Add Folder Sync Connection")); + setObjectName("folderWizard"); setOptions(QWizard::CancelButtonOnLeft); setButtonText(QWizard::FinishButton, tr("Add Sync Connection")); } diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index 0e2446c14ef6..dd6ac70927d0 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -41,12 +41,6 @@ #include namespace { - -constexpr auto highlightColor = "color"; -constexpr auto highlightTextColor = "color"; -constexpr auto dark = "color"; -constexpr auto background = "color"; - const float buttonSizeRatio = 1.618f; // golden ratio @@ -86,10 +80,6 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) _toolBar = new QToolBar; _toolBar->setIconSize(QSize(32, 32)); _toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - //_toolBar->setProperty(highlightColor, palette().highlight().color().name()); - //_toolBar->setProperty(highlightTextColor, Theme::defaultColor().name()); - //_toolBar->setProperty(dark, palette().dark().color().name()); - //_toolBar->setProperty(background, palette().base().color().name()); layout()->setMenuBar(_toolBar); // People perceive this as a Window, so also make Ctrl+W work @@ -339,12 +329,6 @@ void SettingsDialog::accountRemoved(AccountState *s) void SettingsDialog::customizeStyle() { - /* QString highlightColor(palette().highlight().color().name()); - QString highlightTextColor(palette().highlightedText().color().name()); - QString dark(palette().dark().color().name()); - 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); diff --git a/src/gui/wizard/owncloudwizard.cpp b/src/gui/wizard/owncloudwizard.cpp index afc19c40986f..cd5184fa4983 100644 --- a/src/gui/wizard/owncloudwizard.cpp +++ b/src/gui/wizard/owncloudwizard.cpp @@ -300,12 +300,17 @@ void OwncloudWizard::slotCurrentPageChanged(int id) qCDebug(lcWizard) << "Current Wizard page changed to " << id; const auto setNextButtonAsDefault = [this]() { - auto nextButton = qobject_cast(button(QWizard::NextButton)); - if (nextButton) { + if (auto nextButton = qobject_cast(button(QWizard::NextButton))) { + nextButton->setObjectName("nextButton"); nextButton->setDefault(true); } }; + if (auto backButton = qobject_cast(button(QWizard::BackButton))) { + backButton->setObjectName("backButton"); + backButton->setDefault(true); + } + if (id == WizardCommon::Page_Welcome) { // Set next button to just hidden so it retains it's layout button(QWizard::NextButton)->setHidden(true); diff --git a/theme/Style/style.qss b/theme/Style/style.qss index e7d6ec71ed8c..9c41a145a526 100644 --- a/theme/Style/style.qss +++ b/theme/Style/style.qss @@ -5,3 +5,5 @@ QToolBar QToolBarExtension { padding:0; } QToolBar QToolButton:checked { background: %3; color: %4; } +QProgressBar { border: 1px solid grey; border-radius: 5px; text-align: center; } +QProgressBar::chunk { background-color: %3 ; width: 1px; }