Mercurial > minori
annotate src/gui/dialog/settings.cc @ 368:6d37a998cf91
gui/dialog: consolidate win32 dark theme cruft into a single class
| author | Paper <paper@tflc.us> |
|---|---|
| date | Fri, 25 Jul 2025 10:05:23 -0400 |
| parents | 180714442770 |
| children | ea3a74ed2ef9 |
| rev | line source |
|---|---|
| 9 | 1 #include "gui/dialog/settings.h" |
| 108 | 2 #include "core/session.h" |
| 46 | 3 #include "gui/widgets/sidebar.h" |
| 4 #include "gui/widgets/text.h" | |
| 9 | 5 #include <QDialogButtonBox> |
| 76 | 6 #include <QHBoxLayout> |
| 7 #include <QLabel> | |
| 9 | 8 #include <QStackedWidget> |
| 9 #include <QVBoxLayout> | |
|
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
10 #include <QWidget> |
| 108 | 11 #ifdef WIN32 |
| 258 | 12 # include "sys/win32/dark_theme.h" |
| 108 | 13 #endif |
|
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
14 |
| 316 | 15 SettingsPage::SettingsPage(QWidget* parent, QString title) |
| 16 : QWidget(parent) | |
| 17 , page_title_(title) | |
| 18 , layout_(this) { | |
|
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
19 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); |
| 36 | 20 |
| 316 | 21 page_title_.setWordWrap(false); |
| 22 page_title_.setFrameShape(QFrame::Panel); | |
| 23 page_title_.setFrameShadow(QFrame::Sunken); | |
| 36 | 24 |
| 102 | 25 { |
| 316 | 26 QFont fnt(page_title_.font()); |
| 27 fnt.setPixelSize(12); | |
| 28 fnt.setWeight(QFont::Bold); | |
| 29 page_title_.setFont(fnt); | |
| 30 } | |
| 31 | |
| 32 { | |
| 33 QPalette pal(page_title_.palette()); | |
| 102 | 34 pal.setColor(QPalette::Window, QColor(0xAB, 0xAB, 0xAB)); |
| 35 pal.setColor(QPalette::WindowText, Qt::white); | |
| 316 | 36 page_title_.setPalette(pal); |
| 102 | 37 } |
|
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
116
diff
changeset
|
38 |
| 316 | 39 page_title_.setAutoFillBackground(true); |
| 36 | 40 |
| 316 | 41 page_title_.setFixedHeight(23); |
| 42 page_title_.setAlignment(Qt::AlignVCenter | Qt::AlignLeft); | |
| 43 page_title_.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); | |
| 46 | 44 |
| 316 | 45 tab_widget_.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); |
|
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
46 |
| 316 | 47 layout_.setContentsMargins(0, 0, 0, 0); |
| 48 layout_.addWidget(&page_title_); | |
| 49 layout_.addWidget(&tab_widget_); | |
|
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
50 } |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
51 |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
52 void SettingsPage::SetTitle(QString title) { |
| 316 | 53 page_title_.setText(title); |
|
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
54 } |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
55 |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
56 void SettingsPage::AddTab(QWidget* tab, QString title) { |
| 316 | 57 tab_widget_.addTab(tab, title); |
|
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
58 } |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
59 |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
60 void SettingsPage::SaveInfo() { |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
61 // no-op... child classes will implement this |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
62 } |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
63 |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
64 void SettingsDialog::OnOK() { |
| 316 | 65 services_page_.SaveInfo(); |
| 66 library_page_.SaveInfo(); | |
| 67 application_page_.SaveInfo(); | |
| 68 recognition_page_.SaveInfo(); | |
| 69 torrents_page_.SaveInfo(); | |
| 70 | |
|
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
71 QDialog::accept(); |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
72 } |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
73 |
| 316 | 74 SettingsDialog::SettingsDialog(QWidget* parent) |
|
368
6d37a998cf91
gui/dialog: consolidate win32 dark theme cruft into a single class
Paper <paper@tflc.us>
parents:
316
diff
changeset
|
75 : Dialog(parent) |
| 316 | 76 , layout_(this) |
| 77 , widget_layout_(&widget_) | |
| 78 , button_box_(QDialogButtonBox::Ok | QDialogButtonBox::Cancel) { | |
|
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
79 setFixedSize(755, 566); |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
80 setWindowTitle(tr("Settings")); |
|
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
81 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); |
| 108 | 82 |
| 83 { | |
| 316 | 84 widget_.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); |
| 108 | 85 |
| 86 { | |
| 316 | 87 sidebar_.setCurrentItem(sidebar_.AddItem(tr("Services"), SideBar::CreateIcon(":/icons/24x24/globe.png"))); |
| 88 sidebar_.AddItem(tr("Library"), SideBar::CreateIcon(":/icons/24x24/inbox-film.png")); | |
| 89 sidebar_.AddItem(tr("Application"), SideBar::CreateIcon(":/icons/24x24/application-sidebar-list.png")); | |
| 90 sidebar_.AddItem(tr("Recognition"), SideBar::CreateIcon(":/icons/24x24/question.png")); | |
| 108 | 91 // sidebar->AddItem(tr("Sharing"), SideBar::CreateIcon(":/icons/24x24/megaphone.png")); |
| 316 | 92 sidebar_.AddItem(tr("Torrents"), SideBar::CreateIcon(":/icons/24x24/feed.png")); |
| 108 | 93 // sidebar->AddItem(tr("Advanced"), SideBar::CreateIcon(":/icons/24x24/gear.png")); |
| 36 | 94 |
| 316 | 95 sidebar_.setIconSize(QSize(24, 24)); |
| 96 sidebar_.setFrameShape(QFrame::Box); | |
| 108 | 97 |
| 316 | 98 sidebar_.SetBackgroundTransparent(false); |
| 99 sidebar_.setBackgroundRole(QPalette::Base); | |
| 9 | 100 |
| 316 | 101 sidebar_.setFixedWidth(158); |
| 102 sidebar_.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); | |
| 103 widget_layout_.addWidget(&sidebar_); | |
| 108 | 104 } |
| 7 | 105 |
| 108 | 106 { |
| 316 | 107 stacked_.addWidget(&services_page_); |
| 108 stacked_.addWidget(&library_page_); | |
| 109 stacked_.addWidget(&application_page_); | |
| 110 stacked_.addWidget(&recognition_page_); | |
| 111 stacked_.addWidget(&torrents_page_); | |
| 112 stacked_.setCurrentIndex(0); | |
| 108 | 113 |
| 316 | 114 connect(&sidebar_, &QListWidget::currentRowChanged, &stacked_, &QStackedWidget::setCurrentIndex); |
|
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
115 |
| 316 | 116 widget_layout_.addWidget(&stacked_); |
| 108 | 117 } |
| 118 | |
| 316 | 119 widget_layout_.setContentsMargins(0, 0, 0, 0); |
| 120 layout_.addWidget(&widget_); | |
| 108 | 121 } |
| 9 | 122 |
| 108 | 123 { |
| 316 | 124 connect(&button_box_, &QDialogButtonBox::accepted, this, &SettingsDialog::OnOK); |
| 125 connect(&button_box_, &QDialogButtonBox::rejected, this, &QDialog::reject); | |
| 126 layout_.addWidget(&button_box_); | |
| 108 | 127 } |
|
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
128 } |
