aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-12-15 22:21:33 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-12-15 22:21:33 +0100
commit1c11fbe6451efc4ad98d7540f29bdddb6f3d3db3 (patch)
treeda39d763181523bf16c62016c43a964b5c38352e /src/mainwindow
parentMove tab actions to Subwindow menu (diff)
downloadsmolbote-1c11fbe6451efc4ad98d7540f29bdddb6f3d3db3.tar.xz
Add restore last tab shortcut
Diffstat (limited to 'src/mainwindow')
-rw-r--r--src/mainwindow/menubar.cpp40
1 files changed, 17 insertions, 23 deletions
diff --git a/src/mainwindow/menubar.cpp b/src/mainwindow/menubar.cpp
index bdfbd23..bc06f65 100644
--- a/src/mainwindow/menubar.cpp
+++ b/src/mainwindow/menubar.cpp
@@ -144,23 +144,22 @@ MenuBar::MenuBar(const Configuration *config, MainWindow *parent)
auto *subwindow = this->addMenu(tr("Subwindow"));
{
auto *actionNewTab = subwindow->addAction(tr("New Tab"), parent, [parent]() {
- auto *_subwindow = parent->currentSubWindow();
- if(_subwindow != nullptr) {
+ run_if(parent->currentSubWindow(), [](SubWindow *_subwindow, int) {
const int index = _subwindow->addTab();
_subwindow->setCurrentTab(index);
- }
+ });
});
config->setShortcut(actionNewTab, "subwindow.shortcuts.new");
subwindow->addSeparator();
- subwindow->addAction(tr("Restore last tab"), parent, [parent]() {
- auto *_subwindow = parent->currentSubWindow();
- if(_subwindow != nullptr) {
+ auto *actionRestoreTab = subwindow->addAction(tr("Restore last tab"), parent, [parent]() {
+ run_if(parent->currentSubWindow(), [](SubWindow *_subwindow, int) {
const int index = _subwindow->restoreLastTab();
_subwindow->setCurrentTab(index);
- }
+ });
});
+ config->setShortcut(actionRestoreTab, "subwindow.shortcuts.restoreTab");
auto *restoreTabsMenu = subwindow->addMenu(tr("Restore previous tab"));
connect(restoreTabsMenu, &QMenu::aboutToShow, parent, [parent, restoreTabsMenu]() {
@@ -178,34 +177,29 @@ MenuBar::MenuBar(const Configuration *config, MainWindow *parent)
actionPinTab->setEnabled(false);
auto *actionLockClose = subwindow->addAction(tr("Prevent tab from closing"), parent, [parent](bool checked) {
- auto *_subwindow = parent->currentSubWindow();
- if(_subwindow != nullptr) {
- const int idx = _subwindow->currentTabIndex();
- auto data = _subwindow->tabData(idx);
+ run_if(parent->currentSubWindow(), [checked](SubWindow *_subwindow, int currentIdx) {
+ auto data = _subwindow->tabData(currentIdx);
data.closeLocked = checked;
- _subwindow->setTabData(data, idx);
- }
+ _subwindow->setTabData(data, currentIdx);
+ });
});
actionLockClose->setCheckable(true);
auto *actionLockRefresh = subwindow->addAction(tr("Prevent tab from refreshing"), parent, [parent](bool checked) {
- auto *_subwindow = parent->currentSubWindow();
- if(_subwindow != nullptr) {
- const int idx = _subwindow->currentTabIndex();
- auto data = _subwindow->tabData(idx);
+ run_if(parent->currentSubWindow(), [checked](SubWindow *_subwindow, int currentIdx) {
+ auto data = _subwindow->tabData(currentIdx);
data.refreshLocked = checked;
- _subwindow->setTabData(data, idx);
- }
+ _subwindow->setTabData(data, currentIdx);
+ });
});
actionLockRefresh->setCheckable(true);
connect(subwindow, &QMenu::aboutToShow, subwindow, [=]() {
- auto *_subwindow = parent->currentSubWindow();
- if(_subwindow != nullptr) {
- auto data = _subwindow->tabData(_subwindow->currentTabIndex());
+ run_if(parent->currentSubWindow(), [=](SubWindow *_subwindow, int currentIdx) {
+ auto data = _subwindow->tabData(currentIdx);
actionLockClose->setChecked(data.closeLocked);
actionLockRefresh->setChecked(data.refreshLocked);
- }
+ });
});
subwindow->addSeparator()->setText(tr("Tab Actions"));