┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Armbruster <[email protected]>2023-09-06 06:34:13 +0200
committerEric Armbruster <[email protected]>2023-09-09 15:45:26 +0000
commita85863befd616fe86669ac363d74fa7f466ca523 (patch)
tree3f8a87f6a3b13bb935e0332679922a0ce17a76f7
parentf900801540af7d8c54b75ba7476ebed05529aa59 (diff)
Add open in split view action
This action is shown only if a single folder is selected. The action opens the selected folder in the inactive split view (and opens the split view if necessary). FEATURE: 465500
-rw-r--r--src/dolphincontextmenu.cpp4
-rw-r--r--src/dolphinmainwindow.cpp35
-rw-r--r--src/dolphinmainwindow.h5
-rw-r--r--src/dolphintabpage.h4
-rw-r--r--src/panels/places/placespanel.cpp10
-rw-r--r--src/panels/places/placespanel.h2
-rw-r--r--src/settings/contextmenu/contextmenusettingspage.cpp4
-rw-r--r--src/settings/dolphin_contextmenusettings.kcfg4
-rw-r--r--src/settings/dolphinsettingsdialog.cpp1
9 files changed, 66 insertions, 3 deletions
diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp
index 83329dd71..4dc54946f 100644
--- a/src/dolphincontextmenu.cpp
+++ b/src/dolphincontextmenu.cpp
@@ -165,6 +165,10 @@ void DolphinContextMenu::addDirectoryItemContextMenu()
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_window")));
}
+ if (ContextMenuSettings::showOpenInSplitView()) {
+ addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_split_view")));
+ }
+
// Insert 'Open With' entries
addOpenWithActions();
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index e3373efe2..744ad8f0a 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -497,6 +497,32 @@ void DolphinMainWindow::openInNewWindow()
}
}
+void DolphinMainWindow::openInSplitView(const QUrl &url)
+{
+ QUrl newSplitViewUrl = url;
+
+ if (newSplitViewUrl.isEmpty()) {
+ const KFileItemList list = m_activeViewContainer->view()->selectedItems();
+ if (list.count() == 1) {
+ const KFileItem &item = list.first();
+ newSplitViewUrl = DolphinView::openItemAsFolderUrl(item);
+ }
+ }
+
+ if (newSplitViewUrl.isEmpty()) {
+ return;
+ }
+
+ DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
+ if (tabPage->splitViewEnabled()) {
+ tabPage->switchActiveView();
+ tabPage->activeViewContainer()->setUrl(newSplitViewUrl);
+ } else {
+ tabPage->setSplitViewEnabled(true, WithAnimation, newSplitViewUrl);
+ updateViewActions();
+ }
+}
+
void DolphinMainWindow::showTarget()
{
const KFileItem link = m_activeViewContainer->view()->selectedItems().at(0);
@@ -885,7 +911,6 @@ void DolphinMainWindow::toggleSplitView()
{
DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
tabPage->setSplitViewEnabled(!tabPage->splitViewEnabled(), WithAnimation);
-
updateViewActions();
}
@@ -1985,6 +2010,13 @@ void DolphinMainWindow::setupActions()
openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window"));
openInNewWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
connect(openInNewWindow, &QAction::triggered, this, &DolphinMainWindow::openInNewWindow);
+
+ QAction *openInSplitViewAction = actionCollection()->addAction(QStringLiteral("open_in_split_view"));
+ openInSplitViewAction->setText(i18nc("@action:inmenu", "Open in Split View"));
+ openInSplitViewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
+ connect(openInSplitViewAction, &QAction::triggered, this, [this]() {
+ openInSplitView(QUrl());
+ });
}
void DolphinMainWindow::setupDockWidgets()
@@ -2160,6 +2192,7 @@ void DolphinMainWindow::setupDockWidgets()
connect(m_placesPanel, &PlacesPanel::newWindowRequested, this, [this](const QUrl &url) {
Dolphin::openNewWindow({url}, this);
});
+ connect(m_placesPanel, &PlacesPanel::openInSplitViewRequested, this, &DolphinMainWindow::openInSplitView);
connect(m_placesPanel, &PlacesPanel::errorMessage, this, &DolphinMainWindow::showErrorMessage);
connect(this, &DolphinMainWindow::urlChanged, m_placesPanel, &PlacesPanel::setUrl);
connect(placesDock, &DolphinDockWidget::visibilityChanged, &DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged);
diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h
index 5bb17e79a..b45c846b8 100644
--- a/src/dolphinmainwindow.h
+++ b/src/dolphinmainwindow.h
@@ -477,6 +477,11 @@ private Q_SLOTS:
void openInNewWindow();
/**
+ * Opens the selected folder in the other inactive split view, enables split view if necessary.
+ */
+ void openInSplitView(const QUrl &url);
+
+ /**
* Show the target of the selected symlink
*/
void showTarget();
diff --git a/src/dolphintabpage.h b/src/dolphintabpage.h
index 0c691830e..4a8bd365a 100644
--- a/src/dolphintabpage.h
+++ b/src/dolphintabpage.h
@@ -138,6 +138,8 @@ public:
*/
void setActive(bool active);
+ void switchActiveView();
+
Q_SIGNALS:
void activeViewChanged(DolphinViewContainer *viewContainer);
void activeViewUrlChanged(const QUrl &url);
@@ -170,8 +172,6 @@ private Q_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/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp
index 3c3f7bb87..e3d133ff0 100644
--- a/src/panels/places/placespanel.cpp
+++ b/src/panels/places/placespanel.cpp
@@ -47,6 +47,15 @@ PlacesPanel::PlacesPanel(QWidget *parent)
connect(m_configureTrashAction, &QAction::triggered, this, &PlacesPanel::slotConfigureTrash);
addAction(m_configureTrashAction);
+ m_openInSplitView = new QAction(QIcon::fromTheme(QStringLiteral("view-right-new")), i18nc("@action:inmenu", "Open in Split View"));
+ m_openInSplitView->setPriority(QAction::HighPriority);
+ connect(m_openInSplitView, &QAction::triggered, this, [this]() {
+ const QUrl url = currentIndex().data(KFilePlacesModel::UrlRole).toUrl();
+ Q_EMIT openInSplitViewRequested(url);
+ });
+
+ addAction(m_openInSplitView);
+
connect(this, &PlacesPanel::contextMenuAboutToShow, this, &PlacesPanel::slotContextMenuAboutToShow);
connect(this, &PlacesPanel::iconSizeChanged, this, [](const QSize &newSize) {
@@ -188,6 +197,7 @@ void PlacesPanel::slotContextMenuAboutToShow(const QModelIndex &index, QMenu *me
const Solid::Device device = placesModel->deviceForIndex(index);
m_configureTrashAction->setVisible(url.scheme() == QLatin1String("trash"));
+ m_openInSplitView->setVisible(url.isValid());
// show customContextMenuActions only on the view's context menu
if (!url.isValid() && !device.isValid()) {
diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h
index 2eb309483..cbd5fc224 100644
--- a/src/panels/places/placespanel.h
+++ b/src/panels/places/placespanel.h
@@ -51,6 +51,7 @@ Q_SIGNALS:
void storageTearDownRequested(const QString &mountPath);
void storageTearDownExternallyRequested(const QString &mountPath);
void storageTearDownSuccessful();
+ void openInSplitViewRequested(const QUrl &url);
protected:
void showEvent(QShowEvent *event) override;
@@ -75,6 +76,7 @@ private:
QPersistentModelIndex m_indexToTearDown;
QAction *m_configureTrashAction;
+ QAction *m_openInSplitView;
QAction *m_lockPanelsAction;
};
diff --git a/src/settings/contextmenu/contextmenusettingspage.cpp b/src/settings/contextmenu/contextmenusettingspage.cpp
index ea780550a..23ddfba31 100644
--- a/src/settings/contextmenu/contextmenusettingspage.cpp
+++ b/src/settings/contextmenu/contextmenusettingspage.cpp
@@ -122,6 +122,8 @@ bool ContextMenuSettingsPage::entryVisible(const QString &id)
return ContextMenuSettings::showOpenInNewTab();
} else if (id == "open_in_new_window") {
return ContextMenuSettings::showOpenInNewWindow();
+ } else if (id == "open_in_split_view") {
+ return ContextMenuSettings::showOpenInSplitView();
} else if (id == "copy_location") {
return ContextMenuSettings::showCopyLocation();
} else if (id == "duplicate") {
@@ -148,6 +150,8 @@ void ContextMenuSettingsPage::setEntryVisible(const QString &id, bool visible)
ContextMenuSettings::setShowOpenInNewTab(visible);
} else if (id == "open_in_new_window") {
ContextMenuSettings::setShowOpenInNewWindow(visible);
+ } else if (id == "open_in_split_view") {
+ return ContextMenuSettings::setShowOpenInSplitView(visible);
} else if (id == "copy_location") {
ContextMenuSettings::setShowCopyLocation(visible);
} else if (id == "duplicate") {
diff --git a/src/settings/dolphin_contextmenusettings.kcfg b/src/settings/dolphin_contextmenusettings.kcfg
index 63ca079af..6e45d9bcd 100644
--- a/src/settings/dolphin_contextmenusettings.kcfg
+++ b/src/settings/dolphin_contextmenusettings.kcfg
@@ -30,6 +30,10 @@
<label>Show 'Open in New Window' in context menu.</label>
<default>true</default>
</entry>
+ <entry name="ShowOpenInSplitView" type="Bool">
+ <label>Show 'Open In Split View' in context menu.</label>
+ <default>true</default>
+ </entry>
<entry name="ShowCopyLocation" type="Bool">
<label>Show 'Copy Location' in context menu.</label>
<default>true</default>
diff --git a/src/settings/dolphinsettingsdialog.cpp b/src/settings/dolphinsettingsdialog.cpp
index 3a2ad31e9..d05d5a814 100644
--- a/src/settings/dolphinsettingsdialog.cpp
+++ b/src/settings/dolphinsettingsdialog.cpp
@@ -68,6 +68,7 @@ DolphinSettingsDialog::DolphinSettingsDialog(const QUrl &url, QWidget *parent, K
QStringLiteral("view_mode"),
QStringLiteral("open_in_new_tab"),
QStringLiteral("open_in_new_window"),
+ QStringLiteral("open_in_split_view"),
QStringLiteral("copy_location"),
QStringLiteral("duplicate"),
QStringLiteral("open_terminal_here"),