[utilities/konsole] /: Allow pressing Esc to quit keyboard selection mode

Kurt Hindenburg null at kde.org
Fri Feb 24 00:44:18 GMT 2023


Git commit 0375b56d744ef6c2dc9abb0b627eceed809a3f80 by Kurt Hindenburg, on behalf of Matan Ziv-Av.
Committed on 24/02/2023 at 00:18.
Pushed by hindenburg into branch 'master'.

Allow pressing Esc to quit keyboard selection mode

M  +5    -1    doc/manual/index.docbook
M  +10   -6    src/session/SessionController.cpp
M  +3    -0    src/session/SessionController.h
M  +3    -0    src/terminalDisplay/TerminalDisplay.cpp

https://invent.kde.org/utilities/konsole/commit/0375b56d744ef6c2dc9abb0b627eceed809a3f80

diff --git a/doc/manual/index.docbook b/doc/manual/index.docbook
index 4ba39eb6f..016b7edd2 100644
--- a/doc/manual/index.docbook
+++ b/doc/manual/index.docbook
@@ -52,7 +52,7 @@
 
 <legalnotice>&FDLNotice;</legalnotice>
 
-<date>2022-12-10</date>
+<date>2023-02-10</date>
 <releaseinfo>KDE Gear 23.04</releaseinfo>
 
 <abstract><para>&konsole; is &kde;'s terminal emulator.</para></abstract>
@@ -119,6 +119,10 @@ without the mouse.</para>
 Enter and leave this mode by using the keyboard shortcut (<keycombo action="simul">&Ctrl;&Shift;<keycap>D</keycap></keycombo> by default).
 </para>
 
+<para>
+<keycap>Esc</keycap> also leaves the keyboard selection mode.
+</para>
+
 <para>
 Moving the cursor: Arrows, <keycap>PageUp</keycap>, <keycap>PageDown</keycap>, <keycap>Home</keycap>, <keycap>End</keycap>.
 </para>
diff --git a/src/session/SessionController.cpp b/src/session/SessionController.cpp
index 5cf6f6b5a..cd5d49b6f 100644
--- a/src/session/SessionController.cpp
+++ b/src/session/SessionController.cpp
@@ -452,14 +452,12 @@ void SessionController::setupPrimaryScreenSpecificActions(bool use)
     QAction *clearAction = collection->action(QStringLiteral("clear-history"));
     QAction *resetAction = collection->action(QStringLiteral("clear-history-and-reset"));
     QAction *selectAllAction = collection->action(QStringLiteral("select-all"));
-    QAction *selectModeAction = collection->action(QStringLiteral("select-mode"));
     QAction *selectLineAction = collection->action(QStringLiteral("select-line"));
 
     // these actions are meaningful only when primary screen is used.
     clearAction->setEnabled(use);
     resetAction->setEnabled(use);
     selectAllAction->setEnabled(use);
-    selectModeAction->setEnabled(use);
     selectLineAction->setEnabled(use);
 }
 
@@ -1241,11 +1239,17 @@ void SessionController::selectAll()
 void SessionController::selectMode()
 {
     if (!session().isNull()) {
-        QAction *readonlyAction = actionCollection()->action(QStringLiteral("view-readonly"));
         bool Mode = session()->getSelectMode();
-        session()->setSelectMode(!Mode);
-        readonlyAction->setEnabled(Mode);
-        view()->setSelectMode(!Mode);
+        setSelectMode(!Mode);
+    }
+}
+void SessionController::setSelectMode(bool mode)
+{
+    if (!session().isNull()) {
+        QAction *readonlyAction = actionCollection()->action(QStringLiteral("view-readonly"));
+        session()->setSelectMode(mode);
+        readonlyAction->setEnabled(!mode);
+        view()->setSelectMode(mode);
     }
 }
 
diff --git a/src/session/SessionController.h b/src/session/SessionController.h
index e284aa205..39473bc12 100644
--- a/src/session/SessionController.h
+++ b/src/session/SessionController.h
@@ -144,6 +144,9 @@ public:
     bool isReadOnly() const;
     bool isCopyInputActive() const;
 
+    /* Set/reset selection mode */
+    void setSelectMode(bool mode);
+
 Q_SIGNALS:
     /**
      * Emitted when the view associated with the controller is focused.
diff --git a/src/terminalDisplay/TerminalDisplay.cpp b/src/terminalDisplay/TerminalDisplay.cpp
index fb8ba7465..cd9c5b729 100644
--- a/src/terminalDisplay/TerminalDisplay.cpp
+++ b/src/terminalDisplay/TerminalDisplay.cpp
@@ -2631,6 +2631,9 @@ void TerminalDisplay::keyPressEvent(QKeyEvent *event)
             }
         }
         switch (event->key()) {
+        case Qt::Key_Escape:
+            sessionController()->setSelectMode(false);
+            break;
         case Qt::Key_Left:
         case Qt::Key_H:
             SELECT_BY_MODIFIERS;



More information about the kde-doc-english mailing list