on xenial help sign in
Implement Ctrl+Alt+T to launch the terminal app (LP: #1673500)

Approved by: Michael Terry, Unity8 CI Bot

commit21080b9af8f8b546c410f1bdcedc95dc7971c604 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateTue 28 Mar 2017, 21:44 (10 years ago) parent78ebe21738283a
4 files changed+57
qml/Components/KeyboardShortcutsOverlay.qml+13 qml/Stage/Stage.qml+20 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+20
@@ -224,10 +224,30 @@ FocusScope {
224224 active: priv.focusedAppDelegate !== null
225225 }
226226
227+ GlobalShortcut {
228+ shortcut: Qt.ControlModifier|Qt.AltModifier|Qt.Key_T
229+ onTriggered: {
230+ // try in this order: snap pkg, new deb name, old deb name
231+ var candidates = ["ubuntu-terminal-app_ubuntu-terminal-app", "ubuntu-terminal-app", "com.ubuntu.terminal"];
232+ for (var i = 0; i < candidates.length; i++) {
233+ if (priv.startApp(candidates[i]))
234+ break;
235+ }
236+ }
237+ }
238+
227239 QtObject {
228240 id: priv
229241 objectName: "DesktopStagePrivate"
230242
243+ function startApp(appId) {
244+ if (root.applicationManager.findApplication(appId)) {
245+ return root.applicationManager.requestFocusApplication(appId);
246+ } else {
247+ return root.applicationManager.startApplication(appId) !== null;
248+ }
249+ }
250+
231251 property var focusedAppDelegate: null
232252 property var foregroundMaximizedAppDelegate: null // for stuff like drop shadow and focusing maximized app by clicking panel
233253
tests/mocks/Unity/Application/ApplicationManager.cpp+5
@@ -474,6 +474,11 @@ void ApplicationManager::buildListOfAvailableApplications()
474474 application->setIsTouchApp(false);
475475 m_availableApplications.append(application);
476476
477+ application = new ApplicationInfo(this);
478+ application->setAppId("ubuntu-terminal-app");
479+ application->setName("Terminal");
480+ m_availableApplications.append(application);
481+
477482 application = new ApplicationInfo(this);
478483 application->setAppId("primary-oriented-app");
479484 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},