mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
Merge pull request #1120 from kiwix/Issue#1073-remember-current-tab-from-prev-session
Remembers Previous Current Tab Index From Last Session
This commit is contained in:
commit
1cad7057b2
@ -207,15 +207,17 @@ void KiwixApp::restoreTabs()
|
|||||||
{
|
{
|
||||||
for (const auto &zimUrl : tabsToOpen)
|
for (const auto &zimUrl : tabsToOpen)
|
||||||
{
|
{
|
||||||
try
|
if (zimUrl == "SettingsTab")
|
||||||
{
|
getTabWidget()->openOrSwitchToSettingsTab();
|
||||||
/* Throws exception if zim file cannot be found */
|
else if (zimUrl.isEmpty())
|
||||||
m_library.getArchive(QUrl(zimUrl).host().split('.')[0]);
|
getTabWidget()->createNewTab(true, true);
|
||||||
|
else
|
||||||
openUrl(QUrl(zimUrl));
|
openUrl(QUrl(zimUrl));
|
||||||
}
|
|
||||||
catch (std::exception &e) { /* Blank */ }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Restore current tab index. */
|
||||||
|
getTabWidget()->setCurrentIndex(mp_session->value("currentTabIndex", 0).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
KiwixApp *KiwixApp::instance()
|
KiwixApp *KiwixApp::instance()
|
||||||
@ -570,3 +572,8 @@ void KiwixApp::restoreWindowState()
|
|||||||
getMainWindow()->restoreGeometry(mp_session->value("geometry").toByteArray());
|
getMainWindow()->restoreGeometry(mp_session->value("geometry").toByteArray());
|
||||||
getMainWindow()->restoreState(mp_session->value("windowState").toByteArray());
|
getMainWindow()->restoreState(mp_session->value("windowState").toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KiwixApp::saveCurrentTabIndex()
|
||||||
|
{
|
||||||
|
return mp_session->setValue("currentTabIndex", getTabWidget()->currentIndex());
|
||||||
|
}
|
||||||
|
@ -91,6 +91,7 @@ public:
|
|||||||
void saveListOfOpenTabs();
|
void saveListOfOpenTabs();
|
||||||
void saveWindowState();
|
void saveWindowState();
|
||||||
void restoreWindowState();
|
void restoreWindowState();
|
||||||
|
void saveCurrentTabIndex();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void newTab();
|
void newTab();
|
||||||
|
@ -81,6 +81,7 @@ void TabBar::openOrSwitchToSettingsTab()
|
|||||||
insertTab(index,QIcon(":/icons/settings.svg"), gt("settings"));
|
insertTab(index,QIcon(":/icons/settings.svg"), gt("settings"));
|
||||||
setCloseTabButton(index);
|
setCloseTabButton(index);
|
||||||
setCurrentIndex(index);
|
setCurrentIndex(index);
|
||||||
|
KiwixApp::instance()->saveListOfOpenTabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabBar::setStackedWidget(QStackedWidget *widget) {
|
void TabBar::setStackedWidget(QStackedWidget *widget) {
|
||||||
@ -163,6 +164,7 @@ ZimView* TabBar::createNewTab(bool setCurrent, bool nextToCurrentTab)
|
|||||||
connect(tab, &ZimView::webActionEnabledChanged,
|
connect(tab, &ZimView::webActionEnabledChanged,
|
||||||
this, &TabBar::onWebviewHistoryActionChanged);
|
this, &TabBar::onWebviewHistoryActionChanged);
|
||||||
|
|
||||||
|
KiwixApp::instance()->saveListOfOpenTabs();
|
||||||
return tab;
|
return tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,6 +276,8 @@ QStringList TabBar::getTabUrls() const {
|
|||||||
{
|
{
|
||||||
if (ZimView* zv = qobject_cast<ZimView*>(mp_stackedWidget->widget(index)))
|
if (ZimView* zv = qobject_cast<ZimView*>(mp_stackedWidget->widget(index)))
|
||||||
idList.push_back(zv->getWebView()->url().url());
|
idList.push_back(zv->getWebView()->url().url());
|
||||||
|
else if (qobject_cast<SettingsView*>(mp_stackedWidget->widget(index)))
|
||||||
|
idList.push_back("SettingsTab");
|
||||||
}
|
}
|
||||||
return idList;
|
return idList;
|
||||||
}
|
}
|
||||||
@ -334,6 +338,8 @@ void TabBar::onCurrentChanged(int index)
|
|||||||
// In the future, other types of tabs can be added.
|
// In the future, other types of tabs can be added.
|
||||||
// For example, About dialog, or Kiwix Server control panel.
|
// For example, About dialog, or Kiwix Server control panel.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KiwixApp::instance()->saveCurrentTabIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabBar::fullScreenRequested(QWebEngineFullScreenRequest request)
|
void TabBar::fullScreenRequested(QWebEngineFullScreenRequest request)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user