┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dolphinmainwindow.cpp24
-rw-r--r--src/dolphintabwidget.cpp12
-rw-r--r--src/dolphintabwidget.h10
3 files changed, 46 insertions, 0 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index ce2013798..ce1746d2b 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -93,6 +93,8 @@ namespace {
const int CurrentDolphinVersion = 200;
// The maximum number of entries in the back/forward popup menu
const int MaxNumberOfNavigationentries = 12;
+ // The maximum number of "Activate Tab" shortcuts
+ const int MaxActivateTabShortcuts = 9;
}
DolphinMainWindow::DolphinMainWindow() :
@@ -1178,6 +1180,10 @@ void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer)
void DolphinMainWindow::tabCountChanged(int count)
{
const bool enableTabActions = (count > 1);
+ for (int i = 0; i < MaxActivateTabShortcuts; ++i) {
+ actionCollection()->action(QStringLiteral("activate_tab_%1").arg(i))->setEnabled(enableTabActions);
+ }
+ actionCollection()->action(QStringLiteral("activate_last_tab"))->setEnabled(enableTabActions);
actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions);
actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions);
}
@@ -1503,6 +1509,24 @@ void DolphinMainWindow::setupActions()
QList<QKeySequence> prevTabKeys = KStandardShortcut::tabPrev();
prevTabKeys.append(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab));
+ for (int i = 0; i < MaxActivateTabShortcuts; ++i) {
+ QAction* activateTab = actionCollection()->addAction(QStringLiteral("activate_tab_%1").arg(i));
+ activateTab->setText(i18nc("@action:inmenu", "Activate Tab %1", i + 1));
+ activateTab->setEnabled(false);
+ connect(activateTab, &QAction::triggered, this, [this, i]() { m_tabWidget->activateTab(i); });
+
+ // only add default shortcuts for the first 9 tabs regardless of MaxActivateTabShortcuts
+ if (i < 9) {
+ actionCollection()->setDefaultShortcut(activateTab, QStringLiteral("Alt+%1").arg(i + 1));
+ }
+ }
+
+ QAction* activateLastTab = actionCollection()->addAction(QStringLiteral("activate_last_tab"));
+ activateLastTab->setText(i18nc("@action:inmenu", "Activate Last Tab"));
+ activateLastTab->setEnabled(false);
+ connect(activateLastTab, &QAction::triggered, m_tabWidget, &DolphinTabWidget::activateLastTab);
+ actionCollection()->setDefaultShortcut(activateLastTab, Qt::ALT + Qt::Key_0);
+
QAction* activateNextTab = actionCollection()->addAction(QStringLiteral("activate_next_tab"));
activateNextTab->setIconText(i18nc("@action:inmenu", "Next Tab"));
activateNextTab->setText(i18nc("@action:inmenu", "Activate Next Tab"));
diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp
index ec0c783bc..0408d7ed4 100644
--- a/src/dolphintabwidget.cpp
+++ b/src/dolphintabwidget.cpp
@@ -266,6 +266,18 @@ void DolphinTabWidget::closeTab(const int index)
tabPage->deleteLater();
}
+void DolphinTabWidget::activateTab(const int index)
+{
+ if (index < count()) {
+ setCurrentIndex(index);
+ }
+}
+
+void DolphinTabWidget::activateLastTab()
+{
+ setCurrentIndex(count() - 1);
+}
+
void DolphinTabWidget::activateNextTab()
{
const int index = currentIndex() + 1;
diff --git a/src/dolphintabwidget.h b/src/dolphintabwidget.h
index 4351a40a8..746aec6c6 100644
--- a/src/dolphintabwidget.h
+++ b/src/dolphintabwidget.h
@@ -155,6 +155,16 @@ public slots:
void closeTab(const int index);
/**
+ * Activates the tab with the index \a index.
+ */
+ void activateTab(const int index);
+
+ /**
+ * Activates the last tab in the tab bar.
+ */
+ void activateLastTab();
+
+ /**
* Activates the next tab in the tab bar.
* If the current active tab is the last tab, it activates the first tab.
*/