Mercurial > minori
comparison src/gui/window.cpp @ 10:4b198a111713
Update
things actually compile now btw
qttest wants to fuck over the model but that might be my fault so /shrug
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sat, 16 Sep 2023 02:06:01 -0400 |
parents | 5c0397762b53 |
children | cde8f67a7c7d |
comparison
equal
deleted
inserted
replaced
9:5c0397762b53 | 10:4b198a111713 |
---|---|
1 #include "gui/window.h" | 1 #include "gui/window.h" |
2 #include "core/config.h" | 2 #include "core/config.h" |
3 #include "core/session.h" | 3 #include "core/session.h" |
4 #include "services/services.h" | |
4 #include "gui/dialog/settings.h" | 5 #include "gui/dialog/settings.h" |
5 #include "gui/pages/anime_list.h" | 6 #include "gui/pages/anime_list.h" |
6 #include "gui/pages/now_playing.h" | 7 #include "gui/pages/now_playing.h" |
7 #include "gui/pages/statistics.h" | 8 #include "gui/pages/statistics.h" |
8 #include "gui/sidebar.h" | 9 #include "gui/sidebar.h" |
22 | 23 |
23 /* note that this code was originally created for use in | 24 /* note that this code was originally created for use in |
24 wxWidgets, but I thought the API was a little meh, so | 25 wxWidgets, but I thought the API was a little meh, so |
25 I switched to Qt. */ | 26 I switched to Qt. */ |
26 | 27 |
28 enum class Pages { | |
29 NOW_PLAYING, | |
30 | |
31 ANIME_LIST, | |
32 HISTORY, | |
33 STATISTICS, | |
34 | |
35 SEARCH, | |
36 SEASONS, | |
37 TORRENTS | |
38 }; | |
39 | |
27 MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) { | 40 MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) { |
28 main_widget = new QWidget(parent); | 41 main_widget = new QWidget(parent); |
29 /* Menu Bar */ | |
30 QAction* action; | |
31 QMenuBar* menubar = new QMenuBar(parent); | |
32 QMenu* menu = menubar->addMenu("&File"); | |
33 QMenu* submenu = menu->addMenu("&Library folders"); | |
34 action = new QAction("&Add new folder..."); | |
35 submenu->addAction(action); | |
36 action = new QAction("&Scan available episodes"); | |
37 menu->addAction(action); | |
38 | |
39 menu->addSeparator(); | |
40 | |
41 action = menu->addAction("Play &next episode"); | |
42 action = menu->addAction("Play &random episode"); | |
43 menu->addSeparator(); | |
44 action = menu->addAction("E&xit", qApp, &QApplication::quit); | |
45 | |
46 menu = menubar->addMenu("&Services"); | |
47 action = new QAction("Synchronize &list"); | |
48 | |
49 menu->addSeparator(); | |
50 | |
51 submenu = menu->addMenu("&AniList"); | |
52 action = submenu->addAction("Go to my &profile"); | |
53 action = submenu->addAction("Go to my &stats"); | |
54 | |
55 submenu = menu->addMenu("&Kitsu"); | |
56 action = submenu->addAction("Go to my &feed"); | |
57 action = submenu->addAction("Go to my &library"); | |
58 action = submenu->addAction("Go to my &profile"); | |
59 | |
60 submenu = menu->addMenu("&MyAnimeList"); | |
61 action = submenu->addAction("Go to my p&anel"); | |
62 action = submenu->addAction("Go to my &profile"); | |
63 action = submenu->addAction("Go to my &history"); | |
64 | |
65 menu = menubar->addMenu("&Tools"); | |
66 submenu = menu->addMenu("&Export anime list"); | |
67 action = submenu->addAction("Export as &Markdown..."); | |
68 action = submenu->addAction("Export as MyAnimeList &XML..."); | |
69 | |
70 menu->addSeparator(); | |
71 | |
72 action = menu->addAction("Enable anime &recognition"); | |
73 action->setCheckable(true); | |
74 action = menu->addAction("Enable auto &sharing"); | |
75 action->setCheckable(true); | |
76 action = menu->addAction("Enable &auto synchronization"); | |
77 action->setCheckable(true); | |
78 | |
79 menu->addSeparator(); | |
80 | |
81 action = menu->addAction("&Settings", [this] { | |
82 SettingsDialog dialog(this); | |
83 dialog.exec(); | |
84 }); | |
85 | |
86 setMenuBar(menubar); | |
87 | 42 |
88 SideBar* sidebar = new SideBar(main_widget); | 43 SideBar* sidebar = new SideBar(main_widget); |
89 sidebar->AddItem("Now Playing", SideBar::CreateIcon(":/icons/16x16/film.png")); | 44 sidebar->AddItem("Now Playing", SideBar::CreateIcon(":/icons/16x16/film.png")); |
90 sidebar->AddSeparator(); | 45 sidebar->AddSeparator(); |
91 sidebar->AddItem("Anime List", SideBar::CreateIcon(":/icons/16x16/document-list.png")); | 46 sidebar->AddItem("Anime List", SideBar::CreateIcon(":/icons/16x16/document-list.png")); |
97 sidebar->AddItem("Torrents", SideBar::CreateIcon(":/icons/16x16/feed.png")); | 52 sidebar->AddItem("Torrents", SideBar::CreateIcon(":/icons/16x16/feed.png")); |
98 sidebar->setFixedWidth(128); | 53 sidebar->setFixedWidth(128); |
99 sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); | 54 sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); |
100 | 55 |
101 QStackedWidget* stack = new QStackedWidget(main_widget); | 56 QStackedWidget* stack = new QStackedWidget(main_widget); |
102 stack->addWidget(new NowPlayingWidget(parent)); | 57 stack->addWidget(new NowPlayingWidget(main_widget)); |
103 stack->addWidget(new AnimeListWidget(parent)); | 58 stack->addWidget(new AnimeListWidget(main_widget)); |
104 stack->addWidget(new StatisticsWidget(parent)); | 59 stack->addWidget(new StatisticsWidget(main_widget)); |
105 | 60 |
106 connect(sidebar, &SideBar::CurrentItemChanged, stack, [stack](int index) { | 61 connect(sidebar, &SideBar::CurrentItemChanged, stack, [stack](int index) { |
107 switch (index) { | 62 switch (index) { |
108 case 0: | 63 case 0: |
109 case 1: stack->setCurrentIndex(index); break; | 64 case 1: stack->setCurrentIndex(index); break; |
110 case 3: stack->setCurrentIndex(2); break; | 65 case 3: stack->setCurrentIndex(2); break; |
111 default: break; | 66 default: break; |
112 } | 67 } |
113 }); | 68 }); |
114 sidebar->setCurrentRow(2); | 69 sidebar->setCurrentRow(2); |
70 | |
71 /* Menu Bar */ | |
72 QAction* action; | |
73 QMenuBar* menubar = new QMenuBar(parent); | |
74 QMenu* menu = menubar->addMenu("&File"); | |
75 QMenu* submenu = menu->addMenu("&Library folders"); | |
76 action = submenu->addAction("&Add new folder..."); | |
77 action = menu->addAction("&Scan available episodes"); | |
78 | |
79 menu->addSeparator(); | |
80 | |
81 action = menu->addAction("Play &next episode"); | |
82 action = menu->addAction("Play &random episode"); | |
83 menu->addSeparator(); | |
84 action = menu->addAction("E&xit", qApp, &QApplication::quit); | |
85 | |
86 menu = menubar->addMenu("&Services"); | |
87 action = menu->addAction("Synchronize &list", [this, stack] { | |
88 Services::Synchronize(); | |
89 ((AnimeListWidget*)stack->widget((int)Pages::ANIME_LIST))->RefreshList(); | |
90 }); | |
91 | |
92 menu->addSeparator(); | |
93 | |
94 submenu = menu->addMenu("&AniList"); | |
95 action = submenu->addAction("Go to my &profile"); | |
96 action = submenu->addAction("Go to my &stats"); | |
97 | |
98 submenu = menu->addMenu("&Kitsu"); | |
99 action = submenu->addAction("Go to my &feed"); | |
100 action = submenu->addAction("Go to my &library"); | |
101 action = submenu->addAction("Go to my &profile"); | |
102 | |
103 submenu = menu->addMenu("&MyAnimeList"); | |
104 action = submenu->addAction("Go to my p&anel"); | |
105 action = submenu->addAction("Go to my &profile"); | |
106 action = submenu->addAction("Go to my &history"); | |
107 | |
108 menu = menubar->addMenu("&Tools"); | |
109 submenu = menu->addMenu("&Export anime list"); | |
110 action = submenu->addAction("Export as &Markdown..."); | |
111 action = submenu->addAction("Export as MyAnimeList &XML..."); | |
112 | |
113 menu->addSeparator(); | |
114 | |
115 action = menu->addAction("Enable anime &recognition"); | |
116 action->setCheckable(true); | |
117 action = menu->addAction("Enable auto &sharing"); | |
118 action->setCheckable(true); | |
119 action = menu->addAction("Enable &auto synchronization"); | |
120 action->setCheckable(true); | |
121 | |
122 menu->addSeparator(); | |
123 | |
124 action = menu->addAction("&Settings", [this] { | |
125 SettingsDialog dialog(this); | |
126 dialog.exec(); | |
127 }); | |
128 | |
129 setMenuBar(menubar); | |
115 | 130 |
116 QHBoxLayout* layout = new QHBoxLayout(main_widget); | 131 QHBoxLayout* layout = new QHBoxLayout(main_widget); |
117 layout->addWidget(sidebar, 0, Qt::AlignLeft | Qt::AlignTop); | 132 layout->addWidget(sidebar, 0, Qt::AlignLeft | Qt::AlignTop); |
118 layout->addWidget(stack); | 133 layout->addWidget(stack); |
119 setCentralWidget(main_widget); | 134 setCentralWidget(main_widget); |