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