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