Mercurial > minori
annotate src/gui/window.cc @ 154:d43d68408d3c
dep/animia: fix XnuFdTools
also we use anitomy directly now.
HG Enter commit message. Lines beginning with 'HG:' are removed.
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Wed, 15 Nov 2023 14:14:17 -0500 |
parents | 6fdf0632c003 |
children | 79a2a24453fa |
rev | line source |
---|---|
9 | 1 #include "gui/window.h" |
64 | 2 #include "core/anime_db.h" |
9 | 3 #include "core/config.h" |
4 #include "core/session.h" | |
64 | 5 #include "core/strings.h" |
102 | 6 #include "gui/theme.h" |
62 | 7 #include "gui/dialog/about.h" |
9 | 8 #include "gui/dialog/settings.h" |
9 #include "gui/pages/anime_list.h" | |
62 | 10 #include "gui/pages/history.h" |
9 | 11 #include "gui/pages/now_playing.h" |
62 | 12 #include "gui/pages/search.h" |
13 #include "gui/pages/seasons.h" | |
9 | 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 | 16 #include "gui/widgets/sidebar.h" |
15 | 17 #include "services/services.h" |
64 | 18 #include "track/media.h" |
147
6fdf0632c003
track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents:
139
diff
changeset
|
19 |
154 | 20 #include "anitomy/anitomy.h" |
21 | |
63 | 22 #include <QActionGroup> |
7 | 23 #include <QApplication> |
64 | 24 #include <QDebug> |
9 | 25 #include <QFile> |
69 | 26 #include <QHBoxLayout> |
7 | 27 #include <QMainWindow> |
28 #include <QMenuBar> | |
63 | 29 #include <QMessageBox> |
7 | 30 #include <QPlainTextEdit> |
31 #include <QStackedWidget> | |
63 | 32 #include <QTextStream> |
77 | 33 #include <QThreadPool> |
62 | 34 #include <QTimer> |
69 | 35 #include <QToolBar> |
36 #include <QToolButton> | |
147
6fdf0632c003
track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents:
139
diff
changeset
|
37 |
106
c8c72278f6fd
*: #if -> #ifdef, remove outdated comments in sys/win32/dark_theme.cc
Paper <mrpapersonic@gmail.com>
parents:
105
diff
changeset
|
38 #ifdef MACOSX |
15 | 39 # include "sys/osx/dark_theme.h" |
46 | 40 #elif defined(WIN32) |
15 | 41 # include "sys/win32/dark_theme.h" |
2 | 42 #endif |
43 | |
10 | 44 enum class Pages { |
45 NOW_PLAYING, | |
46 | |
47 ANIME_LIST, | |
48 HISTORY, | |
49 STATISTICS, | |
50 | |
51 SEARCH, | |
52 SEASONS, | |
53 TORRENTS | |
54 }; | |
55 | |
9 | 56 MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) { |
103 | 57 setWindowIcon(QIcon(":/favicon.png")); |
58 | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
59 main_widget.reset(new QWidget(this)); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
60 /*QHBoxLayout* layout = */new QHBoxLayout(main_widget.get()); |
10 | 61 |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
62 AddMainWidgets(); |
10 | 63 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
64 setCentralWidget(main_widget.get()); |
79 | 65 |
66 CreateBars(); | |
67 | |
68 QTimer* timer = new QTimer(this); | |
135
0a458cb26ff4
filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents:
118
diff
changeset
|
69 |
0a458cb26ff4
filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents:
118
diff
changeset
|
70 /* this is very very stinky */ |
79 | 71 connect(timer, &QTimer::timeout, this, [this] { |
139
478f3b366199
dep/animia: separate lots of things, use base class for OS stuff
Paper <mrpapersonic@gmail.com>
parents:
138
diff
changeset
|
72 bool success = false; |
478f3b366199
dep/animia: separate lots of things, use base class for OS stuff
Paper <mrpapersonic@gmail.com>
parents:
138
diff
changeset
|
73 |
79 | 74 NowPlayingPage* page = reinterpret_cast<NowPlayingPage*>(stack->widget(static_cast<int>(Pages::NOW_PLAYING))); |
75 | |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
76 std::vector<std::string> files; |
139
478f3b366199
dep/animia: separate lots of things, use base class for OS stuff
Paper <mrpapersonic@gmail.com>
parents:
138
diff
changeset
|
77 Track::Media::GetCurrentlyPlaying(files); |
79 | 78 |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
79 /* this should really be more intertwined with anitomy */ |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
80 for (const auto& file : files) { |
154 | 81 anitomy::Anitomy anitomy; |
82 anitomy.Parse(Strings::ToWstring(file)); | |
83 | |
84 const auto& elements = anitomy.elements(); | |
85 | |
86 int id = Anime::db.GetAnimeFromTitle(Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle))); | |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
87 if (id <= 0) |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
88 continue; |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
89 |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
90 qDebug() << id; |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
91 |
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
92 page->SetPlaying(Anime::db.items[id], elements); |
139
478f3b366199
dep/animia: separate lots of things, use base class for OS stuff
Paper <mrpapersonic@gmail.com>
parents:
138
diff
changeset
|
93 |
478f3b366199
dep/animia: separate lots of things, use base class for OS stuff
Paper <mrpapersonic@gmail.com>
parents:
138
diff
changeset
|
94 success = true; |
138
28842a8d0c6b
dep/animia: huge refactor (again...)
Paper <mrpapersonic@gmail.com>
parents:
135
diff
changeset
|
95 } |
139
478f3b366199
dep/animia: separate lots of things, use base class for OS stuff
Paper <mrpapersonic@gmail.com>
parents:
138
diff
changeset
|
96 |
478f3b366199
dep/animia: separate lots of things, use base class for OS stuff
Paper <mrpapersonic@gmail.com>
parents:
138
diff
changeset
|
97 if (!success) |
478f3b366199
dep/animia: separate lots of things, use base class for OS stuff
Paper <mrpapersonic@gmail.com>
parents:
138
diff
changeset
|
98 page->SetDefault(); |
79 | 99 }); |
100 timer->start(5000); | |
101 } | |
102 | |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
103 void MainWindow::AddMainWidgets() { |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
104 int page = static_cast<int>(Pages::ANIME_LIST); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
105 if (sidebar.get()) { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
106 main_widget->layout()->removeWidget(sidebar.get()); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
107 sidebar.reset(); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
108 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
109 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
110 if (stack.get()) { |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
111 page = stack->currentIndex(); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
112 main_widget->layout()->removeWidget(stack.get()); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
113 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
114 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
115 sidebar.reset(new SideBar(main_widget.get())); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
116 sidebar->setFixedWidth(128); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
117 sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
118 |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
119 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
|
120 sidebar->AddSeparator(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
121 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
|
122 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
|
123 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
|
124 sidebar->AddSeparator(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
125 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
|
126 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
|
127 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
|
128 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
129 stack.reset(new QStackedWidget(main_widget.get())); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
130 stack->addWidget(new NowPlayingPage(main_widget.get())); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
131 stack->addWidget(new AnimeListPage(main_widget.get())); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
132 stack->addWidget(new HistoryPage(main_widget.get())); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
133 stack->addWidget(new StatisticsPage(main_widget.get())); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
134 stack->addWidget(new SearchPage(main_widget.get())); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
135 stack->addWidget(new SeasonsPage(main_widget.get())); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
136 stack->addWidget(new TorrentsPage(main_widget.get())); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
137 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
138 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
|
139 sidebar->SetCurrentItem(page); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
140 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
141 main_widget->layout()->addWidget(sidebar.get()); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
142 main_widget->layout()->addWidget(stack.get()); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
143 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
144 |
79 | 145 void MainWindow::CreateBars() { |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
146 /* Menu Bar |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
147 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
|
148 (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
|
149 if you're in submenu or not. */ |
79 | 150 QMenuBar* menubar = new QMenuBar(this); |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
151 |
114
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 /* File */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
154 QMenu* menu = menubar->addMenu(tr("&File")); |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
155 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
156 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
157 QMenu* submenu = menu->addMenu(tr("&Library folders")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
158 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
159 QAction* action = submenu->addAction(tr("&Add new folder...")); |
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 } |
2 | 162 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
163 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
164 QAction* action = menu->addAction(tr("&Scan available episodes")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
165 } |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
166 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
167 menu->addSeparator(); |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
168 |
114
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("Play &next episode")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
171 // action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N)); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
172 // } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
173 // |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
174 // { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
175 // QAction* action = menu->addAction(tr("Play &random episode")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
176 // action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R)); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
177 // } |
2 | 178 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
179 menu->addSeparator(); |
2 | 180 |
114
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 QAction* action = menu->addAction(tr("E&xit"), qApp, &QApplication::quit); |
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 } |
2 | 185 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
186 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
187 /* Services */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
188 QMenu* menu = menubar->addMenu(tr("&Services")); |
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 QAction* action = menu->addAction(tr("Synchronize &list"), [this] { AsyncSynchronize(stack.get()); }); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
192 action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S)); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
193 } |
2 | 194 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
195 // menu->addSeparator(); |
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 // { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
198 // /* AniList */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
199 // QMenu* submenu = menu->addMenu(tr("&AniList")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
200 // QAction* action = submenu->addAction(tr("Go to my &profile")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
201 // action = submenu->addAction(tr("Go to my &stats")); |
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 // |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
204 // { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
205 // /* Kitsu */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
206 // QMenu* submenu = menu->addMenu(tr("&Kitsu")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
207 // QAction* action = submenu->addAction(tr("Go to my &feed")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
208 // action = submenu->addAction(tr("Go to my &library")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
209 // action = submenu->addAction(tr("Go to my &profile")); |
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 // QMenu* submenu = menu->addMenu(tr("&MyAnimeList")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
213 // QAction* action = submenu->addAction(tr("Go to my p&anel")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
214 // action = submenu->addAction(tr("Go to my &profile")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
215 // action = submenu->addAction(tr("Go to my &history")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
216 // } |
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 } |
2 | 219 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
220 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
221 /* Tools */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
222 QMenu* menu = menubar->addMenu(tr("&Tools")); |
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 // /* Export anime list */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
225 // QMenu* submenu = menu->addMenu(tr("&Export anime list")); |
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 // /* Markdown export */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
229 // QAction* action = submenu->addAction(tr("Export as &Markdown...")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
230 // } |
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 // /* XML export */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
234 // QAction* action = submenu->addAction(tr("Export as MyAnimeList &XML...")); |
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 // } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
237 // menu->addSeparator(); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
238 // |
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 // QAction* action = menu->addAction(tr("Enable anime &recognition")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
241 // action->setCheckable(true); |
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 // QAction* action = menu->addAction(tr("Enable auto &sharing")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
246 // action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
247 // } |
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 // { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
250 // QAction* action = menu->addAction(tr("Enable &auto synchronization")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
251 // action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
252 // } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
253 // |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
254 // menu->addSeparator(); |
44
619cbd6e69f9
filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents:
37
diff
changeset
|
255 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
256 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
257 QAction* action = menu->addAction(tr("&Settings"), [this] { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
258 SettingsDialog dialog(this); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
259 dialog.exec(); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
260 }); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
261 action->setMenuRole(QAction::PreferencesRole); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
262 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
263 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
264 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
265 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
266 /* View */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
267 QMenu* menu = menubar->addMenu(tr("&View")); |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
268 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
269 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
270 /* Pages... */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
271 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
|
272 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
273 QActionGroup* pages_group = new QActionGroup(this); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
274 pages_group->setExclusive(true); |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
275 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
276 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
277 QAction* action = pages_group->addAction(menu->addAction(tr("&Now Playing"))); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
278 action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
279 page_to_index_map[action] = 0; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
280 } |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
281 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
282 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
283 QAction* action = pages_group->addAction(menu->addAction(tr("&Anime List"))); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
284 action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
285 action->setChecked(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
286 page_to_index_map[action] = 1; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
287 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
288 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
289 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
290 QAction* action = pages_group->addAction(menu->addAction(tr("&History"))); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
291 action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
292 page_to_index_map[action] = 2; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
293 } |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
294 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
295 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
296 QAction* action = pages_group->addAction(menu->addAction(tr("&Statistics"))); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
297 action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
298 page_to_index_map[action] = 3; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
299 } |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
300 |
114
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 QAction* action = pages_group->addAction(menu->addAction(tr("S&earch"))); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
303 action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
304 page_to_index_map[action] = 4; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
305 } |
44
619cbd6e69f9
filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents:
37
diff
changeset
|
306 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
307 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
308 QAction* action = pages_group->addAction(menu->addAction(tr("Se&asons"))); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
309 action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
310 page_to_index_map[action] = 5; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
311 } |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
312 |
114
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 QAction* action = pages_group->addAction(menu->addAction(tr("&Torrents"))); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
315 action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
316 page_to_index_map[action] = 6; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
317 } |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
318 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
319 /* pain in my ass */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
320 connect(sidebar.get(), &SideBar::CurrentItemChanged, this, |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
321 [pages_group](int index) { pages_group->actions()[index]->setChecked(true); }); |
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 connect(pages_group, &QActionGroup::triggered, this, |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
324 [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
|
325 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
326 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
327 menu->addSeparator(); |
44
619cbd6e69f9
filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents:
37
diff
changeset
|
328 |
114
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 // QAction* action = menu->addAction(tr("Show sidebar")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
331 // } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
332 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
333 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
334 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
335 /* Help */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
336 QMenu* menu = menubar->addMenu(tr("&Help")); |
2 | 337 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
338 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
339 /* About Minori */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
340 menu->addAction(tr("&About Minori"), this, [this] { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
341 AboutWindow dialog(this); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
342 dialog.exec(); |
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 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
345 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
346 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
347 /* About Qt */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
348 QAction* action = menu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
349 action->setMenuRole(QAction::AboutQtRole); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
350 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
351 } |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
352 /* QMainWindow will delete the old one for us, |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
353 according to the docs */ |
2 | 354 setMenuBar(menubar); |
7 | 355 |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
64
diff
changeset
|
356 /* Toolbar */ |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
357 |
79 | 358 /* remove old toolbar(s) */ |
115 | 359 /* the empty QString() is a Qt 5 wart... */ |
360 for (QToolBar*& t : findChildren<QToolBar*>(QString(), Qt::FindDirectChildrenOnly)) { | |
79 | 361 removeToolBar(t); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
362 delete t; |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
363 } |
79 | 364 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
365 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
366 /* Toolbar */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
367 QToolBar* toolbar = new QToolBar(this); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
368 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
|
369 [this] { AsyncSynchronize(stack.get()); }); |
69 | 370 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
371 toolbar->addSeparator(); |
69 | 372 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
373 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
374 QToolButton* button = new QToolButton(toolbar); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
375 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
376 QMenu* menu = new QMenu(button); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
377 QAction* action = menu->addAction(tr("...")); |
69 | 378 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
379 button->setMenu(menu); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
380 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
381 button->setIcon(QIcon(":/icons/24x24/folder-open.png")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
382 button->setPopupMode(QToolButton::InstantPopup); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
383 toolbar->addWidget(button); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
384 } |
69 | 385 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
386 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
387 QToolButton* button = new QToolButton(toolbar); |
69 | 388 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
389 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
390 QMenu* menu = new QMenu(button); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
391 QAction* action = menu->addAction(tr("...")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
392 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
393 button->setMenu(menu); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
394 } |
69 | 395 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
396 button->setIcon(QIcon(":/icons/24x24/application-export.png")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
397 button->setPopupMode(QToolButton::InstantPopup); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
398 toolbar->addWidget(button); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
399 } |
69 | 400 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
401 toolbar->addSeparator(); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
402 toolbar->addAction(QIcon(":/icons/24x24/gear.png"), tr("S&ettings"), [this] { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
403 SettingsDialog dialog(this); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
404 dialog.exec(); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
405 }); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
406 addToolBar(toolbar); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
407 } |
2 | 408 } |
409 | |
410 void MainWindow::SetActivePage(QWidget* page) { | |
411 this->setCentralWidget(page); | |
412 } | |
413 | |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
414 void MainWindow::AsyncSynchronize(QStackedWidget* stack) { |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
415 if (session.config.service == Anime::Services::NONE) { |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
416 QMessageBox msg; |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
417 msg.setWindowTitle(tr("Error synchronizing with service!")); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
418 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
|
419 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
|
420 msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
421 msg.setDefaultButton(QMessageBox::Yes); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
422 int ret = msg.exec(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
423 if (ret == QMessageBox::Yes) { |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
424 SettingsDialog dialog; |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
425 dialog.exec(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
426 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
427 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
428 QThreadPool::globalInstance()->start([stack] { |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
429 Services::Synchronize(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
430 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
|
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 |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
434 void MainWindow::RetranslateUI() { |
113
32afe0e940bf
window: remove tiny little debug thing
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
435 /* 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
|
436 the application language all the time :p */ |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
437 setUpdatesEnabled(false); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
438 AddMainWidgets(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
439 CreateBars(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
440 setUpdatesEnabled(true); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
441 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
442 |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
443 void MainWindow::changeEvent(QEvent* event) { |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
444 if (event) { /* is this really necessary */ |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
445 switch (event->type()) { |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
446 // this event is send if a translator is loaded |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
447 case QEvent::LanguageChange: |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
448 RetranslateUI(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
449 break; |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
450 |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
451 default: |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
452 break; |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
453 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
454 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
455 QMainWindow::changeEvent(event); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
456 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
457 |
105
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
103
diff
changeset
|
458 void MainWindow::showEvent(QShowEvent* event) { |
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
103
diff
changeset
|
459 QMainWindow::showEvent(event); |
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
103
diff
changeset
|
460 #ifdef WIN32 |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
461 /* Technically this *should* be |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
462 session.config.theme.IsInDarkTheme() && win32::IsInDarkTheme() |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
463 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
|
464 is enabled :/ */ |
108 | 465 win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme()); |
105
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
103
diff
changeset
|
466 #endif |
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
103
diff
changeset
|
467 } |
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
103
diff
changeset
|
468 |
2 | 469 void MainWindow::closeEvent(QCloseEvent* event) { |
470 session.config.Save(); | |
471 event->accept(); | |
472 } | |
473 | |
9 | 474 #include "gui/moc_window.cpp" |