mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-23 12:07:00 -04:00
Fixed the bug with closing of non-current tab
This commit is contained in:
parent
4c831f0228
commit
99609644d0
@ -382,8 +382,7 @@ void KiwixApp::createActions()
|
|||||||
|
|
||||||
CREATE_ACTION_ICON_SHORTCUT(NewTabAction,"new-tab-icon", gt("new-tab"), QKeySequence::AddTab);
|
CREATE_ACTION_ICON_SHORTCUT(NewTabAction,"new-tab-icon", gt("new-tab"), QKeySequence::AddTab);
|
||||||
|
|
||||||
CREATE_ACTION_ICON_SHORTCUTS(CloseTabAction, "close", gt("close-tab"), QList<QKeySequence>({QKeySequence(Qt::CTRL | Qt::Key_F4), QKeySequence(Qt::CTRL | Qt::Key_W)}));
|
CREATE_ACTION_SHORTCUTS(CloseCurrentTabAction, gt("close-tab"), QList<QKeySequence>({QKeySequence(Qt::CTRL | Qt::Key_F4), QKeySequence(Qt::CTRL | Qt::Key_W)}));
|
||||||
mpa_actions[CloseTabAction]->setIconVisibleInMenu(false);
|
|
||||||
|
|
||||||
CREATE_ACTION_SHORTCUT(ReopenClosedTabAction, gt("reopen-closed-tab"), QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_T));
|
CREATE_ACTION_SHORTCUT(ReopenClosedTabAction, gt("reopen-closed-tab"), QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_T));
|
||||||
HIDE_ACTION(ReopenClosedTabAction);
|
HIDE_ACTION(ReopenClosedTabAction);
|
||||||
|
@ -34,7 +34,7 @@ public:
|
|||||||
OpenHomePageAction,
|
OpenHomePageAction,
|
||||||
PrintAction,
|
PrintAction,
|
||||||
NewTabAction,
|
NewTabAction,
|
||||||
CloseTabAction,
|
CloseCurrentTabAction,
|
||||||
ReopenClosedTabAction,
|
ReopenClosedTabAction,
|
||||||
BrowseLibraryAction,
|
BrowseLibraryAction,
|
||||||
OpenFileAction,
|
OpenFileAction,
|
||||||
|
@ -19,7 +19,7 @@ MainMenu::MainMenu(QWidget *parent) :
|
|||||||
|
|
||||||
m_fileMenu.setTitle(gt("file"));
|
m_fileMenu.setTitle(gt("file"));
|
||||||
m_fileMenu.ADD_ACTION(NewTabAction);
|
m_fileMenu.ADD_ACTION(NewTabAction);
|
||||||
m_fileMenu.ADD_ACTION(CloseTabAction);
|
m_fileMenu.ADD_ACTION(CloseCurrentTabAction);
|
||||||
m_fileMenu.ADD_ACTION(ReopenClosedTabAction);
|
m_fileMenu.ADD_ACTION(ReopenClosedTabAction);
|
||||||
m_fileMenu.ADD_ACTION(BrowseLibraryAction);
|
m_fileMenu.ADD_ACTION(BrowseLibraryAction);
|
||||||
m_fileMenu.ADD_ACTION(OpenFileAction);
|
m_fileMenu.ADD_ACTION(OpenFileAction);
|
||||||
|
@ -28,7 +28,7 @@ TabBar::TabBar(QWidget *parent) :
|
|||||||
|
|
||||||
connect(app->getAction(KiwixApp::NextTabAction), &QAction::triggered, this, &TabBar::moveToNextTab);
|
connect(app->getAction(KiwixApp::NextTabAction), &QAction::triggered, this, &TabBar::moveToNextTab);
|
||||||
connect(app->getAction(KiwixApp::PreviousTabAction), &QAction::triggered, this, &TabBar::moveToPreviousTab);
|
connect(app->getAction(KiwixApp::PreviousTabAction), &QAction::triggered, this, &TabBar::moveToPreviousTab);
|
||||||
connect(app->getAction(KiwixApp::CloseTabAction), &QAction::triggered,
|
connect(app->getAction(KiwixApp::CloseCurrentTabAction), &QAction::triggered,
|
||||||
this, [=]() {
|
this, [=]() {
|
||||||
this->closeTab(currentIndex());
|
this->closeTab(currentIndex());
|
||||||
});
|
});
|
||||||
@ -127,8 +127,17 @@ void TabBar::setCloseTabButton(int index)
|
|||||||
Q_ASSERT(index > 0 && index < realTabCount());
|
Q_ASSERT(index > 0 && index < realTabCount());
|
||||||
|
|
||||||
QToolButton *tb = new QToolButton(this);
|
QToolButton *tb = new QToolButton(this);
|
||||||
tb->setDefaultAction(KiwixApp::instance()->getAction(KiwixApp::CloseTabAction));
|
QAction *a = new QAction(QIcon(":/icons/close.svg"), gt("close-tab"), tb);
|
||||||
|
tb->setDefaultAction(a);
|
||||||
setTabButton(index, QTabBar::RightSide, tb);
|
setTabButton(index, QTabBar::RightSide, tb);
|
||||||
|
connect(tb, &QToolButton::triggered, this, [=]() {
|
||||||
|
for ( int i = 0; i < realTabCount(); ++i ) {
|
||||||
|
if ( tb == tabButton(i, QTabBar::RightSide) ) {
|
||||||
|
closeTab(i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ZimView* TabBar::createNewTab(bool setCurrent, bool nextToCurrentTab)
|
ZimView* TabBar::createNewTab(bool setCurrent, bool nextToCurrentTab)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user