diff --git a/src/kiwixapp.cpp b/src/kiwixapp.cpp index f50e262..b32f57d 100644 --- a/src/kiwixapp.cpp +++ b/src/kiwixapp.cpp @@ -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()); +} diff --git a/src/kiwixapp.h b/src/kiwixapp.h index 209b05c..bcecd0a 100644 --- a/src/kiwixapp.h +++ b/src/kiwixapp.h @@ -91,6 +91,7 @@ public: void saveListOfOpenTabs(); void saveWindowState(); void restoreWindowState(); + void saveCurrentTabIndex(); public slots: void newTab(); diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 25f9c6f..f5456cd 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -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)