Mercurial > minori
diff src/main.cpp @ 7:07a9095eaeed
Update
Refactored some code, moved some around
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Thu, 24 Aug 2023 23:11:38 -0400 |
parents | 1d82f6e04d7d |
children | b1f73678ef61 |
line wrap: on
line diff
--- a/src/main.cpp Wed Aug 16 00:49:17 2023 -0400 +++ b/src/main.cpp Thu Aug 24 23:11:38 2023 -0400 @@ -1,18 +1,27 @@ +#include <QApplication> +#include <QMainWindow> +#include <QMenuBar> +#include <QPlainTextEdit> +#include <QStackedWidget> +#include <QFile> +#include <QTextStream> +#include <QMessageBox> #include "window.h" #include "config.h" -#include "anime.h" +#include "anime_list.h" +#include "now_playing.h" +#include "statistics.h" #include "sidebar.h" #include "ui_utils.h" #include "settings.h" +#include "session.h" #if MACOSX #include "sys/osx/dark_theme.h" #elif WIN32 #include "sys/win32/dark_theme.h" #endif -Session session = { - .config = Config() -}; +Session session; /* note that this code was originally created for use in wxWidgets, but I thought the API was a little meh, so @@ -79,8 +88,7 @@ }); setMenuBar(menubar); - - /* Side toolbar */ + SideBar* sidebar = new SideBar(main_widget); sidebar->AddItem("Now Playing", UiUtils::CreateSideBarIcon(":/icons/16x16/film.png")); sidebar->AddSeparator(); @@ -94,59 +102,31 @@ sidebar->setFixedWidth(128); sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); - anime_list_page = new AnimeListPage(parent); + QStackedWidget* stack = new QStackedWidget(main_widget); + stack->addWidget(new NowPlayingWidget(parent)); + AnimeListWidget* list_widget = new AnimeListWidget(parent); + list_widget->SyncAnimeList(); + stack->addWidget(list_widget); + stack->addWidget(new StatisticsWidget(list_widget, parent)); + + connect(sidebar, &SideBar::CurrentItemChanged, stack, [stack](int index){ + switch (index) { + case 0: + case 1: + case 2: + stack->setCurrentIndex(index); + break; + default: + break; + } + }); + sidebar->setCurrentRow(2); QHBoxLayout* layout = new QHBoxLayout(main_widget); layout->addWidget(sidebar, 0, Qt::AlignLeft | Qt::AlignTop); - layout->addWidget(anime_list_page); - SetActivePage(main_widget); -/* - QToolBar* toolbar = new QToolBar(parent); - QActionGroup* tb_action_group = new QActionGroup(toolbar); - - action = toolbar->addAction("Now Playing"); - action->setActionGroup(tb_action_group); - action->setCheckable(true); - - toolbar->addSeparator(); + layout->addWidget(stack); + setCentralWidget(main_widget); - action = toolbar->addAction("Anime List", [this]() { - setCentralWidget(anime_list_page); - }); - action->setActionGroup(tb_action_group); - action->setCheckable(true); - action->setChecked(true); - anime_list_page = new AnimeListPage(parent); - SetActivePage(anime_list_page); - action = toolbar->addAction("History"); - action->setActionGroup(tb_action_group); - action->setCheckable(true); - action = toolbar->addAction("Statistics"); - action->setActionGroup(tb_action_group); - action->setCheckable(true); - - toolbar->addSeparator(); - - action = toolbar->addAction("Search"); - action->setActionGroup(tb_action_group); - action->setCheckable(true); - action = toolbar->addAction("Seasons"); - action->setActionGroup(tb_action_group); - action->setCheckable(true); - action = toolbar->addAction("Torrents"); - action->setActionGroup(tb_action_group); - action->setCheckable(true); - - toolbar->setMovable(false); - toolbar->setFloatable(false); - toolbar->setMinimumSize(QSize(140, 0)); - toolbar->setObjectName("sidebar"); - toolbar->setStyleSheet("QToolBar#sidebar{margin: 6px;}"); - //toolbar->setFrameShape(QFrame::NoFrame); - toolbar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum); - - addToolBar(Qt::LeftToolBarArea, toolbar); -*/ ThemeChanged(); }