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