Mercurial > minori
comparison src/gui/window.cpp @ 77:6f7385bd334c
*: update
formatted all source files, no more subclassing QThread... many other
changes :)
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Fri, 06 Oct 2023 06:18:53 -0400 |
parents | 27a19dd6cba1 |
children | c489dd4434af |
comparison
equal
deleted
inserted
replaced
76:3364fadc8a36 | 77:6f7385bd334c |
---|---|
25 #include <QMenuBar> | 25 #include <QMenuBar> |
26 #include <QMessageBox> | 26 #include <QMessageBox> |
27 #include <QPlainTextEdit> | 27 #include <QPlainTextEdit> |
28 #include <QStackedWidget> | 28 #include <QStackedWidget> |
29 #include <QTextStream> | 29 #include <QTextStream> |
30 #include <QThreadPool> | |
30 #include <QTimer> | 31 #include <QTimer> |
31 #include <QToolBar> | 32 #include <QToolBar> |
32 #include <QToolButton> | 33 #include <QToolButton> |
33 #if MACOSX | 34 #if MACOSX |
34 # include "sys/osx/dark_theme.h" | 35 # include "sys/osx/dark_theme.h" |
45 | 46 |
46 SEARCH, | 47 SEARCH, |
47 SEASONS, | 48 SEASONS, |
48 TORRENTS | 49 TORRENTS |
49 }; | 50 }; |
51 | |
52 static void AsyncSynchronize(QStackedWidget* stack) { | |
53 QThreadPool::globalInstance()->start([stack] { | |
54 Services::Synchronize(); | |
55 reinterpret_cast<AnimeListPage*>(stack->widget(static_cast<int>(Pages::ANIME_LIST)))->Refresh(); | |
56 }); | |
57 } | |
50 | 58 |
51 MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) { | 59 MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) { |
52 main_widget = new QWidget(parent); | 60 main_widget = new QWidget(parent); |
53 | 61 |
54 SideBar* sidebar = new SideBar(main_widget); | 62 SideBar* sidebar = new SideBar(main_widget); |
96 menu->addSeparator(); | 104 menu->addSeparator(); |
97 | 105 |
98 action = menu->addAction(tr("E&xit"), qApp, &QApplication::quit); | 106 action = menu->addAction(tr("E&xit"), qApp, &QApplication::quit); |
99 | 107 |
100 menu = menubar->addMenu(tr("&Services")); | 108 menu = menubar->addMenu(tr("&Services")); |
101 action = menu->addAction(tr("Synchronize &list"), [stack] { | 109 action = menu->addAction(tr("Synchronize &list"), [stack] { AsyncSynchronize(stack); }); |
102 Services::Synchronize(); | |
103 reinterpret_cast<AnimeListPage*>(stack->widget(static_cast<int>(Pages::ANIME_LIST)))->Refresh(); | |
104 }); | |
105 action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S)); | 110 action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S)); |
106 | 111 |
107 menu->addSeparator(); | 112 menu->addSeparator(); |
108 | 113 |
109 submenu = menu->addMenu(tr("&AniList")); | 114 submenu = menu->addMenu(tr("&AniList")); |
197 | 202 |
198 setMenuBar(menubar); | 203 setMenuBar(menubar); |
199 | 204 |
200 /* Toolbar */ | 205 /* Toolbar */ |
201 QToolBar* toolbar = new QToolBar(this); | 206 QToolBar* toolbar = new QToolBar(this); |
202 toolbar->addAction(QIcon(":/icons/24x24/arrow-circle-double-135.png"), tr("&Synchronize"), [stack] { | 207 toolbar->addAction(QIcon(":/icons/24x24/arrow-circle-double-135.png"), tr("&Synchronize"), |
203 Services::Synchronize(); | 208 [stack] { AsyncSynchronize(stack); }); |
204 reinterpret_cast<AnimeListPage*>(stack->widget(static_cast<int>(Pages::ANIME_LIST)))->Refresh(); | |
205 }); | |
206 toolbar->addSeparator(); | 209 toolbar->addSeparator(); |
207 | 210 |
208 QToolButton* button = new QToolButton(toolbar); | 211 QToolButton* button = new QToolButton(toolbar); |
209 | 212 |
210 menu = new QMenu(button); | 213 menu = new QMenu(button); |