Dynamically change the status bar color depending on the current screen (#11672)

* Revert (https://github.com/keepassxreboot/keepassxc/pull/11455)
* Do not use styles for QStatusBar
* Dynamically change the status bar color depending on the current screen
This commit is contained in:
xboxones1 2025-02-23 21:32:51 +09:00 committed by GitHub
parent e4bb80b96c
commit 5a3289ee3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 12 additions and 19 deletions

View File

@ -687,11 +687,6 @@ MainWindow::MainWindow()
restoreConfigState();
updateMenuActionState();
// Check the current screen and hide the status bar if it is the WelcomeScreen
if (m_ui->stackedWidget->currentIndex() == WelcomeScreen) {
statusBar()->hide();
}
}
MainWindow::~MainWindow()
@ -1197,10 +1192,10 @@ void MainWindow::switchToDatabases()
{
if (m_ui->tabWidget->currentIndex() == -1) {
m_ui->stackedWidget->setCurrentIndex(WelcomeScreen);
statusBar()->hide();
statusBar()->setAutoFillBackground(false);
} else {
m_ui->stackedWidget->setCurrentIndex(DatabaseTabScreen);
statusBar()->show();
statusBar()->setAutoFillBackground(true);
}
}
@ -1209,6 +1204,7 @@ void MainWindow::switchToSettings(bool enabled)
if (enabled) {
m_ui->settingsWidget->loadSettings();
m_ui->stackedWidget->setCurrentIndex(SettingsScreen);
statusBar()->setAutoFillBackground(true);
} else {
switchToDatabases();
}
@ -1220,6 +1216,7 @@ void MainWindow::togglePasswordGenerator(bool enabled)
m_ui->passwordGeneratorWidget->loadSettings();
m_ui->passwordGeneratorWidget->regeneratePassword();
m_ui->stackedWidget->setCurrentIndex(PasswordGeneratorScreen);
statusBar()->setAutoFillBackground(false);
} else {
m_ui->passwordGeneratorWidget->saveSettings();
switchToDatabases();
@ -1309,10 +1306,10 @@ void MainWindow::databaseTabChanged(int tabIndex)
{
if (tabIndex != -1 && m_ui->stackedWidget->currentIndex() == WelcomeScreen) {
m_ui->stackedWidget->setCurrentIndex(DatabaseTabScreen);
statusBar()->show();
statusBar()->setAutoFillBackground(true);
} else if (tabIndex == -1 && m_ui->stackedWidget->currentIndex() == DatabaseTabScreen) {
m_ui->stackedWidget->setCurrentIndex(WelcomeScreen);
statusBar()->hide();
statusBar()->setAutoFillBackground(false);
}
m_actionMultiplexer.setCurrentObject(m_ui->tabWidget->currentDatabaseWidget());

View File

@ -72,10 +72,6 @@ QPlainTextEdit, QTextEdit {
padding-left: 4px;
}
QStatusBar {
background-color: palette(window);
}
*[title="true"] {
font-weight: bold;
}

View File

@ -113,7 +113,7 @@ QString DarkStyle::getAppStyleSheet() const
void DarkStyle::polish(QWidget* widget)
{
if (qobject_cast<QMainWindow*>(widget) || qobject_cast<QDialog*>(widget) || qobject_cast<QMenuBar*>(widget)
|| qobject_cast<QToolBar*>(widget) || qobject_cast<QStatusBar*>(widget)) {
|| qobject_cast<QToolBar*>(widget)) {
auto palette = widget->palette();
#if defined(Q_OS_MACOS)
if (!osUtils->isDarkMode()) {

View File

@ -1,12 +1,12 @@
DatabaseWidget:!active,
DatabaseWidget #groupView:!active, DatabaseWidget #tagView:!active,
EntryPreviewWidget *:!active[blendIn="true"], QStatusBar:!active {
EntryPreviewWidget *:!active[blendIn="true"] {
background-color: #404042;
}
DatabaseWidget:disabled,
DatabaseWidget #groupView:disabled, DatabaseWidget #tagView:disabled,
EntryPreviewWidget *:disabled[blendIn="true"], QStatusBar:disabled {
EntryPreviewWidget *:disabled[blendIn="true"] {
background-color: #424242;
}

View File

@ -113,7 +113,7 @@ QString LightStyle::getAppStyleSheet() const
void LightStyle::polish(QWidget* widget)
{
if (qobject_cast<QMainWindow*>(widget) || qobject_cast<QDialog*>(widget) || qobject_cast<QMenuBar*>(widget)
|| qobject_cast<QToolBar*>(widget) || qobject_cast<QStatusBar*>(widget)) {
|| qobject_cast<QToolBar*>(widget)) {
auto palette = widget->palette();
#if defined(Q_OS_MACOS)
if (osUtils->isDarkMode()) {

View File

@ -1,12 +1,12 @@
DatabaseWidget:!active,
DatabaseWidget #groupView:!active, DatabaseWidget #tagView:!active,
EntryPreviewWidget *:!active[blendIn="true"], QStatusBar:!active {
EntryPreviewWidget *:!active[blendIn="true"] {
background-color: #FCFCFC;
}
DatabaseWidget:disabled,
DatabaseWidget #groupView:disabled, DatabaseWidget #tagView:disabled,
EntryPreviewWidget *:disabled[blendIn="true"], QStatusBar:disabled {
EntryPreviewWidget *:disabled[blendIn="true"] {
background-color: #EDEDED;
}