annotate src/main.cpp @ 6:1d82f6e04d7d

Update: add first parts to the settings dialog
author Paper <mrpapersonic@gmail.com>
date Wed, 16 Aug 2023 00:49:17 -0400
parents 51ae25154b70
children 07a9095eaeed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
1 #include "window.h"
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
2 #include "config.h"
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
3 #include "anime.h"
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
4 #include "sidebar.h"
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
5 #include "ui_utils.h"
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
6 #include "settings.h"
5
51ae25154b70 Fix OS X support code
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
7 #if MACOSX
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
8 #include "sys/osx/dark_theme.h"
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
9 #elif WIN32
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
10 #include "sys/win32/dark_theme.h"
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
11 #endif
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
12
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
13 Session session = {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
14 .config = Config()
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
15 };
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
16
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
17 /* note that this code was originally created for use in
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
18 wxWidgets, but I thought the API was a little meh, so
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
19 I switched to Qt. */
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
20
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
21 MainWindow::MainWindow(QWidget* parent) :
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
22 QMainWindow(parent) {
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
23 main_widget = new QWidget(parent);
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
24 /* Menu Bar */
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
25 QAction* action;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
26 QMenuBar* menubar = new QMenuBar(parent);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
27 QMenu* menu = menubar->addMenu("&File");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
28 QMenu* submenu = menu->addMenu("&Library folders");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
29 action = new QAction("&Add new folder...");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
30 submenu->addAction(action);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
31 action = new QAction("&Scan available episodes");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
32 menu->addAction(action);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
33
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
34 menu->addSeparator();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
35
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
36 action = menu->addAction("Play &next episode");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
37 action = menu->addAction("Play &random episode");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
38 menu->addSeparator();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
39 action = menu->addAction("E&xit", qApp, &QApplication::quit);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
40
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
41 menu = menubar->addMenu("&Services");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
42 action = new QAction("Synchronize &list");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
43
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
44 menu->addSeparator();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
45
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
46 submenu = menu->addMenu("&AniList");
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
47 action = submenu->addAction("Go to my &profile");
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
48 action = submenu->addAction("Go to my &stats");
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
49
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
50 submenu = menu->addMenu("&Kitsu");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
51 action = submenu->addAction("Go to my &feed");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
52 action = submenu->addAction("Go to my &library");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
53 action = submenu->addAction("Go to my &profile");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
54
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
55 submenu = menu->addMenu("&MyAnimeList");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
56 action = submenu->addAction("Go to my p&anel");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
57 action = submenu->addAction("Go to my &profile");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
58 action = submenu->addAction("Go to my &history");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
59
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
60 menu = menubar->addMenu("&Tools");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
61 submenu = menu->addMenu("&Export anime list");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
62 action = submenu->addAction("Export as &Markdown...");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
63 action = submenu->addAction("Export as MyAnimeList &XML...");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
64
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
65 menu->addSeparator();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
66
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
67 action = menu->addAction("Enable anime &recognition");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
68 action->setCheckable(true);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
69 action = menu->addAction("Enable auto &sharing");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
70 action->setCheckable(true);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
71 action = menu->addAction("Enable &auto synchronization");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
72 action->setCheckable(true);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
73
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
74 menu->addSeparator();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
75
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
76 action = menu->addAction("&Settings", [this]{
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
77 SettingsDialog dialog(this);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
78 dialog.exec();
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
79 });
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
80
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
81 setMenuBar(menubar);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
82
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
83 /* Side toolbar */
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
84 SideBar* sidebar = new SideBar(main_widget);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
85 sidebar->AddItem("Now Playing", UiUtils::CreateSideBarIcon(":/icons/16x16/film.png"));
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
86 sidebar->AddSeparator();
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
87 sidebar->AddItem("Anime List", UiUtils::CreateSideBarIcon(":/icons/16x16/document-list.png"));
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
88 sidebar->AddItem("History", UiUtils::CreateSideBarIcon(":/icons/16x16/clock-history-frame.png"));
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
89 sidebar->AddItem("Statistics", UiUtils::CreateSideBarIcon(":/icons/16x16/chart.png"));
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
90 sidebar->AddSeparator();
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
91 sidebar->AddItem("Search", UiUtils::CreateSideBarIcon(":/icons/16x16/magnifier.png"));
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
92 sidebar->AddItem("Seasons", UiUtils::CreateSideBarIcon(":/icons/16x16/calendar.png"));
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
93 sidebar->AddItem("Torrents", UiUtils::CreateSideBarIcon(":/icons/16x16/feed.png"));
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
94 sidebar->setFixedWidth(128);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
95 sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
96
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
97 anime_list_page = new AnimeListPage(parent);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
98
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
99 QHBoxLayout* layout = new QHBoxLayout(main_widget);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
100 layout->addWidget(sidebar, 0, Qt::AlignLeft | Qt::AlignTop);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
101 layout->addWidget(anime_list_page);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
102 SetActivePage(main_widget);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
103 /*
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
104 QToolBar* toolbar = new QToolBar(parent);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
105 QActionGroup* tb_action_group = new QActionGroup(toolbar);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
106
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
107 action = toolbar->addAction("Now Playing");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
108 action->setActionGroup(tb_action_group);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
109 action->setCheckable(true);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
110
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
111 toolbar->addSeparator();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
112
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
113 action = toolbar->addAction("Anime List", [this]() {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
114 setCentralWidget(anime_list_page);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
115 });
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
116 action->setActionGroup(tb_action_group);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
117 action->setCheckable(true);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
118 action->setChecked(true);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
119 anime_list_page = new AnimeListPage(parent);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
120 SetActivePage(anime_list_page);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
121 action = toolbar->addAction("History");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
122 action->setActionGroup(tb_action_group);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
123 action->setCheckable(true);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
124 action = toolbar->addAction("Statistics");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
125 action->setActionGroup(tb_action_group);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
126 action->setCheckable(true);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
127
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
128 toolbar->addSeparator();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
129
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
130 action = toolbar->addAction("Search");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
131 action->setActionGroup(tb_action_group);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
132 action->setCheckable(true);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
133 action = toolbar->addAction("Seasons");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
134 action->setActionGroup(tb_action_group);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
135 action->setCheckable(true);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
136 action = toolbar->addAction("Torrents");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
137 action->setActionGroup(tb_action_group);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
138 action->setCheckable(true);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
139
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
140 toolbar->setMovable(false);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
141 toolbar->setFloatable(false);
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
142 toolbar->setMinimumSize(QSize(140, 0));
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
143 toolbar->setObjectName("sidebar");
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
144 toolbar->setStyleSheet("QToolBar#sidebar{margin: 6px;}");
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
145 //toolbar->setFrameShape(QFrame::NoFrame);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
146 toolbar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum);
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
147
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
148 addToolBar(Qt::LeftToolBarArea, toolbar);
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
149 */
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
150 ThemeChanged();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
151 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
152
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
153 void MainWindow::SetStyleSheet(enum Themes theme) {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
154 switch (theme) {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
155 case DARK: {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
156 QFile f(":qdarkstyle/dark/darkstyle.qss");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
157 if (!f.exists())
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
158 return; // fail
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
159 f.open(QFile::ReadOnly | QFile::Text);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
160 QTextStream ts(&f);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
161 setStyleSheet(ts.readAll());
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
162 break;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
163 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
164 default:
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
165 setStyleSheet("");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
166 break;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
167 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
168 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
169
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
170 void MainWindow::ThemeChanged() {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
171 switch (session.config.theme) {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
172 case LIGHT: {
5
51ae25154b70 Fix OS X support code
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
173 #if MACOSX
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
174 if (osx::DarkThemeAvailable())
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
175 osx::SetToLightTheme();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
176 else
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
177 SetStyleSheet(LIGHT);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
178 #else
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
179 SetStyleSheet(LIGHT);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
180 #endif
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
181 break;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
182 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
183 case DARK: {
5
51ae25154b70 Fix OS X support code
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
184 #if MACOSX
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
185 if (osx::DarkThemeAvailable())
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
186 osx::SetToDarkTheme();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
187 else
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
188 SetStyleSheet(DARK);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
189 #else
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
190 SetStyleSheet(DARK);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
191 #endif
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
192 break;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
193 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
194 case OS: {
5
51ae25154b70 Fix OS X support code
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
195 #if MACOSX
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
196 if (osx::DarkThemeAvailable())
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
197 osx::SetToAutoTheme();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
198 else
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
199 SetStyleSheet(LIGHT);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
200 #elif defined(WIN32)
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
201 if (win32::DarkThemeAvailable()) {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
202 if (win32::IsInDarkTheme()) {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
203 SetStyleSheet(DARK);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
204 } else {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
205 SetStyleSheet(LIGHT);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
206 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
207 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
208 #else
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
209 /* Currently OS detection only supports Windows and macOS.
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
210 Please don't be shy if you're willing to port it to other OSes
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
211 (or desktop environments, or window managers) */
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
212 SetStyleSheet(LIGHT);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
213 #endif
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
214 break;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
215 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
216 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
217 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
218
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
219 void MainWindow::SetActivePage(QWidget* page) {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
220 this->setCentralWidget(page);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
221 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
222
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
223 void MainWindow::closeEvent(QCloseEvent* event) {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
224 session.config.Save();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
225 event->accept();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
226 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
227
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
228 int main(int argc, char** argv) {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
229 QApplication app(argc, argv);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
230
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
231 session.config.Load();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
232
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
233 MainWindow window;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
234
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
235 window.resize(941, 750);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
236 window.setWindowTitle("Weeaboo");
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
237 window.show();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
238
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
239 return app.exec();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
240 }