Mercurial > minori
annotate src/gui/window.cc @ 241:06d6c351925c
*: reorganize resources, +docs, build translations with autotools
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Mon, 22 Jan 2024 16:36:19 -0500 |
parents | a7d0d543b334 |
children | c130f47f6f48 |
rev | line source |
---|---|
9 | 1 #include "gui/window.h" |
64 | 2 #include "core/anime_db.h" |
9 | 3 #include "core/config.h" |
4 #include "core/session.h" | |
64 | 5 #include "core/strings.h" |
102 | 6 #include "gui/theme.h" |
62 | 7 #include "gui/dialog/about.h" |
9 | 8 #include "gui/dialog/settings.h" |
9 #include "gui/pages/anime_list.h" | |
62 | 10 #include "gui/pages/history.h" |
9 | 11 #include "gui/pages/now_playing.h" |
62 | 12 #include "gui/pages/search.h" |
13 #include "gui/pages/seasons.h" | |
9 | 14 #include "gui/pages/statistics.h" |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
15 #include "gui/pages/torrents.h" |
46 | 16 #include "gui/widgets/sidebar.h" |
15 | 17 #include "services/services.h" |
64 | 18 #include "track/media.h" |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
19 #include "library/library.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 | |
10 | 51 enum class Pages { |
52 NOW_PLAYING, | |
53 | |
54 ANIME_LIST, | |
55 HISTORY, | |
56 STATISTICS, | |
57 | |
58 SEARCH, | |
59 SEASONS, | |
60 TORRENTS | |
61 }; | |
62 | |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
63 void PlayingThread::run() { |
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
64 std::vector<std::string> files; |
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
65 Track::Media::GetCurrentlyPlaying(files); |
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
66 emit Done(files); |
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
67 } |
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
68 |
9 | 69 MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) { |
241
06d6c351925c
*: reorganize resources, +docs, build translations with autotools
Paper <paper@paper.us.eu.org>
parents:
237
diff
changeset
|
70 setWindowIcon(QIcon(":/icons/favicon.png")); |
103 | 71 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
72 main_widget.reset(new QWidget(this)); |
190
2d5823df870f
dep/animia: finalize de-objc-ifying quartz
Paper <mrpapersonic@gmail.com>
parents:
174
diff
changeset
|
73 new QHBoxLayout(main_widget.get()); |
10 | 74 |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
75 AddMainWidgets(); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
76 setCentralWidget(main_widget.get()); |
79 | 77 |
78 CreateBars(); | |
79 | |
168
79a2a24453fa
window: improve performance when getting running files
paper@DavesDouble.local
parents:
154
diff
changeset
|
80 NowPlayingPage* page = reinterpret_cast<NowPlayingPage*>(stack->widget(static_cast<int>(Pages::NOW_PLAYING))); |
79 | 81 |
168
79a2a24453fa
window: improve performance when getting running files
paper@DavesDouble.local
parents:
154
diff
changeset
|
82 qRegisterMetaType<std::vector<std::string>>(); |
79 | 83 |
195
975a3f0965e2
locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents:
190
diff
changeset
|
84 /* This thread will be destroyed on |
975a3f0965e2
locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents:
190
diff
changeset
|
85 * close of the program OR on the destruction |
975a3f0965e2
locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents:
190
diff
changeset
|
86 * of MainWindow |
975a3f0965e2
locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents:
190
diff
changeset
|
87 */ |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
88 thread.reset(new PlayingThread(this)); |
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
89 |
232
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
90 connect(thread.get(), &PlayingThread::Done, this, [page](const std::vector<std::string>& files) { |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
91 for (const auto& file : files) { |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
92 anitomy::Anitomy anitomy; |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
93 anitomy.Parse(Strings::ToWstring(file)); |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
94 |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
95 const auto& elements = anitomy.elements(); |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
96 const std::string title = Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle)); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
97 std::cout << title << std::endl; |
232
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
98 |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
99 int id = Anime::db.GetAnimeFromTitle(title); |
232
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
100 if (id <= 0) |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
101 continue; |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
102 |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
103 page->SetPlaying(Anime::db.items[id], elements); |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
104 break; |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
105 } |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
106 }); |
ff0061e75f0f
theme: add OS detection with glib
Paper <mrpapersonic@gmail.com>
parents:
228
diff
changeset
|
107 |
190
2d5823df870f
dep/animia: finalize de-objc-ifying quartz
Paper <mrpapersonic@gmail.com>
parents:
174
diff
changeset
|
108 QTimer* timer = new QTimer(this); |
154 | 109 |
168
79a2a24453fa
window: improve performance when getting running files
paper@DavesDouble.local
parents:
154
diff
changeset
|
110 connect(timer, &QTimer::timeout, this, [this, page] { |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
111 if (!thread.get() || thread->isRunning()) |
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
112 return; |
190
2d5823df870f
dep/animia: finalize de-objc-ifying quartz
Paper <mrpapersonic@gmail.com>
parents:
174
diff
changeset
|
113 |
168
79a2a24453fa
window: improve performance when getting running files
paper@DavesDouble.local
parents:
154
diff
changeset
|
114 thread->start(); |
79 | 115 }); |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
116 |
237 | 117 #ifdef MACOSX |
118 if (!osx::AskForPermissions()) | |
119 return; | |
120 #endif | |
121 | |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
122 timer->start(5000); |
79 | 123 } |
124 | |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
125 void MainWindow::AddMainWidgets() { |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
126 int page = static_cast<int>(Pages::ANIME_LIST); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
127 if (sidebar.get()) { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
128 main_widget->layout()->removeWidget(sidebar.get()); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
129 sidebar.reset(); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
130 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
131 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
132 if (stack.get()) { |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
133 page = stack->currentIndex(); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
134 main_widget->layout()->removeWidget(stack.get()); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
135 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
136 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
137 sidebar.reset(new SideBar(main_widget.get())); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
138 sidebar->setFixedWidth(128); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
139 sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
140 |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
141 sidebar->AddItem(tr("Now Playing"), SideBar::CreateIcon(":/icons/16x16/film.png")); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
142 sidebar->AddSeparator(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
143 sidebar->AddItem(tr("Anime List"), SideBar::CreateIcon(":/icons/16x16/document-list.png")); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
144 sidebar->AddItem(tr("History"), SideBar::CreateIcon(":/icons/16x16/clock-history-frame.png")); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
145 sidebar->AddItem(tr("Statistics"), SideBar::CreateIcon(":/icons/16x16/chart.png")); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
146 sidebar->AddSeparator(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
147 sidebar->AddItem(tr("Search"), SideBar::CreateIcon(":/icons/16x16/magnifier.png")); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
148 sidebar->AddItem(tr("Seasons"), SideBar::CreateIcon(":/icons/16x16/calendar.png")); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
149 sidebar->AddItem(tr("Torrents"), SideBar::CreateIcon(":/icons/16x16/feed.png")); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
150 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
151 stack.reset(new QStackedWidget(main_widget.get())); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
152 stack->addWidget(new NowPlayingPage(main_widget.get())); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
153 stack->addWidget(new AnimeListPage(main_widget.get())); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
154 stack->addWidget(new HistoryPage(main_widget.get())); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
155 stack->addWidget(new StatisticsPage(main_widget.get())); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
156 stack->addWidget(new SearchPage(main_widget.get())); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
157 stack->addWidget(new SeasonsPage(main_widget.get())); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
158 stack->addWidget(new TorrentsPage(main_widget.get())); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
159 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
160 connect(sidebar.get(), &SideBar::CurrentItemChanged, stack.get(), &QStackedWidget::setCurrentIndex); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
161 sidebar->SetCurrentItem(page); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
162 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
163 main_widget->layout()->addWidget(sidebar.get()); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
164 main_widget->layout()->addWidget(stack.get()); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
165 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
166 |
79 | 167 void MainWindow::CreateBars() { |
168 QMenuBar* menubar = new QMenuBar(this); | |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
169 QMenu* folder_menu; /* this is used twice, so we declare it here */ |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
170 QAction* sync_action; |
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 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
173 /* File */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
174 QMenu* menu = menubar->addMenu(tr("&File")); |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
175 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
176 { |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
177 folder_menu = menu->addMenu(tr("&Library folders")); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
178 |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
179 /* add in all of our existing folders... */ |
226 | 180 std::size_t i = 0; |
181 for (const auto& path : session.config.library.paths) { | |
182 const QString folder = Strings::ToQString(path); | |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
183 QAction* action = folder_menu->addAction(folder, [folder]{ |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
184 QDesktopServices::openUrl(QUrl::fromLocalFile(folder)); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
185 }); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
186 if (i < 9) |
228
d030b30526d5
config: remove unused username parameter from anilist auth
Paper <mrpapersonic@gmail.com>
parents:
226
diff
changeset
|
187 action->setShortcut(QKeySequence(Qt::ALT | static_cast<Qt::Modifier>(Qt::Key_1 + i))); |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
188 else if (i == 9) |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
189 action->setShortcut(QKeySequence(Qt::ALT | Qt::Key_0)); |
228
d030b30526d5
config: remove unused username parameter from anilist auth
Paper <mrpapersonic@gmail.com>
parents:
226
diff
changeset
|
190 /* don't bother with a shortcut in case of more... */ |
d030b30526d5
config: remove unused username parameter from anilist auth
Paper <mrpapersonic@gmail.com>
parents:
226
diff
changeset
|
191 i++; |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
192 } |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
193 |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
194 folder_menu->addSeparator(); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
195 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
196 { |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
197 folder_menu->addAction(tr("&Add new folder..."), [this]{ |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
198 const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), |
226 | 199 QDir::homePath(), |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
200 QFileDialog::ShowDirsOnly |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
201 | QFileDialog::DontResolveSymlinks); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
202 if (dir.isEmpty()) |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
203 return; |
226 | 204 session.config.library.paths.insert(Strings::ToUtf8String(dir)); |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
205 /* we have to recreate the menu bar to add the new folder */ |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
206 CreateBars(); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
207 }); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
208 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
209 } |
2 | 210 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
211 { |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
212 menu->addAction(tr("&Scan available episodes"), []{ |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
213 Library::SearchLibraryFolders(); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
214 }); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
215 } |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
216 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
217 menu->addSeparator(); |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
218 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
219 // { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
220 // QAction* action = menu->addAction(tr("Play &next episode")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
221 // action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N)); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
222 // } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
223 // |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
224 // { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
225 // QAction* action = menu->addAction(tr("Play &random episode")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
226 // action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R)); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
227 // } |
2 | 228 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
229 menu->addSeparator(); |
2 | 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 QAction* action = menu->addAction(tr("E&xit"), qApp, &QApplication::quit); |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
233 action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q)); |
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 } |
2 | 236 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
237 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
238 /* Services */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
239 QMenu* menu = menubar->addMenu(tr("&Services")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
240 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
241 { |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
242 sync_action = menu->addAction(tr("Synchronize &list")); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
243 |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
244 connect(sync_action, &QAction::triggered, this, [this, sync_action]{ |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
245 AsyncSynchronize(sync_action, stack.get()); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
246 }); |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
247 |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
248 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
|
249 sync_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S)); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
250 } |
2 | 251 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
252 // menu->addSeparator(); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
253 // |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
254 // { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
255 // /* AniList */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
256 // QMenu* submenu = menu->addMenu(tr("&AniList")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
257 // QAction* action = submenu->addAction(tr("Go to my &profile")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
258 // action = submenu->addAction(tr("Go to my &stats")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
259 // } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
260 // |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
261 // { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
262 // /* Kitsu */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
263 // QMenu* submenu = menu->addMenu(tr("&Kitsu")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
264 // QAction* action = submenu->addAction(tr("Go to my &feed")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
265 // action = submenu->addAction(tr("Go to my &library")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
266 // action = submenu->addAction(tr("Go to my &profile")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
267 // } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
268 // { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
269 // QMenu* submenu = menu->addMenu(tr("&MyAnimeList")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
270 // QAction* action = submenu->addAction(tr("Go to my p&anel")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
271 // action = submenu->addAction(tr("Go to my &profile")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
272 // action = submenu->addAction(tr("Go to my &history")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
273 // } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
274 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
275 } |
2 | 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 /* Tools */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
279 QMenu* menu = menubar->addMenu(tr("&Tools")); |
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 // /* Export anime list */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
282 // QMenu* submenu = menu->addMenu(tr("&Export anime list")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
283 // |
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 // /* Markdown export */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
286 // QAction* action = submenu->addAction(tr("Export as &Markdown...")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
287 // } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
288 // |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
289 // { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
290 // /* XML export */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
291 // QAction* action = submenu->addAction(tr("Export as MyAnimeList &XML...")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
292 // } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
293 // } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
294 // menu->addSeparator(); |
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 // { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
297 // QAction* action = menu->addAction(tr("Enable anime &recognition")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
298 // action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
299 // } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
300 // |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
301 // { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
302 // QAction* action = menu->addAction(tr("Enable auto &sharing")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
303 // action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
304 // } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
305 // |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
306 // { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
307 // QAction* action = menu->addAction(tr("Enable &auto synchronization")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
308 // action->setCheckable(true); |
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 // |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
311 // menu->addSeparator(); |
44
619cbd6e69f9
filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents:
37
diff
changeset
|
312 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
313 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
314 QAction* action = menu->addAction(tr("&Settings"), [this] { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
315 SettingsDialog dialog(this); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
316 dialog.exec(); |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
317 CreateBars(); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
318 }); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
319 action->setMenuRole(QAction::PreferencesRole); |
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 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
322 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
323 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
324 /* View */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
325 QMenu* menu = menubar->addMenu(tr("&View")); |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
326 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
327 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
328 /* Pages... */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
329 std::map<QAction*, int> page_to_index_map = {}; |
58
b7a1c0010ffd
sidebar: link view menu and sidebar together
Paper <mrpapersonic@gmail.com>
parents:
54
diff
changeset
|
330 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
331 QActionGroup* pages_group = new QActionGroup(this); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
332 pages_group->setExclusive(true); |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
333 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
334 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
335 QAction* action = pages_group->addAction(menu->addAction(tr("&Now Playing"))); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
336 action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
337 page_to_index_map[action] = 0; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
338 } |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
339 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
340 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
341 QAction* action = pages_group->addAction(menu->addAction(tr("&Anime List"))); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
342 action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
343 action->setChecked(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
344 page_to_index_map[action] = 1; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
345 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
346 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
347 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
348 QAction* action = pages_group->addAction(menu->addAction(tr("&History"))); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
349 action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
350 page_to_index_map[action] = 2; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
351 } |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
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 QAction* action = pages_group->addAction(menu->addAction(tr("&Statistics"))); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
355 action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
356 page_to_index_map[action] = 3; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
357 } |
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
46
diff
changeset
|
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 QAction* action = pages_group->addAction(menu->addAction(tr("S&earch"))); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
361 action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
362 page_to_index_map[action] = 4; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
363 } |
44
619cbd6e69f9
filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents:
37
diff
changeset
|
364 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
365 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
366 QAction* action = pages_group->addAction(menu->addAction(tr("Se&asons"))); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
367 action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
368 page_to_index_map[action] = 5; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
369 } |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
370 |
114
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 QAction* action = pages_group->addAction(menu->addAction(tr("&Torrents"))); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
373 action->setCheckable(true); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
374 page_to_index_map[action] = 6; |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
375 } |
54
466ac9870df9
add stub pages (to be implemented)
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
376 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
377 /* pain in my ass */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
378 connect(sidebar.get(), &SideBar::CurrentItemChanged, this, |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
379 [pages_group](int index) { pages_group->actions()[index]->setChecked(true); }); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
380 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
381 connect(pages_group, &QActionGroup::triggered, this, |
170
c8375765f0fc
window: make threading somewhat sane
Paper <mrpapersonic@gmail.com>
parents:
168
diff
changeset
|
382 [this, page_to_index_map](QAction* action) { sidebar->SetCurrentItem(page_to_index_map.at(action)); }); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
383 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
384 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
385 menu->addSeparator(); |
44
619cbd6e69f9
filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents:
37
diff
changeset
|
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 // QAction* action = menu->addAction(tr("Show sidebar")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
389 // } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
390 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
391 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
392 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
393 /* Help */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
394 QMenu* menu = menubar->addMenu(tr("&Help")); |
2 | 395 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
396 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
397 /* About Minori */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
398 menu->addAction(tr("&About Minori"), this, [this] { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
399 AboutWindow dialog(this); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
400 dialog.exec(); |
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 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
403 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
404 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
405 /* About Qt */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
406 QAction* action = menu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
407 action->setMenuRole(QAction::AboutQtRole); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
408 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
409 } |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
410 /* QMainWindow will delete the old one for us, |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
411 according to the docs */ |
2 | 412 setMenuBar(menubar); |
7 | 413 |
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
64
diff
changeset
|
414 /* Toolbar */ |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
415 |
79 | 416 /* remove old toolbar(s) */ |
115 | 417 /* the empty QString() is a Qt 5 wart... */ |
418 for (QToolBar*& t : findChildren<QToolBar*>(QString(), Qt::FindDirectChildrenOnly)) { | |
79 | 419 removeToolBar(t); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
420 delete t; |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
421 } |
79 | 422 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
423 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
424 /* Toolbar */ |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
425 QToolBar* toolbar = new QToolBar(this); |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
426 toolbar->addAction(sync_action); |
69 | 427 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
428 toolbar->addSeparator(); |
69 | 429 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
430 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
431 QToolButton* button = new QToolButton(toolbar); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
432 { |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
433 button->setMenu(folder_menu); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
434 } |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
435 button->setIcon(QIcon(":/icons/24x24/folder-open.png")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
436 button->setPopupMode(QToolButton::InstantPopup); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
437 toolbar->addWidget(button); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
438 } |
69 | 439 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
440 { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
441 QToolButton* button = new QToolButton(toolbar); |
69 | 442 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
443 { |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
444 /* links */ |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
445 QMenu* menu = new QMenu(button); |
223
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
446 menu->addAction("Hibari", []{ |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
447 QDesktopServices::openUrl(QUrl("https://hb.wopian.me/")); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
448 }); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
449 menu->addAction("MALgraph", []{ |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
450 QDesktopServices::openUrl(QUrl("https://graph.anime.plus/")); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
451 }); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
452 menu->addSeparator(); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
453 menu->addAction("AniChart", []{ |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
454 QDesktopServices::openUrl(QUrl("https://anichart.net/airing")); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
455 }); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
456 menu->addAction("Monthly.moe", []{ |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
457 QDesktopServices::openUrl(QUrl("https://www.monthly.moe/weekly")); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
458 }); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
459 menu->addAction("Senpai Anime Charts", []{ |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
460 QDesktopServices::openUrl(QUrl("https://www.senpai.moe/?mode=calendar")); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
461 }); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
462 menu->addSeparator(); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
463 menu->addAction("Anime Streaming Search Engine", []{ |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
464 QDesktopServices::openUrl(QUrl("https://because.moe/")); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
465 }); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
466 menu->addAction("The Fansub Database", []{ |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
467 QDesktopServices::openUrl(QUrl("https://fansubdb.com")); |
84e0a3c4737a
library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
468 }); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
469 |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
470 button->setMenu(menu); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
471 } |
69 | 472 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
473 button->setIcon(QIcon(":/icons/24x24/application-export.png")); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
474 button->setPopupMode(QToolButton::InstantPopup); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
475 toolbar->addWidget(button); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
476 } |
69 | 477 |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
478 toolbar->addSeparator(); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
479 toolbar->addAction(QIcon(":/icons/24x24/gear.png"), tr("S&ettings"), [this] { |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
480 SettingsDialog dialog(this); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
481 dialog.exec(); |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
482 CreateBars(); |
114
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
483 }); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
484 addToolBar(toolbar); |
ab191e28e69d
*: add initial torrent stuff
Paper <mrpapersonic@gmail.com>
parents:
113
diff
changeset
|
485 } |
2 | 486 } |
487 | |
488 void MainWindow::SetActivePage(QWidget* page) { | |
489 this->setCentralWidget(page); | |
490 } | |
491 | |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
492 void MainWindow::AsyncSynchronize(QAction* action, QStackedWidget* stack) { |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
493 if (session.config.service == Anime::Services::NONE) { |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
494 QMessageBox msg; |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
495 msg.setWindowTitle(tr("Error synchronizing with service!")); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
496 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
|
497 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
|
498 msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
499 msg.setDefaultButton(QMessageBox::Yes); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
500 int ret = msg.exec(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
501 if (ret == QMessageBox::Yes) { |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
502 SettingsDialog dialog; |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
503 dialog.exec(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
504 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
505 } |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
506 |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
507 QThreadPool::globalInstance()->start([stack, action] { |
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
508 action->setEnabled(false); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
509 Services::Synchronize(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
510 reinterpret_cast<AnimeListPage*>(stack->widget(static_cast<int>(Pages::ANIME_LIST)))->Refresh(); |
236
4d461ef7d424
HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents:
232
diff
changeset
|
511 action->setEnabled(true); |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
512 }); |
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() { |
113
32afe0e940bf
window: remove tiny little debug thing
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
516 /* This kinda sucks but nobody's really going to be changing |
32afe0e940bf
window: remove tiny little debug thing
Paper <mrpapersonic@gmail.com>
parents:
112
diff
changeset
|
517 the application language all the time :p */ |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
518 setUpdatesEnabled(false); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
519 AddMainWidgets(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
520 CreateBars(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
521 setUpdatesEnabled(true); |
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 |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
524 void MainWindow::changeEvent(QEvent* event) { |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
525 if (event) { /* is this really necessary */ |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
526 switch (event->type()) { |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
527 // this event is send if a translator is loaded |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
528 case QEvent::LanguageChange: |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
529 RetranslateUI(); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
530 break; |
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 default: |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
533 break; |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
534 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
535 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
536 QMainWindow::changeEvent(event); |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
537 } |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
538 |
105
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
103
diff
changeset
|
539 void MainWindow::showEvent(QShowEvent* event) { |
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
103
diff
changeset
|
540 QMainWindow::showEvent(event); |
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
103
diff
changeset
|
541 #ifdef WIN32 |
112
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
542 /* Technically this *should* be |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
543 session.config.theme.IsInDarkTheme() && win32::IsInDarkTheme() |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
544 but I prefer the title bar being black even when light mode |
80f49f623d30
locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents:
108
diff
changeset
|
545 is enabled :/ */ |
108 | 546 win32::SetTitleBarsToBlack(session.config.theme.IsInDarkTheme()); |
105
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
103
diff
changeset
|
547 #endif |
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
103
diff
changeset
|
548 } |
6d8da6e64d61
theme: add dark stylesheet, make it actually usable
Paper <mrpapersonic@gmail.com>
parents:
103
diff
changeset
|
549 |
2 | 550 void MainWindow::closeEvent(QCloseEvent* event) { |
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 | 553 event->accept(); |
554 } |