annotate src/gui/window.cc @ 102:b315f3759c56

*: big patch 1. use a wrapper for mINI that enables case sensitivity (personal preference) 2. rename dark_theme.cc to theme.cc and change it to be a class 3. include the "dep" folder so we don't have stupidity in json.h or ini.h 4. I think the graph was also tweaked a lot in this, nothing is constexpr and size is found at runtime...
author Paper <mrpapersonic@gmail.com>
date Fri, 03 Nov 2023 21:32:52 -0400
parents d02fdf1d6708
children 621084cc542c
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"
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
2 #include "core/anime_db.h"
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
3 #include "core/config.h"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
4 #include "core/session.h"
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
5 #include "core/strings.h"
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 83
diff changeset
6 #include "gui/theme.h"
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 58
diff changeset
7 #include "gui/dialog/about.h"
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
8 #include "gui/dialog/settings.h"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
9 #include "gui/pages/anime_list.h"
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 58
diff changeset
10 #include "gui/pages/history.h"
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
11 #include "gui/pages/now_playing.h"
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 58
diff changeset
12 #include "gui/pages/search.h"
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 58
diff changeset
13 #include "gui/pages/seasons.h"
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
14 #include "gui/pages/statistics.h"
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
15 #include "gui/pages/torrents.h"
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
16 #include "gui/widgets/sidebar.h"
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
17 #include "services/services.h"
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
18 #include "track/media.h"
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
19 #include <QActionGroup>
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
20 #include <QApplication>
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
21 #include <QDebug>
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
22 #include <QFile>
69
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
23 #include <QHBoxLayout>
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
24 #include <QMainWindow>
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
25 #include <QMenuBar>
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
26 #include <QMessageBox>
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
27 #include <QPlainTextEdit>
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
28 #include <QStackedWidget>
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
29 #include <QTextStream>
77
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 69
diff changeset
30 #include <QThreadPool>
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 58
diff changeset
31 #include <QTimer>
69
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
32 #include <QToolBar>
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
33 #include <QToolButton>
5
51ae25154b70 Fix OS X support code
Paper <mrpapersonic@gmail.com>
parents: 2
diff changeset
34 #if MACOSX
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
35 # include "sys/osx/dark_theme.h"
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
36 #elif defined(WIN32)
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
37 # include "sys/win32/dark_theme.h"
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
38 #endif
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
39
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
40 enum class Pages {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
41 NOW_PLAYING,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
42
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
43 ANIME_LIST,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
44 HISTORY,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
45 STATISTICS,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
46
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
47 SEARCH,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
48 SEASONS,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
49 TORRENTS
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
50 };
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
51
77
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 69
diff changeset
52 static void AsyncSynchronize(QStackedWidget* stack) {
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 69
diff changeset
53 QThreadPool::globalInstance()->start([stack] {
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 69
diff changeset
54 Services::Synchronize();
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 69
diff changeset
55 reinterpret_cast<AnimeListPage*>(stack->widget(static_cast<int>(Pages::ANIME_LIST)))->Refresh();
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 69
diff changeset
56 });
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 69
diff changeset
57 }
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 69
diff changeset
58
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
59 MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) {
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
60 main_widget = new QWidget(parent);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
61
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
62 sidebar = new SideBar(main_widget);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
63 sidebar->AddItem(tr("Now Playing"), SideBar::CreateIcon(":/icons/16x16/film.png"));
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
64 sidebar->AddSeparator();
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
65 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
66 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
67 sidebar->AddItem(tr("Statistics"), SideBar::CreateIcon(":/icons/16x16/chart.png"));
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
68 sidebar->AddSeparator();
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
69 sidebar->AddItem(tr("Search"), SideBar::CreateIcon(":/icons/16x16/magnifier.png"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
70 sidebar->AddItem(tr("Seasons"), SideBar::CreateIcon(":/icons/16x16/calendar.png"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
71 sidebar->AddItem(tr("Torrents"), SideBar::CreateIcon(":/icons/16x16/feed.png"));
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
72 sidebar->setFixedWidth(128);
36
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
73 sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
74
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
75 stack = new QStackedWidget(main_widget);
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
76 stack->addWidget(new NowPlayingPage(main_widget));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
77 stack->addWidget(new AnimeListPage(main_widget));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
78 stack->addWidget(new HistoryPage(main_widget));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
79 stack->addWidget(new StatisticsPage(main_widget));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
80 stack->addWidget(new SearchPage(main_widget));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
81 stack->addWidget(new SeasonsPage(main_widget));
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
82 stack->addWidget(new TorrentsPage(main_widget));
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
83
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
84 connect(sidebar, &SideBar::CurrentItemChanged, stack, &QStackedWidget::setCurrentIndex);
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
85 sidebar->SetCurrentItem(static_cast<int>(Pages::ANIME_LIST));
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
86
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
87 QHBoxLayout* layout = new QHBoxLayout(main_widget);
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
88 layout->addWidget(sidebar);
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
89 layout->addWidget(stack);
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
90 setCentralWidget(main_widget);
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
91
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
92 CreateBars();
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
93
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
94 QTimer* timer = new QTimer(this);
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
95 connect(timer, &QTimer::timeout, this, [this] {
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
96 NowPlayingPage* page = reinterpret_cast<NowPlayingPage*>(stack->widget(static_cast<int>(Pages::NOW_PLAYING)));
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
97
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
98 Filesystem::Path p = Track::Media::GetCurrentPlaying();
80
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 79
diff changeset
99 std::unordered_map<std::string, std::string> elements = Track::Media::GetFileElements(p);
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 79
diff changeset
100 int id = Anime::db.GetAnimeFromTitle(elements["title"]);
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
101 if (id <= 0) {
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
102 page->SetDefault();
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
103 return;
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
104 }
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
105
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
106 page->SetPlaying(Anime::db.items[id], elements);
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
107 });
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
108 timer->start(5000);
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
109 }
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
110
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
111 void MainWindow::CreateBars() {
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
112 /* Menu Bar */
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
113 QAction* action;
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
114 QMenuBar* menubar = new QMenuBar(this);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
115 QMenu* menu = menubar->addMenu(tr("&File"));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
116
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
117 QMenu* submenu = menu->addMenu(tr("&Library folders"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
118 action = submenu->addAction(tr("&Add new folder..."));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
119
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
120 action = menu->addAction(tr("&Scan available episodes"));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
121
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
122 menu->addSeparator();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
123
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
124 action = menu->addAction(tr("Play &next episode"));
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 58
diff changeset
125 action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N));
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
126 action = menu->addAction(tr("Play &random episode"));
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 58
diff changeset
127 action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
128
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
129 menu->addSeparator();
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
130
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
131 action = menu->addAction(tr("E&xit"), qApp, &QApplication::quit);
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
132
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
133 menu = menubar->addMenu(tr("&Services"));
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
134 action = menu->addAction(tr("Synchronize &list"), [this] { AsyncSynchronize(stack); });
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 58
diff changeset
135 action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
136
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
137 menu->addSeparator();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
138
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
139 submenu = menu->addMenu(tr("&AniList"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
140 action = submenu->addAction(tr("Go to my &profile"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
141 action = submenu->addAction(tr("Go to my &stats"));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
142
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
143 submenu = menu->addMenu(tr("&Kitsu"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
144 action = submenu->addAction(tr("Go to my &feed"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
145 action = submenu->addAction(tr("Go to my &library"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
146 action = submenu->addAction(tr("Go to my &profile"));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
147
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
148 submenu = menu->addMenu(tr("&MyAnimeList"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
149 action = submenu->addAction(tr("Go to my p&anel"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
150 action = submenu->addAction(tr("Go to my &profile"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
151 action = submenu->addAction(tr("Go to my &history"));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
152
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
153 menu = menubar->addMenu(tr("&Tools"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
154 submenu = menu->addMenu(tr("&Export anime list"));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
155 action = submenu->addAction(tr("Export as &Markdown..."));
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
156 action = submenu->addAction(tr("Export as MyAnimeList &XML..."));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
157
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
158 menu->addSeparator();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
159
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
160 action = menu->addAction(tr("Enable anime &recognition"));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
161 action->setCheckable(true);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
162 action = menu->addAction(tr("Enable auto &sharing"));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
163 action->setCheckable(true);
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
164 action = menu->addAction(tr("Enable &auto synchronization"));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
165 action->setCheckable(true);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
166
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
167 menu->addSeparator();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
168
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
169 action = menu->addAction(tr("&Settings"), [this] {
6
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
170 SettingsDialog dialog(this);
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
171 dialog.exec();
1d82f6e04d7d Update: add first parts to the settings dialog
Paper <mrpapersonic@gmail.com>
parents: 5
diff changeset
172 });
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
173 action->setMenuRole(QAction::PreferencesRole);
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
174
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
175 menu = menubar->addMenu(tr("&View"));
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
176
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
177 std::map<QAction*, int> page_to_index_map = {};
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
178
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
179 QActionGroup* pages_group = new QActionGroup(this);
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
180 pages_group->setExclusive(true);
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 action = pages_group->addAction(menu->addAction(tr("&Now Playing")));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
183 action->setCheckable(true);
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
184 page_to_index_map[action] = 0;
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
185
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
186 action = pages_group->addAction(menu->addAction(tr("&Anime List")));
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
187 page_to_index_map[action] = 1;
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
188 action->setCheckable(true);
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
189 action->setChecked(true);
58
b7a1c0010ffd sidebar: link view menu and sidebar together
Paper <mrpapersonic@gmail.com>
parents: 54
diff changeset
190
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
191 action = pages_group->addAction(menu->addAction(tr("&History")));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
192 action->setCheckable(true);
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
193 page_to_index_map[action] = 2;
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
194
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
195 action = pages_group->addAction(menu->addAction(tr("&Statistics")));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
196 action->setCheckable(true);
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
197 page_to_index_map[action] = 3;
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
198
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
199 action = pages_group->addAction(menu->addAction(tr("S&earch")));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
200 action->setCheckable(true);
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
201 page_to_index_map[action] = 4;
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
202
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
203 action = pages_group->addAction(menu->addAction(tr("Se&asons")));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
204 action->setCheckable(true);
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
205 page_to_index_map[action] = 5;
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
206
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
207 action = pages_group->addAction(menu->addAction(tr("&Torrents")));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
208 action->setCheckable(true);
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
209 page_to_index_map[action] = 6;
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
210
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
211 connect(sidebar, &SideBar::CurrentItemChanged, this,
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
212 [pages_group](int index) { pages_group->actions()[index]->setChecked(true); });
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
213
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
214 connect(pages_group, &QActionGroup::triggered, this,
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
215 [this, page_to_index_map](QAction* action) { sidebar->SetCurrentItem(page_to_index_map.at(action)); });
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
216
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
217 menu->addSeparator();
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
218 menu->addAction(tr("Show sidebar"));
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
219
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
220 menu = menubar->addMenu(tr("&Help"));
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
221 action = menu->addAction(tr("&About Minori"), this, [this] {
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
222 AboutWindow dialog(this);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
223 dialog.exec();
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
224 });
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
225 action = menu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
226 action->setMenuRole(QAction::AboutQtRole);
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
227
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
228 setMenuBar(menubar);
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
229
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
230 /* Toolbar */
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
231 /* remove old toolbar(s) */
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
232 QList<QToolBar*> toolbars = findChildren<QToolBar*>();
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
233 for (auto& t : toolbars)
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
234 removeToolBar(t);
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
235
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
236 QToolBar* toolbar = new QToolBar(this);
77
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 69
diff changeset
237 toolbar->addAction(QIcon(":/icons/24x24/arrow-circle-double-135.png"), tr("&Synchronize"),
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
238 [this] { AsyncSynchronize(stack); });
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
239 toolbar->addSeparator();
69
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
240
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
241 QToolButton* button = new QToolButton(toolbar);
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
242
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
243 menu = new QMenu(button);
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
244 action = menu->addAction(tr("Add new folder..."));
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
245
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
246 button->setMenu(menu);
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
247 button->setIcon(QIcon(":/icons/24x24/folder-open.png"));
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
248 button->setPopupMode(QToolButton::InstantPopup);
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
249 toolbar->addWidget(button);
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
250
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
251 button = new QToolButton(toolbar);
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
252
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
253 menu = new QMenu(button);
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
254 action = menu->addAction(tr("Placeholder"));
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
255
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
256 button->setMenu(menu);
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
257 button->setIcon(QIcon(":/icons/24x24/application-export.png"));
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
258 button->setPopupMode(QToolButton::InstantPopup);
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
259 toolbar->addWidget(button);
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
260
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
261 toolbar->addSeparator();
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
262 toolbar->addAction(QIcon(":/icons/24x24/gear.png"), tr("S&ettings"), [this] {
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
263 SettingsDialog dialog(this);
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
264 dialog.exec();
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
265 });
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
266 addToolBar(toolbar);
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
267 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
268
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
269 void MainWindow::SetActivePage(QWidget* page) {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
270 this->setCentralWidget(page);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
271 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
272
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
273 void MainWindow::closeEvent(QCloseEvent* event) {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
274 session.config.Save();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
275 event->accept();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
276 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
277
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
278 #include "gui/moc_window.cpp"