Commit 51e29b8f authored by Eric Armbruster's avatar Eric Armbruster Committed by Christoph Cullmann
Browse files

Add convenience split actions

These new actions split the view and move the currently active document to the new viewspace.
parent 29ec6af9
Pipeline #158353 passed with stage
in 9 minutes and 17 seconds
......@@ -75,6 +75,8 @@
<Separator/>
<Action name="view_split_vert"/>
<Action name="view_split_horiz"/>
<Action name="view_split_vert_move_doc"/>
<Action name="view_split_horiz_move_doc"/>
<Action name="view_split_toggle"/>
<Separator/>
<Action name="view_close_current_space"/>
......
......@@ -125,6 +125,24 @@ void KateViewManager::setupActions()
m_splitViewHoriz->setWhatsThis(i18n("Split the currently active view horizontally into two views."));
m_splitViewVertMove = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_split_vert_move_doc"));
m_splitViewVertMove->setIcon(QIcon::fromTheme(QStringLiteral("view-split-left-right")));
m_splitViewVertMove->setText(i18n("Move Document to New Vertical Split"));
connect(m_splitViewVertMove, &QAction::triggered, this, &KateViewManager::slotSplitViewSpaceVertMoveDoc);
m_splitViewVertMove->setWhatsThis(
i18n("Split the currently active view vertically into two views "
"and move the currently active document to right view."));
m_splitViewHorizMove = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_split_horiz_move_doc"));
m_splitViewHorizMove->setIcon(QIcon::fromTheme(QStringLiteral("view-split-top-bottom")));
m_splitViewHorizMove->setText(i18n("Move Document to New Horizontal Split"));
connect(m_splitViewHorizMove, &QAction::triggered, this, &KateViewManager::slotSplitViewSpaceHorizMoveDoc);
m_splitViewHorizMove->setWhatsThis(
i18n("Split the currently active view horizontally into two views "
"and move the currently active document to view below."));
m_closeView = m_mainWindow->actionCollection()->addAction(QStringLiteral("view_close_current_space"));
m_closeView->setIcon(QIcon::fromTheme(QStringLiteral("view-close")));
m_closeView->setText(i18n("Cl&ose Current View"));
......@@ -794,7 +812,8 @@ void KateViewManager::moveViewToViewSpace(KateViewSpace *dest, KateViewSpace *sr
}
void KateViewManager::splitViewSpace(KateViewSpace *vs, // = 0
Qt::Orientation o) // = Qt::Horizontal
Qt::Orientation o,
bool moveDocument) // = Qt::Horizontal
{
// emergency: fallback to activeViewSpace, and if still invalid, abort
if (!vs) {
......@@ -803,6 +822,9 @@ void KateViewManager::splitViewSpace(KateViewSpace *vs, // = 0
if (!vs) {
return;
}
if (moveDocument && vs->documentList().size() <= 1) {
return;
}
// get current splitter, and abort if null
KateSplitter *currentSplitter = qobject_cast<KateSplitter *>(vs->parentWidget());
......@@ -860,6 +882,10 @@ void KateViewManager::splitViewSpace(KateViewSpace *vs, // = 0
createView(activeView()->document());
if (moveDocument) {
vs->closeDocument(vs->currentView()->document());
}
updateViewSpaceActions();
}
......
......@@ -171,7 +171,7 @@ public Q_SLOTS:
* The orientation of the new splitter is determined by the value of o.
* Note: horizontal splitter means vertically aligned views.
*/
void splitViewSpace(KateViewSpace *vs = nullptr, Qt::Orientation o = Qt::Horizontal);
void splitViewSpace(KateViewSpace *vs = nullptr, Qt::Orientation o = Qt::Horizontal, bool moveDocument = false);
/**
* Close the view space that contains the given view. If no view was
......@@ -202,6 +202,18 @@ public Q_SLOTS:
splitViewSpace();
}
/** Splits the active viewspace horizontally and moves the active document to the viewspace below */
void slotSplitViewSpaceHorizMoveDoc()
{
splitViewSpace(nullptr, Qt::Vertical, true);
}
/** Splits the active viewspace vertically and moves the active document to the right viewspace */
void slotSplitViewSpaceVertMoveDoc()
{
splitViewSpace(nullptr, Qt::Horizontal, true);
}
/** moves the splitter according to the key that has been pressed */
void moveSplitter(Qt::Key key, int repeats = 1);
......@@ -284,6 +296,8 @@ private:
QAction *m_splitViewVert = nullptr;
QAction *m_splitViewHoriz = nullptr;
QAction *m_splitViewVertMove = nullptr;
QAction *m_splitViewHorizMove = nullptr;
QAction *m_closeView = nullptr;
QAction *m_closeOtherViews = nullptr;
QAction *m_toggleSplitterOrientation = nullptr;
......
......@@ -112,6 +112,8 @@ KateViewSpace::KateViewSpace(KateViewManager *viewManager, QWidget *parent, cons
m_split->setIcon(QIcon::fromTheme(QStringLiteral("view-split-left-right")));
m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_vert")));
m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_horiz")));
m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_vert_move_doc")));
m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_horiz_move_doc")));
m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_close_current_space")));
m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_close_others")));
m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_hide_others")));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment