mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 03:26:05 -04:00
TabBar::setCloseTabButton()
Deduplicated the code responsible for setting up the tab closing button.
This commit is contained in:
parent
bbceea3d5e
commit
4c831f0228
@ -71,9 +71,7 @@ void TabBar::openOrSwitchToSettingsTab()
|
|||||||
mp_stackedWidget->insertWidget(index, view);
|
mp_stackedWidget->insertWidget(index, view);
|
||||||
emit tabDisplayed(TabType::SettingsTab);
|
emit tabDisplayed(TabType::SettingsTab);
|
||||||
insertTab(index,QIcon(":/icons/settings.svg"), gt("settings"));
|
insertTab(index,QIcon(":/icons/settings.svg"), gt("settings"));
|
||||||
QToolButton *tb = new QToolButton(this);
|
setCloseTabButton(index);
|
||||||
tb->setDefaultAction(KiwixApp::instance()->getAction(KiwixApp::CloseTabAction));
|
|
||||||
setTabButton(index, QTabBar::RightSide, tb);
|
|
||||||
setCurrentIndex(index);
|
setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,15 +122,22 @@ void TabBar::moveToPreviousTab()
|
|||||||
setCurrentIndex(index <= 0 ? realTabCount() - 1 : index - 1);
|
setCurrentIndex(index <= 0 ? realTabCount() - 1 : index - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabBar::setCloseTabButton(int index)
|
||||||
|
{
|
||||||
|
Q_ASSERT(index > 0 && index < realTabCount());
|
||||||
|
|
||||||
|
QToolButton *tb = new QToolButton(this);
|
||||||
|
tb->setDefaultAction(KiwixApp::instance()->getAction(KiwixApp::CloseTabAction));
|
||||||
|
setTabButton(index, QTabBar::RightSide, tb);
|
||||||
|
}
|
||||||
|
|
||||||
ZimView* TabBar::createNewTab(bool setCurrent, bool nextToCurrentTab)
|
ZimView* TabBar::createNewTab(bool setCurrent, bool nextToCurrentTab)
|
||||||
{
|
{
|
||||||
auto tab = new ZimView(this, this);
|
auto tab = new ZimView(this, this);
|
||||||
const int index = nextToCurrentTab ? currentIndex() + 1 : realTabCount();
|
const int index = nextToCurrentTab ? currentIndex() + 1 : realTabCount();
|
||||||
mp_stackedWidget->insertWidget(index, tab);
|
mp_stackedWidget->insertWidget(index, tab);
|
||||||
insertTab(index, "");
|
insertTab(index, "");
|
||||||
QToolButton *tb = new QToolButton(this);
|
setCloseTabButton(index);
|
||||||
tb->setDefaultAction(KiwixApp::instance()->getAction(KiwixApp::CloseTabAction));
|
|
||||||
setTabButton(index, QTabBar::RightSide, tb);
|
|
||||||
if (setCurrent) {
|
if (setCurrent) {
|
||||||
setCurrentIndex(index);
|
setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,9 @@ public slots:
|
|||||||
void moveToNextTab();
|
void moveToNextTab();
|
||||||
void moveToPreviousTab();
|
void moveToPreviousTab();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setCloseTabButton(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStackedWidget* mp_stackedWidget;
|
QStackedWidget* mp_stackedWidget;
|
||||||
QScopedPointer<FullScreenWindow> m_fullScreenWindow;
|
QScopedPointer<FullScreenWindow> m_fullScreenWindow;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user