Restores the previous current tab index on startup

Current tab index will be saved now and will be reset with respect to the reopened tabs upon startup
This commit is contained in:
ShaopengLin 2024-06-16 17:19:59 -04:00
parent 9bd598b00e
commit 65fe4b4997
3 changed files with 11 additions and 0 deletions

View File

@ -215,6 +215,9 @@ void KiwixApp::restoreTabs()
openUrl(QUrl(zimUrl));
}
}
/* Restore current tab index. */
getTabWidget()->setCurrentIndex(mp_session->value("currentTabIndex", 0).toInt());
}
KiwixApp *KiwixApp::instance()
@ -569,3 +572,8 @@ void KiwixApp::restoreWindowState()
getMainWindow()->restoreGeometry(mp_session->value("geometry").toByteArray());
getMainWindow()->restoreState(mp_session->value("windowState").toByteArray());
}
void KiwixApp::saveCurrentTabIndex()
{
return mp_session->setValue("currentTabIndex", getTabWidget()->currentIndex());
}

View File

@ -91,6 +91,7 @@ public:
void saveListOfOpenTabs();
void saveWindowState();
void restoreWindowState();
void saveCurrentTabIndex();
public slots:
void newTab();

View File

@ -338,6 +338,8 @@ void TabBar::onCurrentChanged(int index)
// In the future, other types of tabs can be added.
// For example, About dialog, or Kiwix Server control panel.
}
KiwixApp::instance()->saveCurrentTabIndex();
}
void TabBar::fullScreenRequested(QWebEngineFullScreenRequest request)