← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~nikwen/ubuntu-terminal-app/exit-handling into lp:ubuntu-terminal-app

 

Niklas Wenzel has proposed merging lp:~nikwen/ubuntu-terminal-app/exit-handling into lp:ubuntu-terminal-app.

Commit message:
Add the ability to close tabs using the "exit" command.
Automatically close the application when the last tab was closed using the "exit" command.

Requested reviews:
  Ubuntu Terminal Developers (ubuntu-terminal-dev)
Related bugs:
  Bug #1372915 in Ubuntu Terminal App: "Typing exit in terminal app should close it or result in login prompt"
  https://bugs.launchpad.net/ubuntu-terminal-app/+bug/1372915

For more details, see:
https://code.launchpad.net/~nikwen/ubuntu-terminal-app/exit-handling/+merge/261770

Add the ability to close tabs using the "exit" command.
Automatically close the application when the last tab was closed using the "exit" command.

As discussed in LP: #1372915.
-- 
Your team Ubuntu Terminal Developers is requested to review the proposed merge of lp:~nikwen/ubuntu-terminal-app/exit-handling into lp:ubuntu-terminal-app.
=== modified file 'po/com.ubuntu.terminal.pot'
--- po/com.ubuntu.terminal.pot	2015-06-02 19:51:45 +0000
+++ po/com.ubuntu.terminal.pot	2015-06-11 17:58:06 +0000
@@ -8,8 +8,7 @@
 msgstr ""
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: \n"
-
-"POT-Creation-Date: 2015-04-02 14:49+0200\n"
+"POT-Creation-Date: 2015-06-11 19:52+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"
@@ -43,7 +42,7 @@
 msgstr ""
 
 #: ../src/app/qml/AuthenticationDialog.qml:50
-msgid "Ok"
+msgid "OK"
 msgstr ""
 
 #: ../src/app/qml/AuthenticationDialog.qml:62
@@ -54,7 +53,7 @@
 msgid "Authentication failed"
 msgstr ""
 
-#: ../src/app/qml/KeyboardBar.qml:163
+#: ../src/app/qml/KeyboardBar.qml:174
 msgid "Change Keyboard"
 msgstr ""
 

=== modified file 'src/app/qml/TabsModel.qml'
--- src/app/qml/TabsModel.qml	2014-11-17 21:12:53 +0000
+++ src/app/qml/TabsModel.qml	2015-06-11 17:58:06 +0000
@@ -11,6 +11,14 @@
             return;
 
         var termObject = terminalComponent.createObject(terminalPage.terminalContainer);
+        termObject.onSessionFinished.connect(function(session) {
+            for (var i = 0; i < tabsModel.count; i++) {
+                if (session === tabsModel.get(i).terminal.session) {
+                    removeTab(i);
+                    return;
+                }
+            }
+        })
         tabsModel.append({terminal: termObject});
 
         termObject.visible = false;
@@ -37,9 +45,14 @@
     }
 
     function removeTab(index) {
-        if (tabsModel.count <= 1)
+        if (tabsModel.count === 0 || index >= tabsModel.count)
             return;
+
         get(index).terminal.destroy();
+
+        if (tabsModel.count === 1) // The last tab was closed, probably by running the "exit" command (otherwise this is prevented by the UI)
+            Qt.quit();
+
         remove(index);
 
         // Decrease the selected index to keep the state consistent.

=== modified file 'src/app/qml/TerminalComponent.qml'
--- src/app/qml/TerminalComponent.qml	2015-03-23 11:12:46 +0000
+++ src/app/qml/TerminalComponent.qml	2015-06-11 17:58:06 +0000
@@ -4,6 +4,7 @@
 
 Component {
     id: terminalComponent
+
     QMLTermWidget {
         id: terminal
         width: parent.width
@@ -13,9 +14,13 @@
         font.family: settings.fontStyle
         font.pointSize: settings.fontSize
 
+        signal sessionFinished(var session);
+
         session: QMLTermSession {
             id: terminalSession
             initialWorkingDirectory: workdir
+
+            onFinished: terminal.sessionFinished(terminalSession);
         }
 
         QMLTermScrollbar {


Follow ups