Commit 8663b4be authored by Kamay Xutax's avatar Kamay Xutax Committed by Tomaz Canabrava
Browse files

Be able to resize the splits to the same size.

Here how it looks like:

Before, it was impossible to resize the splits
with the same size in case they were manually resized.

I have added a new button menu for doing so:
in View -> Split View -> Equal size to all views.

First I wanted to make this as a plugin,
but since I thought it could make splits a bit more useful,
I decided to merge it not as a plugin but internally.

GUI: Menu -> View -> Split View -> Equal size to all views
CHANGELOG: Added equal size to all split views.
parent 7e37cbab
Pipeline #180036 passed with stage
in 3 minutes and 7 seconds
......@@ -25,6 +25,7 @@
<Action name="expand-active-view"/>
<Action name="shrink-active-view"/>
<Action name="toggle-maximize-current-view"/>
<Action name="equal-size-view"/>
<Action name="detach-tab" />
......@@ -695,6 +695,14 @@ Any output on one view is duplicated in the other view.
<shortcut><keycombo action="simul">&Ctrl;&Shift;<keycap>\</keycap></keycombo></shortcut>
<guimenu>View</guimenu><guisubmenu>Split View</guisubmenu><guimenuitem>Equal size to all views</guimenuitem></menuchoice>
<listitem><para><action>Sets the same size for all views</action>
......@@ -274,6 +274,14 @@ void ViewManager::setupActions()
_multiTabOnlyActions << action;
action = new QAction(this);
action->setText(i18nc("@action:inmenu", "Equal size to all views"));
collection->setDefaultShortcut(action, Konsole::ACCEL | Qt::SHIFT | Qt::Key_Backslash);
collection->addAction(QStringLiteral("equal-size-view"), action);
connect(action, &QAction::triggered, this, &ViewManager::equalSizeAllContainers);
_multiSplitterOnlyActions << action;
// _viewSplitter->addAction(lastUsedViewReverseAction);
const int SWITCH_TO_TAB_COUNT = 19;
for (int i = 0; i < SWITCH_TO_TAB_COUNT; ++i) {
......@@ -632,6 +640,36 @@ void ViewManager::shrinkActiveContainer()
void ViewManager::equalSizeAllContainers()
std::function<void(ViewSplitter *)> processChildren = [&processChildren](ViewSplitter *viewSplitter) -> void {
// divide the size of the parent widget by the amount of children splits
auto hintSize = viewSplitter->size();
auto sizes = viewSplitter->sizes();
auto sharedSize = hintSize / sizes.size();
if (viewSplitter->orientation() == Qt::Horizontal) {
for (auto &&size : sizes) {
size = sharedSize.width();
} else {
for (auto &&size : sizes) {
size = sharedSize.height();
// set new sizes
// set equal sizes for each splitter children
for (auto &&child : viewSplitter->children()) {
auto childViewSplitter = qobject_cast<ViewSplitter *>(child);
if (childViewSplitter) {
SessionController *ViewManager::createController(Session *session, TerminalDisplay *view)
// create a new controller for the session, and ensure that this view manager
......@@ -318,6 +318,7 @@ private Q_SLOTS:
void splitTopBottom();
void expandActiveContainer();
void shrinkActiveContainer();
void equalSizeAllContainers();
// called when the "Detach View" menu item is selected
void detachActiveView();
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