← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~popey/ubuntu-terminal-app/add-control into lp:ubuntu-terminal-app

 

Alan Pope  has proposed merging lp:~popey/ubuntu-terminal-app/add-control into lp:ubuntu-terminal-app.

Requested reviews:
  Jenkins Bot (ubuntu-core-apps-jenkins-bot): continuous-integration
  Victor Thompson (vthompson)

For more details, see:
https://code.launchpad.net/~popey/ubuntu-terminal-app/add-control/+merge/282280

Adds a toggle-able general purpose control key to the functions keys overlay.
-- 
Your team Ubuntu Terminal Developers is subscribed to branch lp:ubuntu-terminal-app.
=== modified file 'po/com.ubuntu.terminal.pot'
--- po/com.ubuntu.terminal.pot	2015-08-09 14:03:25 +0000
+++ po/com.ubuntu.terminal.pot	2016-01-12 09:58:28 +0000
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-08-09 16:01+0200\n"
+"POT-Creation-Date: 2016-01-10 19:21+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"
@@ -53,7 +53,7 @@
 msgid "Authentication failed"
 msgstr ""
 
-#: ../src/app/qml/KeyboardBar.qml:174
+#: ../src/app/qml/KeyboardBar.qml:178
 msgid "Change Keyboard"
 msgstr ""
 
@@ -177,7 +177,7 @@
 msgid "New tab"
 msgstr ""
 
-#: ../src/app/qml/TerminalPage.qml:164
+#: ../src/app/qml/TerminalPage.qml:165
 msgid "Selection Mode"
 msgstr ""
 
@@ -214,7 +214,7 @@
 msgstr ""
 
 #: ../src/plugin/konsole/Vt102Emulation.cpp:961
-#: ../src/plugin/qmltermwidget/lib/Vt102Emulation.cpp:977
+#: ../src/plugin/qmltermwidget/lib/Vt102Emulation.cpp:985
 msgid ""
 "No keyboard translator available.  The information needed to convert key "
 "presses into characters to send to the terminal is missing."

=== modified file 'src/app/qml/KeyboardBar.qml'
--- src/app/qml/KeyboardBar.qml	2015-07-13 20:25:21 +0000
+++ src/app/qml/KeyboardBar.qml	2016-01-12 09:58:28 +0000
@@ -12,6 +12,7 @@
 
     signal simulateCommand(string command);
     signal simulateKey(int key, int mod);
+    signal simulateModifier(int modifiers);
 
     ListModel {
         id: layoutsList
@@ -56,6 +57,7 @@
         layoutObject.z = rootItem.z;
         layoutObject.simulateKey.disconnect(simulateKey);
         layoutObject.simulateCommand.disconnect(simulateCommand);
+        layoutObject.simulateModifier.disconnect(simulateModifier);
     }
 
     function enableLayout(index) {
@@ -68,6 +70,7 @@
         layoutObject.z = rootItem.z + 0.01;
         layoutObject.simulateKey.connect(simulateKey);
         layoutObject.simulateCommand.connect(simulateCommand);
+        layoutObject.simulateModifier.connect(simulateModifier);
     }
 
     function isIndexLayoutValid(index) {
@@ -161,6 +164,7 @@
 
     onSimulateKey: pressFeedbackEffect.start();
     onSimulateCommand: pressFeedbackEffect.start();
+    onSimulateModifier: pressFeedbackEffect.start();
 
     Item {
         id: keyboardContainer

=== modified file 'src/app/qml/KeyboardRows/KeyboardLayout.qml'
--- src/app/qml/KeyboardRows/KeyboardLayout.qml	2015-08-09 14:25:36 +0000
+++ src/app/qml/KeyboardRows/KeyboardLayout.qml	2016-01-12 09:58:28 +0000
@@ -28,6 +28,8 @@
             return createKeyActionString(action.key, action.mod, action.text, action.id);
         case "string":
             return createStringActionString(action.string, action.text);
+        case "modifier":
+            return createNextModifierActionString(action.modifier);
         }
     }
 
@@ -56,6 +58,10 @@
         return "Action { " + textString + " onTriggered: simulateCommand(\"" + string + "\"); }";
     }
 
+    function createNextModifierActionString(modifier) {
+        return "Action { text: \"" + modifier + "\"; onTriggered: simulateModifier(Qt." + modifier + "Modifier); }";
+    }
+
     function createEntryString(text, actionString, otherActionsString) {
         var objectString = "
             import QtQuick 2.4

=== modified file 'src/app/qml/KeyboardRows/KeyboardRow.qml'
--- src/app/qml/KeyboardRows/KeyboardRow.qml	2015-07-13 20:25:21 +0000
+++ src/app/qml/KeyboardRows/KeyboardRow.qml	2016-01-12 09:58:28 +0000
@@ -14,6 +14,7 @@
     // External signals.
     signal simulateKey(int key, int mod);
     signal simulateCommand(string command);
+    signal simulateModifier(int modifiers);
 
     // Internal variables
     property int _firstVisibleIndex: gridView.contentX / keyWidth

=== modified file 'src/app/qml/KeyboardRows/Layouts/FunctionKeys.json'
--- src/app/qml/KeyboardRows/Layouts/FunctionKeys.json	2015-07-10 14:34:00 +0000
+++ src/app/qml/KeyboardRows/Layouts/FunctionKeys.json	2016-01-12 09:58:28 +0000
@@ -11,6 +11,13 @@
         },
         {
             "main_action" : {
+                "type": "modifier",
+                "modifier": "Control",
+                "text": "Control"
+            }
+        },
+        {
+            "main_action" : {
                 "type": "key",
                 "key" : "F1"
             }

=== modified file 'src/app/qml/KeyboardRows/jsonParser.js'
--- src/app/qml/KeyboardRows/jsonParser.js	2015-07-13 17:36:57 +0000
+++ src/app/qml/KeyboardRows/jsonParser.js	2016-01-12 09:58:28 +0000
@@ -22,12 +22,19 @@
         raiseException("string is missing in", stringObject);
 }
 
+function validateModifierAction(modifierObject) {
+    if (!modifierObject.modifier)
+        return raiseException("modifier is missing");
+    if (!isAllowed(modifierObject.modifier, ["Control", "Shift", "Alt"]))
+        return raiseException("modifier is invalid in", modifierObject);
+}
+
 function validateAction(actionObject) {
     if (!actionObject.type)
         raiseException("type is missing in", actionObject);
-    if (!isAllowed(actionObject.type, ["key", "string"]))
+    if (!isAllowed(actionObject.type, ["key", "string", "modifier"]))
         raiseException("type must be either key or string in", actionObject);
-    if (!(actionObject.type === "key" ? actionObject.key : actionObject.string))
+    if (!actionObject[actionObject.type])
         raiseException(actionObject.type + " is missing in", actionObject);
     if (actionObject.id && actionObject.text)
         raiseException("Should not define id and text together in", actionObject);
@@ -45,6 +52,9 @@
     case "string":
         validateStringAction(actionObject);
         break;
+    case "modifier":
+        validateModifierAction(actionObject);
+        break;
     }
 }
 

=== modified file 'src/app/qml/TerminalPage.qml'
--- src/app/qml/TerminalPage.qml	2015-07-13 20:25:21 +0000
+++ src/app/qml/TerminalPage.qml	2016-01-12 09:58:28 +0000
@@ -140,6 +140,7 @@
             height: units.gu(5)
             onSimulateKey: terminal.simulateKeyPress(key, mod, true, 0, "");
             onSimulateCommand: terminal.session.sendText(command);
+            onSimulateModifier: terminal.session.addNextModifiers(modifiers);
         }
     }
 

=== modified file 'src/plugin/qmltermwidget/lib/Emulation.cpp'
--- src/plugin/qmltermwidget/lib/Emulation.cpp	2014-11-12 00:10:12 +0000
+++ src/plugin/qmltermwidget/lib/Emulation.cpp	2016-01-12 09:58:28 +0000
@@ -55,7 +55,8 @@
   _codec(0),
   _decoder(0),
   _keyTranslator(0),
-  _usesMouse(false)
+  _usesMouse(false),
+  _nextModifiers(0)
 {
   // create screens with a default size
   _screen[0] = new Screen(40,80);
@@ -359,6 +360,11 @@
   return QSize(_currentScreen->getColumns(), _currentScreen->getLines());
 }
 
+void Emulation::addNextModifiers(int modifiers)
+{
+    _nextModifiers ^= modifiers;
+}
+
 ushort ExtendedCharTable::extendedCharHash(ushort* unicodePoints , ushort length) const
 {
     ushort hash = 0;

=== modified file 'src/plugin/qmltermwidget/lib/Emulation.h'
--- src/plugin/qmltermwidget/lib/Emulation.h	2014-11-12 00:10:12 +0000
+++ src/plugin/qmltermwidget/lib/Emulation.h	2016-01-12 09:58:28 +0000
@@ -218,6 +218,8 @@
    */
   bool programUsesMouse() const;
 
+  void addNextModifiers(int modifiers);
+
 public slots: 
 
   /** Change the size of the emulation's image */
@@ -442,6 +444,7 @@
   const QTextCodec* _codec;
   QTextDecoder* _decoder;
   const KeyboardTranslator* _keyTranslator; // the keyboard layout
+  int _nextModifiers;
 
 protected slots:
   /** 

=== modified file 'src/plugin/qmltermwidget/lib/Vt102Emulation.cpp'
--- src/plugin/qmltermwidget/lib/Vt102Emulation.cpp	2014-11-12 00:10:12 +0000
+++ src/plugin/qmltermwidget/lib/Vt102Emulation.cpp	2016-01-12 09:58:28 +0000
@@ -968,6 +968,14 @@
             textToSend += _codec->fromUnicode(event->text());
         }
 
+        if (textToSend.length() == 1 && _nextModifiers)
+        {
+            char first = textToSend[0];
+            if ((_nextModifiers & Qt::ControlModifier) && first >= 0x4f && first < 0x7f)
+                textToSend[0] = first & 0x1f;
+            _nextModifiers = 0;
+        }
+
         sendData( textToSend.constData() , textToSend.length() );
     }
     else

=== modified file 'src/plugin/qmltermwidget/src/ksession.cpp'
--- src/plugin/qmltermwidget/src/ksession.cpp	2014-11-12 00:10:12 +0000
+++ src/plugin/qmltermwidget/src/ksession.cpp	2016-01-12 09:58:28 +0000
@@ -22,6 +22,7 @@
 
 // Own
 #include "ksession.h"
+#include "Emulation.h"
 
 // Qt
 #include <QTextCodec>
@@ -211,6 +212,11 @@
 //    }
 }
 
+void KSession::addNextModifiers(int modifiers)
+{
+    m_session->emulation()->addNextModifiers(modifiers);
+}
+
 void KSession::setFlowControlEnabled(bool enabled)
 {
     m_session->setFlowControlEnabled(enabled);

=== modified file 'src/plugin/qmltermwidget/src/ksession.h'
--- src/plugin/qmltermwidget/src/ksession.h	2014-11-12 00:10:12 +0000
+++ src/plugin/qmltermwidget/src/ksession.h	2016-01-12 09:58:28 +0000
@@ -122,6 +122,7 @@
     void sendText(QString text);
     // Send some text to terminal
     void sendKey(int rep, int key, int mod) const;
+    void addNextModifiers(int modifiers);
 
 
 protected slots:


Follow ups