diff --git a/gui/dbquerywidget.cpp b/gui/dbquerywidget.cpp index 6ad50e1..d72fd0b 100644 --- a/gui/dbquerywidget.cpp +++ b/gui/dbquerywidget.cpp @@ -49,11 +49,7 @@ DbQueryWidget::DbQueryWidget(TagEditorWidget *tagEditorWidget, QWidget *parent) , m_menu(new QMenu(parent)) { m_ui->setupUi(this); -#ifdef Q_OS_WIN32 - setStyleSheet(dialogStyle()); -#else - setStyleSheet(QStringLiteral("QGroupBox { color: palette(text); background-color: palette(base); }")); -#endif + updateStyleSheet(); m_ui->notificationLabel->setText(tr("Search hasn't been started")); m_ui->notificationLabel->setContext(tr("MusicBrainz/LyricsWikia notifications")); @@ -714,6 +710,18 @@ void DbQueryWidget::showLyricsFromIndex(const QModelIndex &index) } } +bool DbQueryWidget::event(QEvent *event) +{ + const auto res = QWidget::event(event); + switch (event->type()) { + case QEvent::PaletteChange: + updateStyleSheet(); + break; + default:; + } + return res; +} + void DbQueryWidget::clearSearchCriteria() { m_ui->titleLineEdit->clear(); @@ -722,6 +730,15 @@ void DbQueryWidget::clearSearchCriteria() m_ui->trackSpinBox->setValue(0); } +void DbQueryWidget::updateStyleSheet() +{ +#ifdef Q_OS_WINDOWS + setStyleSheet(dialogStyleForPalette(palette())); +#else + setStyleSheet(QStringLiteral("QGroupBox { color: palette(text); background-color: palette(base); }")); +#endif +} + bool DbQueryWidget::eventFilter(QObject *obj, QEvent *event) { if (obj == m_ui->searchGroupBox) { diff --git a/gui/dbquerywidget.h b/gui/dbquerywidget.h index 06a902b..9915137 100644 --- a/gui/dbquerywidget.h +++ b/gui/dbquerywidget.h @@ -49,6 +49,7 @@ public Q_SLOTS: void clearSearchCriteria(); private Q_SLOTS: + void updateStyleSheet(); void showResults(); void setStatus(bool aborted); void fileStatusChanged(bool opened, bool hasTags); @@ -65,6 +66,7 @@ private Q_SLOTS: void showLyricsFromIndex(const QModelIndex &index); protected: + bool event(QEvent *event) override; bool eventFilter(QObject *obj, QEvent *event) override; private: diff --git a/gui/entertargetdialog.cpp b/gui/entertargetdialog.cpp index 4ee6725..59c495e 100644 --- a/gui/entertargetdialog.cpp +++ b/gui/entertargetdialog.cpp @@ -68,10 +68,7 @@ EnterTargetDialog::EnterTargetDialog(QWidget *parent) { // setup UI m_ui->setupUi(this); - // apply style sheets -#ifdef Q_OS_WIN32 - setStyleSheet(dialogStyle()); -#endif + updateStyleSheet(); // setup views m_ui->tracksListView->setModel(m_tracksModel); m_ui->chaptersListView->setModel(m_chaptersModel); @@ -91,7 +88,14 @@ EnterTargetDialog::~EnterTargetDialog() void EnterTargetDialog::updateLevelNamePlaceholderText(int i) { m_ui->levelNameLineEdit->setPlaceholderText(qstringFromStdStringView( - i >= 0 ? tagTargetLevelName(containerTargetLevel(m_currentContainerFormat, static_cast(i))) : std::string_view())); + i >= 0 ? tagTargetLevelName(containerTargetLevel(m_currentContainerFormat, static_cast(i))) : std::string_view())); +} + +void EnterTargetDialog::updateStyleSheet() +{ +#ifdef Q_OS_WINDOWS + setStyleSheet(dialogStyleForPalette(palette())); +#endif } TagParser::TagTarget EnterTargetDialog::target() const @@ -141,4 +145,16 @@ void EnterTargetDialog::setTarget(const TagTarget &target, const MediaFileInfo * } } +bool EnterTargetDialog::event(QEvent *event) +{ + const auto res = QDialog::event(event); + switch (event->type()) { + case QEvent::PaletteChange: + updateStyleSheet(); + break; + default:; + } + return res; +} + } // namespace QtGui diff --git a/gui/entertargetdialog.h b/gui/entertargetdialog.h index 4638ad3..fc60d2f 100644 --- a/gui/entertargetdialog.h +++ b/gui/entertargetdialog.h @@ -33,8 +33,12 @@ public: TagParser::TagTarget target() const; void setTarget(const TagParser::TagTarget &target, const TagParser::MediaFileInfo *file = nullptr); +protected: + bool event(QEvent *event) override; + private Q_SLOTS: void updateLevelNamePlaceholderText(int i); + void updateStyleSheet(); private: std::unique_ptr m_ui; diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index ebf8ae6..e4c2548 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -76,11 +76,7 @@ MainWindow::MainWindow(QWidget *parent) { // setup UI m_ui->setupUi(this); -#ifdef Q_OS_WIN32 - setStyleSheet(dialogStyle() + QStringLiteral("#tagEditorWidget { color: palette(text); background-color: palette(base); }")); -#else - setStyleSheet(dialogStyle()); -#endif + updateStyleSheet(); // restore geometry and state const auto &settings = Settings::values(); @@ -243,6 +239,9 @@ bool MainWindow::event(QEvent *event) { auto &settings = Settings::values(); switch (event->type()) { + case QEvent::PaletteChange: + updateStyleSheet(); + break; case QEvent::Close: if (m_ui->tagEditorWidget->isFileOperationOngoing()) { event->ignore(); @@ -348,6 +347,18 @@ void MainWindow::handleCurrentPathChanged(const QString &newPath) activateWindow(); } +/*! + * \brief Updates the style sheet. + */ +void MainWindow::updateStyleSheet() +{ +#ifdef Q_OS_WINDOWS + setStyleSheet(dialogStyleForPalette(palette()) + QStringLiteral("#tagEditorWidget { color: palette(text); background-color: palette(base); }")); +#else + setStyleSheet(dialogStyleForPalette(palette())); +#endif +} + /*! * \brief Spawns an external player for the current file. */ diff --git a/gui/mainwindow.h b/gui/mainwindow.h index b36878e..0e4b51b 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -67,6 +67,7 @@ private Q_SLOTS: void showSaveAsDlg(); void handleFileStatusChange(bool opened, bool hasTag); void handleCurrentPathChanged(const QString &newPath); + void updateStyleSheet(); // settings void showNewWindow(); diff --git a/gui/picturepreviewselection.cpp b/gui/picturepreviewselection.cpp index 4444ec5..fe4678f 100644 --- a/gui/picturepreviewselection.cpp +++ b/gui/picturepreviewselection.cpp @@ -601,8 +601,8 @@ void PicturePreviewSelection::convertSelected() m_imageConversionDialog = new QDialog(this); m_imageConversionUI = make_unique(); m_imageConversionUI->setupUi(m_imageConversionDialog); -#ifdef Q_OS_WIN32 - m_imageConversionDialog->setStyleSheet(dialogStyle()); +#ifdef Q_OS_WINDOWS + m_imageConversionDialog->setStyleSheet(dialogStyleForPalette(palette())); #endif m_imageConversionUI->formatComboBox->addItems({ tr("JPEG"), tr("PNG") }); m_imageConversionUI->aspectRatioComboBox->addItems({ tr("Ignore"), tr("Keep"), tr("Keep by expanding") }); @@ -638,6 +638,22 @@ void PicturePreviewSelection::setCoverButtonsHidden(bool hideCoverButtons) m_ui->coverButtonsWidget->setHidden(hideCoverButtons); } +bool PicturePreviewSelection::event(QEvent *event) +{ + const auto res = QWidget::event(event); +#ifdef Q_OS_WINDOWS + switch (event->type()) { + case QEvent::PaletteChange: + if (m_imageConversionDialog) { + m_imageConversionDialog->setStyleSheet(dialogStyleForPalette(palette())); + } + break; + default:; + } +#endif + return res; +} + void PicturePreviewSelection::changeEvent(QEvent *event) { switch (event->type()) { diff --git a/gui/picturepreviewselection.h b/gui/picturepreviewselection.h index 7d1fa3d..6c92db5 100644 --- a/gui/picturepreviewselection.h +++ b/gui/picturepreviewselection.h @@ -68,6 +68,7 @@ Q_SIGNALS: void pictureChanged(); protected: + bool event(QEvent *event) override; void changeEvent(QEvent *event) override; void resizeEvent(QResizeEvent *event) override; void dragEnterEvent(QDragEnterEvent *event) override; diff --git a/gui/renamefilesdialog.cpp b/gui/renamefilesdialog.cpp index 8b1fc1d..d4d76c0 100644 --- a/gui/renamefilesdialog.cpp +++ b/gui/renamefilesdialog.cpp @@ -37,9 +37,7 @@ RenameFilesDialog::RenameFilesDialog(QWidget *parent) { setAttribute(Qt::WA_QuitOnClose, false); m_ui->setupUi(this); -#ifdef Q_OS_WIN32 - setStyleSheet(dialogStyle() + QStringLiteral("QSplitter:handle { background-color: palette(base); }")); -#endif + updateStyleSheet(); // setup javascript editor and script file selection m_ui->javaScriptPlainTextEdit->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); m_highlighter = new JavaScriptHighlighter(m_ui->javaScriptPlainTextEdit->document()); @@ -114,6 +112,9 @@ bool RenameFilesDialog::event(QEvent *event) { auto &settings = Settings::values().renamingUtility; switch (event->type()) { + case QEvent::PaletteChange: + updateStyleSheet(); + break; case QEvent::Close: // save settings settings.scriptSource = m_ui->sourceFileStackedWidget->currentIndex(); @@ -402,4 +403,11 @@ void RenameFilesDialog::setScriptModified(bool scriptModified) m_scriptModified = scriptModified; } +void RenameFilesDialog::updateStyleSheet() +{ +#ifdef Q_OS_WINDOWS + setStyleSheet(dialogStyleForPalette(palette()) + QStringLiteral("QSplitter:handle { background-color: palette(base); }")); +#endif +} + } // namespace QtGui diff --git a/gui/renamefilesdialog.h b/gui/renamefilesdialog.h index 5c832e1..f3a5a13 100644 --- a/gui/renamefilesdialog.h +++ b/gui/renamefilesdialog.h @@ -52,6 +52,7 @@ private Q_SLOTS: void abortClose(); void toggleScriptSource(); void setScriptModified(bool scriptModified); + void updateStyleSheet(); private: std::unique_ptr m_ui;