mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -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/");
|
current->setUrl("zim://" + current->zimId() + ".zim/");
|
||||||
});
|
});
|
||||||
connect(app->getAction(KiwixApp::SettingAction), &QAction::triggered,
|
connect(app->getAction(KiwixApp::SettingAction), &QAction::triggered,
|
||||||
this, [=]() {
|
this, &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);
|
|
||||||
});
|
|
||||||
|
|
||||||
for (int i = 0 ; i <= 9 ; i++) {
|
for (int i = 0 ; i <= 9 ; i++) {
|
||||||
QAction *a = new QAction(this);
|
QAction *a = new QAction(this);
|
||||||
@ -95,6 +79,25 @@ TabBar::TabBar(QWidget *parent) :
|
|||||||
this, SLOT(onTabMoved(int,int)), Qt::DirectConnection);
|
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) {
|
void TabBar::setStackedWidget(QStackedWidget *widget) {
|
||||||
mp_stackedWidget = widget;
|
mp_stackedWidget = widget;
|
||||||
connect(this, &QTabBar::currentChanged,
|
connect(this, &QTabBar::currentChanged,
|
||||||
|
@ -61,6 +61,7 @@ signals:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void closeTab(int index);
|
void closeTab(int index);
|
||||||
|
void openOrSwitchToSettingsTab();
|
||||||
void fullScreenRequested(QWebEngineFullScreenRequest request);
|
void fullScreenRequested(QWebEngineFullScreenRequest request);
|
||||||
void on_webview_titleChanged(const QString& title);
|
void on_webview_titleChanged(const QString& title);
|
||||||
void moveToNextTab();
|
void moveToNextTab();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user