# HG changeset patch # User Paper # Date 1753452323 14400 # Node ID 6d37a998cf91afd3cfb661ae579852bf9557d7e8 # Parent 8d45d892be880932e3d66e688ae6514f8a205f7f gui/dialog: consolidate win32 dark theme cruft into a single class diff -r 8d45d892be88 -r 6d37a998cf91 CMakeLists.txt --- a/CMakeLists.txt Sun Nov 17 22:55:47 2024 -0500 +++ b/CMakeLists.txt Fri Jul 25 10:05:23 2025 -0400 @@ -68,6 +68,7 @@ include/core/http.h include/core/session.h include/gui/dialog/about.h + include/gui/dialog/dialog.h include/gui/dialog/licenses.h include/gui/dialog/information.h include/gui/dialog/settings.h @@ -141,6 +142,7 @@ # Dialogs src/gui/dialog/about.cc + src/gui/dialog/dialog.cc src/gui/dialog/licenses.cc src/gui/dialog/information.cc src/gui/dialog/settings.cc diff -r 8d45d892be88 -r 6d37a998cf91 include/gui/dialog/about.h --- a/include/gui/dialog/about.h Sun Nov 17 22:55:47 2024 -0500 +++ b/include/gui/dialog/about.h Fri Jul 25 10:05:23 2025 -0400 @@ -1,16 +1,13 @@ #ifndef MINORI_GUI_DIALOG_ABOUT_H_ #define MINORI_GUI_DIALOG_ABOUT_H_ -#include +#include "gui/dialog/dialog.h" -class AboutWindow final : public QDialog { +class AboutWindow final : public Dialog { Q_OBJECT public: AboutWindow(QWidget* parent = nullptr); - -protected: - void showEvent(QShowEvent* event) override; }; #endif // MINORI_GUI_DIALOG_ABOUT_H_ diff -r 8d45d892be88 -r 6d37a998cf91 include/gui/dialog/dialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/gui/dialog/dialog.h Fri Jul 25 10:05:23 2025 -0400 @@ -0,0 +1,17 @@ +#ifndef MINORI_GUI_DIALOG_DIALOG_H_ +#define MINORI_GUI_DIALOG_DIALOG_H_ + +/* generic dialog widget; this abstracts away the win32 title bar hackery */ +#include + +class Dialog : public QDialog { + Q_OBJECT + +public: + Dialog(QWidget *parent = nullptr) : QDialog(parent) {} + +protected: + void showEvent(QShowEvent *event) override; +}; + +#endif // MINORI_GUI_DIALOG_DIALOG_H_ diff -r 8d45d892be88 -r 6d37a998cf91 include/gui/dialog/information.h --- a/include/gui/dialog/information.h Sun Nov 17 22:55:47 2024 -0500 +++ b/include/gui/dialog/information.h Fri Jul 25 10:05:23 2025 -0400 @@ -3,10 +3,10 @@ #include "core/anime.h" #include "core/date.h" -#include +#include "gui/dialog/dialog.h" #include -class InformationDialog final : public QDialog { +class InformationDialog final : public Dialog { Q_OBJECT public: @@ -15,12 +15,11 @@ PAGE_MY_LIST }; + /* weird, the page should be first + * also this should take an anime ID, rather than a pointer --paper */ InformationDialog(Anime::Anime* anime, std::function accept = {}, enum Pages page = Pages::PAGE_MAIN_INFO, QWidget* parent = nullptr); -protected: - void showEvent(QShowEvent* event) override; - private: void SaveData(Anime::Anime* anime); unsigned int _progress; diff -r 8d45d892be88 -r 6d37a998cf91 include/gui/dialog/licenses.h --- a/include/gui/dialog/licenses.h Sun Nov 17 22:55:47 2024 -0500 +++ b/include/gui/dialog/licenses.h Fri Jul 25 10:05:23 2025 -0400 @@ -1,16 +1,13 @@ #ifndef MINORI_GUI_DIALOG_LICENSES_H_ #define MINORI_GUI_DIALOG_LICENSES_H_ -#include +#include "gui/dialog/dialog.h" -class LicensesWindow final : public QDialog { +class LicensesWindow final : public Dialog { Q_OBJECT public: LicensesWindow(QWidget* parent = nullptr); - -protected: - void showEvent(QShowEvent* event) override; }; #endif // MINORI_GUI_DIALOG_LICENSES_H_ diff -r 8d45d892be88 -r 6d37a998cf91 include/gui/dialog/settings.h --- a/include/gui/dialog/settings.h Sun Nov 17 22:55:47 2024 -0500 +++ b/include/gui/dialog/settings.h Fri Jul 25 10:05:23 2025 -0400 @@ -5,7 +5,7 @@ #include "core/config.h" #include "core/session.h" #include "gui/widgets/sidebar.h" -#include +#include "gui/dialog/dialog.h" #include #include #include @@ -108,7 +108,7 @@ decltype(session.config.library.real_time_monitor) real_time_monitor; }; -class SettingsDialog final : public QDialog { +class SettingsDialog final : public Dialog { Q_OBJECT public: @@ -116,9 +116,6 @@ QWidget* CreateServicesMainPage(QWidget* parent); void OnOK(); -protected: - void showEvent(QShowEvent* event) override; - private: QVBoxLayout layout_; diff -r 8d45d892be88 -r 6d37a998cf91 src/gui/dialog/about.cc --- a/src/gui/dialog/about.cc Sun Nov 17 22:55:47 2024 -0500 +++ b/src/gui/dialog/about.cc Fri Jul 25 10:05:23 2025 -0400 @@ -63,7 +63,7 @@ "" ""; -AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) { +AboutWindow::AboutWindow(QWidget* parent) : Dialog(parent) { setMinimumSize(641, 325); setWindowTitle(tr("About Minori")); setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); @@ -95,10 +95,3 @@ }); } } - -void AboutWindow::showEvent(QShowEvent* event) { - QDialog::showEvent(event); -#ifdef WIN32 - win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme()); -#endif -} diff -r 8d45d892be88 -r 6d37a998cf91 src/gui/dialog/dialog.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/gui/dialog/dialog.cc Fri Jul 25 10:05:23 2025 -0400 @@ -0,0 +1,13 @@ +#include "gui/dialog/dialog.h" +#include "gui/widgets/text.h" + +#ifdef WIN32 +# include "sys/win32/dark_theme.h" +#endif + +void Dialog::showEvent(QShowEvent* event) { + QDialog::showEvent(event); +#ifdef WIN32 + win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme()); +#endif +} diff -r 8d45d892be88 -r 6d37a998cf91 src/gui/dialog/information.cc --- a/src/gui/dialog/information.cc Sun Nov 17 22:55:47 2024 -0500 +++ b/src/gui/dialog/information.cc Fri Jul 25 10:05:23 2025 -0400 @@ -47,7 +47,7 @@ InformationDialog::InformationDialog(Anime::Anime* anime, std::function accept, enum Pages page, QWidget* parent) - : QDialog(parent) { + : Dialog(parent) { /* ack. lots of brackets here, but MUCH, MUCH MUCH better than what it used to be */ setFixedSize(842, 613); setWindowTitle(tr("Anime Information")); @@ -317,10 +317,3 @@ full_layout->addWidget(button_box, 0, Qt::AlignBottom); } } - -void InformationDialog::showEvent(QShowEvent* event) { - QDialog::showEvent(event); -#ifdef WIN32 - win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme()); -#endif -} diff -r 8d45d892be88 -r 6d37a998cf91 src/gui/dialog/licenses.cc --- a/src/gui/dialog/licenses.cc Sun Nov 17 22:55:47 2024 -0500 +++ b/src/gui/dialog/licenses.cc Fri Jul 25 10:05:23 2025 -0400 @@ -63,7 +63,7 @@ tab_widget->addTab(dual, title1); } -LicensesWindow::LicensesWindow(QWidget* parent) : QDialog(parent) { +LicensesWindow::LicensesWindow(QWidget* parent) : Dialog(parent) { resize(641, 500); setWindowTitle(tr("About Minori")); setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); @@ -88,10 +88,3 @@ create_basic_license(tab_widget, ":/licenses/LICENSE.toml11", tr("toml11")); create_basic_license(tab_widget, ":/licenses/LICENSE.utf8proc", tr("utf8proc")); } - -void LicensesWindow::showEvent(QShowEvent* event) { - QDialog::showEvent(event); -#ifdef WIN32 - win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme()); -#endif -} diff -r 8d45d892be88 -r 6d37a998cf91 src/gui/dialog/settings.cc --- a/src/gui/dialog/settings.cc Sun Nov 17 22:55:47 2024 -0500 +++ b/src/gui/dialog/settings.cc Fri Jul 25 10:05:23 2025 -0400 @@ -71,15 +71,8 @@ QDialog::accept(); } -void SettingsDialog::showEvent(QShowEvent* event) { - QDialog::showEvent(event); -#ifdef WIN32 - win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme()); -#endif -} - SettingsDialog::SettingsDialog(QWidget* parent) - : QDialog(parent) + : Dialog(parent) , layout_(this) , widget_layout_(&widget_) , button_box_(QDialogButtonBox::Ok | QDialogButtonBox::Cancel) {