[X2Go-Commits] [x2goclient] 02/03: Disable settings editing if a directory with central settings is exists.

git-admin at x2go.org git-admin at x2go.org
Wed Dec 2 17:32:22 CET 2015


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

x2go pushed a commit to branch master
in repository x2goclient.

commit 1828803ce0c086829378b0015f8069ca8518a3a2
Author: Oleksandr Shneyder <o.shneyder at phoca-gmbh.de>
Date:   Wed Dec 2 16:26:16 2015 +0100

    Disable settings editing if a directory with central settings is exists.
---
 debian/changelog     |    1 +
 src/exportdialog.cpp |    5 +++++
 src/onmainwindow.cpp |   28 +++++++++++++++++++---------
 src/x2gosettings.cpp |    9 +++++++++
 src/x2gosettings.h   |    1 +
 5 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 0445e4e..c406240 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -17,6 +17,7 @@ x2goclient (4.0.5.1-0x2go1) UNRELEASED; urgency=low
     - Configure audio input in pulseaudio on Windows.
     - Reconnect ssh broker in case of IO Error.
     - Reformat source onmainwindow.cpp.
+    - Disable settings editing if a directory with central settings is exists.
 
   [ Mike Gabriel ]
   * New upstream release (4.0.5.1):
diff --git a/src/exportdialog.cpp b/src/exportdialog.cpp
index 6d4495c..6017d24 100644
--- a/src/exportdialog.cpp
+++ b/src/exportdialog.cpp
@@ -52,6 +52,11 @@ ExportDialog::ExportDialog ( QString sid,QWidget * par, Qt::WFlags f )
     editSession=new QPushButton ( tr ( "&Preferences ..." ),fr );
     newDir=new QPushButton ( tr ( "&Custom folder ..." ),fr );
 
+    if(X2goSettings::centralSettings())
+    {
+        editSession->setEnabled(false);
+        editSession->setVisible(false);
+    }
 
     QVBoxLayout* actLay=new QVBoxLayout();
     actLay->addWidget ( exportDir );
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index d228607..4e94f9a 100644
--- a/src/onmainwindow.cpp
+++ b/src/onmainwindow.cpp
@@ -178,6 +178,11 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent )
     xDisplay=0;
 #endif
 
+    if(X2goSettings::centralSettings())
+    {
+        x2goInfof(0)<<"using central configuration";
+        noSessionEdit=true;
+    }
 
     cleanAskPass();
     setWindowTitle ( tr ( "X2Go Client" ) );
@@ -924,8 +929,10 @@ void ONMainWindow::initWidgetsNormal()
     if ( drawMenu )
     {
         QMenu* menu_sess=menuBar()->addMenu ( tr ( "&Session" ) );
-        QMenu* menu_opts=menuBar()->addMenu ( tr ( "&Options" ) );
-        if (!brokerMode)
+        QMenu* menu_opts=0;
+        if(!X2goSettings::centralSettings())
+            menu_opts=menuBar()->addMenu ( tr ( "&Options" ) );
+        if (!brokerMode && !X2goSettings::centralSettings())
         {
             menu_sess->addAction ( act_new );
             menu_sess->addAction ( act_edit );
@@ -936,12 +943,15 @@ void ONMainWindow::initWidgetsNormal()
             menu_sess->addSeparator();
         }
         menu_sess->addAction ( act_exit );
-        menu_opts->addAction ( act_set );
-        menu_opts->addAction ( act_tb );
-        if (changeBrokerPass)
-            menu_opts->addAction(act_changeBrokerPass);
-        if (connTest)
-            menu_opts->addAction(act_testCon);
+        if(!X2goSettings::centralSettings())
+        {
+            menu_opts->addAction ( act_set );
+            menu_opts->addAction ( act_tb );
+            if (changeBrokerPass)
+                menu_opts->addAction(act_changeBrokerPass);
+            if (connTest)
+                menu_opts->addAction(act_testCon);
+        }
 
         QMenu* menu_help=menuBar()->addMenu ( tr ( "&Help" ) );
         if (supportMenuFile!=QString::null)
@@ -965,7 +975,7 @@ void ONMainWindow::initWidgetsNormal()
         if (connTest)
             stb->addAction(act_testCon);
 
-        if ( !showToolBar )
+        if ( !showToolBar  || X2goSettings::centralSettings())
             stb->hide();
         connect ( act_tb,SIGNAL ( toggled ( bool ) ),stb,
                   SLOT ( setVisible ( bool ) ) );
diff --git a/src/x2gosettings.cpp b/src/x2gosettings.cpp
index 32161e2..943cdf0 100644
--- a/src/x2gosettings.cpp
+++ b/src/x2gosettings.cpp
@@ -20,6 +20,7 @@
 #include "x2gologdebug.h"
 #include "onmainwindow.h"
 #include <QTemporaryFile>
+#include <QDir>
 
 X2goSettings::X2goSettings(QString fileContent, QSettings::Format format)
 {
@@ -70,4 +71,12 @@ X2goSettings::~X2goSettings()
         delete cfgFile;
 }
 
+bool X2goSettings::centralSettings()
+{
+#ifndef Q_OS_WIN
+    QDir d("/etc/x2goclient/settings");
+    x2goDebug<<d.exists();
+    return d.exists();
+#endif
+}
 
diff --git a/src/x2gosettings.h b/src/x2gosettings.h
index dd5913b..a72005c 100644
--- a/src/x2gosettings.h
+++ b/src/x2gosettings.h
@@ -31,6 +31,7 @@ public:
     X2goSettings ( QString fileContent, QSettings::Format format);
     ~X2goSettings();
 
+    static bool centralSettings();
     QSettings* setting()
     {
         return set;

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


More information about the x2go-commits mailing list