Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix folder wizard warning color for local path in dark mode #5968

Merged
merged 4 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions src/gui/folderwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@

#include <cstdlib>

namespace
{
constexpr QColor darkWarnYellow(63, 63, 0);
constexpr QColor lightWarnYellow(255, 255, 192);

QPalette yellowWarnWidgetPalette(const QPalette &existingPalette)
{
const auto warnYellow = OCC::Theme::instance()->darkMode() ? darkWarnYellow : lightWarnYellow;
auto modifiedPalette = existingPalette;
modifiedPalette.setColor(QPalette::Window, warnYellow);
modifiedPalette.setColor(QPalette::Base, warnYellow);
return modifiedPalette;
}
}

namespace OCC {

QString FormatWarningsWizardPage::formatWarnings(const QStringList &warnings) const
Expand Down Expand Up @@ -162,10 +177,8 @@ void FolderWizardLocalPath::changeEvent(QEvent *e)

void FolderWizardLocalPath::changeStyle()
{
const auto warnYellow = Theme::isDarkColor(QGuiApplication::palette().base().color()) ? QColor(63, 63, 0) : QColor(255, 255, 192);
auto modifiedPalette = _ui.warnLabel->palette();
modifiedPalette.setColor(QPalette::Window, warnYellow);
_ui.warnLabel->setPalette(modifiedPalette);
const auto yellowWarnPalette = yellowWarnWidgetPalette(_ui.warnLabel->palette());
_ui.warnLabel->setPalette(yellowWarnPalette);
}

// =================================================================================
Expand All @@ -192,6 +205,8 @@ FolderWizardRemotePath::FolderWizardRemotePath(const AccountPtr &account)
_ui.folderTreeWidget->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
// Make sure that there will be a scrollbar when the contents is too wide
_ui.folderTreeWidget->header()->setStretchLastSection(false);

changeStyle();
}

void FolderWizardRemotePath::slotAddRemoteFolder()
Expand Down Expand Up @@ -523,6 +538,28 @@ void FolderWizardRemotePath::showWarn(const QString &msg) const
}
}

void FolderWizardRemotePath::changeEvent(QEvent *e)
{
switch (e->type()) {
case QEvent::StyleChange:
case QEvent::PaletteChange:
case QEvent::ThemeChange:
// Notify the other widgets (Dark-/Light-Mode switching)
changeStyle();
break;
default:
break;
}

FormatWarningsWizardPage::changeEvent(e);
}

void FolderWizardRemotePath::changeStyle()
{
const auto yellowWarnPalette = yellowWarnWidgetPalette(_ui.warnLabel->palette());
_ui.warnLabel->setPalette(yellowWarnPalette);
}

// ====================================================================================

FolderWizardSelectiveSync::FolderWizardSelectiveSync(const AccountPtr &account)
Expand Down
7 changes: 6 additions & 1 deletion src/gui/folderwizard.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ class FolderWizardRemotePath : public FormatWarningsWizardPage
void cleanupPage() override;

protected slots:

void showWarn(const QString & = QString()) const;
void slotAddRemoteFolder();
void slotCreateRemoteFolder(const QString &);
Expand All @@ -110,6 +109,12 @@ protected slots:
void slotLsColFolderEntry();
void slotTypedPathFound(const QStringList &subpaths);

protected:
void changeEvent(QEvent *) override;

private slots:
void changeStyle();

private:
LsColJob *runLsColJob(const QString &path);
void recursiveInsert(QTreeWidgetItem *parent, QStringList pathTrail, QString path);
Expand Down
Loading