]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Use tab for switching active split
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>
Sun, 31 Jul 2016 17:16:18 +0000 (19:16 +0200)
committerMartin T. H. Sandsmark <martin.sandsmark@kde.org>
Sun, 4 Sep 2016 12:12:53 +0000 (14:12 +0200)
REVIEW: 128564
REVIEW: 110970
BUGS: 171743

src/dolphintabpage.cpp
src/dolphintabpage.h
src/settings/dolphin_generalsettings.kcfg
src/settings/general/behaviorsettingspage.cpp
src/settings/general/behaviorsettingspage.h
src/views/dolphinview.cpp
src/views/dolphinview.h

index 0382341c80a2bc5dbd33c00be79364a0bb22ab0d..c674e1eb018d192ac48901edb53d062d18b2a24f 100644 (file)
@@ -323,6 +323,18 @@ void DolphinTabPage::slotViewUrlRedirection(const QUrl& oldUrl, const QUrl& newU
     emit activeViewUrlChanged(newUrl);
 }
 
+void DolphinTabPage::switchActiveView()
+{
+    if (!m_splitViewEnabled) {
+        return;
+    }
+    if (m_primaryViewActive) {
+       m_secondaryViewContainer->setActive(true);
+    } else {
+       m_primaryViewContainer->setActive(true);
+    }
+}
+
 DolphinViewContainer* DolphinTabPage::createViewContainer(const QUrl& url) const
 {
     DolphinViewContainer* container = new DolphinViewContainer(url, m_splitter);
@@ -332,5 +344,8 @@ DolphinViewContainer* DolphinTabPage::createViewContainer(const QUrl& url) const
     connect(view, &DolphinView::activated,
             this, &DolphinTabPage::slotViewActivated);
 
+    connect(view, &DolphinView::toggleActiveViewRequested,
+            this, &DolphinTabPage::switchActiveView);
+
     return container;
 }
index b46daf350c115df7c30b3978c3eeebf8501fa033..9d180883ab06b1bc59f35f8f0d35672f69c416ab 100644 (file)
@@ -149,6 +149,8 @@ private slots:
      */
     void slotViewUrlRedirection(const QUrl& oldUrl, const QUrl& newUrl);
 
+    void switchActiveView();
+
 private:
     /**
      * Creates a new view container and does the default initialization.
index 12f158541187bd8d8e1359c589c1c99be6ae07a8..c724afcd1c0dac12bebe335cfcf7895590a0d832 100644 (file)
             <label>Show selection toggle</label>
             <default>true</default>
         </entry>
+        <entry name="UseTabForSwitchingSplitView" type="Bool">
+            <label>Use tab for switching between right and left split</label>
+            <default>false</default>
+        </entry>
         <entry name="ShowToolTips" type="Bool">
             <label>Show tooltips</label>
             <default>false</default>
index 86a4ad3bbcabd03e19bd1237f0bb95324da3c1d7..6d1e8bb104c110445e06f1fb3e835f9f85cf93a2 100644 (file)
@@ -41,7 +41,8 @@ BehaviorSettingsPage::BehaviorSettingsPage(const QUrl& url, QWidget* parent) :
     m_naturalSorting(0),
     m_caseSensitiveSorting(0),
     m_caseInsensitiveSorting(0),
-    m_renameInline(0)
+    m_renameInline(0),
+    m_useTabForSplitViewSwitch(0)
 {
     QVBoxLayout* topLayout = new QVBoxLayout(this);
 
@@ -78,11 +79,15 @@ BehaviorSettingsPage::BehaviorSettingsPage(const QUrl& url, QWidget* parent) :
     // 'Inline renaming of items'
     m_renameInline = new QCheckBox(i18nc("option:check", "Rename inline"), this);
 
+    // 'Use tab for switching between right and left split'
+    m_useTabForSplitViewSwitch = new QCheckBox(i18nc("option:check", "Use tab for switching between right and left split view"), this);
+
     topLayout->addWidget(viewPropsBox);
     topLayout->addWidget(sortingPropsBox);
     topLayout->addWidget(m_showToolTips);
     topLayout->addWidget(m_showSelectionToggle);
     topLayout->addWidget(m_renameInline);
+    topLayout->addWidget(m_useTabForSplitViewSwitch);
     topLayout->addStretch();
 
     loadSettings();
@@ -95,6 +100,7 @@ BehaviorSettingsPage::BehaviorSettingsPage(const QUrl& url, QWidget* parent) :
     connect(m_caseInsensitiveSorting, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed);
     connect(m_caseSensitiveSorting, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed);
     connect(m_renameInline, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
+    connect(m_useTabForSplitViewSwitch, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
 }
 
 BehaviorSettingsPage::~BehaviorSettingsPage()
@@ -112,6 +118,7 @@ void BehaviorSettingsPage::applySettings()
     settings->setShowSelectionToggle(m_showSelectionToggle->isChecked());
     setSortingChoiceValue(settings);
     settings->setRenameInline(m_renameInline->isChecked());
+    settings->setUseTabForSwitchingSplitView(m_useTabForSplitViewSwitch->isChecked());
     settings->save();
 
     if (useGlobalViewProps) {
@@ -141,6 +148,7 @@ void BehaviorSettingsPage::loadSettings()
     m_showToolTips->setChecked(GeneralSettings::showToolTips());
     m_showSelectionToggle->setChecked(GeneralSettings::showSelectionToggle());
     m_renameInline->setChecked(GeneralSettings::renameInline());
+    m_useTabForSplitViewSwitch->setChecked(GeneralSettings::useTabForSwitchingSplitView());
 
     loadSortingChoiceSettings();
 }
index 6213734f1e5146856639aa78c0268c793735403c..96eaf3d64413c5d71414a32d7d8b766b9992144f 100644 (file)
@@ -65,6 +65,7 @@ private:
     QRadioButton* m_caseInsensitiveSorting;
 
     QCheckBox* m_renameInline;
+    QCheckBox* m_useTabForSplitViewSwitch;
 };
 
 #endif
index a737dd0a632cf9b27a660aac53889b5dd299057f..4105628ee1d2b9f220eaff355dc2b6d8a0ea2741 100644 (file)
@@ -724,6 +724,15 @@ void DolphinView::stopLoading()
 bool DolphinView::eventFilter(QObject* watched, QEvent* event)
 {
     switch (event->type()) {
+    case QEvent::KeyPress:
+        if (GeneralSettings::useTabForSwitchingSplitView()) {
+            QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
+            if (keyEvent->key() == Qt::Key_Tab && keyEvent->modifiers() == Qt::NoModifier) {
+                toggleActiveViewRequested();
+                return true;
+            }
+        }
+        break;
     case QEvent::FocusIn:
         if (watched == m_container) {
             setActive(true);
index d1a5d5005f81bfc07dcb62bfc38b3d0ac06a5f11..0b0d8196d68714042177829545e32593826c799b 100644 (file)
@@ -546,6 +546,11 @@ signals:
      */
     void goForwardRequested();
 
+    /**
+     * Is emitted when the user wants to move the focus to another view.
+     */
+    void toggleActiveViewRequested();
+
 protected:
     /** Changes the zoom level if Control is pressed during a wheel event. */
     virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE;