┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinmainwindow.cpp
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 /src/dolphinmainwindow.cpp
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
Diffstat (limited to 'src/dolphinmainwindow.cpp')
-rw-r--r--src/dolphinmainwindow.cpp35
1 files changed, 34 insertions, 1 deletions
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);