From cd966ad04f85cf08df09cb713ee4bf583e1653a2 Mon Sep 17 00:00:00 2001 From: Sharma Date: Wed, 7 Jun 2023 12:06:16 +0530 Subject: [PATCH] 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; }