Mercurial > minori
comparison src/main.cpp @ 6:1d82f6e04d7d
Update: add first parts to the settings dialog
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Wed, 16 Aug 2023 00:49:17 -0400 |
| parents | 51ae25154b70 |
| children | 07a9095eaeed |
comparison
equal
deleted
inserted
replaced
| 5:51ae25154b70 | 6:1d82f6e04d7d |
|---|---|
| 1 #include "window.h" | 1 #include "window.h" |
| 2 #include "config.h" | 2 #include "config.h" |
| 3 #include "anime.h" | 3 #include "anime.h" |
| 4 #include "sidebar.h" | |
| 5 #include "ui_utils.h" | |
| 6 #include "settings.h" | |
| 4 #if MACOSX | 7 #if MACOSX |
| 5 #include "sys/osx/dark_theme.h" | 8 #include "sys/osx/dark_theme.h" |
| 6 #elif WIN32 | 9 #elif WIN32 |
| 7 #include "sys/win32/dark_theme.h" | 10 #include "sys/win32/dark_theme.h" |
| 8 #endif | 11 #endif |
| 15 wxWidgets, but I thought the API was a little meh, so | 18 wxWidgets, but I thought the API was a little meh, so |
| 16 I switched to Qt. */ | 19 I switched to Qt. */ |
| 17 | 20 |
| 18 MainWindow::MainWindow(QWidget* parent) : | 21 MainWindow::MainWindow(QWidget* parent) : |
| 19 QMainWindow(parent) { | 22 QMainWindow(parent) { |
| 23 main_widget = new QWidget(parent); | |
| 20 /* Menu Bar */ | 24 /* Menu Bar */ |
| 21 QAction* action; | 25 QAction* action; |
| 22 QMenuBar* menubar = new QMenuBar(parent); | 26 QMenuBar* menubar = new QMenuBar(parent); |
| 23 QMenu* menu = menubar->addMenu("&File"); | 27 QMenu* menu = menubar->addMenu("&File"); |
| 24 QMenu* submenu = menu->addMenu("&Library folders"); | 28 QMenu* submenu = menu->addMenu("&Library folders"); |
| 38 action = new QAction("Synchronize &list"); | 42 action = new QAction("Synchronize &list"); |
| 39 | 43 |
| 40 menu->addSeparator(); | 44 menu->addSeparator(); |
| 41 | 45 |
| 42 submenu = menu->addMenu("&AniList"); | 46 submenu = menu->addMenu("&AniList"); |
| 43 action = menu->addAction("Go to my &profile"); | 47 action = submenu->addAction("Go to my &profile"); |
| 44 action = menu->addAction("Go to my &stats"); | 48 action = submenu->addAction("Go to my &stats"); |
| 45 | 49 |
| 46 submenu = menu->addMenu("&Kitsu"); | 50 submenu = menu->addMenu("&Kitsu"); |
| 47 action = submenu->addAction("Go to my &feed"); | 51 action = submenu->addAction("Go to my &feed"); |
| 48 action = submenu->addAction("Go to my &library"); | 52 action = submenu->addAction("Go to my &library"); |
| 49 action = submenu->addAction("Go to my &profile"); | 53 action = submenu->addAction("Go to my &profile"); |
| 67 action = menu->addAction("Enable &auto synchronization"); | 71 action = menu->addAction("Enable &auto synchronization"); |
| 68 action->setCheckable(true); | 72 action->setCheckable(true); |
| 69 | 73 |
| 70 menu->addSeparator(); | 74 menu->addSeparator(); |
| 71 | 75 |
| 72 action = menu->addAction("&Settings"); | 76 action = menu->addAction("&Settings", [this]{ |
| 77 SettingsDialog dialog(this); | |
| 78 dialog.exec(); | |
| 79 }); | |
| 73 | 80 |
| 74 setMenuBar(menubar); | 81 setMenuBar(menubar); |
| 75 | 82 |
| 76 /* Side toolbar */ | 83 /* Side toolbar */ |
| 84 SideBar* sidebar = new SideBar(main_widget); | |
| 85 sidebar->AddItem("Now Playing", UiUtils::CreateSideBarIcon(":/icons/16x16/film.png")); | |
| 86 sidebar->AddSeparator(); | |
| 87 sidebar->AddItem("Anime List", UiUtils::CreateSideBarIcon(":/icons/16x16/document-list.png")); | |
| 88 sidebar->AddItem("History", UiUtils::CreateSideBarIcon(":/icons/16x16/clock-history-frame.png")); | |
| 89 sidebar->AddItem("Statistics", UiUtils::CreateSideBarIcon(":/icons/16x16/chart.png")); | |
| 90 sidebar->AddSeparator(); | |
| 91 sidebar->AddItem("Search", UiUtils::CreateSideBarIcon(":/icons/16x16/magnifier.png")); | |
| 92 sidebar->AddItem("Seasons", UiUtils::CreateSideBarIcon(":/icons/16x16/calendar.png")); | |
| 93 sidebar->AddItem("Torrents", UiUtils::CreateSideBarIcon(":/icons/16x16/feed.png")); | |
| 94 sidebar->setFixedWidth(128); | |
| 95 sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); | |
| 96 | |
| 97 anime_list_page = new AnimeListPage(parent); | |
| 98 | |
| 99 QHBoxLayout* layout = new QHBoxLayout(main_widget); | |
| 100 layout->addWidget(sidebar, 0, Qt::AlignLeft | Qt::AlignTop); | |
| 101 layout->addWidget(anime_list_page); | |
| 102 SetActivePage(main_widget); | |
| 103 /* | |
| 77 QToolBar* toolbar = new QToolBar(parent); | 104 QToolBar* toolbar = new QToolBar(parent); |
| 78 QActionGroup* tb_action_group = new QActionGroup(toolbar); | 105 QActionGroup* tb_action_group = new QActionGroup(toolbar); |
| 79 | 106 |
| 80 action = toolbar->addAction("Now Playing"); | 107 action = toolbar->addAction("Now Playing"); |
| 81 action->setActionGroup(tb_action_group); | 108 action->setActionGroup(tb_action_group); |
| 110 action->setActionGroup(tb_action_group); | 137 action->setActionGroup(tb_action_group); |
| 111 action->setCheckable(true); | 138 action->setCheckable(true); |
| 112 | 139 |
| 113 toolbar->setMovable(false); | 140 toolbar->setMovable(false); |
| 114 toolbar->setFloatable(false); | 141 toolbar->setFloatable(false); |
| 142 toolbar->setMinimumSize(QSize(140, 0)); | |
| 143 toolbar->setObjectName("sidebar"); | |
| 144 toolbar->setStyleSheet("QToolBar#sidebar{margin: 6px;}"); | |
| 145 //toolbar->setFrameShape(QFrame::NoFrame); | |
| 146 toolbar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum); | |
| 115 | 147 |
| 116 addToolBar(Qt::LeftToolBarArea, toolbar); | 148 addToolBar(Qt::LeftToolBarArea, toolbar); |
| 117 | 149 */ |
| 118 ThemeChanged(); | 150 ThemeChanged(); |
| 119 } | 151 } |
| 120 | 152 |
| 121 void MainWindow::SetStyleSheet(enum Themes theme) { | 153 void MainWindow::SetStyleSheet(enum Themes theme) { |
| 122 switch (theme) { | 154 switch (theme) { |
| 172 } else { | 204 } else { |
| 173 SetStyleSheet(LIGHT); | 205 SetStyleSheet(LIGHT); |
| 174 } | 206 } |
| 175 } | 207 } |
| 176 #else | 208 #else |
| 209 /* Currently OS detection only supports Windows and macOS. | |
| 210 Please don't be shy if you're willing to port it to other OSes | |
| 211 (or desktop environments, or window managers) */ | |
| 177 SetStyleSheet(LIGHT); | 212 SetStyleSheet(LIGHT); |
| 178 #endif | 213 #endif |
| 179 break; | 214 break; |
| 180 } | 215 } |
| 181 } | 216 } |
