Mercurial > minori
annotate src/gui/dialog/settings.cc @ 327:b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
ToLocalString has also been altered to take in both season
and year because lots of locales actually treat formatting
seasons differently! most notably is Russian which adds a
suffix at the end to notate seasons(??)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 13 Jun 2024 01:49:18 -0400 |
parents | 180714442770 |
children |
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 |
108 | 74 void SettingsDialog::showEvent(QShowEvent* event) { |
75 QDialog::showEvent(event); | |
76 #ifdef WIN32 | |
77 win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme()); | |
78 #endif | |
79 } | |
80 | |
316 | 81 SettingsDialog::SettingsDialog(QWidget* parent) |
82 : QDialog(parent) | |
83 , layout_(this) | |
84 , widget_layout_(&widget_) | |
85 , button_box_(QDialogButtonBox::Ok | QDialogButtonBox::Cancel) { | |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
86 setFixedSize(755, 566); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
87 setWindowTitle(tr("Settings")); |
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
88 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); |
108 | 89 |
90 { | |
316 | 91 widget_.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); |
108 | 92 |
93 { | |
316 | 94 sidebar_.setCurrentItem(sidebar_.AddItem(tr("Services"), SideBar::CreateIcon(":/icons/24x24/globe.png"))); |
95 sidebar_.AddItem(tr("Library"), SideBar::CreateIcon(":/icons/24x24/inbox-film.png")); | |
96 sidebar_.AddItem(tr("Application"), SideBar::CreateIcon(":/icons/24x24/application-sidebar-list.png")); | |
97 sidebar_.AddItem(tr("Recognition"), SideBar::CreateIcon(":/icons/24x24/question.png")); | |
108 | 98 // sidebar->AddItem(tr("Sharing"), SideBar::CreateIcon(":/icons/24x24/megaphone.png")); |
316 | 99 sidebar_.AddItem(tr("Torrents"), SideBar::CreateIcon(":/icons/24x24/feed.png")); |
108 | 100 // sidebar->AddItem(tr("Advanced"), SideBar::CreateIcon(":/icons/24x24/gear.png")); |
36 | 101 |
316 | 102 sidebar_.setIconSize(QSize(24, 24)); |
103 sidebar_.setFrameShape(QFrame::Box); | |
108 | 104 |
316 | 105 sidebar_.SetBackgroundTransparent(false); |
106 sidebar_.setBackgroundRole(QPalette::Base); | |
9 | 107 |
316 | 108 sidebar_.setFixedWidth(158); |
109 sidebar_.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); | |
110 widget_layout_.addWidget(&sidebar_); | |
108 | 111 } |
7 | 112 |
108 | 113 { |
316 | 114 stacked_.addWidget(&services_page_); |
115 stacked_.addWidget(&library_page_); | |
116 stacked_.addWidget(&application_page_); | |
117 stacked_.addWidget(&recognition_page_); | |
118 stacked_.addWidget(&torrents_page_); | |
119 stacked_.setCurrentIndex(0); | |
108 | 120 |
316 | 121 connect(&sidebar_, &QListWidget::currentRowChanged, &stacked_, &QStackedWidget::setCurrentIndex); |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
122 |
316 | 123 widget_layout_.addWidget(&stacked_); |
108 | 124 } |
125 | |
316 | 126 widget_layout_.setContentsMargins(0, 0, 0, 0); |
127 layout_.addWidget(&widget_); | |
108 | 128 } |
9 | 129 |
108 | 130 { |
316 | 131 connect(&button_box_, &QDialogButtonBox::accepted, this, &SettingsDialog::OnOK); |
132 connect(&button_box_, &QDialogButtonBox::rejected, this, &QDialog::reject); | |
133 layout_.addWidget(&button_box_); | |
108 | 134 } |
6
1d82f6e04d7d
Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
135 } |