openHomePage code to standalone function

This commit is contained in:
sgourdas 2024-07-23 11:58:01 +03:00 committed by Kelson
parent a7c19105f9
commit 76bb8228ee
2 changed files with 8 additions and 5 deletions

View File

@ -41,11 +41,7 @@ TabBar::TabBar(QWidget *parent) :
this->closeTab(currentIndex()); this->closeTab(currentIndex());
}); });
connect(getAction(KiwixApp::OpenHomePageAction), &QAction::triggered, connect(getAction(KiwixApp::OpenHomePageAction), &QAction::triggered,
this, [=]() { this, &TabBar::openHomePage);
auto current = this->currentWebView();
QUITIFNULL(current);
current->setUrl("zim://" + current->zimId() + ".zim/");
});
connect(getAction(KiwixApp::SettingAction), &QAction::triggered, connect(getAction(KiwixApp::SettingAction), &QAction::triggered,
this, &TabBar::openOrSwitchToSettingsTab); this, &TabBar::openOrSwitchToSettingsTab);
@ -66,6 +62,12 @@ TabBar::TabBar(QWidget *parent) :
this, SLOT(onTabMoved(int,int)), Qt::DirectConnection); this, SLOT(onTabMoved(int,int)), Qt::DirectConnection);
} }
void TabBar::openHomePage() {
auto current = this->currentWebView();
QUITIFNULL(current);
current->setUrl("zim://" + current->zimId() + ".zim/");
}
void TabBar::openOrSwitchToSettingsTab() void TabBar::openOrSwitchToSettingsTab()
{ {
SettingsView* view = KiwixApp::instance()->getSettingsManager()->getView(); SettingsView* view = KiwixApp::instance()->getSettingsManager()->getView();

View File

@ -62,6 +62,7 @@ signals:
public slots: public slots:
void closeTab(int index); void closeTab(int index);
void openHomePage();
void openOrSwitchToSettingsTab(); void openOrSwitchToSettingsTab();
void fullScreenRequested(QWebEngineFullScreenRequest request); void fullScreenRequested(QWebEngineFullScreenRequest request);
void on_webview_titleChanged(const QString& title); void on_webview_titleChanged(const QString& title);