on xenial help sign in
Implement Ctrl+Alt+T to launch the terminal app (LP: #1673500)
21080b9Lukáš Tinkl
qml/Components/KeyboardShortcutsOverlay.qml+13
@@ -110,6 +110,19 @@ Rectangle {
110 Layout.maximumWidth: maxTextSize
110 Layout.maximumWidth: maxTextSize
111 }
111 }
112
112
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+
113
126
114 // Launcher section
127 // Launcher section
115 Item { Layout.columnSpan: 2; height: units.gu(2) }
128 Item { Layout.columnSpan: 2; height: units.gu(2) }
qml/Stage/Stage.qml+20
@@ -224,10 +224,30 @@ FocusScope {
224 active: priv.focusedAppDelegate !== null
224 active: priv.focusedAppDelegate !== null
225 }
225 }
226
226
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+
227 QtObject {
239 QtObject {
228 id: priv
240 id: priv
229 objectName: "DesktopStagePrivate"
241 objectName: "DesktopStagePrivate"
230
242
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+
231 property var focusedAppDelegate: null
251 property var focusedAppDelegate: null
232 property var foregroundMaximizedAppDelegate: null // for stuff like drop shadow and focusing maximized app by clicking panel
252 property var foregroundMaximizedAppDelegate: null // for stuff like drop shadow and focusing maximized app by clicking panel
233
253
tests/mocks/Unity/Application/ApplicationManager.cpp+5
@@ -474,6 +474,11 @@ void ApplicationManager::buildListOfAvailableApplications()
474 application->setIsTouchApp(false);
474 application->setIsTouchApp(false);
475 m_availableApplications.append(application);
475 m_availableApplications.append(application);
476
476
477+ application = new ApplicationInfo(this);
478+ application->setAppId("ubuntu-terminal-app");
479+ application->setName("Terminal");
480+ m_availableApplications.append(application);
481+
477 application = new ApplicationInfo(this);
482 application = new ApplicationInfo(this);
478 application->setAppId("primary-oriented-app");
483 application->setAppId("primary-oriented-app");
479 application->setName("Primary Oriented");
484 application->setName("Primary Oriented");
tests/qmltests/tst_Shell.qml+19
@@ -1460,6 +1460,25 @@ Rectangle {
1460 confirmLoggedIn(true);
1460 confirmLoggedIn(true);
1461 }
1461 }
1462
1462
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+
1463 function test_launcherInverted_data() {
1482 function test_launcherInverted_data() {
1464 return [
1483 return [
1465 {tag: "phone", formFactor: "phone", usageScenario: "phone", launcherInverted: true},
1484 {tag: "phone", formFactor: "phone", usageScenario: "phone", launcherInverted: true},