From: Martin T. H. Sandsmark Date: Sun, 31 Jul 2016 17:16:18 +0000 (+0200) Subject: Use tab for switching active split X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/b706108206be1c9e777e1ace02aa99247fdfc3ca Use tab for switching active split REVIEW: 128564 REVIEW: 110970 BUGS: 171743 --- diff --git a/src/dolphintabpage.cpp b/src/dolphintabpage.cpp index 0382341c8..c674e1eb0 100644 --- a/src/dolphintabpage.cpp +++ b/src/dolphintabpage.cpp @@ -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; } diff --git a/src/dolphintabpage.h b/src/dolphintabpage.h index b46daf350..9d180883a 100644 --- a/src/dolphintabpage.h +++ b/src/dolphintabpage.h @@ -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. diff --git a/src/settings/dolphin_generalsettings.kcfg b/src/settings/dolphin_generalsettings.kcfg index 12f158541..c724afcd1 100644 --- a/src/settings/dolphin_generalsettings.kcfg +++ b/src/settings/dolphin_generalsettings.kcfg @@ -62,6 +62,10 @@ true + + + false + false diff --git a/src/settings/general/behaviorsettingspage.cpp b/src/settings/general/behaviorsettingspage.cpp index 86a4ad3bb..6d1e8bb10 100644 --- a/src/settings/general/behaviorsettingspage.cpp +++ b/src/settings/general/behaviorsettingspage.cpp @@ -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(); } diff --git a/src/settings/general/behaviorsettingspage.h b/src/settings/general/behaviorsettingspage.h index 6213734f1..96eaf3d64 100644 --- a/src/settings/general/behaviorsettingspage.h +++ b/src/settings/general/behaviorsettingspage.h @@ -65,6 +65,7 @@ private: QRadioButton* m_caseInsensitiveSorting; QCheckBox* m_renameInline; + QCheckBox* m_useTabForSplitViewSwitch; }; #endif diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index a737dd0a6..4105628ee 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -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(event); + if (keyEvent->key() == Qt::Key_Tab && keyEvent->modifiers() == Qt::NoModifier) { + toggleActiveViewRequested(); + return true; + } + } + break; case QEvent::FocusIn: if (watched == m_container) { setActive(true); diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index d1a5d5005..0b0d8196d 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -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;