[X2Go-Commits] [x2goclient] 01/01: Add "clipboard" parameter to session profile and to command line options. Replace qCritical() with printError() by argument parsing.

git-admin at x2go.org git-admin at x2go.org
Mon Jun 30 16:01:22 CEST 2014


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2goclient.

commit ca8724654564726b30bc59dbb9496bd837cc06e0
Author: Oleksandr Shneyder <o.shneyder at phoca-gmbh.de>
Date:   Mon Jun 30 16:01:16 2014 +0200

    Add "clipboard" parameter to session profile and to command line options. Replace qCritical() with printError() by argument parsing.
---
 debian/changelog   |    2 +
 onmainwindow.cpp   |  106 +++++++++++++++++++++++++++++++++-------------------
 onmainwindow.h     |    6 +++
 settingswidget.cpp |   55 ++++++++++++++++++++++++++-
 settingswidget.h   |    5 +++
 5 files changed, 134 insertions(+), 40 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 593b55e..10995b6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -45,6 +45,8 @@ x2goclient (4.0.2.1-0x2go1) UNRELEASED; urgency=low
       enabled.
     - Fork x2goclient on windows and terminate child processes if x2go client
       crashed. (Fixes: #159).
+    - Add "clipboard" parameter to session profile and to command line options.
+      Replace qCritical() with printError() by argument parsing.
 
   [ Mike DePaulo ]
   * New upstream release (4.0.2.1):
diff --git a/onmainwindow.cpp b/onmainwindow.cpp
index 835c835..6f2e89c 100644
--- a/onmainwindow.cpp
+++ b/onmainwindow.cpp
@@ -102,6 +102,7 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent )
     defaultPack="16m-jpeg";
     defaultQuality=9;
     defaultLayout<<tr ( "us" );
+    defaultClipboardMode="both";
     defaultKbdType="auto";
     defaultCmd="KDE";
     defaultSshPort=sshPort=clientSshPort="22";
@@ -3715,6 +3716,7 @@ void ONMainWindow::startNewSession()
     QString layout;
     QString type;
     QString command;
+    QString clipMode=defaultClipboardMode;
     QString xdmcpServer;
     runRemoteCommand=true;
     QString host=QString::null;
@@ -3811,6 +3813,9 @@ void ONMainWindow::startNewSession()
         speed=st->setting()->value ( sid+"/speed",
                                      ( QVariant ) defaultLink ).toInt();
 
+        clipMode=st->setting()->value ( sid+"/clipboard",
+                                        ( QVariant ) defaultClipboardMode ).toString();
+
         usekbd=st->setting()->value ( sid+"/usekbd",
                                       ( QVariant ) defaultSetKbd ).toBool();
         layout=st->setting()->value ( sid+"/layout",
@@ -4040,7 +4045,9 @@ void ONMainWindow::startNewSession()
         cmd+=sessTypeStr+QString::number ( shadowMode ) +"XSHAD"+
              shadowUser+"XSHAD"+shadowDisplay;
     }
+
     resumingSession.fullscreen=fullscreen;
+    cmd+=" "+clipMode;
 
     x2goDebug<<"Executing remote command: "<<cmd;
 
@@ -4068,6 +4075,8 @@ void ONMainWindow::resumeSession ( const x2goSession& s )
     QString host=s.server;
     bool rootless=false;
 
+    QString clipMode=defaultClipboardMode;
+
     QString pack;
     bool fullscreen;
     int height;
@@ -4129,6 +4138,10 @@ void ONMainWindow::resumeSession ( const x2goSession& s )
                                        defaultQuality ).toInt();
         speed=st->setting()->value ( sid+"/speed",
                                      ( QVariant ) defaultLink ).toInt();
+
+        clipMode=st->setting()->value ( sid+"/clipboard",
+                                        ( QVariant ) defaultClipboardMode ).toString();
+
         usekbd=st->setting()->value ( sid+"/usekbd",
                                       ( QVariant ) defaultSetKbd ).toBool();
         layout=st->setting()->value ( sid+"/layout",
@@ -4289,6 +4302,7 @@ void ONMainWindow::resumeSession ( const x2goSession& s )
         cmd += "1";
     else
         cmd += "0";
+    cmd +=" "+clipMode;
 
     sshConnection->executeCommand ( cmd, this,  SLOT ( slotRetResumeSess ( bool, QString,
                                     int ) ));
@@ -6793,6 +6807,10 @@ bool ONMainWindow::parseParameter ( QString param )
     {
         return linkParameter ( value );
     }
+    if ( setting=="--clipboard" )
+    {
+        return clipboardParameter ( value );
+    }
     if ( setting=="--sound" )
     {
         return soundParameter ( value );
@@ -7047,13 +7065,28 @@ bool ONMainWindow::linkParameter ( QString value )
         defaultLink=LAN;
     else
     {
-        qCritical (
-            "%s",tr (
-                "wrong value for argument\"--link\""
-            ).toLocal8Bit().data() );
+        printError( tr (
+                        "wrong value for argument\"--link\""
+                    ).toLocal8Bit().data() );
         return false;
     }
     return true;
+}
+
+bool ONMainWindow::clipboardParameter ( QString value )
+{
+    if ( value=="both"  || value=="client" || value=="server"||value == "none")
+    {
+        defaultClipboardMode=value;
+        return true;
+    }
+    else
+    {
+        printError( tr (
+                        "wrong value for argument\"--clipboard\""
+                    ).toLocal8Bit().data() );
+        return false;
+    }
 
 }
 
@@ -7065,9 +7098,8 @@ bool ONMainWindow::soundParameter ( QString val )
         defaultUseSound=false;
     else
     {
-        qCritical (
-            "%s",tr ( "wrong value for "
-                      "argument\"--sound\"" ).toLocal8Bit().data() );
+        printError( tr ( "wrong value for "
+                         "argument\"--sound\"" ).toLocal8Bit().data() );
         return false;
     }
     return true;
@@ -7082,10 +7114,9 @@ bool ONMainWindow::geometry_par ( QString val )
         QStringList res=val.split ( "x" );
         if ( res.size() !=2 )
         {
-            qCritical (
-                "%s",tr (
-                    "wrong value for argument\"--geometry\"" ).
-                toLocal8Bit().data() );
+            printError( tr (
+                            "wrong value for argument\"--geometry\"" ).
+                        toLocal8Bit().data() );
             return false;
         }
         bool o1,o2;
@@ -7093,10 +7124,9 @@ bool ONMainWindow::geometry_par ( QString val )
         defaultHeight=res[1].toInt ( &o2 );
         if ( ! ( defaultWidth >0 && defaultHeight >0 && o1 && o2 ) )
         {
-            qCritical (
-                "%s",tr (
-                    "wrong value for argument\"--geometry\"" ).
-                toLocal8Bit().data() );
+            printError( tr (
+                            "wrong value for argument\"--geometry\"" ).
+                        toLocal8Bit().data() );
             return false;
         }
     }
@@ -7111,10 +7141,9 @@ bool ONMainWindow::setKbd_par ( QString val )
         defaultSetKbd=false;
     else
     {
-        qCritical (
-            "%s",tr (
-                "wrong value for argument\"--set-kbd\"" ).
-            toLocal8Bit().data() );
+        printError( tr (
+                        "wrong value for argument\"--set-kbd\"" ).
+                    toLocal8Bit().data() );
         return false;
     }
     return true;
@@ -7128,10 +7157,9 @@ bool ONMainWindow::ldapParameter ( QString val )
     QStringList lst=ldapstring.split ( ':',QString::SkipEmptyParts );
     if ( lst.size() !=3 )
     {
-        qCritical (
-            "%s",tr (
-                "wrong value for argument\"--ldap\"" ).
-            toLocal8Bit().data() );
+        printError( tr (
+                        "wrong value for argument\"--ldap\"" ).
+                    toLocal8Bit().data() );
         return false;
     }
     ldapOnly=true;
@@ -7150,10 +7178,9 @@ bool ONMainWindow::ldap1Parameter ( QString val )
     QStringList lst=ldapstring.split ( ':',QString::SkipEmptyParts );
     if ( lst.size() !=2 )
     {
-        qCritical (
-            "%s",tr (
-                "wrong value for argument\"--ldap1\"" ).
-            toLocal8Bit().data() );
+        printError( tr (
+                        "wrong value for argument\"--ldap1\"" ).
+                    toLocal8Bit().data() );
         return false;
     }
     ldapServer1=lst[0];
@@ -7169,10 +7196,10 @@ bool ONMainWindow::ldap2Parameter ( QString val )
     QStringList lst=ldapstring.split ( ':',QString::SkipEmptyParts );
     if ( lst.size() !=2 )
     {
-        qCritical ( "%s",
-                    tr (
-                        "wrong value for argument\"--ldap2\"" ).
-                    toLocal8Bit().data() );
+        printError(
+            tr (
+                "wrong value for argument\"--ldap2\"" ).
+            toLocal8Bit().data() );
         return false;
     }
     ldapServer2=lst[0];
@@ -7224,8 +7251,7 @@ bool ONMainWindow::packParameter ( QString val )
         }
     }
     file.close();
-    qCritical ( "%s",tr ( "wrong value for argument\"--pack\"" ).
-                toLocal8Bit().data() );
+    printError ( tr("wrong value for argument\"--pack\"" ));
     return false;
 }
 
@@ -7299,6 +7325,8 @@ void ONMainWindow::showHelp()
         "default 'adsl'\n"
         "--pack=<packmethod>\t\t set default pack method, default "
         "'16m-jpeg-9'\n"
+        "--clipboard=<both|client|server|none>\t set default clipboard mode, "
+        "default 'both'\n"
         "--kbd-layout=<layout>\t\t set default keyboard layout or layouts\n"
         "\t\t\t\t comma separated\n"
         "--kbd-type=<typed>\t\t set default keyboard type\n"
@@ -7308,7 +7336,7 @@ void ONMainWindow::showHelp()
         "applications\" mode\n"
         "--session-conf=<file>\t\t path to alternative session config\n"
         "--tray-icon\t\t\t force to show session trayicon\n"
-        "--close-disconnect\t\t close X2Go Client after disconnect\n";
+        "--close-disconnect\t\t close X2Go Client after disconnect\n"
         "--hide-foldersharing\t\t\t hide all folder sharing related options\n";
 
     qCritical ( "%s",helpMsg.toLocal8Bit().data() );
@@ -11392,7 +11420,7 @@ void ONMainWindow::printSshDError_startupFailure()
 
                                  "If you see this message, please report a bug against\n"
                                  "the X2Go bugtracker."
-                            ),
+                               ),
                             QMessageBox::Ok,QMessageBox::NoButton );
 #else
     if ( closeEventSent )
@@ -11404,7 +11432,7 @@ void ONMainWindow::printSshDError_startupFailure()
 
                                  "Please ask your system administrator to provide the SSH\n"
                                  "service on your computer."
-                            ),
+                               ),
                             QMessageBox::Ok,QMessageBox::NoButton );
 #endif
 }
@@ -11415,7 +11443,7 @@ void ONMainWindow::printSshDError_noHostPubKey()
         return;
     QMessageBox::critical ( 0l,tr ( "SSH Error" ),
                             tr ( "SSH daemon failed to open the application's public host key."
-                            ),
+                               ),
                             QMessageBox::Ok,QMessageBox::NoButton );
 }
 
@@ -11426,7 +11454,7 @@ void ONMainWindow::printSshDError_noExportPubKey()
     QMessageBox::critical ( 0l,tr ( "SSH Error" ),
                             tr ( "SSH daemon failed to open the application's public key\n"
                                  "used for exporting folders and printers."
-                            ),
+                               ),
                             QMessageBox::Ok,QMessageBox::NoButton );
 }
 
@@ -11437,7 +11465,7 @@ void ONMainWindow::printSshDError_noAuthorizedKeysFile()
     QMessageBox::critical ( 0l,tr ( "SSH Error" ),
                             tr ( "SSH daemon failed to open the application's\n"
                                  "authoized_keys file."
-                            ),
+                               ),
                             QMessageBox::Ok,QMessageBox::NoButton );
 }
 
diff --git a/onmainwindow.h b/onmainwindow.h
index 1764993..88b5da7 100644
--- a/onmainwindow.h
+++ b/onmainwindow.h
@@ -424,6 +424,10 @@ public:
     {
         return defaultSshPort;
     }
+    QString getDefaultClipboardMode()
+    {
+        return defaultClipboardMode;
+    }
     QString getDefaultKbdType()
     {
         return defaultKbdType;
@@ -598,6 +602,7 @@ private:
     QStringList defaultLayout;
     QString selectedLayout;
     QString defaultKbdType;
+    QString defaultClipboardMode;
     QString defaultCmd;
     bool defaultSetDPI;
     uint defaultDPI;
@@ -887,6 +892,7 @@ private:
     x2goSession getSelectedSession();
     bool parseParameter ( QString param );
     bool linkParameter ( QString value );
+    bool clipboardParameter ( QString value );
     bool geometry_par ( QString value );
     bool setKbd_par ( QString value );
     bool ldapParameter ( QString value );
diff --git a/settingswidget.cpp b/settingswidget.cpp
index 4add99c..5b634a1 100644
--- a/settingswidget.cpp
+++ b/settingswidget.cpp
@@ -49,11 +49,13 @@ SettingsWidget::SettingsWidget ( QString id, ONMainWindow * mw,
     tabSettings->addTab ( sbgr,tr ( "Sound" ) );
 #else
     QGroupBox *dgb=new QGroupBox ( tr ( "&Display" ),this );
+    clipGr=new QGroupBox ( tr ( "&Clipboard Mode" ),this );
     kgb=new QGroupBox ( tr ( "&Keyboard" ),this );
     sbgr=new QGroupBox ( tr ( "Sound" ),this );
 #endif
     QVBoxLayout *dbLay = new QVBoxLayout ( dgb );
-    QVBoxLayout  *sndLay=new QVBoxLayout ( sbgr );
+    QVBoxLayout *sndLay=new QVBoxLayout ( sbgr );
+    QVBoxLayout *cbLay=new QVBoxLayout ( clipGr );
     QHBoxLayout* sLay=new QHBoxLayout ( );
     QVBoxLayout* sLay_sys=new QVBoxLayout ( );
     QVBoxLayout* sLay_opt=new QVBoxLayout ( );
@@ -150,6 +152,20 @@ SettingsWidget::SettingsWidget ( QString id, ONMainWindow * mw,
 #endif
 
 
+    rbClipBoth=new QRadioButton(tr("Bidirectional copy and paste"), clipGr);
+    rbClipClient=new QRadioButton(tr("Copy and paste from client to server"), clipGr);
+    rbClipServer=new QRadioButton(tr("Copy and paste from server to client"), clipGr);
+    rbClipNone=new QRadioButton(tr("Disable clipboard completely"), clipGr);
+    cbLay->addWidget(rbClipBoth);
+    cbLay->addWidget(rbClipClient);
+    cbLay->addWidget(rbClipServer);
+    cbLay->addWidget(rbClipNone);
+    QButtonGroup* clipRadioGroup=new QButtonGroup(clipGr);
+    clipRadioGroup->addButton(rbClipBoth);
+    clipRadioGroup->addButton(rbClipClient);
+    clipRadioGroup->addButton(rbClipServer);
+    clipRadioGroup->addButton(rbClipNone);
+
 
     rbKbdAuto=new QRadioButton(tr("Auto detect keyboard settings"),kgb);
     rbKbdNoSet=new QRadioButton(tr("Do not configure keyboard"),kgb);
@@ -240,6 +256,7 @@ SettingsWidget::SettingsWidget ( QString id, ONMainWindow * mw,
 #endif
 #ifndef Q_WS_HILDON
     setLay->addWidget ( dgb );
+    setLay->addWidget ( clipGr );
     setLay->addWidget ( kgb );
     setLay->addWidget ( sbgr );
 #ifdef Q_OS_LINUX
@@ -330,6 +347,7 @@ void SettingsWidget::slot_kbdClicked()
 void SettingsWidget::setDirectRdp(bool direct)
 {
     cbClientPrint->setVisible(!direct);
+    clipGr->setVisible(!direct);
     kgb->setVisible(!direct);
     sbgr->setVisible(!direct);
     cbSetDPI->setVisible(!direct);
@@ -568,6 +586,26 @@ void SettingsWidget::readConfig()
         st.setting()->value ( sessionId+"/dpi",
                               ( QVariant ) mainWindow->getDefaultDPI() ).toUInt() );
 
+    QString clipboard=st.setting()->value ( sessionId+"/clipboard",
+                                            ( QVariant ) mainWindow->getDefaultClipboardMode()
+                                          ).toString();
+    if(clipboard =="both")
+    {
+        rbClipBoth->setChecked(true);
+    }
+    if(clipboard =="client")
+    {
+        rbClipClient->setChecked(true);
+    }
+    if(clipboard =="server")
+    {
+        rbClipServer->setChecked(true);
+    }
+    if(clipboard =="none")
+    {
+        rbClipNone->setChecked(true);
+    }
+
     QString ktype=st.setting()->value ( sessionId+"/type",
                                         ( QVariant ) mainWindow->getDefaultKbdType()
                                       ).toString();
@@ -675,6 +713,8 @@ void SettingsWidget::setDefaults()
     DPI->setValue ( mainWindow->getDefaultDPI() );
     DPI->setEnabled ( mainWindow->getDefaultSetDPI() );
 
+    rbClipBoth->setChecked(true);
+
     rbKbdAuto->setChecked ( mainWindow->getDefaultSetKbd() );
     rbKbdNoSet->setChecked ( !mainWindow->getDefaultSetKbd() );
     rbKbdSet->setChecked (false );
@@ -752,6 +792,19 @@ void SettingsWidget::saveSettings()
     st.setting()->setValue ( sessionId+"/xinerama",
                              ( QVariant ) cbXinerama->isChecked() );
 
+    QString clipMode;
+    if(rbClipBoth->isChecked())
+        clipMode="both";
+    if(rbClipClient->isChecked())
+        clipMode="client";
+    if(rbClipServer->isChecked())
+        clipMode="server";
+    if(rbClipNone->isChecked())
+        clipMode="none";
+    st.setting()->setValue ( sessionId+"/clipboard",
+                             ( QVariant ) clipMode );
+
+
     st.setting()->setValue ( sessionId+"/usekbd",
                              ( QVariant ) !rbKbdNoSet->isChecked() );
 
diff --git a/settingswidget.h b/settingswidget.h
index 816a762..9036529 100644
--- a/settingswidget.h
+++ b/settingswidget.h
@@ -98,6 +98,11 @@ private:
     QList <QMainWindow*> identWins;
     QGroupBox *kgb;
     QGroupBox *sbgr;
+    QGroupBox *clipGr;
+    QRadioButton *rbClipBoth;
+    QRadioButton *rbClipServer;
+    QRadioButton *rbClipClient;
+    QRadioButton *rbClipNone;
 
 #ifdef Q_OS_LINUX
     QGroupBox *rdpBox;

--
Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git


More information about the x2go-commits mailing list