annotate src/gui/dialog/settings.cc @ 250:c130f47f6f48

*: many many changes e.g. the search page is actually implemented now!
author Paper <paper@paper.us.eu.org>
date Sun, 04 Feb 2024 21:17:17 -0500
parents 4d461ef7d424
children 862d0d8619f6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
1 #include "gui/dialog/settings.h"
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
2 #include "core/session.h"
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
3 #include "gui/widgets/sidebar.h"
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
4 #include "gui/widgets/text.h"
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
5 #include <QDialogButtonBox>
76
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
6 #include <QHBoxLayout>
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
7 #include <QLabel>
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
8 #include <QStackedWidget>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
9 #include <QVBoxLayout>
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10 #include <QWidget>
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
11 #ifdef WIN32
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
12 #include "sys/win32/dark_theme.h"
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
13 #endif
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
15 SettingsPage::SettingsPage(QWidget* parent, QString title) : QWidget(parent) {
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17 page_title = new QLabel(title, this);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18 page_title->setWordWrap(false);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 page_title->setFrameShape(QFrame::Panel);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
20 page_title->setFrameShadow(QFrame::Sunken);
36
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
21
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
22 QFont font(page_title->font());
77
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
23 font.setPixelSize(12);
36
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
24 font.setWeight(QFont::Bold);
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
25 page_title->setFont(font);
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
26
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
27 {
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
28 QPalette pal = page_title->palette();
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
29 pal.setColor(QPalette::Window, QColor(0xAB, 0xAB, 0xAB));
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
30 pal.setColor(QPalette::WindowText, Qt::white);
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
31 page_title->setPalette(pal);
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
32 }
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 116
diff changeset
33
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
34 page_title->setAutoFillBackground(true);
36
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
35
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
36 page_title->setFixedHeight(23);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
37 page_title->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38 page_title->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
39
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
40 tab_widget = new QTabWidget(this);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
41 tab_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
42
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
43 QVBoxLayout* layout = new QVBoxLayout(this);
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
44 layout->setContentsMargins(0, 0, 0, 0);
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
45 layout->addWidget(page_title);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
46 layout->addWidget(tab_widget);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
47 }
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
48
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
49 void SettingsPage::SetTitle(QString title) {
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
50 page_title->setText(title);
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
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
53 void SettingsPage::AddTab(QWidget* tab, QString title) {
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
54 tab_widget->addTab(tab, title);
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
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
57 void SettingsPage::SaveInfo() {
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
58 // no-op... child classes will implement this
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
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
61 void SettingsDialog::OnOK() {
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
62 for (int i = 0; i < stacked->count(); i++) {
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
63 reinterpret_cast<SettingsPage*>(stacked->widget(i))->SaveInfo();
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
64 }
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
65 QDialog::accept();
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
66 }
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
67
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
68 void SettingsDialog::showEvent(QShowEvent* event) {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
69 QDialog::showEvent(event);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
70 #ifdef WIN32
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
71 win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme());
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
72 #endif
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
73 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
74
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
75 SettingsDialog::SettingsDialog(QWidget* parent) : QDialog(parent) {
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
76 setFixedSize(755, 566);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
77 setWindowTitle(tr("Settings"));
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
78 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
79
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
80 QVBoxLayout* full_layout = new QVBoxLayout(this);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
81
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
82 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
83 QWidget* widget = new QWidget(this);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
84 widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
85 QHBoxLayout* layout = new QHBoxLayout(widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
86
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
87 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
88 sidebar = new SideBar(widget);
36
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
89
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
90 sidebar->setCurrentItem(sidebar->AddItem(tr("Services"), SideBar::CreateIcon(":/icons/24x24/globe.png")));
226
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents: 119
diff changeset
91 sidebar->AddItem(tr("Library"), SideBar::CreateIcon(":/icons/24x24/inbox-film.png"));
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
92 sidebar->AddItem(tr("Application"), SideBar::CreateIcon(":/icons/24x24/application-sidebar-list.png"));
119
4eae379cb1ff settings: add a very early recognition tab for configuring players and extensions
Paper <mrpapersonic@gmail.com>
parents: 118
diff changeset
93 sidebar->AddItem(tr("Recognition"), SideBar::CreateIcon(":/icons/24x24/question.png"));
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
94 // sidebar->AddItem(tr("Sharing"), SideBar::CreateIcon(":/icons/24x24/megaphone.png"));
116
254b1d2b7096 settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
95 sidebar->AddItem(tr("Torrents"), SideBar::CreateIcon(":/icons/24x24/feed.png"));
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
96 // sidebar->AddItem(tr("Advanced"), SideBar::CreateIcon(":/icons/24x24/gear.png"));
36
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
97
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
98 sidebar->setIconSize(QSize(24, 24));
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
99 sidebar->setFrameShape(QFrame::Box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
100
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
101 QPalette pal(sidebar->palette());
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
102 sidebar->SetBackgroundColor(pal.color(QPalette::Base));
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
103
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
104 sidebar->setFixedWidth(158);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
105 sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
106 layout->addWidget(sidebar);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
107 }
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
108
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
109 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
110 stacked = new QStackedWidget(widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
111 stacked->addWidget(new SettingsPageServices(stacked));
226
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents: 119
diff changeset
112 stacked->addWidget(new SettingsPageLibrary(stacked));
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
113 stacked->addWidget(new SettingsPageApplication(stacked));
119
4eae379cb1ff settings: add a very early recognition tab for configuring players and extensions
Paper <mrpapersonic@gmail.com>
parents: 118
diff changeset
114 stacked->addWidget(new SettingsPageRecognition(stacked));
116
254b1d2b7096 settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
115 stacked->addWidget(new SettingsPageTorrents(stacked));
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
116 stacked->setCurrentIndex(0);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
117
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
118 connect(sidebar, &QListWidget::currentRowChanged, stacked, &QStackedWidget::setCurrentIndex);
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
119
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
120 layout->addWidget(stacked);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
121 }
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
122
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
123 layout->setContentsMargins(0, 0, 0, 0);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
124 full_layout->addWidget(widget);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
125 }
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
126
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
127 {
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
128 QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
129 connect(button_box, &QDialogButtonBox::accepted, this, &SettingsDialog::OnOK);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
130 connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
131 full_layout->addWidget(button_box);
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
132 }
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
133 }