Mercurial > minori
annotate src/gui/window.cc @ 374:f7bb2978de48
gui/pages/anime_list: add Search right-click menu, don't create menu items that do nothing
author | Paper <paper@tflc.us> |
---|---|
date | Fri, 25 Jul 2025 11:03:34 -0400 |
parents | 47c9f8502269 |
children |
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" |
62 | 6 #include "gui/dialog/about.h" |
9 | 7 #include "gui/dialog/settings.h" |
8 #include "gui/pages/anime_list.h" | |
62 | 9 #include "gui/pages/history.h" |
9 | 10 #include "gui/pages/now_playing.h" |
62 | 11 #include "gui/pages/search.h" |
12 #include "gui/pages/seasons.h" | |
9 | 13 #include "gui/pages/statistics.h" |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
14 #include "gui/pages/torrents.h" |
258 | 15 #include "gui/theme.h" |
46 | 16 #include "gui/widgets/sidebar.h" |
258 | 17 #include "library/library.h" |
15 | 18 #include "services/services.h" |
64 | 19 #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
|
20 |
154 | 21 #include "anitomy/anitomy.h" |
22 | |
63 | 23 #include <QActionGroup> |
7 | 24 #include <QApplication> |
64 | 25 #include <QDebug> |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
26 #include <QDesktopServices> |
9 | 27 #include <QFile> |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
28 #include <QFileDialog> |
69 | 29 #include <QHBoxLayout> |
7 | 30 #include <QMainWindow> |
31 #include <QMenuBar> | |
63 | 32 #include <QMessageBox> |
7 | 33 #include <QPlainTextEdit> |
34 #include <QStackedWidget> | |
315
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
309
diff
changeset
|
35 #include <QStatusBar> |
63 | 36 #include <QTextStream> |
168
79a2a24453fa
window: improve performance when getting running files
paper@DavesDouble.local
parents:
154
diff
changeset
|
37 #include <QThread> |
77 | 38 #include <QThreadPool> |
62 | 39 #include <QTimer> |
69 | 40 #include <QToolBar> |
41 #include <QToolButton> | |
147
6fdf0632c003
track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents:
139
diff
changeset
|
42 |
190
2d5823df870f
dep/animia: finalize de-objc-ifying quartz
Paper <mrpapersonic@gmail.com>
parents:
174
diff
changeset
|
43 #include <iostream> |
2d5823df870f
dep/animia: finalize de-objc-ifying quartz
Paper <mrpapersonic@gmail.com>
parents:
174
diff
changeset
|
44 |
106
c8c72278f6fd
*: #if -> #ifdef, remove outdated comments in sys/win32/dark_theme.cc
Paper <mrpapersonic@gmail.com>
parents:
105
diff
changeset
|
45 #ifdef MACOSX |
369 | 46 # include "sys/osx/dark_theme.h" |
47 # include "sys/osx/permissions.h" | |
46 | 48 #elif defined(WIN32) |
369 | 49 # include "sys/win32/dark_theme.h" |
2 | 50 #endif |
51 | |
369 | 52 void MainWindowPlayingThread::run() |
53 { | |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
54 std::vector<std::string> files; |
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
55 Track::Media::GetCurrentlyPlaying(files); |
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
56 emit Done(files); |
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
57 } |
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
58 |
369 | 59 MainWindowAsyncSynchronizeThread::MainWindowAsyncSynchronizeThread(QAction *action, AnimeListPage *page, |
60 QObject *parent) | |
61 : QThread(parent) | |
62 { | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
63 SetAction(action); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
64 SetPage(page); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
65 } |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
66 |
369 | 67 void MainWindowAsyncSynchronizeThread::SetAction(QAction *action) |
68 { | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
69 action_ = action; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
70 } |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
71 |
369 | 72 void MainWindowAsyncSynchronizeThread::SetPage(AnimeListPage *page) |
73 { | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
74 page_ = page; |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
75 } |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
76 |
369 | 77 void MainWindowAsyncSynchronizeThread::run() |
78 { | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
79 action_->setEnabled(false); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
80 Services::Synchronize(); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
81 page_->Refresh(); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
82 action_->setEnabled(true); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
83 } |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
84 |
369 | 85 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), async_synchronize_thread_(nullptr, nullptr) |
86 { | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
87 sidebar_.setFixedWidth(128); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
88 sidebar_.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
89 |
315
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
309
diff
changeset
|
90 statusBar(); |
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
309
diff
changeset
|
91 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
92 new QHBoxLayout(&main_widget_); |
10 | 93 |
291 | 94 CreateBars(); |
95 | |
96 stack_.addWidget(&now_playing_page_); | |
97 /* ---- */ | |
98 stack_.addWidget(&anime_list_page_); | |
99 stack_.addWidget(&history_page_); | |
100 stack_.addWidget(&statistics_page_); | |
101 /* ---- */ | |
102 stack_.addWidget(&search_page_); | |
103 stack_.addWidget(&seasons_page_); | |
104 stack_.addWidget(&torrents_page_); | |
105 | |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
106 AddMainWidgets(); |
291 | 107 sidebar_.SetCurrentItem(static_cast<int>(Pages::ANIME_LIST)); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
108 setCentralWidget(&main_widget_); |
79 | 109 |
369 | 110 NowPlayingPage *page = reinterpret_cast<NowPlayingPage *>(stack_.widget(static_cast<int>(Pages::NOW_PLAYING))); |
79 | 111 |
369 | 112 connect(&playing_thread_, &MainWindowPlayingThread::Done, this, [page](const std::vector<std::string> &files) { |
113 for (const auto &file : files) { | |
232
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
114 anitomy::Anitomy anitomy; |
347
a0aa8c8c4307
dep/anitomy: port to use UCS-4 rather than wide strings
Paper <paper@paper.us.eu.org>
parents:
328
diff
changeset
|
115 anitomy.Parse(file); |
232
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
116 |
369 | 117 const auto &elements = anitomy.elements(); |
347
a0aa8c8c4307
dep/anitomy: port to use UCS-4 rather than wide strings
Paper <paper@paper.us.eu.org>
parents:
328
diff
changeset
|
118 |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
119 const std::string title = Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle)); |
232
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
120 |
319
d928ec7b6a0d
services/kitsu: implement GetAnimeList()
Paper <paper@paper.us.eu.org>
parents:
315
diff
changeset
|
121 int id = Anime::db.LookupAnimeTitle(title); |
232
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
122 if (id <= 0) |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
123 continue; |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
124 |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
125 page->SetPlaying(Anime::db.items[id], elements); |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
126 break; |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
127 } |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
128 }); |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
129 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
130 connect(&playing_thread_timer_, &QTimer::timeout, this, [this] { |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
131 if (playing_thread_.isRunning()) |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
132 return; |
190
2d5823df870f
dep/animia: finalize de-objc-ifying quartz
Paper <mrpapersonic@gmail.com>
parents:
174
diff
changeset
|
133 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
134 playing_thread_.start(); |
79 | 135 }); |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
136 |
237 | 137 #ifdef MACOSX |
138 if (!osx::AskForPermissions()) | |
139 return; | |
140 #endif | |
141 | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
142 playing_thread_timer_.start(5000); |
79 | 143 } |
144 | |
369 | 145 void MainWindow::SetStatusMessage(const std::string &message) |
146 { | |
315
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
309
diff
changeset
|
147 statusBar()->showMessage(Strings::ToQString(message), 2000); |
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
309
diff
changeset
|
148 } |
34347fd2a2de
session: allow printing status messages
Paper <paper@paper.us.eu.org>
parents:
309
diff
changeset
|
149 |
366
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
347
diff
changeset
|
150 /* FIXME: |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
347
diff
changeset
|
151 * ALL of the pages need to have a retranslate function. This would require |
886f66775f31
animone: add preliminary AT-SPI stuff
Paper <paper@tflc.us>
parents:
347
diff
changeset
|
152 * huge amounts of refactoring hence why it hasn't been done yet. */ |
369 | 153 void MainWindow::AddMainWidgets() |
154 { | |
291 | 155 int page = sidebar_.GetCurrentItem(); |
250 | 156 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
157 sidebar_.clear(); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
158 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
159 sidebar_.AddItem(tr("Now Playing"), SideBar::CreateIcon(":/icons/16x16/film.png")); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
160 sidebar_.AddSeparator(); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
161 sidebar_.AddItem(tr("Anime List"), SideBar::CreateIcon(":/icons/16x16/document-list.png")); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
162 sidebar_.AddItem(tr("History"), SideBar::CreateIcon(":/icons/16x16/clock-history-frame.png")); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
163 sidebar_.AddItem(tr("Statistics"), SideBar::CreateIcon(":/icons/16x16/chart.png")); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
164 sidebar_.AddSeparator(); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
165 sidebar_.AddItem(tr("Search"), SideBar::CreateIcon(":/icons/16x16/magnifier.png")); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
166 sidebar_.AddItem(tr("Seasons"), SideBar::CreateIcon(":/icons/16x16/calendar.png")); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
167 sidebar_.AddItem(tr("Torrents"), SideBar::CreateIcon(":/icons/16x16/feed.png")); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
168 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
169 sidebar_.SetCurrentItem(page); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
170 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
171 main_widget_.layout()->addWidget(&sidebar_); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
172 main_widget_.layout()->addWidget(&stack_); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
173 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
174 |
369 | 175 void MainWindow::CreateBars() |
176 { | |
177 QMenuBar *menubar = new QMenuBar(this); | |
178 QAction *sync_action; | |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
179 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
180 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
181 /* File */ |
369 | 182 QMenu *menu = menubar->addMenu(tr("&File")); |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
183 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
184 { |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
185 folder_menu = menu->addMenu(tr("&Library folders")); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
186 |
250 | 187 UpdateFolderMenu(); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
188 } |
2 | 189 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
190 { |
328
71396ecb6f7e
library: convert to class + database
Paper <paper@paper.us.eu.org>
parents:
319
diff
changeset
|
191 menu->addAction(tr("&Scan available episodes"), [] { Library::db.Refresh(); }); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
192 } |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
193 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
194 menu->addSeparator(); |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
195 |
258 | 196 // { |
197 // QAction* action = menu->addAction(tr("Play &next episode")); | |
198 // action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N)); | |
199 // } | |
200 // | |
201 // { | |
202 // QAction* action = menu->addAction(tr("Play &random episode")); | |
203 // action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R)); | |
204 // } | |
2 | 205 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
206 menu->addSeparator(); |
2 | 207 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
208 { |
369 | 209 QAction *action = menu->addAction(tr("E&xit"), this, &MainWindow::close); |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
210 action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q)); |
114
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 } |
2 | 213 |
114
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 /* Services */ |
369 | 216 QMenu *menu = menubar->addMenu(tr("&Services")); |
114
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 { |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
219 sync_action = menu->addAction(tr("Synchronize &list")); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
220 |
258 | 221 connect(sync_action, &QAction::triggered, this, |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
222 [this, sync_action] { AsyncSynchronize(sync_action, &stack_); }); |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
223 |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
224 sync_action->setIcon(QIcon(":/icons/24x24/arrow-circle-double-135.png")); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
225 sync_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S)); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
226 } |
2 | 227 |
258 | 228 // menu->addSeparator(); |
229 // | |
230 // { | |
231 // /* AniList */ | |
232 // QMenu* submenu = menu->addMenu(tr("&AniList")); | |
233 // QAction* action = submenu->addAction(tr("Go to my &profile")); | |
234 // action = submenu->addAction(tr("Go to my &stats")); | |
235 // } | |
236 // | |
237 // { | |
238 // /* Kitsu */ | |
239 // QMenu* submenu = menu->addMenu(tr("&Kitsu")); | |
240 // QAction* action = submenu->addAction(tr("Go to my &feed")); | |
241 // action = submenu->addAction(tr("Go to my &library")); | |
242 // action = submenu->addAction(tr("Go to my &profile")); | |
243 // } | |
244 // { | |
245 // QMenu* submenu = menu->addMenu(tr("&MyAnimeList")); | |
246 // QAction* action = submenu->addAction(tr("Go to my p&anel")); | |
247 // action = submenu->addAction(tr("Go to my &profile")); | |
248 // action = submenu->addAction(tr("Go to my &history")); | |
249 // } | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
250 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
251 } |
2 | 252 |
114
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 /* Tools */ |
369 | 255 QMenu *menu = menubar->addMenu(tr("&Tools")); |
258 | 256 // { |
257 // /* Export anime list */ | |
258 // QMenu* submenu = menu->addMenu(tr("&Export anime list")); | |
259 // | |
260 // { | |
261 // /* Markdown export */ | |
262 // QAction* action = submenu->addAction(tr("Export as &Markdown...")); | |
263 // } | |
264 // | |
265 // { | |
266 // /* XML export */ | |
267 // QAction* action = submenu->addAction(tr("Export as MyAnimeList &XML...")); | |
268 // } | |
269 // } | |
270 // menu->addSeparator(); | |
271 // | |
272 // { | |
273 // QAction* action = menu->addAction(tr("Enable anime &recognition")); | |
274 // action->setCheckable(true); | |
275 // } | |
276 // | |
277 // { | |
278 // QAction* action = menu->addAction(tr("Enable auto &sharing")); | |
279 // action->setCheckable(true); | |
280 // } | |
281 // | |
282 // { | |
283 // QAction* action = menu->addAction(tr("Enable &auto synchronization")); | |
284 // action->setCheckable(true); | |
285 // } | |
286 // | |
287 // menu->addSeparator(); | |
44
619cbd6e69f9
filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents:
37
diff
changeset
|
288 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
289 { |
369 | 290 QAction *action = menu->addAction(tr("&Settings"), [this] { |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
291 SettingsDialog dialog(this); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
292 dialog.exec(); |
250 | 293 UpdateFolderMenu(); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
294 }); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
295 action->setMenuRole(QAction::PreferencesRole); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
296 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
297 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
298 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
299 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
300 /* View */ |
369 | 301 QMenu *menu = menubar->addMenu(tr("&View")); |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
302 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
303 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
304 /* Pages... */ |
369 | 305 QActionGroup *pages_group = new QActionGroup(menu); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
306 pages_group->setExclusive(true); |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
307 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
308 { |
369 | 309 QAction *action = pages_group->addAction(menu->addAction(tr("&Now Playing"))); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
310 action->setCheckable(true); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
311 connect(action, &QAction::toggled, this, [this] { sidebar_.SetCurrentItem(0); }); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
312 } |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
313 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
314 { |
369 | 315 QAction *action = pages_group->addAction(menu->addAction(tr("&Anime List"))); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
316 action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
317 action->setChecked(true); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
318 connect(action, &QAction::toggled, this, [this] { sidebar_.SetCurrentItem(1); }); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
319 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
320 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
321 { |
369 | 322 QAction *action = pages_group->addAction(menu->addAction(tr("&History"))); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
323 action->setCheckable(true); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
324 connect(action, &QAction::toggled, this, [this] { sidebar_.SetCurrentItem(2); }); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
325 } |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
326 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
327 { |
369 | 328 QAction *action = pages_group->addAction(menu->addAction(tr("&Statistics"))); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
329 action->setCheckable(true); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
330 connect(action, &QAction::toggled, this, [this] { sidebar_.SetCurrentItem(3); }); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
331 } |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
332 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
333 { |
369 | 334 QAction *action = pages_group->addAction(menu->addAction(tr("S&earch"))); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
335 action->setCheckable(true); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
336 connect(action, &QAction::toggled, this, [this] { sidebar_.SetCurrentItem(4); }); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
337 } |
44
619cbd6e69f9
filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents:
37
diff
changeset
|
338 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
339 { |
369 | 340 QAction *action = pages_group->addAction(menu->addAction(tr("Se&asons"))); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
341 action->setCheckable(true); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
342 connect(action, &QAction::toggled, this, [this] { sidebar_.SetCurrentItem(5); }); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
343 } |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
344 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
345 { |
369 | 346 QAction *action = pages_group->addAction(menu->addAction(tr("&Torrents"))); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
347 action->setCheckable(true); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
348 connect(action, &QAction::toggled, this, [this] { sidebar_.SetCurrentItem(6); }); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
349 } |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
350 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
351 /* pain in the ass */ |
291 | 352 disconnect(&sidebar_, &SideBar::CurrentItemChanged, nullptr, nullptr); |
353 connect(&sidebar_, &SideBar::CurrentItemChanged, &stack_, &QStackedWidget::setCurrentIndex); | |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
354 connect(&sidebar_, &SideBar::CurrentItemChanged, this, [pages_group](int index) { |
369 | 355 QAction *checked = pages_group->checkedAction(); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
356 |
369 | 357 const QList<QAction *> &actions = pages_group->actions(); |
250 | 358 if (index > actions.size()) |
359 return; | |
360 | |
361 if (checked) | |
362 checked->setChecked(false); | |
363 actions[index]->setChecked(true); | |
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 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
367 menu->addSeparator(); |
44
619cbd6e69f9
filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents:
37
diff
changeset
|
368 |
258 | 369 // { |
370 // QAction* action = menu->addAction(tr("Show sidebar")); | |
371 // } | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
372 } |
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 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
375 /* Help */ |
369 | 376 QMenu *menu = menubar->addMenu(tr("&Help")); |
2 | 377 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
378 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
379 /* About Minori */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
380 menu->addAction(tr("&About Minori"), this, [this] { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
381 AboutWindow 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 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
385 |
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 /* About Qt */ |
369 | 388 QAction *action = menu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
389 action->setMenuRole(QAction::AboutQtRole); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
390 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
391 } |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
392 /* QMainWindow will delete the old one for us, |
255 | 393 * according to the docs |
258 | 394 */ |
2 | 395 setMenuBar(menubar); |
7 | 396 |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
64
diff
changeset
|
397 /* Toolbar */ |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
398 |
79 | 399 /* remove old toolbar(s) */ |
115 | 400 /* the empty QString() is a Qt 5 wart... */ |
369 | 401 for (QToolBar *&t : findChildren<QToolBar *>(QString(), Qt::FindDirectChildrenOnly)) { |
79 | 402 removeToolBar(t); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
403 delete t; |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
404 } |
79 | 405 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
406 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
407 /* Toolbar */ |
369 | 408 QToolBar *toolbar = new QToolBar(this); |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
409 toolbar->addAction(sync_action); |
69 | 410 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
411 toolbar->addSeparator(); |
69 | 412 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
413 { |
369 | 414 QToolButton *button = new QToolButton(toolbar); |
415 { | |
416 button->setMenu(folder_menu); | |
417 } | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
418 button->setIcon(QIcon(":/icons/24x24/folder-open.png")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
419 button->setPopupMode(QToolButton::InstantPopup); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
420 toolbar->addWidget(button); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
421 } |
69 | 422 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
423 { |
369 | 424 QToolButton *button = new QToolButton(toolbar); |
69 | 425 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
426 { |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
427 /* links */ |
369 | 428 QMenu *menu = new QMenu(button); |
258 | 429 menu->addAction("Hibari", [] { QDesktopServices::openUrl(QUrl("https://hb.wopian.me/")); }); |
430 menu->addAction("MALgraph", [] { QDesktopServices::openUrl(QUrl("https://graph.anime.plus/")); }); | |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
431 menu->addSeparator(); |
258 | 432 menu->addAction("AniChart", [] { QDesktopServices::openUrl(QUrl("https://anichart.net/airing")); }); |
433 menu->addAction("Monthly.moe", | |
434 [] { QDesktopServices::openUrl(QUrl("https://www.monthly.moe/weekly")); }); | |
435 menu->addAction("Senpai Anime Charts", | |
436 [] { QDesktopServices::openUrl(QUrl("https://www.senpai.moe/?mode=calendar")); }); | |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
437 menu->addSeparator(); |
258 | 438 menu->addAction("Anime Streaming Search Engine", |
439 [] { QDesktopServices::openUrl(QUrl("https://because.moe/")); }); | |
440 menu->addAction("The Fansub Database", [] { QDesktopServices::openUrl(QUrl("https://fansubdb.com")); }); | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
441 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
442 button->setMenu(menu); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
443 } |
69 | 444 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
445 button->setIcon(QIcon(":/icons/24x24/application-export.png")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
446 button->setPopupMode(QToolButton::InstantPopup); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
447 toolbar->addWidget(button); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
448 } |
69 | 449 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
450 toolbar->addSeparator(); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
451 toolbar->addAction(QIcon(":/icons/24x24/gear.png"), tr("S&ettings"), [this] { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
452 SettingsDialog dialog(this); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
453 dialog.exec(); |
250 | 454 /* library folders might have changed! */ |
455 UpdateFolderMenu(); | |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
456 }); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
457 addToolBar(toolbar); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
458 } |
2 | 459 } |
460 | |
369 | 461 void MainWindow::UpdateFolderMenu() |
462 { | |
250 | 463 if (!folder_menu) |
464 return; | |
465 | |
466 folder_menu->clear(); | |
467 | |
468 /* add in all of our existing folders... */ | |
469 std::size_t i = 0; | |
369 | 470 for (const auto &path : session.config.library.paths) { |
250 | 471 const QString folder = Strings::ToQString(path); |
369 | 472 QAction *action = |
258 | 473 folder_menu->addAction(folder, [folder] { QDesktopServices::openUrl(QUrl::fromLocalFile(folder)); }); |
250 | 474 |
475 if (i < 9) { | |
476 /* Qt::Key_1 is equivalent to 1 in ASCII, so we can use the same | |
477 * stupid `'0' + i` trick here | |
258 | 478 */ |
250 | 479 action->setShortcut(QKeySequence(Qt::ALT | static_cast<Qt::Modifier>(Qt::Key_1 + i))); |
480 } else if (i == 9) { | |
481 action->setShortcut(QKeySequence(Qt::ALT | Qt::Key_0)); | |
482 } | |
483 /* don't bother with a shortcut in case of more... */ | |
484 i++; | |
485 } | |
486 | |
487 folder_menu->addSeparator(); | |
488 | |
489 { | |
258 | 490 folder_menu->addAction(tr("&Add new folder..."), [this] { |
491 const QString dir = | |
492 QFileDialog::getExistingDirectory(this, tr("Open Directory"), QDir::homePath(), | |
493 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); | |
250 | 494 if (dir.isEmpty()) |
495 return; | |
496 session.config.library.paths.insert(Strings::ToUtf8String(dir)); | |
497 UpdateFolderMenu(); | |
498 }); | |
499 } | |
500 } | |
501 | |
369 | 502 void MainWindow::SetActivePage(QWidget *page) |
503 { | |
2 | 504 this->setCentralWidget(page); |
505 } | |
506 | |
369 | 507 void MainWindow::AsyncSynchronize(QAction *action, QStackedWidget *stack) |
508 { | |
279 | 509 if (session.config.service == Anime::Service::None) { |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
510 QMessageBox msg; |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
511 msg.setWindowTitle(tr("Error synchronizing with service!")); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
512 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
|
513 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
|
514 msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
515 msg.setDefaultButton(QMessageBox::Yes); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
516 int ret = msg.exec(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
517 if (ret == QMessageBox::Yes) { |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
518 SettingsDialog dialog; |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
519 dialog.exec(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
520 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
521 } |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
522 |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
523 /* FIXME: make this use a QThread; this is *very* unsafe */ |
369 | 524 AnimeListPage *page = reinterpret_cast<AnimeListPage *>(stack->widget(static_cast<int>(Pages::ANIME_LIST))); |
273
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
525 if (!async_synchronize_thread_.isRunning()) { |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
526 async_synchronize_thread_.SetAction(action); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
527 async_synchronize_thread_.SetPage(page); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
528 async_synchronize_thread_.start(); |
f31305b9f60a
*: various code safety changes
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
529 } |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
530 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
531 |
369 | 532 void MainWindow::RetranslateUI() |
533 { | |
291 | 534 /* This sucks a LOT */ |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
535 setUpdatesEnabled(false); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
536 AddMainWidgets(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
537 CreateBars(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
538 setUpdatesEnabled(true); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
539 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
540 |
369 | 541 void MainWindow::changeEvent(QEvent *event) |
542 { | |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
543 if (event) { /* is this really necessary */ |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
544 switch (event->type()) { |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
545 // this event is send if a translator is loaded |
258 | 546 case QEvent::LanguageChange: RetranslateUI(); break; |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
547 |
258 | 548 default: break; |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
549 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
550 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
551 QMainWindow::changeEvent(event); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
552 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
553 |
369 | 554 void MainWindow::showEvent(QShowEvent *event) |
555 { | |
105
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
103
diff
changeset
|
556 QMainWindow::showEvent(event); |
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
103
diff
changeset
|
557 #ifdef WIN32 |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
558 /* Technically this *should* be |
291 | 559 * session.config.theme.IsInDarkTheme() && win32::IsInDarkTheme() |
560 * but I prefer the title bar being black even when light mode | |
561 * is enabled :/ */ | |
108 | 562 win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme()); |
105
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
103
diff
changeset
|
563 #endif |
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
103
diff
changeset
|
564 } |
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
103
diff
changeset
|
565 |
369 | 566 void MainWindow::closeEvent(QCloseEvent *event) |
567 { | |
291 | 568 playing_thread_timer_.stop(); |
569 playing_thread_.wait(); | |
570 async_synchronize_thread_.wait(); | |
571 | |
2 | 572 session.config.Save(); |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
170
diff
changeset
|
573 Anime::db.SaveDatabaseToDisk(); |
2 | 574 event->accept(); |
575 } |