summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-07-31 17:16:18 (GMT)
committerMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-09-04 12:12:53 (GMT)
commitb706108206be1c9e777e1ace02aa99247fdfc3ca (patch)
tree0ba2a2885cdd18ea7f1960f9e4d1a867ecaff44e
parent1bdebe6d7c38d6c263b34917f10f3daaf2b00b54 (diff)
Use tab for switching active split
REVIEW: 128564 REVIEW: 110970 BUGS: 171743
-rw-r--r--src/dolphintabpage.cpp15
-rw-r--r--src/dolphintabpage.h2
-rw-r--r--src/settings/dolphin_generalsettings.kcfg4
-rw-r--r--src/settings/general/behaviorsettingspage.cpp10
-rw-r--r--src/settings/general/behaviorsettingspage.h1
-rw-r--r--src/views/dolphinview.cpp9
-rw-r--r--src/views/dolphinview.h5
7 files changed, 45 insertions, 1 deletions
diff --git a/src/dolphintabpage.cpp b/src/dolphintabpage.cpp
index 0382341..c674e1e 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 b46daf3..9d18088 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 12f1585..c724afc 100644
--- a/src/settings/dolphin_generalsettings.kcfg
+++ b/src/settings/dolphin_generalsettings.kcfg
@@ -62,6 +62,10 @@
<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>
diff --git a/src/settings/general/behaviorsettingspage.cpp b/src/settings/general/behaviorsettingspage.cpp
index 86a4ad3..6d1e8bb 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 6213734..96eaf3d 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 a737dd0..4105628 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<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);
diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h
index d1a5d50..0b0d819 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;