Skip to content

Commit

Permalink
Remove stylesheet from cpp files and add objectname
Browse files Browse the repository at this point in the history
- Separated the set style sheet changes
- Removed progress bar stylesheet from accountsettings.cpp

Signed-off-by: Camila <hello@camila.codes>
  • Loading branch information
TSI-parulsharma authored and Camila committed Jul 24, 2023
1 parent 6400db0 commit 3f43297
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 46 deletions.
2 changes: 1 addition & 1 deletion resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<file>src/gui/ConflictDelegate.qml</file>
<file>src/gui/ConflictItemFileInfo.qml</file>
</qresource>
<qresource prefix="/qss">
<qresource prefix="/qss">
<file>theme/Style/style.qss</file>
</qresource>
</RCC>
18 changes: 0 additions & 18 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<void(void)> onAccept)
{
const auto messageBox = new QMessageBox;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand Down
25 changes: 16 additions & 9 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/gui/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ protected slots:
*/
bool configVersionMigration();

void addCustomStyleSheet();

QPointer<ownCloudGui> _gui;

Theme *_theme;
Expand Down
1 change: 1 addition & 0 deletions src/gui/folderwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
Expand Down
16 changes: 0 additions & 16 deletions src/gui/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@
#include <QPainterPath>

namespace {

constexpr auto highlightColor = "color";
constexpr auto highlightTextColor = "color";
constexpr auto dark = "color";
constexpr auto background = "color";

const float buttonSizeRatio = 1.618f; // golden ratio


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions src/gui/wizard/owncloudwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,16 @@ void OwncloudWizard::slotCurrentPageChanged(int id)
qCDebug(lcWizard) << "Current Wizard page changed to " << id;

const auto setNextButtonAsDefault = [this]() {
auto nextButton = qobject_cast<QPushButton *>(button(QWizard::NextButton));
if (nextButton) {
if (auto nextButton = qobject_cast<QPushButton *>(button(QWizard::NextButton))) {
nextButton->setObjectName("nextButton");
nextButton->setDefault(true);
}
};

if (auto backButton = qobject_cast<QPushButton *>(button(QWizard::BackButton))) {
backButton->setObjectName("backButton");
}

if (id == WizardCommon::Page_Welcome) {
// Set next button to just hidden so it retains it's layout
button(QWizard::NextButton)->setHidden(true);
Expand Down
2 changes: 2 additions & 0 deletions theme/Style/style.qss
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

0 comments on commit 3f43297

Please sign in to comment.