Commit 217ed276 authored by Nathan Sprangers's avatar Nathan Sprangers Committed by Kurt Hindenburg
Browse files

Move splitview toolbar buttons into a button menu

The buttons have very long labels, which made the window too wide
or caused the toolbar to display a disclosure button to show all the
options.

This moves those buttons into a "Split View" toolbar button, which
fixes those issues and looks much nicer.

BUG: 437555
parent 51ab3770
<?xml version="1.0"?>
<!DOCTYPE gui SYSTEM "kpartgui.dtd">
<gui name="konsole" version="17">
<gui name="konsole" version="18">
<MenuBar>
<Menu name="file"><text>File</text>
<Action name="new-window"/>
......@@ -57,10 +57,6 @@
<text>Main Toolbar</text>
<index>0</index>
<Action name="new-tab"/>
<Action name="split-view-left-right"/>
<Action name="split-view-top-bottom"/>
<Action name="load-terminals-layout-2x2"/>
<Action name="load-terminals-layout-2x1"/>
<Action name="load-terminals-layout-1x2"/>
<Action name="split-view"/>
</ToolBar>
</gui>
......@@ -21,6 +21,7 @@
// KDE
#include <KActionCollection>
#include <KActionMenu>
#include <KConfigGroup>
#include <KLocalizedString>
#include <KMessageBox>
......@@ -101,6 +102,11 @@ void ViewManager::setupActions()
}
KActionCollection *collection = _actionCollection;
KActionMenu *splitViewActions =
new KActionMenu(QIcon::fromTheme(QStringLiteral("view-split-left-right")), i18nc("@action:inmenu", "Split View"), collection);
splitViewActions->setPopupMode(QToolButton::InstantPopup);
collection->addAction(QStringLiteral("split-view"), splitViewActions);
// Let's reuse the pointer, no need not to.
auto *action = new QAction(this);
action->setIcon(QIcon::fromTheme(QStringLiteral("view-split-left-right")));
......@@ -108,6 +114,7 @@ void ViewManager::setupActions()
connect(action, &QAction::triggered, this, &ViewManager::splitLeftRight);
collection->addAction(QStringLiteral("split-view-left-right"), action);
collection->setDefaultShortcut(action, Konsole::ACCEL | Qt::Key_ParenLeft);
splitViewActions->addAction(action);
action = new QAction(this);
action->setIcon(QIcon::fromTheme(QStringLiteral("view-split-top-bottom")));
......@@ -115,6 +122,9 @@ void ViewManager::setupActions()
connect(action, &QAction::triggered, this, &ViewManager::splitTopBottom);
collection->setDefaultShortcut(action, Konsole::ACCEL | Qt::Key_ParenRight);
collection->addAction(QStringLiteral("split-view-top-bottom"), action);
splitViewActions->addAction(action);
splitViewActions->addSeparator();
action = new QAction(this);
action->setIcon(QIcon::fromTheme(QStringLiteral("view-split-top-bottom")));
......@@ -123,6 +133,7 @@ void ViewManager::setupActions()
this->loadLayout(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/2x2-terminals.json")));
});
collection->addAction(QStringLiteral("load-terminals-layout-2x2"), action);
splitViewActions->addAction(action);
action = new QAction(this);
action->setIcon(QIcon::fromTheme(QStringLiteral("view-split-left-right")));
......@@ -131,14 +142,16 @@ void ViewManager::setupActions()
this->loadLayout(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/2x1-terminals.json")));
});
collection->addAction(QStringLiteral("load-terminals-layout-2x1"), action);
splitViewActions->addAction(action);
action = new QAction(this);
action->setIcon(QIcon::fromTheme(QStringLiteral("view-split-top-bottom")));
action->setText(i18nc("@action:inmenu", "Load a new tab with layout 2x1 terminals"));
action->setText(i18nc("@action:inmenu", "Load a new tab with layout 1x2 terminals"));
connect(action, &QAction::triggered, this, [this]() {
this->loadLayout(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/1x2-terminals.json")));
});
collection->addAction(QStringLiteral("load-terminals-layout-1x2"), action);
splitViewActions->addAction(action);
action = new QAction(this);
action->setText(i18nc("@action:inmenu", "Expand View"));
......
Markdown is supported
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