← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~nikwen/ubuntu-terminal-app/keyboard-shortcuts into lp:ubuntu-terminal-app

 

Niklas Wenzel has proposed merging lp:~nikwen/ubuntu-terminal-app/keyboard-shortcuts into lp:ubuntu-terminal-app with lp:~nikwen/ubuntu-terminal-app/exit-handling as a prerequisite.

Commit message:
Added keyboard shortcuts for desktop use.

Available commands:

Open Tab: Shift+Ctrl+T
Close Tab: Shift+Ctrl+W
Close Window: Shift+Ctrl+Q

Copy: Shift+Ctrl+C
Paste: Shift+Ctrl+V

Zoom In: Ctrl++
Zoom Out: Ctrl+-
Normal Size: Ctrl+0

Requested reviews:
  Ubuntu Terminal Developers (ubuntu-terminal-dev)
Related bugs:
  Bug #1401994 in Ubuntu Terminal App: "[Reboot] adopt keyoard shortcuts from gnome-terminal"
  https://bugs.launchpad.net/ubuntu-terminal-app/+bug/1401994

For more details, see:
https://code.launchpad.net/~nikwen/ubuntu-terminal-app/keyboard-shortcuts/+merge/261787

Added keyboard shortcuts which are known to users from gnome-terminal.

As this uses a function for tab closing which I introduced in the MP for proper handling of the "exit" command (https://code.launchpad.net/~nikwen/ubuntu-terminal-app/exit-handling/+merge/261770), that one needs to be merged first.

The detailed list:

Open Tab: Shift+Ctrl+T
Close Tab: Shift+Ctrl+W
Close Window: Shift+Ctrl+Q

Copy: Shift+Ctrl+C
Paste: Shift+Ctrl+V

Zoom In: Ctrl++
Zoom Out: Ctrl+-
Normal Size: Ctrl+0
-- 
Your team Ubuntu Terminal Developers is requested to review the proposed merge of lp:~nikwen/ubuntu-terminal-app/keyboard-shortcuts into lp:ubuntu-terminal-app.
=== modified file 'po/com.ubuntu.terminal.pot'
--- po/com.ubuntu.terminal.pot	2015-06-11 22:18:25 +0000
+++ po/com.ubuntu.terminal.pot	2015-06-11 22:18:25 +0000
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-06-11 23:33+0200\n"
+"POT-Creation-Date: 2015-06-11 23:58+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"
@@ -73,7 +73,7 @@
 msgid "Font Size:"
 msgstr ""
 
-#: ../src/app/qml/SettingsPage.qml:78
+#: ../src/app/qml/SettingsPage.qml:85
 msgid "Color Scheme"
 msgstr ""
 

=== modified file 'src/app/qml/SettingsPage.qml'
--- src/app/qml/SettingsPage.qml	2015-04-01 22:50:53 +0000
+++ src/app/qml/SettingsPage.qml	2015-06-11 22:18:25 +0000
@@ -61,14 +61,21 @@
                     bottom: parent.bottom
                     margins: units.gu(2)
                 }
-                minimumValue: 8;
-                maximumValue: 32;
+                minimumValue: settings.minFontSize;
+                maximumValue: settings.maxFontSize;
                 onValueChanged: {
                     settings.fontSize = value;
                 }
                 Component.onCompleted: {
                     value = settings.fontSize;
                 }
+
+                Connections {
+                    target: settings
+                    onFontSizeChanged: {
+                        slFont.value = settings.fontSize
+                    }
+                }
             }
         }
 

=== modified file 'src/app/qml/TerminalComponent.qml'
--- src/app/qml/TerminalComponent.qml	2015-06-11 22:18:25 +0000
+++ src/app/qml/TerminalComponent.qml	2015-06-11 22:18:25 +0000
@@ -23,6 +23,56 @@
             onFinished: tabsModel.removeTabWithSession(terminalSession);
         }
 
+        Keys.onPressed: { // Keyboard shortcuts
+            if (event.modifiers & Qt.ControlModifier) {
+                if (event.modifiers & Qt.ShiftModifier) {
+                    event.accepted = true; // That way shortcuts will not be processed by the terminal widget (Ctrl + Shift is always interpreted as a shortcut)
+
+                    switch (event.key) {
+                    // Window/tab handling
+                    case Qt.Key_T: // Open tab
+                        tabsModel.addTab();
+                        tabsModel.selectTab(tabsModel.count - 1);
+                        break;
+                    case Qt.Key_W: //Close tab
+                        tabsModel.removeTabWithSession(terminalSession);
+                        break;
+                    case Qt.Key_Q: //Close window
+                        for (var i = tabsModel.count - 1; i >= 0; i--) {
+                            tabsModel.removeTab(i); // This will also call Qt.quit()
+                        }
+                        break;
+
+                    // Clipboard
+                    case Qt.Key_C: // Copy
+                        terminal.copyClipboard();
+                        break;
+                    case Qt.Key_V: // Paste
+                        terminal.pasteClipboard();
+                        break;
+                    }
+                } else {
+                    // Do not automatically accept all keys here! Programs like nano may declare their own Ctrl-shortcuts.
+
+                    switch (event.key) {
+                    // Font size
+                    case Qt.Key_Plus: // Zoom in
+                        event.accepted = true;
+                        settings.fontSize = Math.min(settings.fontSize + 1, settings.maxFontSize);
+                        break;
+                    case Qt.Key_Minus: // Zoom out
+                        event.accepted = true;
+                        settings.fontSize = Math.max(settings.fontSize - 1, settings.minFontSize);
+                        break;
+                    case Qt.Key_0: // Normal size
+                        event.accepted = true;
+                        settings.fontSize = settings.defaultFontSize;
+                        break;
+                    }
+                }
+            }
+        }
+
         QMLTermScrollbar {
             z: parent.z + 2
             terminal: parent

=== modified file 'src/app/qml/TerminalSettings.qml'
--- src/app/qml/TerminalSettings.qml	2015-04-02 12:53:43 +0000
+++ src/app/qml/TerminalSettings.qml	2015-06-11 22:18:25 +0000
@@ -10,6 +10,10 @@
     property alias colorScheme: innerSettings.colorScheme
     property alias showKeyboardBar: innerSettings.showKeyboardBar
 
+    readonly property int defaultFontSize: 14
+    readonly property int minFontSize: 8
+    readonly property int maxFontSize: 32
+
     property alias jsonVisibleProfiles: innerSettings.jsonVisibleProfiles
 
     property ListModel profilesList: ListModel {}
@@ -31,7 +35,7 @@
 
     Settings {
         id: innerSettings
-        property int fontSize: 14
+        property int fontSize: defaultFontSize
         property string fontStyle: "Ubuntu Mono"
         property string colorScheme: "Ubuntu"
         property bool showKeyboardBar: true


Follow ups