Skip to content

Commit 5a3289e

Browse files
authored
Dynamically change the status bar color depending on the current screen (#11672)
* Revert (#11455) * Do not use styles for QStatusBar * Dynamically change the status bar color depending on the current screen
1 parent e4bb80b commit 5a3289e

File tree

6 files changed

+12
-19
lines changed

6 files changed

+12
-19
lines changed

src/gui/MainWindow.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -687,11 +687,6 @@ MainWindow::MainWindow()
687687

688688
restoreConfigState();
689689
updateMenuActionState();
690-
691-
// Check the current screen and hide the status bar if it is the WelcomeScreen
692-
if (m_ui->stackedWidget->currentIndex() == WelcomeScreen) {
693-
statusBar()->hide();
694-
}
695690
}
696691

697692
MainWindow::~MainWindow()
@@ -1197,10 +1192,10 @@ void MainWindow::switchToDatabases()
11971192
{
11981193
if (m_ui->tabWidget->currentIndex() == -1) {
11991194
m_ui->stackedWidget->setCurrentIndex(WelcomeScreen);
1200-
statusBar()->hide();
1195+
statusBar()->setAutoFillBackground(false);
12011196
} else {
12021197
m_ui->stackedWidget->setCurrentIndex(DatabaseTabScreen);
1203-
statusBar()->show();
1198+
statusBar()->setAutoFillBackground(true);
12041199
}
12051200
}
12061201

@@ -1209,6 +1204,7 @@ void MainWindow::switchToSettings(bool enabled)
12091204
if (enabled) {
12101205
m_ui->settingsWidget->loadSettings();
12111206
m_ui->stackedWidget->setCurrentIndex(SettingsScreen);
1207+
statusBar()->setAutoFillBackground(true);
12121208
} else {
12131209
switchToDatabases();
12141210
}
@@ -1220,6 +1216,7 @@ void MainWindow::togglePasswordGenerator(bool enabled)
12201216
m_ui->passwordGeneratorWidget->loadSettings();
12211217
m_ui->passwordGeneratorWidget->regeneratePassword();
12221218
m_ui->stackedWidget->setCurrentIndex(PasswordGeneratorScreen);
1219+
statusBar()->setAutoFillBackground(false);
12231220
} else {
12241221
m_ui->passwordGeneratorWidget->saveSettings();
12251222
switchToDatabases();
@@ -1309,10 +1306,10 @@ void MainWindow::databaseTabChanged(int tabIndex)
13091306
{
13101307
if (tabIndex != -1 && m_ui->stackedWidget->currentIndex() == WelcomeScreen) {
13111308
m_ui->stackedWidget->setCurrentIndex(DatabaseTabScreen);
1312-
statusBar()->show();
1309+
statusBar()->setAutoFillBackground(true);
13131310
} else if (tabIndex == -1 && m_ui->stackedWidget->currentIndex() == DatabaseTabScreen) {
13141311
m_ui->stackedWidget->setCurrentIndex(WelcomeScreen);
1315-
statusBar()->hide();
1312+
statusBar()->setAutoFillBackground(false);
13161313
}
13171314

13181315
m_actionMultiplexer.setCurrentObject(m_ui->tabWidget->currentDatabaseWidget());

src/gui/styles/base/basestyle.qss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ QPlainTextEdit, QTextEdit {
7272
padding-left: 4px;
7373
}
7474

75-
QStatusBar {
76-
background-color: palette(window);
77-
}
78-
7975
*[title="true"] {
8076
font-weight: bold;
8177
}

src/gui/styles/dark/DarkStyle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ QString DarkStyle::getAppStyleSheet() const
113113
void DarkStyle::polish(QWidget* widget)
114114
{
115115
if (qobject_cast<QMainWindow*>(widget) || qobject_cast<QDialog*>(widget) || qobject_cast<QMenuBar*>(widget)
116-
|| qobject_cast<QToolBar*>(widget) || qobject_cast<QStatusBar*>(widget)) {
116+
|| qobject_cast<QToolBar*>(widget)) {
117117
auto palette = widget->palette();
118118
#if defined(Q_OS_MACOS)
119119
if (!osUtils->isDarkMode()) {

src/gui/styles/dark/darkstyle.qss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
DatabaseWidget:!active,
22
DatabaseWidget #groupView:!active, DatabaseWidget #tagView:!active,
3-
EntryPreviewWidget *:!active[blendIn="true"], QStatusBar:!active {
3+
EntryPreviewWidget *:!active[blendIn="true"] {
44
background-color: #404042;
55
}
66

77
DatabaseWidget:disabled,
88
DatabaseWidget #groupView:disabled, DatabaseWidget #tagView:disabled,
9-
EntryPreviewWidget *:disabled[blendIn="true"], QStatusBar:disabled {
9+
EntryPreviewWidget *:disabled[blendIn="true"] {
1010
background-color: #424242;
1111
}
1212

src/gui/styles/light/LightStyle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ QString LightStyle::getAppStyleSheet() const
113113
void LightStyle::polish(QWidget* widget)
114114
{
115115
if (qobject_cast<QMainWindow*>(widget) || qobject_cast<QDialog*>(widget) || qobject_cast<QMenuBar*>(widget)
116-
|| qobject_cast<QToolBar*>(widget) || qobject_cast<QStatusBar*>(widget)) {
116+
|| qobject_cast<QToolBar*>(widget)) {
117117
auto palette = widget->palette();
118118
#if defined(Q_OS_MACOS)
119119
if (osUtils->isDarkMode()) {

src/gui/styles/light/lightstyle.qss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
DatabaseWidget:!active,
22
DatabaseWidget #groupView:!active, DatabaseWidget #tagView:!active,
3-
EntryPreviewWidget *:!active[blendIn="true"], QStatusBar:!active {
3+
EntryPreviewWidget *:!active[blendIn="true"] {
44
background-color: #FCFCFC;
55
}
66

77
DatabaseWidget:disabled,
88
DatabaseWidget #groupView:disabled, DatabaseWidget #tagView:disabled,
9-
EntryPreviewWidget *:disabled[blendIn="true"], QStatusBar:disabled {
9+
EntryPreviewWidget *:disabled[blendIn="true"] {
1010
background-color: #EDEDED;
1111
}
1212

0 commit comments

Comments
 (0)