mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
Restored the tooltip of the tab closing button
Notes: - The `getAction()` helper function was introduced in order to keep the line length within the 80 chars limit and was applied to other usages of `KiwixApp::getAction()` too. - The tooltip includes the keyboard shortcut which closes only the current tab but the tooltip is the same for all the tabs.
This commit is contained in:
parent
99609644d0
commit
1daefccfbd
@ -13,6 +13,15 @@ class QMenu;
|
||||
#define QUITIFNULL(VIEW) if (nullptr==(VIEW)) { return; }
|
||||
#define CURRENTIFNULL(VIEW) if(nullptr==VIEW) { VIEW = currentZimView();}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
QAction* getAction(KiwixApp::Actions action) {
|
||||
return KiwixApp::instance()->getAction(action);
|
||||
}
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
TabBar::TabBar(QWidget *parent) :
|
||||
QTabBar(parent)
|
||||
{
|
||||
@ -24,21 +33,20 @@ TabBar::TabBar(QWidget *parent) :
|
||||
setMovable(true);
|
||||
setIconSize(QSize(30, 30));
|
||||
connect(this, &QTabBar::currentChanged, this, &TabBar::onCurrentChanged, Qt::QueuedConnection);
|
||||
auto app = KiwixApp::instance();
|
||||
|
||||
connect(app->getAction(KiwixApp::NextTabAction), &QAction::triggered, this, &TabBar::moveToNextTab);
|
||||
connect(app->getAction(KiwixApp::PreviousTabAction), &QAction::triggered, this, &TabBar::moveToPreviousTab);
|
||||
connect(app->getAction(KiwixApp::CloseCurrentTabAction), &QAction::triggered,
|
||||
connect(getAction(KiwixApp::NextTabAction), &QAction::triggered, this, &TabBar::moveToNextTab);
|
||||
connect(getAction(KiwixApp::PreviousTabAction), &QAction::triggered, this, &TabBar::moveToPreviousTab);
|
||||
connect(getAction(KiwixApp::CloseCurrentTabAction), &QAction::triggered,
|
||||
this, [=]() {
|
||||
this->closeTab(currentIndex());
|
||||
});
|
||||
connect(app->getAction(KiwixApp::OpenHomePageAction), &QAction::triggered,
|
||||
connect(getAction(KiwixApp::OpenHomePageAction), &QAction::triggered,
|
||||
this, [=]() {
|
||||
auto current = this->currentWebView();
|
||||
QUITIFNULL(current);
|
||||
current->setUrl("zim://" + current->zimId() + ".zim/");
|
||||
});
|
||||
connect(app->getAction(KiwixApp::SettingAction), &QAction::triggered,
|
||||
connect(getAction(KiwixApp::SettingAction), &QAction::triggered,
|
||||
this, &TabBar::openOrSwitchToSettingsTab);
|
||||
|
||||
for (int i = 0 ; i <= 9 ; i++) {
|
||||
@ -128,6 +136,7 @@ void TabBar::setCloseTabButton(int index)
|
||||
|
||||
QToolButton *tb = new QToolButton(this);
|
||||
QAction *a = new QAction(QIcon(":/icons/close.svg"), gt("close-tab"), tb);
|
||||
a->setToolTip(getAction(KiwixApp::CloseCurrentTabAction)->toolTip());
|
||||
tb->setDefaultAction(a);
|
||||
setTabButton(index, QTabBar::RightSide, tb);
|
||||
connect(tb, &QToolButton::triggered, this, [=]() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user