annotate src/gui/window.cpp @ 54:466ac9870df9

add stub pages (to be implemented)
author Paper <mrpapersonic@gmail.com>
date Tue, 26 Sep 2023 11:18:50 -0400
parents 75c804f713b2
children b7a1c0010ffd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
1 #include "gui/window.h"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
2 #include "core/config.h"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
3 #include "core/session.h"
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
4 #include "gui/dark_theme.h"
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
5 #include "gui/dialog/settings.h"
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
6 #include "gui/dialog/about.h"
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
7 #include "gui/pages/anime_list.h"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
8 #include "gui/pages/now_playing.h"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
9 #include "gui/pages/statistics.h"
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
10 #include "gui/pages/seasons.h"
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
11 #include "gui/pages/search.h"
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
12 #include "gui/pages/torrents.h"
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
13 #include "gui/pages/history.h"
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
14 #include "gui/widgets/sidebar.h"
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
15 #include "services/services.h"
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
16 #include <QApplication>
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
17 #include <QFile>
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
18 #include <QMainWindow>
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
19 #include <QMenuBar>
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
20 #include <QPlainTextEdit>
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
21 #include <QStackedWidget>
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
22 #include <QTextStream>
5
51ae25154b70 Fix OS X support code
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
23 #if MACOSX
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
24 # include "sys/osx/dark_theme.h"
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
25 #elif defined(WIN32)
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
26 # include "sys/win32/dark_theme.h"
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
27 #endif
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
28
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
29 enum class Pages {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
30 NOW_PLAYING,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
31
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
32 ANIME_LIST,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
33 HISTORY,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
34 STATISTICS,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
35
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
36 SEARCH,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
37 SEASONS,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
38 TORRENTS
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
39 };
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
40
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
41 MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) {
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
42 main_widget = new QWidget(parent);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
43
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
44 SideBar* sidebar = new SideBar(main_widget);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
45 sidebar->AddItem(tr("Now Playing"), SideBar::CreateIcon(":/icons/16x16/film.png"));
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
46 sidebar->AddSeparator();
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
47 sidebar->AddItem(tr("Anime List"), SideBar::CreateIcon(":/icons/16x16/document-list.png"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
48 sidebar->AddItem(tr("History"), SideBar::CreateIcon(":/icons/16x16/clock-history-frame.png"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
49 sidebar->AddItem(tr("Statistics"), SideBar::CreateIcon(":/icons/16x16/chart.png"));
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
50 sidebar->AddSeparator();
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
51 sidebar->AddItem(tr("Search"), SideBar::CreateIcon(":/icons/16x16/magnifier.png"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
52 sidebar->AddItem(tr("Seasons"), SideBar::CreateIcon(":/icons/16x16/calendar.png"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
53 sidebar->AddItem(tr("Torrents"), SideBar::CreateIcon(":/icons/16x16/feed.png"));
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
54 sidebar->setFixedWidth(128);
36
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
55 sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
56
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
57 QStackedWidget* stack = new QStackedWidget(main_widget);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
58 stack->addWidget(new NowPlayingWidget(main_widget));
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
59 stack->addWidget(new AnimeListWidget(main_widget));
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
60 stack->addWidget(new HistoryWidget(main_widget));
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
61 stack->addWidget(new StatisticsWidget(main_widget));
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
62 stack->addWidget(new SearchWidget(main_widget));
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
63 stack->addWidget(new SeasonsWidget(main_widget));
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
64 stack->addWidget(new TorrentsWidget(main_widget));
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
65
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
66 connect(sidebar, &SideBar::CurrentItemChanged, stack, &QStackedWidget::setCurrentIndex);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
67 sidebar->setCurrentRow(2);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
68
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
69 /* Menu Bar */
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
70 QAction* action;
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
71 QMenuBar* menubar = new QMenuBar(parent);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
72 QMenu* menu = menubar->addMenu(tr("&File"));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
73
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
74 QMenu* submenu = menu->addMenu(tr("&Library folders"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
75 action = submenu->addAction(tr("&Add new folder..."));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
76
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
77 action = menu->addAction(tr("&Scan available episodes"));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
78
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
79 menu->addSeparator();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
80
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
81 action = menu->addAction(tr("Play &next episode"));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
82 action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
83 action = menu->addAction(tr("Play &random episode"));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
84 action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
85
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
86 menu->addSeparator();
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
87
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
88 action = menu->addAction(tr("E&xit"), qApp, &QApplication::quit);
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
89
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
90 menu = menubar->addMenu(tr("&Services"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
91 action = menu->addAction(tr("Synchronize &list"), [this, stack] {
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
92 Services::Synchronize();
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
93 ((AnimeListWidget*)stack->widget((int)Pages::ANIME_LIST))->Refresh();
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
94 });
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
95 action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
96
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
97 menu->addSeparator();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
98
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
99 submenu = menu->addMenu(tr("&AniList"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
100 action = submenu->addAction(tr("Go to my &profile"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
101 action = submenu->addAction(tr("Go to my &stats"));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
102
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
103 submenu = menu->addMenu(tr("&Kitsu"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
104 action = submenu->addAction(tr("Go to my &feed"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
105 action = submenu->addAction(tr("Go to my &library"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
106 action = submenu->addAction(tr("Go to my &profile"));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
107
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
108 submenu = menu->addMenu(tr("&MyAnimeList"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
109 action = submenu->addAction(tr("Go to my p&anel"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
110 action = submenu->addAction(tr("Go to my &profile"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
111 action = submenu->addAction(tr("Go to my &history"));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
112
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
113 menu = menubar->addMenu(tr("&Tools"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
114 submenu = menu->addMenu(tr("&Export anime list"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
115 action = submenu->addAction(tr("Export as &Markdown..."));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
116 action = submenu->addAction(tr("Export as MyAnimeList &XML..."));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
117
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
118 menu->addSeparator();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
119
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
120 action = menu->addAction(tr("Enable anime &recognition"));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
121 action->setCheckable(true);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
122 action = menu->addAction(tr("Enable auto &sharing"));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
123 action->setCheckable(true);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
124 action = menu->addAction(tr("Enable &auto synchronization"));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
125 action->setCheckable(true);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
126
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
127 menu->addSeparator();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
128
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
129 action = menu->addAction(tr("&Settings"), [this] {
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
130 SettingsDialog dialog(this);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
131 dialog.exec();
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
132 });
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
133 action->setMenuRole(QAction::PreferencesRole);
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
134
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
135 menu = menubar->addMenu(tr("&View"));
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
136
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
137 std::map<QAction*, int> page_to_index_map = {};
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
138
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
139 QActionGroup* pages_group = new QActionGroup(this);
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
140 pages_group->setExclusive(true);
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
141
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
142 action = pages_group->addAction(menu->addAction(tr("&Now Playing")));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
143 action->setCheckable(true);
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
144 page_to_index_map[action] = 0;
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
145
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
146 action = pages_group->addAction(menu->addAction(tr("&Anime List")));
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
147 page_to_index_map[action] = 1;
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
148
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
149 action->setCheckable(true);
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
150 action->setChecked(true);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
151 action = pages_group->addAction(menu->addAction(tr("&History")));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
152 action->setCheckable(true);
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
153 page_to_index_map[action] = 2;
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
154
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
155 action = pages_group->addAction(menu->addAction(tr("&Statistics")));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
156 action->setCheckable(true);
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
157 page_to_index_map[action] = 3;
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
158
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
159 action = pages_group->addAction(menu->addAction(tr("S&earch")));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
160 action->setCheckable(true);
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
161 page_to_index_map[action] = 4;
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
162
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
163 action = pages_group->addAction(menu->addAction(tr("Se&asons")));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
164 action->setCheckable(true);
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
165 page_to_index_map[action] = 5;
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
166
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
167 action = pages_group->addAction(menu->addAction(tr("&Torrents")));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
168 action->setCheckable(true);
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
169 page_to_index_map[action] = 6;
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
170
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
171 connect(stack, &QStackedWidget::currentChanged, this, [pages_group, sidebar](int index){
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
172 pages_group->actions()[index]->setChecked(true);
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
173 });
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
174
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
175 connect(pages_group, &QActionGroup::triggered, this, [page_to_index_map, stack](QAction* action) {
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
176 stack->setCurrentIndex(page_to_index_map.at(action));
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
177 });
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
178
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
179 menu->addSeparator();
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
180 menu->addAction(tr("Show sidebar"));
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
181
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
182 menu = menubar->addMenu(tr("&Help"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
183 action = menu->addAction(tr("About Minori"), this, [this] {
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
184 AboutWindow dialog(this);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
185 dialog.exec();
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
186 });
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
187 action = menu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
188 action->setMenuRole(QAction::AboutQtRole);
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
189
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
190 setMenuBar(menubar);
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
191
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
192 QHBoxLayout* layout = new QHBoxLayout(main_widget);
37
9ae9365dd4ea window.cpp: fix sidebar on Linux
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
193 layout->addWidget(sidebar);
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
194 layout->addWidget(stack);
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
195 setCentralWidget(main_widget);
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
196
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
197 DarkTheme::SetTheme(session.config.theme);
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
198 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
199
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
200 void MainWindow::SetActivePage(QWidget* page) {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
201 this->setCentralWidget(page);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
202 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
203
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
204 void MainWindow::closeEvent(QCloseEvent* event) {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
205 session.config.Save();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
206 event->accept();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
207 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
208
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
209 #include "gui/moc_window.cpp"