annotate src/gui/window.cc @ 114:ab191e28e69d

*: add initial torrent stuff WOAH! these checkboxes are a pain in my fucking ass
author Paper <mrpapersonic@gmail.com>
date Tue, 07 Nov 2023 08:03:42 -0500
parents 32afe0e940bf
children c72b907b9bef
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>
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
34 #include <iostream>
106
c8c72278f6fd *: #if -> #ifdef, remove outdated comments in sys/win32/dark_theme.cc
Paper <mrpapersonic@gmail.com>
parents: 105
diff changeset
35 #ifdef MACOSX
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
36 # include "sys/osx/dark_theme.h"
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
37 #elif defined(WIN32)
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
38 # include "sys/win32/dark_theme.h"
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
39 #endif
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
40
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
41 enum class Pages {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
42 NOW_PLAYING,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
43
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
44 ANIME_LIST,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
45 HISTORY,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
46 STATISTICS,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
47
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
48 SEARCH,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
49 SEASONS,
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
50 TORRENTS
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
51 };
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
52
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
53 MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) {
103
621084cc542c resources: add icons
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
54 setWindowIcon(QIcon(":/favicon.png"));
621084cc542c resources: add icons
Paper <mrpapersonic@gmail.com>
parents: 102
diff changeset
55
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
56 main_widget.reset(new QWidget(this));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
57 /*QHBoxLayout* layout = */new QHBoxLayout(main_widget.get());
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
58
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
59 AddMainWidgets();
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
60
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
61 setCentralWidget(main_widget.get());
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
62
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
63 CreateBars();
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
64
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
65 QTimer* timer = new QTimer(this);
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
66 connect(timer, &QTimer::timeout, this, [this] {
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
67 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
68
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
69 Filesystem::Path p = Track::Media::GetCurrentPlaying();
80
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 79
diff changeset
70 std::unordered_map<std::string, std::string> elements = Track::Media::GetFileElements(p);
825506f0e221 [UNFINISHED]: stuff
Paper <mrpapersonic@gmail.com>
parents: 79
diff changeset
71 int id = Anime::db.GetAnimeFromTitle(elements["title"]);
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
72 if (id <= 0) {
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
73 page->SetDefault();
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
74 return;
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
75 }
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
76
83
d02fdf1d6708 *: huuuge update
Paper <mrpapersonic@gmail.com>
parents: 82
diff changeset
77 page->SetPlaying(Anime::db.items[id], elements);
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
78 });
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
79 timer->start(5000);
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
80 }
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
81
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
82 void MainWindow::AddMainWidgets() {
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
83 int page = static_cast<int>(Pages::ANIME_LIST);
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
84 if (sidebar.get()) {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
85 main_widget->layout()->removeWidget(sidebar.get());
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
86 sidebar.reset();
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
87 }
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
88
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
89 if (stack.get()) {
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
90 page = stack->currentIndex();
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
91 main_widget->layout()->removeWidget(stack.get());
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
92 }
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
93
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
94 sidebar.reset(new SideBar(main_widget.get()));
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
95 sidebar->setFixedWidth(128);
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
96 sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
97
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
98 sidebar->AddItem(tr("Now Playing"), SideBar::CreateIcon(":/icons/16x16/film.png"));
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
99 sidebar->AddSeparator();
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
100 sidebar->AddItem(tr("Anime List"), SideBar::CreateIcon(":/icons/16x16/document-list.png"));
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
101 sidebar->AddItem(tr("History"), SideBar::CreateIcon(":/icons/16x16/clock-history-frame.png"));
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
102 sidebar->AddItem(tr("Statistics"), SideBar::CreateIcon(":/icons/16x16/chart.png"));
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
103 sidebar->AddSeparator();
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
104 sidebar->AddItem(tr("Search"), SideBar::CreateIcon(":/icons/16x16/magnifier.png"));
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
105 sidebar->AddItem(tr("Seasons"), SideBar::CreateIcon(":/icons/16x16/calendar.png"));
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
106 sidebar->AddItem(tr("Torrents"), SideBar::CreateIcon(":/icons/16x16/feed.png"));
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
107
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
108 stack.reset(new QStackedWidget(main_widget.get()));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
109 stack->addWidget(new NowPlayingPage(main_widget.get()));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
110 stack->addWidget(new AnimeListPage(main_widget.get()));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
111 stack->addWidget(new HistoryPage(main_widget.get()));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
112 stack->addWidget(new StatisticsPage(main_widget.get()));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
113 stack->addWidget(new SearchPage(main_widget.get()));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
114 stack->addWidget(new SeasonsPage(main_widget.get()));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
115 stack->addWidget(new TorrentsPage(main_widget.get()));
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
116
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
117 connect(sidebar.get(), &SideBar::CurrentItemChanged, stack.get(), &QStackedWidget::setCurrentIndex);
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
118 sidebar->SetCurrentItem(page);
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
119
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
120 main_widget->layout()->addWidget(sidebar.get());
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
121 main_widget->layout()->addWidget(stack.get());
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
122 }
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
123
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
124 void MainWindow::CreateBars() {
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
125 /* Menu Bar
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
126 The notation of these might seem ugly at first, but it's actually very nice
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
127 (just trust me). It makes it much easier to edit the lists and makes it clear
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
128 if you're in submenu or not. */
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
129 QMenuBar* menubar = new QMenuBar(this);
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
130
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
131 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
132 /* File */
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
133 QMenu* menu = menubar->addMenu(tr("&File"));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
134
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
135 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
136 QMenu* submenu = menu->addMenu(tr("&Library folders"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
137 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
138 QAction* action = submenu->addAction(tr("&Add new folder..."));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
139 }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
140 }
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
141
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
142 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
143 QAction* action = menu->addAction(tr("&Scan available episodes"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
144 }
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
145
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
146 menu->addSeparator();
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
147
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
148 // {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
149 // QAction* action = menu->addAction(tr("Play &next episode"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
150 // action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
151 // }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
152 //
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
153 // {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
154 // QAction* action = menu->addAction(tr("Play &random episode"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
155 // action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
156 // }
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
157
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
158 menu->addSeparator();
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
159
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
160 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
161 QAction* action = menu->addAction(tr("E&xit"), qApp, &QApplication::quit);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
162 }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
163 }
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
164
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
165 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
166 /* Services */
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
167 QMenu* menu = menubar->addMenu(tr("&Services"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
168 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
169 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
170 QAction* action = menu->addAction(tr("Synchronize &list"), [this] { AsyncSynchronize(stack.get()); });
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
171 action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
172 }
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
173
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
174 // menu->addSeparator();
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
175 //
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
176 // {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
177 // /* AniList */
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
178 // QMenu* submenu = menu->addMenu(tr("&AniList"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
179 // QAction* action = submenu->addAction(tr("Go to my &profile"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
180 // action = submenu->addAction(tr("Go to my &stats"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
181 // }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
182 //
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
183 // {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
184 // /* Kitsu */
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
185 // QMenu* submenu = menu->addMenu(tr("&Kitsu"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
186 // QAction* action = submenu->addAction(tr("Go to my &feed"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
187 // action = submenu->addAction(tr("Go to my &library"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
188 // action = submenu->addAction(tr("Go to my &profile"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
189 // }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
190 // {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
191 // QMenu* submenu = menu->addMenu(tr("&MyAnimeList"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
192 // QAction* action = submenu->addAction(tr("Go to my p&anel"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
193 // action = submenu->addAction(tr("Go to my &profile"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
194 // action = submenu->addAction(tr("Go to my &history"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
195 // }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
196 }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
197 }
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
198
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
199 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
200 /* Tools */
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
201 QMenu* menu = menubar->addMenu(tr("&Tools"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
202 // {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
203 // /* Export anime list */
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
204 // QMenu* submenu = menu->addMenu(tr("&Export anime list"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
205 //
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
206 // {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
207 // /* Markdown export */
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
208 // QAction* action = submenu->addAction(tr("Export as &Markdown..."));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
209 // }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
210 //
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
211 // {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
212 // /* XML export */
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
213 // QAction* action = submenu->addAction(tr("Export as MyAnimeList &XML..."));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
214 // }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
215 // }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
216 // menu->addSeparator();
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
217 //
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
218 // {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
219 // QAction* action = menu->addAction(tr("Enable anime &recognition"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
220 // action->setCheckable(true);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
221 // }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
222 //
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
223 // {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
224 // QAction* action = menu->addAction(tr("Enable auto &sharing"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
225 // action->setCheckable(true);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
226 // }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
227 //
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
228 // {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
229 // QAction* action = menu->addAction(tr("Enable &auto synchronization"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
230 // action->setCheckable(true);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
231 // }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
232 //
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
233 // menu->addSeparator();
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
234
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
235 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
236 QAction* action = menu->addAction(tr("&Settings"), [this] {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
237 SettingsDialog dialog(this);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
238 dialog.exec();
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
239 });
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
240 action->setMenuRole(QAction::PreferencesRole);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
241 }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
242 }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
243
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
244 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
245 /* View */
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
246 QMenu* menu = menubar->addMenu(tr("&View"));
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
247
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
248 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
249 /* Pages... */
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
250 std::map<QAction*, int> page_to_index_map = {};
58
b7a1c0010ffd sidebar: link view menu and sidebar together
Paper <mrpapersonic@gmail.com>
parents: 54
diff changeset
251
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
252 QActionGroup* pages_group = new QActionGroup(this);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
253 pages_group->setExclusive(true);
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
254
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
255 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
256 QAction* action = pages_group->addAction(menu->addAction(tr("&Now Playing")));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
257 action->setCheckable(true);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
258 page_to_index_map[action] = 0;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
259 }
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
260
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
261 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
262 QAction* action = pages_group->addAction(menu->addAction(tr("&Anime List")));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
263 action->setCheckable(true);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
264 action->setChecked(true);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
265 page_to_index_map[action] = 1;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
266 }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
267
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
268 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
269 QAction* action = pages_group->addAction(menu->addAction(tr("&History")));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
270 action->setCheckable(true);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
271 page_to_index_map[action] = 2;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
272 }
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
273
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
274 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
275 QAction* action = pages_group->addAction(menu->addAction(tr("&Statistics")));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
276 action->setCheckable(true);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
277 page_to_index_map[action] = 3;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
278 }
48
e613772f41d5 statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents: 46
diff changeset
279
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
280 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
281 QAction* action = pages_group->addAction(menu->addAction(tr("S&earch")));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
282 action->setCheckable(true);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
283 page_to_index_map[action] = 4;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
284 }
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
285
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
286 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
287 QAction* action = pages_group->addAction(menu->addAction(tr("Se&asons")));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
288 action->setCheckable(true);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
289 page_to_index_map[action] = 5;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
290 }
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
291
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
292 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
293 QAction* action = pages_group->addAction(menu->addAction(tr("&Torrents")));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
294 action->setCheckable(true);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
295 page_to_index_map[action] = 6;
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
296 }
54
466ac9870df9 add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
297
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
298 /* pain in my ass */
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
299 connect(sidebar.get(), &SideBar::CurrentItemChanged, this,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
300 [pages_group](int index) { pages_group->actions()[index]->setChecked(true); });
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
301
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
302 connect(pages_group, &QActionGroup::triggered, this,
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
303 [this, page_to_index_map](QAction* action) { sidebar->SetCurrentItem(page_to_index_map.at(action)); });
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
304 }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
305
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
306 menu->addSeparator();
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 37
diff changeset
307
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
308 // {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
309 // QAction* action = menu->addAction(tr("Show sidebar"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
310 // }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
311 }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
312
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
313 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
314 /* Help */
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
315 QMenu* menu = menubar->addMenu(tr("&Help"));
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
316
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
317 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
318 /* About Minori */
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
319 menu->addAction(tr("&About Minori"), this, [this] {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
320 AboutWindow dialog(this);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
321 dialog.exec();
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
322 });
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
323 }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
324
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
325 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
326 /* About Qt */
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
327 QAction* action = menu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
328 action->setMenuRole(QAction::AboutQtRole);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
329 }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
330 }
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
331 /* QMainWindow will delete the old one for us,
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
332 according to the docs */
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
333 setMenuBar(menubar);
7
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
334
68
2417121d894e *: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
335 /* Toolbar */
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
336
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
337 /* remove old toolbar(s) */
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
338 for (QToolBar*& t : findChildren<QToolBar*>(Qt::FindDirectChildrenOnly)) {
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
339 removeToolBar(t);
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
340 delete t;
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
341 }
79
c489dd4434af *: what did I do again?
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
342
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
343 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
344 /* Toolbar */
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
345 QToolBar* toolbar = new QToolBar(this);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
346 toolbar->addAction(QIcon(":/icons/24x24/arrow-circle-double-135.png"), tr("&Synchronize"),
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
347 [this] { AsyncSynchronize(stack.get()); });
69
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
348
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
349 toolbar->addSeparator();
69
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
350
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
351 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
352 QToolButton* button = new QToolButton(toolbar);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
353 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
354 QMenu* menu = new QMenu(button);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
355 QAction* action = menu->addAction(tr("..."));
69
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
356
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
357 button->setMenu(menu);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
358 }
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
359 button->setIcon(QIcon(":/icons/24x24/folder-open.png"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
360 button->setPopupMode(QToolButton::InstantPopup);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
361 toolbar->addWidget(button);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
362 }
69
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
363
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
364 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
365 QToolButton* button = new QToolButton(toolbar);
69
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
366
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
367 {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
368 QMenu* menu = new QMenu(button);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
369 QAction* action = menu->addAction(tr("..."));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
370
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
371 button->setMenu(menu);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
372 }
69
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
373
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
374 button->setIcon(QIcon(":/icons/24x24/application-export.png"));
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
375 button->setPopupMode(QToolButton::InstantPopup);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
376 toolbar->addWidget(button);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
377 }
69
27a19dd6cba1 *: fix up some stuff
Paper <mrpapersonic@gmail.com>
parents: 68
diff changeset
378
114
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
379 toolbar->addSeparator();
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
380 toolbar->addAction(QIcon(":/icons/24x24/gear.png"), tr("S&ettings"), [this] {
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
381 SettingsDialog dialog(this);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
382 dialog.exec();
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
383 });
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
384 addToolBar(toolbar);
ab191e28e69d *: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents: 113
diff changeset
385 }
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
386 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
387
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
388 void MainWindow::SetActivePage(QWidget* page) {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
389 this->setCentralWidget(page);
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
390 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
391
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
392 void MainWindow::AsyncSynchronize(QStackedWidget* stack) {
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
393 if (session.config.service == Anime::Services::NONE) {
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
394 QMessageBox msg;
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
395 msg.setWindowTitle(tr("Error synchronizing with service!"));
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
396 msg.setText(tr("It seems you haven't yet selected a service to use."));
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
397 msg.setInformativeText(tr("Would you like to select one now?"));
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
398 msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
399 msg.setDefaultButton(QMessageBox::Yes);
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
400 int ret = msg.exec();
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
401 if (ret == QMessageBox::Yes) {
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
402 SettingsDialog dialog;
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
403 dialog.exec();
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
404 }
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
405 }
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
406 QThreadPool::globalInstance()->start([stack] {
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
407 Services::Synchronize();
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
408 reinterpret_cast<AnimeListPage*>(stack->widget(static_cast<int>(Pages::ANIME_LIST)))->Refresh();
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
409 });
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
410 }
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
411
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
412 void MainWindow::RetranslateUI() {
113
32afe0e940bf window: remove tiny little debug thing
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
413 /* This kinda sucks but nobody's really going to be changing
32afe0e940bf window: remove tiny little debug thing
Paper <mrpapersonic@gmail.com>
parents: 112
diff changeset
414 the application language all the time :p */
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
415 setUpdatesEnabled(false);
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
416 AddMainWidgets();
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
417 CreateBars();
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
418 setUpdatesEnabled(true);
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
419 }
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
420
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
421 void MainWindow::changeEvent(QEvent* event) {
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
422 if (event) { /* is this really necessary */
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
423 switch (event->type()) {
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
424 // this event is send if a translator is loaded
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
425 case QEvent::LanguageChange:
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
426 RetranslateUI();
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
427 break;
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
428
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
429 default:
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
430 break;
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
431 }
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
432 }
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
433 QMainWindow::changeEvent(event);
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
434 }
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
435
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 103
diff changeset
436 void MainWindow::showEvent(QShowEvent* event) {
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 103
diff changeset
437 QMainWindow::showEvent(event);
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 103
diff changeset
438 #ifdef WIN32
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
439 /* Technically this *should* be
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
440 session.config.theme.IsInDarkTheme() && win32::IsInDarkTheme()
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
441 but I prefer the title bar being black even when light mode
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
442 is enabled :/ */
108
2004b41d4a59 *: huge commit
Paper <mrpapersonic@gmail.com>
parents: 106
diff changeset
443 win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme());
105
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 103
diff changeset
444 #endif
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 103
diff changeset
445 }
6d8da6e64d61 theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents: 103
diff changeset
446
2
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
447 void MainWindow::closeEvent(QCloseEvent* event) {
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
448 session.config.Save();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
449 event->accept();
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
450 }
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
451
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 8
diff changeset
452 #include "gui/moc_window.cpp"