Mercurial > minori
comparison src/gui/window.cpp @ 54:466ac9870df9
add stub pages (to be implemented)
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Tue, 26 Sep 2023 11:18:50 -0400 |
parents | 75c804f713b2 |
children | b7a1c0010ffd |
comparison
equal
deleted
inserted
replaced
53:a6e51a03112e | 54:466ac9870df9 |
---|---|
5 #include "gui/dialog/settings.h" | 5 #include "gui/dialog/settings.h" |
6 #include "gui/dialog/about.h" | 6 #include "gui/dialog/about.h" |
7 #include "gui/pages/anime_list.h" | 7 #include "gui/pages/anime_list.h" |
8 #include "gui/pages/now_playing.h" | 8 #include "gui/pages/now_playing.h" |
9 #include "gui/pages/statistics.h" | 9 #include "gui/pages/statistics.h" |
10 #include "gui/pages/seasons.h" | |
11 #include "gui/pages/search.h" | |
12 #include "gui/pages/torrents.h" | |
13 #include "gui/pages/history.h" | |
10 #include "gui/widgets/sidebar.h" | 14 #include "gui/widgets/sidebar.h" |
11 #include "services/services.h" | 15 #include "services/services.h" |
12 #include <QApplication> | 16 #include <QApplication> |
13 #include <QFile> | 17 #include <QFile> |
14 #include <QMainWindow> | 18 #include <QMainWindow> |
51 sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); | 55 sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); |
52 | 56 |
53 QStackedWidget* stack = new QStackedWidget(main_widget); | 57 QStackedWidget* stack = new QStackedWidget(main_widget); |
54 stack->addWidget(new NowPlayingWidget(main_widget)); | 58 stack->addWidget(new NowPlayingWidget(main_widget)); |
55 stack->addWidget(new AnimeListWidget(main_widget)); | 59 stack->addWidget(new AnimeListWidget(main_widget)); |
60 stack->addWidget(new HistoryWidget(main_widget)); | |
56 stack->addWidget(new StatisticsWidget(main_widget)); | 61 stack->addWidget(new StatisticsWidget(main_widget)); |
57 | 62 stack->addWidget(new SearchWidget(main_widget)); |
58 connect(sidebar, &SideBar::CurrentItemChanged, stack, [stack](int index) { | 63 stack->addWidget(new SeasonsWidget(main_widget)); |
59 switch (index) { | 64 stack->addWidget(new TorrentsWidget(main_widget)); |
60 case 0: | 65 |
61 case 1: stack->setCurrentIndex(index); break; | 66 connect(sidebar, &SideBar::CurrentItemChanged, stack, &QStackedWidget::setCurrentIndex); |
62 case 3: stack->setCurrentIndex(2); break; | |
63 default: break; | |
64 } | |
65 }); | |
66 sidebar->setCurrentRow(2); | 67 sidebar->setCurrentRow(2); |
67 | 68 |
68 /* Menu Bar */ | 69 /* Menu Bar */ |
69 QAction* action; | 70 QAction* action; |
70 QMenuBar* menubar = new QMenuBar(parent); | 71 QMenuBar* menubar = new QMenuBar(parent); |
165 | 166 |
166 action = pages_group->addAction(menu->addAction(tr("&Torrents"))); | 167 action = pages_group->addAction(menu->addAction(tr("&Torrents"))); |
167 action->setCheckable(true); | 168 action->setCheckable(true); |
168 page_to_index_map[action] = 6; | 169 page_to_index_map[action] = 6; |
169 | 170 |
171 connect(stack, &QStackedWidget::currentChanged, this, [pages_group, sidebar](int index){ | |
172 pages_group->actions()[index]->setChecked(true); | |
173 }); | |
174 | |
170 connect(pages_group, &QActionGroup::triggered, this, [page_to_index_map, stack](QAction* action) { | 175 connect(pages_group, &QActionGroup::triggered, this, [page_to_index_map, stack](QAction* action) { |
171 int index = page_to_index_map.at(action); | 176 stack->setCurrentIndex(page_to_index_map.at(action)); |
172 switch (index) { | 177 }); |
173 case 0: | 178 |
174 case 1: stack->setCurrentIndex(index); break; | |
175 case 3: stack->setCurrentIndex(2); | |
176 default: break; | |
177 } | |
178 }); | |
179 menu->addSeparator(); | 179 menu->addSeparator(); |
180 menu->addAction(tr("Show sidebar")); | 180 menu->addAction(tr("Show sidebar")); |
181 | 181 |
182 menu = menubar->addMenu(tr("&Help")); | 182 menu = menubar->addMenu(tr("&Help")); |
183 action = menu->addAction(tr("About Minori"), this, [this] { | 183 action = menu->addAction(tr("About Minori"), this, [this] { |