Mercurial > minori
diff 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 |
line wrap: on
line diff
--- a/src/gui/window.cpp Sun Sep 10 03:59:16 2023 -0400 +++ b/src/gui/window.cpp Sat Sep 16 02:06:01 2023 -0400 @@ -1,6 +1,7 @@ #include "gui/window.h" #include "core/config.h" #include "core/session.h" +#include "services/services.h" #include "gui/dialog/settings.h" #include "gui/pages/anime_list.h" #include "gui/pages/now_playing.h" @@ -24,17 +25,56 @@ wxWidgets, but I thought the API was a little meh, so I switched to Qt. */ +enum class Pages { + NOW_PLAYING, + + ANIME_LIST, + HISTORY, + STATISTICS, + + SEARCH, + SEASONS, + TORRENTS +}; + MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) { main_widget = new QWidget(parent); + + SideBar* sidebar = new SideBar(main_widget); + sidebar->AddItem("Now Playing", SideBar::CreateIcon(":/icons/16x16/film.png")); + sidebar->AddSeparator(); + sidebar->AddItem("Anime List", SideBar::CreateIcon(":/icons/16x16/document-list.png")); + sidebar->AddItem("History", SideBar::CreateIcon(":/icons/16x16/clock-history-frame.png")); + sidebar->AddItem("Statistics", SideBar::CreateIcon(":/icons/16x16/chart.png")); + sidebar->AddSeparator(); + sidebar->AddItem("Search", SideBar::CreateIcon(":/icons/16x16/magnifier.png")); + sidebar->AddItem("Seasons", SideBar::CreateIcon(":/icons/16x16/calendar.png")); + sidebar->AddItem("Torrents", SideBar::CreateIcon(":/icons/16x16/feed.png")); + sidebar->setFixedWidth(128); + sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); + + QStackedWidget* stack = new QStackedWidget(main_widget); + stack->addWidget(new NowPlayingWidget(main_widget)); + stack->addWidget(new AnimeListWidget(main_widget)); + stack->addWidget(new StatisticsWidget(main_widget)); + + connect(sidebar, &SideBar::CurrentItemChanged, stack, [stack](int index) { + switch (index) { + case 0: + case 1: stack->setCurrentIndex(index); break; + case 3: stack->setCurrentIndex(2); break; + default: break; + } + }); + sidebar->setCurrentRow(2); + /* Menu Bar */ QAction* action; QMenuBar* menubar = new QMenuBar(parent); QMenu* menu = menubar->addMenu("&File"); QMenu* submenu = menu->addMenu("&Library folders"); - action = new QAction("&Add new folder..."); - submenu->addAction(action); - action = new QAction("&Scan available episodes"); - menu->addAction(action); + action = submenu->addAction("&Add new folder..."); + action = menu->addAction("&Scan available episodes"); menu->addSeparator(); @@ -44,7 +84,10 @@ action = menu->addAction("E&xit", qApp, &QApplication::quit); menu = menubar->addMenu("&Services"); - action = new QAction("Synchronize &list"); + action = menu->addAction("Synchronize &list", [this, stack] { + Services::Synchronize(); + ((AnimeListWidget*)stack->widget((int)Pages::ANIME_LIST))->RefreshList(); + }); menu->addSeparator(); @@ -85,34 +128,6 @@ setMenuBar(menubar); - SideBar* sidebar = new SideBar(main_widget); - sidebar->AddItem("Now Playing", SideBar::CreateIcon(":/icons/16x16/film.png")); - sidebar->AddSeparator(); - sidebar->AddItem("Anime List", SideBar::CreateIcon(":/icons/16x16/document-list.png")); - sidebar->AddItem("History", SideBar::CreateIcon(":/icons/16x16/clock-history-frame.png")); - sidebar->AddItem("Statistics", SideBar::CreateIcon(":/icons/16x16/chart.png")); - sidebar->AddSeparator(); - sidebar->AddItem("Search", SideBar::CreateIcon(":/icons/16x16/magnifier.png")); - sidebar->AddItem("Seasons", SideBar::CreateIcon(":/icons/16x16/calendar.png")); - sidebar->AddItem("Torrents", SideBar::CreateIcon(":/icons/16x16/feed.png")); - sidebar->setFixedWidth(128); - sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); - - QStackedWidget* stack = new QStackedWidget(main_widget); - stack->addWidget(new NowPlayingWidget(parent)); - stack->addWidget(new AnimeListWidget(parent)); - stack->addWidget(new StatisticsWidget(parent)); - - connect(sidebar, &SideBar::CurrentItemChanged, stack, [stack](int index) { - switch (index) { - case 0: - case 1: stack->setCurrentIndex(index); break; - case 3: stack->setCurrentIndex(2); break; - default: break; - } - }); - sidebar->setCurrentRow(2); - QHBoxLayout* layout = new QHBoxLayout(main_widget); layout->addWidget(sidebar, 0, Qt::AlignLeft | Qt::AlignTop); layout->addWidget(stack);