diff 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
line wrap: on
line diff
--- a/src/gui/window.cpp	Thu Sep 28 13:09:11 2023 -0400
+++ b/src/gui/window.cpp	Thu Sep 28 13:32:21 2023 -0400
@@ -64,7 +64,7 @@
 	stack->addWidget(new TorrentsWidget(main_widget));
 
 	connect(sidebar, &SideBar::CurrentItemChanged, stack, &QStackedWidget::setCurrentIndex);
-	sidebar->setCurrentRow(2);
+	sidebar->SetCurrentItem((int)Pages::ANIME_LIST);
 
 	/* Menu Bar */
 	QAction* action;
@@ -145,9 +145,9 @@
 
 	action = pages_group->addAction(menu->addAction(tr("&Anime List")));
 	page_to_index_map[action] = 1;
-
 	action->setCheckable(true);
 	action->setChecked(true);
+
 	action = pages_group->addAction(menu->addAction(tr("&History")));
 	action->setCheckable(true);
 	page_to_index_map[action] = 2;
@@ -168,12 +168,12 @@
 	action->setCheckable(true);
 	page_to_index_map[action] = 6;
 
-	connect(stack, &QStackedWidget::currentChanged, this, [pages_group, sidebar](int index){
+	connect(sidebar, &SideBar::CurrentItemChanged, this, [pages_group](int index){
 		pages_group->actions()[index]->setChecked(true);
 	});
 
-	connect(pages_group, &QActionGroup::triggered, this, [page_to_index_map, stack](QAction* action) {
-		stack->setCurrentIndex(page_to_index_map.at(action));
+	connect(pages_group, &QActionGroup::triggered, this, [page_to_index_map, sidebar](QAction* action) {
+		sidebar->SetCurrentItem(page_to_index_map.at(action));
 	});
 
 	menu->addSeparator();