on xenial help sign in
implement Ctrl+Alt+T to launch the terminal app
commit9e458f499f6714037109654420bbc5e16abb4627 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateSun 19 Mar 2017, 11:02 (10 years ago) parent593d500
4 files changed+52
qml/Components/KeyboardShortcutsOverlay.qml+13 qml/Stage/Stage.qml+15 tests/mocks/Unity/Application/ApplicationManager.cpp+5 tests/qmltests/tst_Shell.qml+19
qml/Components/KeyboardShortcutsOverlay.qml+13
@@ -110,6 +110,19 @@ Rectangle {
110110 Layout.maximumWidth: maxTextSize
111111 }
112112
113+ Label {
114+ text: i18n.tr("Ctrl + Alt + T")
115+ fontSize: "small"
116+ font.weight: Font.Medium
117+ }
118+ Label {
119+ text: i18n.tr("Starts the terminal application.")
120+ fontSize: "small"
121+ font.weight: Font.Light
122+ wrapMode: Text.Wrap
123+ Layout.maximumWidth: maxTextSize
124+ }
125+
113126
114127 // Launcher section
115128 Item { Layout.columnSpan: 2; height: units.gu(2) }
qml/Stage/Stage.qml+15
@@ -224,6 +224,21 @@ FocusScope {
224224 active: priv.focusedAppDelegate !== null
225225 }
226226
227+ GlobalShortcut {
228+ shortcut: Qt.ControlModifier|Qt.AltModifier|Qt.Key_T
229+ onTriggered: {
230+ const termAppName = "ubuntu-terminal-app";
231+ var termInfo = root.applicationManager.findApplication(termAppName);
232+ if (termInfo) {
233+ if (!termInfo.focused) {
234+ root.applicationManager.requestFocusApplication(termAppName);
235+ }
236+ } else {
237+ root.applicationManager.startApplication(termAppName);
238+ }
239+ }
240+ }
241+
227242 QtObject {
228243 id: priv
229244 objectName: "DesktopStagePrivate"
tests/mocks/Unity/Application/ApplicationManager.cpp+5
@@ -476,6 +476,11 @@ void ApplicationManager::buildListOfAvailableApplications()
476476 application->setIsTouchApp(false);
477477 m_availableApplications.append(application);
478478
479+ application = new ApplicationInfo(this);
480+ application->setAppId("ubuntu-terminal-app");
481+ application->setName("Terminal");
482+ m_availableApplications.append(application);
483+
479484 application = new ApplicationInfo(this);
480485 application->setAppId("primary-oriented-app");
481486 application->setName("Primary Oriented");
tests/qmltests/tst_Shell.qml+19
@@ -1460,6 +1460,25 @@ Rectangle {
14601460 confirmLoggedIn(true);
14611461 }
14621462
1463+ function test_terminalShortcut() {
1464+ loadShell("desktop");
1465+ shell.usageScenario = "desktop";
1466+ waitForRendering(shell);
1467+ swipeAwayGreeter();
1468+
1469+ // not running, should start
1470+ keyClick(Qt.Key_T, Qt.ControlModifier|Qt.AltModifier);
1471+ tryCompare(ApplicationManager, "focusedApplicationId", "ubuntu-terminal-app");
1472+
1473+ // start something else
1474+ ApplicationManager.startApplication("dialer-app");
1475+ tryCompare(ApplicationManager, "focusedApplicationId", "dialer-app");
1476+
1477+ // terminal running in background, should get focused
1478+ keyClick(Qt.Key_T, Qt.ControlModifier|Qt.AltModifier);
1479+ tryCompare(ApplicationManager, "focusedApplicationId", "ubuntu-terminal-app");
1480+ }
1481+
14631482 function test_launcherInverted_data() {
14641483 return [
14651484 {tag: "phone", formFactor: "phone", usageScenario: "phone", launcherInverted: true},