Subject: Close button in thinclient mode

From: Walid MOGHRABI <[email-masked]>
Date: Fri, 20 Oct 2017 11:36:23 +0200 (CEST)

package: x2goclient
priority: wishlist
tags: patch

This is a proposal patch for a close button in addition to the current halt button in thinclient mode.

Context : When logged in (right after the credentials prompt, in the client view where all available session slots are listed), if you entered by mistake and just want to get back to the credential form, there is o way to "logout".
Only possibilities are :
* halt button but it will shutdown the computer
* log to a remote X2Go session then logout which is a annoying process. 

The patch is not complete, currently it adds the button but the same way as for halt button and it simply close the client which is slow instead of just get back to the credential form which would be smoother and faster.

Regards,
Walid Moghrabi

TRAVAUX.COM
BAT I - PARC CEZANNE 2 290 AVENUE GALILEE - CS 80403
13591 AIX EN PROVENCE CEDEX 3

---
DISCLAIMER: This e-mail is private and confidential and may contain proprietary or legally privileged information. It is for the intended recipient only. If you have received this email in error, please notify the author by replying to it and then destroy it. If you are not the intended recipient you must not use, disclose, distribute, copy, print or rely on this e-mail or any attachment. Thank you

diff --git a/man/man1/x2goclient.1 b/man/man1/x2goclient.1
index 5738047..f4d2c22 100644
--- a/man/man1/x2goclient.1
+++ b/man/man1/x2goclient.1
@@ -191,6 +191,10 @@
 \*(T<\fB\-\-haltbt\fR\*(T>
 Show a "Shutdown" button in the top left corner of X2Go Client. When pressed, X2Go Client will create the file
 $HOME/.halt. An external script has to watch for this file and trigger a thinclient shutdown once it appears.
+.TP
+\*(T<\fB\-\-closebt\fR\*(T>
+Show a "Close" button in the top left corner of X2Go Client when logged in broker/thinclient mode. 
+When pressed, X2Go Client will be closed and automaticaly restarted if in thinclient mode.
 
 .SH PORTABLE OPTIONS
 X2Go Client can be installed on a USB-Flashdrive as a portable applications. If installed that way, the following
diff --git a/res/img/png/close-button.png b/res/img/png/close-button.png
new file mode 100644
index 0000000..f5b990f
--- /dev/null
+++ b/res/img/png/close-button.png
Binary files differ
diff --git a/res/resources.qrc b/res/resources.qrc
index 478bb55..eaddf61 100644
--- a/res/resources.qrc
+++ b/res/resources.qrc
@@ -16,6 +16,7 @@
        <file>img/png/sess_ico.png</file>
        <file>img/png/ico_440x180.png</file>
        <file>img/png/power-button.png</file>
+       <file>img/png/close-button.png</file>
        <file>img/icons/128x128/x2go.png</file>
        <file>img/icons/128x128/folder.png</file>
        <file>img/icons/128x128/x2gosession.png</file>
diff --git a/src/help.cpp b/src/help.cpp
index 0e54df6..6feef1e 100644
--- a/src/help.cpp
+++ b/src/help.cpp
@@ -125,6 +125,7 @@
   ADD_OPT ("--ldap-printing", QT_TRANSLATE_NOOP ("Help", "Allows client side printing in LDAP mode."));
   ADD_OPT ("--thinclient", QT_TRANSLATE_NOOP ("Help", "Enables thinclient mode. Starts without a window manager."));
   ADD_OPT ("--haltbt", QT_TRANSLATE_NOOP ("Help", "Enables shutdown button."));
+  ADD_OPT ("--closebt", QT_TRANSLATE_NOOP ("Help", "Enables close button."));
   ADD_OPT ("--add-to-known-hosts", QT_TRANSLATE_NOOP ("Help", "Adds RSA key fingerprint to \".ssh/known_hosts\" if authenticity of the server can't be determined."));
   ADD_OPT ("--ldap=<host:port:dn>", QT_TRANSLATE_NOOP ("Help", "Starts with LDAP support. Example: --ldap=ldapserver:389:o=organization,c=de"));
   ADD_OPT ("--ldap1=<host:port>", QT_TRANSLATE_NOOP ("Help", "Defines the first LDAP failover server."));
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index e1da2c8..369c38c 100644
--- a/src/onmainwindow.cpp
+++ b/src/onmainwindow.cpp
@@ -78,6 +78,7 @@
     thinMode=false;
     closeDisconnect=false;
     showHaltBtn=false;
+    showCloseBtn=false;
     defaultUseSound=true;
     defaultSetKbd=true;
     extStarted=false;
@@ -523,6 +524,25 @@
         connect(bHalt,SIGNAL(clicked()),this, SLOT(slotShutdownThinClient()));
     }
 
+    if (showCloseBtn)
+    {
+        QPushButton* bClose=new QPushButton(bgFrame);
+        QPixmap p(":/img/png/close-button.png");
+        bClose->setIcon(p);
+        bClose->setFocusPolicy(Qt::NoFocus);
+        bClose->setFixedSize(32,32);
+        if (showHaltBtn)
+        {
+            bClose->move(40,10);
+        }
+        else
+        {
+            bClose->move(10,10);
+        }
+        bClose->show();
+        connect(bClose,SIGNAL(clicked()),this, SLOT(close()));
+    }
+
     if (brokerMode)
     {
         broker=new HttpBrokerClient ( this, &config );
@@ -7405,6 +7425,11 @@
         showHaltBtn=true;
         return true;
     }
+    if (param == "--closebt")
+    {
+        showCloseBtn=true;
+        return true;
+    }
     if ( param=="--hide" )
     {
         startHidden=true;
diff --git a/src/onmainwindow.h b/src/onmainwindow.h
index 5d3d728..116b16c 100644
--- a/src/onmainwindow.h
+++ b/src/onmainwindow.h
@@ -796,6 +796,7 @@
     bool useLdap;
     bool showToolBar;
     bool showHaltBtn;
+    bool showCloseBtn;
     bool newSession;
     bool runStartApp;
     bool ldapOnly;