comparison src/gui/window.cpp @ 58:b7a1c0010ffd

sidebar: link view menu and sidebar together
author Paper <mrpapersonic@gmail.com>
date Thu, 28 Sep 2023 13:32:21 -0400
parents 466ac9870df9
children 4c6dd5999b39
comparison
equal deleted inserted replaced
57:3c802806b74a 58:b7a1c0010ffd
62 stack->addWidget(new SearchWidget(main_widget)); 62 stack->addWidget(new SearchWidget(main_widget));
63 stack->addWidget(new SeasonsWidget(main_widget)); 63 stack->addWidget(new SeasonsWidget(main_widget));
64 stack->addWidget(new TorrentsWidget(main_widget)); 64 stack->addWidget(new TorrentsWidget(main_widget));
65 65
66 connect(sidebar, &SideBar::CurrentItemChanged, stack, &QStackedWidget::setCurrentIndex); 66 connect(sidebar, &SideBar::CurrentItemChanged, stack, &QStackedWidget::setCurrentIndex);
67 sidebar->setCurrentRow(2); 67 sidebar->SetCurrentItem((int)Pages::ANIME_LIST);
68 68
69 /* Menu Bar */ 69 /* Menu Bar */
70 QAction* action; 70 QAction* action;
71 QMenuBar* menubar = new QMenuBar(parent); 71 QMenuBar* menubar = new QMenuBar(parent);
72 QMenu* menu = menubar->addMenu(tr("&File")); 72 QMenu* menu = menubar->addMenu(tr("&File"));
143 action->setCheckable(true); 143 action->setCheckable(true);
144 page_to_index_map[action] = 0; 144 page_to_index_map[action] = 0;
145 145
146 action = pages_group->addAction(menu->addAction(tr("&Anime List"))); 146 action = pages_group->addAction(menu->addAction(tr("&Anime List")));
147 page_to_index_map[action] = 1; 147 page_to_index_map[action] = 1;
148
149 action->setCheckable(true); 148 action->setCheckable(true);
150 action->setChecked(true); 149 action->setChecked(true);
150
151 action = pages_group->addAction(menu->addAction(tr("&History"))); 151 action = pages_group->addAction(menu->addAction(tr("&History")));
152 action->setCheckable(true); 152 action->setCheckable(true);
153 page_to_index_map[action] = 2; 153 page_to_index_map[action] = 2;
154 154
155 action = pages_group->addAction(menu->addAction(tr("&Statistics"))); 155 action = pages_group->addAction(menu->addAction(tr("&Statistics")));
166 166
167 action = pages_group->addAction(menu->addAction(tr("&Torrents"))); 167 action = pages_group->addAction(menu->addAction(tr("&Torrents")));
168 action->setCheckable(true); 168 action->setCheckable(true);
169 page_to_index_map[action] = 6; 169 page_to_index_map[action] = 6;
170 170
171 connect(stack, &QStackedWidget::currentChanged, this, [pages_group, sidebar](int index){ 171 connect(sidebar, &SideBar::CurrentItemChanged, this, [pages_group](int index){
172 pages_group->actions()[index]->setChecked(true); 172 pages_group->actions()[index]->setChecked(true);
173 }); 173 });
174 174
175 connect(pages_group, &QActionGroup::triggered, this, [page_to_index_map, stack](QAction* action) { 175 connect(pages_group, &QActionGroup::triggered, this, [page_to_index_map, sidebar](QAction* action) {
176 stack->setCurrentIndex(page_to_index_map.at(action)); 176 sidebar->SetCurrentItem(page_to_index_map.at(action));
177 }); 177 });
178 178
179 menu->addSeparator(); 179 menu->addSeparator();
180 menu->addAction(tr("Show sidebar")); 180 menu->addAction(tr("Show sidebar"));
181 181