mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-21 02:51:26 -04:00
Extracted TabBar::openOrSwitchToSettingsTab()
This commit is contained in:
parent
caa6195caa
commit
b39597b501
@ -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,
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user