annotate src/gui/window.cc @ 323:1686fac290c5

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