[konsole] /: Add reset font size shortcut
Tomaz Canabrava
null at kde.org
Mon Sep 17 09:20:14 BST 2018
Git commit f6e432ab0c04226bd772019911b97298070d1264 by Tomaz Canabrava, on behalf of Lukas Bergdoll.
Committed on 17/09/2018 at 08:20.
Pushed by tcanabrava into branch 'master'.
Add reset font size shortcut
Summary:
Whenever I change the font size doing so is usually temporary and I usually go back to the default font size in after a short time. Currently I do so by changing to a different profile and discarding the change, which resets the font size to the default. I feel like there should be a shortcut for resetting the size.
I could not find an appropriate icon, so I left it without icon.
The default shortcut ctrl+r seemed reasonable and easy to type, 'r' reset.
Test Plan: Manual.
Reviewers: hindenburg, tcanabrava, #vdg, ngraham
Reviewed By: #vdg, ngraham
Subscribers: muhlenpfordt, ach, kvermette, rizzitello, lbergdoll, hindenburg, fabianr, dhaumann, kde-doc-english, z3ntu, ngraham, konsole-devel
Tags: #konsole, #documentation
Differential Revision: https://phabricator.kde.org/D15380
M +2 -1 desktop/sessionui.rc
M +8 -0 doc/manual/index.docbook
M +8 -1 src/SessionController.cpp
M +3 -0 src/SessionController.h
M +12 -0 src/TerminalDisplay.cpp
M +3 -0 src/TerminalDisplay.h
https://commits.kde.org/konsole/f6e432ab0c04226bd772019911b97298070d1264
diff --git a/desktop/sessionui.rc b/desktop/sessionui.rc
index 287e1dea..6e6f54a6 100644
--- a/desktop/sessionui.rc
+++ b/desktop/sessionui.rc
@@ -1,6 +1,6 @@
<!DOCTYPE kpartgui>
-<kpartgui name="session" version="25">
+<kpartgui name="session" version="26">
<MenuBar>
<Menu name="file">
<Action name="file_save_as" group="session-operations"/>
@@ -32,6 +32,7 @@
<Action name="view-readonly" group="session-view-operations"/>
<Separator group="session-view-operations"/>
<Action name="enlarge-font" group="session-view-operations"/>
+ <Action name="reset-font-size" group="session-view-operations"/>
<Action name="shrink-font" group="session-view-operations"/>
<Action name="set-encoding" group="session-view-operations"/>
<Separator group="session-view-operations"/>
diff --git a/doc/manual/index.docbook b/doc/manual/index.docbook
index 6671ae5e..854464ad 100644
--- a/doc/manual/index.docbook
+++ b/doc/manual/index.docbook
@@ -768,6 +768,14 @@ drag and drop is disabled.
<listitem><para><action>Increases the text font size</action></para></listitem>
</varlistentry>
+<varlistentry>
+<term><menuchoice>
+<shortcut><keycombo action="simul">&Ctrl;<keycap>0</keycap></keycombo></shortcut>
+<guimenu>View</guimenu><guimenuitem>Reset Font Size</guimenuitem></menuchoice></term>
+<listitem><para><action>Reset the text font size to the profile default</action></para></listitem>
+</varlistentry>
+
+
<varlistentry>
<term><menuchoice>
<shortcut><keycombo action="simul">&Ctrl;<keycap>-</keycap></keycombo></shortcut>
diff --git a/src/SessionController.cpp b/src/SessionController.cpp
index 5cff9c4a..9a96561a 100644
--- a/src/SessionController.cpp
+++ b/src/SessionController.cpp
@@ -718,6 +718,9 @@ void SessionController::setupExtraActions()
action->setIcon(QIcon::fromTheme(QStringLiteral("format-font-size-less")));
collection->setDefaultShortcut(action, Konsole::ACCEL + Qt::Key_Minus);
+ action = collection->addAction(QStringLiteral("reset-font-size"), this, SLOT(resetFontSize()));
+ action->setText(i18n("Reset Font Size"));
+ collection->setDefaultShortcut(action, Konsole::ACCEL + Qt::ALT + Qt::Key_0);
// Send signal
KSelectAction* sendSignalActions = collection->add<KSelectAction>(QStringLiteral("send-signal"));
@@ -1508,6 +1511,11 @@ void SessionController::decreaseFontSize()
_view->decreaseFontSize();
}
+void SessionController::resetFontSize()
+{
+ _view->resetFontSize();
+}
+
void SessionController::monitorActivity(bool monitor)
{
_session->setMonitorActivity(monitor);
@@ -2115,4 +2123,3 @@ QString SessionController::userTitle() const
return QString();
}
}
-
diff --git a/src/SessionController.h b/src/SessionController.h
index 054d48e6..298ad3f2 100644
--- a/src/SessionController.h
+++ b/src/SessionController.h
@@ -219,6 +219,9 @@ public Q_SLOTS:
/** Decrease font size */
void decreaseFontSize();
+ /** Reset font size */
+ void resetFontSize();
+
private Q_SLOTS:
// menu item handlers
void openBrowser();
diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp
index 256a57a4..247908ab 100644
--- a/src/TerminalDisplay.cpp
+++ b/src/TerminalDisplay.cpp
@@ -336,6 +336,18 @@ void TerminalDisplay::decreaseFontSize()
setVTFont(font);
}
+void TerminalDisplay::resetFontSize()
+{
+ const qreal MinimumFontSize = 6;
+
+ QFont font = getVTFont();
+ Profile::Ptr currentProfile = SessionManager::instance()->sessionProfile(_sessionController->session());
+ const qreal defaultFontSize = currentProfile->font().pointSizeF();
+
+ font.setPointSizeF(qMax(defaultFontSize, MinimumFontSize));
+ setVTFont(font);
+}
+
uint TerminalDisplay::lineSpacing() const
{
return _lineSpacing;
diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h
index ed70f85c..b2469e3b 100644
--- a/src/TerminalDisplay.h
+++ b/src/TerminalDisplay.h
@@ -427,6 +427,9 @@ public:
/** Decreases the font size */
void decreaseFontSize();
+ /** Reset the font size */
+ void resetFontSize();
+
/**
* Specified whether anti-aliasing of text in the terminal display
* is enabled or not. Defaults to enabled.
More information about the kde-doc-english
mailing list