diff --git a/src/tabbar.cpp b/src/tabbar.cpp index eb1ad1a..3523c20 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -48,23 +48,7 @@ TabBar::TabBar(QWidget *parent) : current->setUrl("zim://" + current->zimId() + ".zim/"); }); connect(app->getAction(KiwixApp::SettingAction), &QAction::triggered, - this, [=]() { - SettingsView* view = KiwixApp::instance()->getSettingsManager()->getView(); - for (int i = 0 ; i < mp_stackedWidget->count(); i++) { - if (mp_stackedWidget->widget(i) == view) { - setCurrentIndex(i); - return; - } - } - int index = currentIndex() + 1; - mp_stackedWidget->insertWidget(index, view); - emit tabDisplayed(TabType::SettingsTab); - insertTab(index,QIcon(":/icons/settings.svg"), gt("settings")); - QToolButton *tb = new QToolButton(this); - tb->setDefaultAction(KiwixApp::instance()->getAction(KiwixApp::CloseTabAction)); - setTabButton(index, QTabBar::RightSide, tb); - setCurrentIndex(index); - }); + this, &TabBar::openOrSwitchToSettingsTab); for (int i = 0 ; i <= 9 ; i++) { QAction *a = new QAction(this); @@ -95,6 +79,25 @@ TabBar::TabBar(QWidget *parent) : this, SLOT(onTabMoved(int,int)), Qt::DirectConnection); } +void TabBar::openOrSwitchToSettingsTab() +{ + SettingsView* view = KiwixApp::instance()->getSettingsManager()->getView(); + for (int i = 0 ; i < mp_stackedWidget->count(); i++) { + if (mp_stackedWidget->widget(i) == view) { + setCurrentIndex(i); + return; + } + } + int index = currentIndex() + 1; + mp_stackedWidget->insertWidget(index, view); + emit tabDisplayed(TabType::SettingsTab); + insertTab(index,QIcon(":/icons/settings.svg"), gt("settings")); + QToolButton *tb = new QToolButton(this); + tb->setDefaultAction(KiwixApp::instance()->getAction(KiwixApp::CloseTabAction)); + setTabButton(index, QTabBar::RightSide, tb); + setCurrentIndex(index); +} + void TabBar::setStackedWidget(QStackedWidget *widget) { mp_stackedWidget = widget; connect(this, &QTabBar::currentChanged, diff --git a/src/tabbar.h b/src/tabbar.h index b0c30b0..8f97a40 100644 --- a/src/tabbar.h +++ b/src/tabbar.h @@ -61,6 +61,7 @@ signals: public slots: void closeTab(int index); + void openOrSwitchToSettingsTab(); void fullScreenRequested(QWebEngineFullScreenRequest request); void on_webview_titleChanged(const QString& title); void moveToNextTab();