1
0
mirror of https://invent.kde.org/system/dolphin synced 2024-07-04 17:30:55 +00:00

Allow popping out a split view

If you have a split view open, you can now pop the active half out into a new window by clicking the "Pop out" button in the toolbar or by activating "View > Pop out".

BUG: 270604
This commit is contained in:
Loren Burkholder 2023-04-06 20:05:48 -04:00
parent 2cee764ff7
commit f7e2c51198
3 changed files with 38 additions and 5 deletions

View File

@ -469,7 +469,7 @@ void DolphinMainWindow::openNewWindow(const QUrl &url)
void DolphinMainWindow::slotSplitViewChanged()
{
m_tabWidget->currentTabPage()->setSplitViewEnabled(GeneralSettings::splitView(), WithAnimation);
updateSplitAction();
updateSplitActions();
}
void DolphinMainWindow::openInNewTab()
@ -984,6 +984,15 @@ void DolphinMainWindow::toggleSplitView()
updateViewActions();
}
void DolphinMainWindow::popoutSplitView()
{
DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
if (!tabPage->splitViewEnabled())
return;
openNewWindow(tabPage->activeViewContainer()->url());
tabPage->setSplitViewEnabled(false, WithAnimation);
}
void DolphinMainWindow::toggleSplitStash()
{
DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
@ -1829,6 +1838,14 @@ void DolphinMainWindow::setupActions()
actionCollection()->setDefaultShortcut(split, Qt::Key_F3);
connect(split, &QAction::triggered, this, &DolphinMainWindow::toggleSplitView);
QAction *popoutSplit = actionCollection()->addAction(QStringLiteral("popout_split_view"));
popoutSplit->setWhatsThis(xi18nc("@info:whatsthis",
"If the folder view has been split, this will pop the active folder "
"view out into a new window."));
popoutSplit->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
actionCollection()->setDefaultShortcut(popoutSplit, Qt::SHIFT | Qt::Key_F3);
connect(popoutSplit, &QAction::triggered, this, &DolphinMainWindow::popoutSplitView);
QAction *stashSplit = actionCollection()->addAction(QStringLiteral("split_stash"));
actionCollection()->setDefaultShortcut(stashSplit, Qt::CTRL | Qt::Key_S);
stashSplit->setText(i18nc("@action:intoolbar Stash", "Stash"));
@ -2417,7 +2434,7 @@ void DolphinMainWindow::updateViewActions()
QAction *toggleFilterBarAction = actionCollection()->action(QStringLiteral("toggle_filter"));
toggleFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
updateSplitAction();
updateSplitActions();
}
void DolphinMainWindow::updateGoActions()
@ -2446,7 +2463,7 @@ void DolphinMainWindow::refreshViews()
updateWindowTitle();
}
updateSplitAction();
updateSplitActions();
Q_EMIT settingsChanged();
}
@ -2505,24 +2522,31 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer *container)
connect(navigator, &KUrlNavigator::newWindowRequested, this, &DolphinMainWindow::openNewWindow);
}
void DolphinMainWindow::updateSplitAction()
void DolphinMainWindow::updateSplitActions()
{
QAction *splitAction = actionCollection()->action(QStringLiteral("split_view"));
QAction *popoutSplitAction = actionCollection()->action(QStringLiteral("popout_split_view"));
const DolphinTabPage *tabPage = m_tabWidget->currentTabPage();
if (tabPage->splitViewEnabled()) {
if (GeneralSettings::closeActiveSplitView() ? tabPage->primaryViewActive() : !tabPage->primaryViewActive()) {
splitAction->setText(i18nc("@action:intoolbar Close left view", "Close"));
splitAction->setToolTip(i18nc("@info", "Close left view"));
splitAction->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close")));
popoutSplitAction->setText(i18nc("@action:intoolbar Pop out left view", "Pop out"));
popoutSplitAction->setToolTip(i18nc("@info", "Pop out left view"));
} else {
splitAction->setText(i18nc("@action:intoolbar Close right view", "Close"));
splitAction->setToolTip(i18nc("@info", "Close right view"));
splitAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-close")));
popoutSplitAction->setText(i18nc("@action:intoolbar Pop out right view", "Pop out"));
popoutSplitAction->setToolTip(i18nc("@info", "Pop out right view"));
}
popoutSplitAction->setVisible(true);
} else {
splitAction->setText(i18nc("@action:intoolbar Split view", "Split"));
splitAction->setToolTip(i18nc("@info", "Split view"));
splitAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new")));
popoutSplitAction->setVisible(false);
}
}

View File

@ -343,6 +343,13 @@ private Q_SLOTS:
*/
void toggleSplitView();
/**
* Pops out a split view.
* The active view will be popped out, unless the view is not split,
* in which case nothing will happen.
*/
void popoutSplitView();
/** Dedicated action to open the stash:/ ioslave in split view. */
void toggleSplitStash();
@ -662,7 +669,7 @@ private:
* otherwise the text is set to "Join". The icon
* is updated to match with the text and the currently active view.
*/
void updateSplitAction();
void updateSplitActions();
/**
* Sets the window sides the toolbar may be moved to based on toolbar contents.

View File

@ -50,6 +50,7 @@
<Action name="show_hidden_files" />
<Separator/>
<Action name="split_view" />
<Action name="popout_split_view" />
<Action name="split_stash" />
<Action name="redisplay" />
<Action name="stop" />
@ -111,6 +112,7 @@
<Action name="details" />
<Action name="url_navigators" />
<Action name="split_view" />
<Action name="popout_split_view" />
<Action name="split_stash" />
<Action name="toggle_search" />
<Action name="hamburger_menu" />