The branch, master has been updated
via 1452cc08b0133fe54634eb6f8fd0f836b2f44035 (commit)
from 226c0053c56d1aa173ac1d31e0b7e0accb0315bb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 1452cc08b0133fe54634eb6f8fd0f836b2f44035
Author: Oleksandr Shneyder <o.shneyder(a)phoca-gmbh.de>
Date: Mon Oct 29 15:44:17 2012 +0100
Add class x2gosettings. Parsing command line options. Load config file settings.
-----------------------------------------------------------------------
Summary of changes:
profile.cpp | 83 ++++++++++---------
profile.h | 1 +
x2goapplication.cpp | 6 ++
x2goclient2.pro | 2 +
x2goclientconfig.cpp | 178 +++++++++++++++++++++++++++++++++++++++--
x2goclientconfig.h | 15 +++-
x2goclientconfigdetail.cpp | 87 ++++++++++++++++----
x2goclientconfigdetail.h | 8 +-
main.cpp => x2gosettings.cpp | 69 ++++++++++------
searchbar.h => x2gosettings.h | 28 +++----
10 files changed, 378 insertions(+), 99 deletions(-)
copy main.cpp => x2gosettings.cpp (51%)
copy searchbar.h => x2gosettings.h (80%)
The diff of changes is:
diff --git a/profile.cpp b/profile.cpp
index 3b10262..8352e71 100644
--- a/profile.cpp
+++ b/profile.cpp
@@ -22,6 +22,8 @@
#include "profileform.h"
#include "workarea.h"
#include "profilesettingsform.h"
+#include "x2goclientconfig.h"
+#include "x2goclientconfigdetail.h"
#include <QDebug>
#include <QPushButton>
#include <QScrollBar>
@@ -35,9 +37,36 @@
Profile::Profile(QWidget* parent, Qt::WindowFlags f): QFrame(parent, f)
{
//property initialization
- SSHPort=22;
+ setDefaultValues();
+ inited=false;
+ selected=false;
+ startDragPoint=-1;
+ f2SettingsConnector=0;
+ setFixedWidth(PROFILE_HEIGHT);
+
+ connect(X2GoApplication::instance()->get_profileForm(), SIGNAL(signalViewPortResized()), this, SLOT(slotUpdateProfileWidget()));
+ connect(X2GoApplication::instance()->get_profileForm(), SIGNAL(signalProfilesScrolled()), this, SLOT(slotUpdateProfileWidget()));
+ connect(X2GoApplication::instance()->get_profileForm()->scrollArea->verticalScrollBar(),
+ SIGNAL(rangeChanged(int,int)), this, SLOT(slotUpdateProfileWidget()));
+ connect(X2GoApplication::instance(), SIGNAL(signalUpdateProfiles()), this, SLOT(slotUpdateProfileWidget()));
+ connect(this, SIGNAL(signalDragFinished()), X2GoApplication::instance()->get_workArea(), SLOT(slotScrollToNearestForm()));
+ connect(this, SIGNAL(signalSelected(Profile*)), X2GoApplication::instance(), SIGNAL(signalProfilesSelectionChanged(Profile*)));
+ connect(X2GoApplication::instance(), SIGNAL(signalProfilesSelectionChanged(Profile*)),this, SLOT(slotProfileSelected(Profile*)));
+}
+
+
+Profile::~Profile()
+{
+
+}
+
+void Profile::setDefaultValues()
+{
+ X2GoClientConfig* cfg=X2GoApplication::instance()->get_clientConfig();
+ SSHPort=cfg->get_defaultSSHPort().get_value().toInt();
RDPPort=3389;
- autoLogin=false;
+ autoLogin=cfg->get_defaultAutoLogin().get_value().toBool();
+ user=cfg->get_defaultUserName().get_value().toString();
proxy=false;
proxyPort=22;
proxyAutoLogin=false;
@@ -46,23 +75,24 @@ Profile::Profile(QWidget* parent, Qt::WindowFlags f): QFrame(parent, f)
directRDP=false;
rootless=false;
published=false;
- sound=false;
- speed=ADSL;
- quality=9;
- method="16m-jpeg";
- fullscreen=false;
- displayWidth=1024;
- displayHeight=748;
+ sound=cfg->get_defaultSound().get_value().toBool();
+ desktop=cfg->get_defaultSessionCommand().get_value().toString();
+ speed=(SpeedType)cfg->get_defaultSpeed().get_value().toInt();
+ quality=cfg->get_defaultPackQuality().get_value().toInt();
+ method=cfg->get_defaultPackMethod().get_value().toString();
+ fullscreen=cfg->get_defaultSessionGeometryFullScreen().get_value().toBool();
+ displayWidth=cfg->get_defaultSessionGeometryWidth().get_value().toInt();
+ displayHeight=cfg->get_defaultSessionGeometryHeight().get_value().toInt();
multiDisplay=false;
displayNumber=1;
maxDimension=false;
- changeDPI=false;
- dpi=96;
- xinerama=false;
- changeKeyboard=true;
- keyboardModel="pc105/us";
- keyboardLayout="us";
- sound=true;
+ changeDPI=(cfg->get_defaultDpi().get_value().toInt()>0);
+ dpi=cfg->get_defaultDpi().get_value().toInt();
+ xinerama=cfg->get_defaultXinerama().get_value().toInt();
+ changeKeyboard=cfg->get_defaultChangeKbd().get_value().toInt();
+ keyboardModel=cfg->get_defaultKbdType().get_value().toString();
+ keyboardLayout=cfg->get_defaultKbdLayout().get_value().toString();
+ sound=cfg->get_defaultSound().get_value().toBool();
soundTunnel=true;
soundPort=4713;
useDefaultSoundPort=true;
@@ -79,27 +109,6 @@ Profile::Profile(QWidget* parent, Qt::WindowFlags f): QFrame(parent, f)
#ifdef Q_OS_LINUX
localFSEncoding=tr ( "ISO8859-1" );
#endif
-//
- inited=false;
- selected=false;
- startDragPoint=-1;
- f2SettingsConnector=0;
- setFixedWidth(PROFILE_HEIGHT);
-
- connect(X2GoApplication::instance()->get_profileForm(), SIGNAL(signalViewPortResized()), this, SLOT(slotUpdateProfileWidget()));
- connect(X2GoApplication::instance()->get_profileForm(), SIGNAL(signalProfilesScrolled()), this, SLOT(slotUpdateProfileWidget()));
- connect(X2GoApplication::instance()->get_profileForm()->scrollArea->verticalScrollBar(),
- SIGNAL(rangeChanged(int,int)), this, SLOT(slotUpdateProfileWidget()));
- connect(X2GoApplication::instance(), SIGNAL(signalUpdateProfiles()), this, SLOT(slotUpdateProfileWidget()));
- connect(this, SIGNAL(signalDragFinished()), X2GoApplication::instance()->get_workArea(), SLOT(slotScrollToNearestForm()));
- connect(this, SIGNAL(signalSelected(Profile*)), X2GoApplication::instance(), SIGNAL(signalProfilesSelectionChanged(Profile*)));
- connect(X2GoApplication::instance(), SIGNAL(signalProfilesSelectionChanged(Profile*)),this, SLOT(slotProfileSelected(Profile*)));
-}
-
-
-Profile::~Profile()
-{
-
}
int Profile::getProfileIndex()
diff --git a/profile.h b/profile.h
index f639cdf..e460070 100644
--- a/profile.h
+++ b/profile.h
@@ -111,6 +111,7 @@ private:
void initWidget();
void setupRegularWidget();
void setupSelectedWidget();
+ void setDefaultValues();
protected:
virtual void mouseMoveEvent ( QMouseEvent * event );
virtual void mousePressEvent ( QMouseEvent * event );
diff --git a/x2goapplication.cpp b/x2goapplication.cpp
index 7c6efda..deeff4c 100644
--- a/x2goapplication.cpp
+++ b/x2goapplication.cpp
@@ -48,6 +48,12 @@ X2GoApplication::X2GoApplication(int& argc, char** argv, int flags): QApplicatio
addTranslator (appNames, "OFFICE",tr ( "Office" ) );
addTranslator (appNames, "TERMINAL",tr ( "Terminal" ) );
clientConfig=new X2GoClientConfig;
+ clientConfig->loadConfigFiles();
+ if(!clientConfig->parseCommandLineArguments(arguments()))
+ {
+ qDebug()<<"error parsing command line arguments";
+ ::exit(-1);
+ }
}
X2GoApplication::~X2GoApplication()
diff --git a/x2goclient2.pro b/x2goclient2.pro
index cae1795..9f723f0 100755
--- a/x2goclient2.pro
+++ b/x2goclient2.pro
@@ -52,6 +52,7 @@ SOURCES += main.cpp \
messagebox.cpp \
x2goclientconfig.cpp \
x2goclientconfigdetail.cpp \
+ x2gosettings.cpp \
profile.cpp
HEADERS += mainwindow.h \
@@ -77,6 +78,7 @@ HEADERS += mainwindow.h \
messagebox.h \
x2goclientconfig.h \
x2goclientconfigdetail.h \
+ x2gosettings.h \
profile.h
LIBS += -lssh
diff --git a/x2goclientconfig.cpp b/x2goclientconfig.cpp
index 45bfd49..d0bbce9 100644
--- a/x2goclientconfig.cpp
+++ b/x2goclientconfig.cpp
@@ -20,7 +20,11 @@
#include "x2goclientconfig.h"
+#include "profile.h"
+#include "x2gosettings.h"
#include <QDir>
+#include <QTextStream>
+#include <QDebug>
X2GoClientConfig::X2GoClientConfig()
{
@@ -72,11 +76,12 @@ X2GoClientConfig::X2GoClientConfig()
initDetail(&defaultDpi, (int)0, "--dpi", QString::null, tr("set dpi of x2goagent, default - not set"));
initDetail(&defaultLink, (QString)"adsl", "--link", QString::null,
- tr("<modem|isdn|adsl|wan|lan> set default link type, default 'adsl'"));
- initDetail(&defaultPack, (QString)"16m-jpeg-9", "--pack", QString::null, tr("set default pack method, default '16m-jpeg-9'"));
+ tr("<modem|isdn|adsl|wan|lan> set default link type, default 'adsl'"), &X2GoClientConfig::checkLinkParameter);
+ initDetail(&defaultPack, (QString)"16m-jpeg-9", "--pack", QString::null, tr("set default pack method, default '16m-jpeg-9'"),
+ &X2GoClientConfig::checkPackParameter);
initDetail(&defaultSound, (bool)true, "--sound", QString::null, tr("enable or disable sound by default"));
- initDetail(&defaultSessionGeometry, (QString)"1024x768", "--geometry", QString::null,
- tr("<W>x<H>|fullscreen set default geometry, default value '800x600'"));
+ initDetail(&defaultSessionGeometry, (QString)"800x600", "--geometry", QString::null,
+ tr("<W>x<H>|fullscreen set default geometry, default value '800x600'"), &X2GoClientConfig::checkGeometryParameter);
initDetail(&defaultKbdLayout, (QString)tr("us"), "--kbd-layout", QString::null,
tr("set default keyboard layout or layouts comma separated"));
initDetail(&defaultKbdType, (QString)tr("pc105/us"), "--kbd-type", QString::null, tr("set default keyboard type"));
@@ -104,18 +109,181 @@ X2GoClientConfig::X2GoClientConfig()
initDetail(&readExportsFrom, (QString)QString::null, "--read-exports-from", QString::null,
tr("Read FS exports from this directory (thin client mode)"));
+
+ initDetail(&defaultSessionGeometryFullScreen, (bool)false, QString::null, QString::null,
+ tr("default fullscreen - not set directly, only via parsing \"defaultSessionGeometry\""));
+ initDetail(&defaultSessionGeometryWidth, (int)800, QString::null, QString::null,
+ tr("default width - not set directly, only via parsing \"defaultSessionGeometry\""));
+ initDetail(&defaultSessionGeometryHeight, (int)600, QString::null, QString::null,
+ tr("default height - not set directly, only via parsing \"defaultSessionGeometry\""));
+
+ initDetail(&defaultPackMethod, (QString)"16m-jpeg", QString::null, QString::null,
+ tr("default pack method - not set directly, only via parsing \"defaultPack\""));
+ initDetail(&defaultPackQuality, (int)9, QString::null, QString::null,
+ tr("default pack quality - not set directly, only via parsing \"defaultPack\""));
+
+ initDetail(&defaultSpeed, (int)Profile::ADSL, QString::null, QString::null,
+ tr("default connection speed - not set directly, only via parsing \"defaultLink\""));
+
}
void X2GoClientConfig::initDetail(X2GoClientConfigDetail* detail, QVariant value, QString commandLineParameter,
QString configFileParameter,
- QString description, bool (*checkSanityFunction)(QVariant value))
+ QString description, bool (X2GoClientConfig::*checkSanityFunction)(QVariant value))
{
detail->value=value;
detail->commandLineParameter=commandLineParameter;
detail->description=description;
detail->checkSanityFunction=checkSanityFunction;
detail->configFileParameter=configFileParameter;
+ detail->parent=this;
configDetails<<detail;
}
+bool X2GoClientConfig::checkPackParameter(QVariant value)
+{
+ QString val=value.toString();
+ QFile file ( ":/txt/packs" );
+ if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
+ return true;
+ QTextStream in ( &file );
+ while ( !in.atEnd() )
+ {
+ QString pc=in.readLine();
+ if ( pc.indexOf ( "-%" ) !=-1 )
+ {
+ pc=pc.left ( pc.indexOf ( "-%" ) );
+
+ QStringList pctails=val.split ( "-" );
+ QString pcq=pctails[pctails.size()-1];
+ pctails.removeLast();
+
+ if ( pctails.join ( "-" ) ==pc )
+ {
+ bool ok;
+ int v=pcq.toInt ( &ok );
+ if ( ok && v>=0 && v<=9 )
+ {
+ defaultPackMethod.value==pc;
+ defaultPackQuality.value=v;
+ file.close();
+ return true;
+ }
+ else
+ break;
+ }
+ }
+ else
+ {
+ if ( pc==val )
+ {
+ defaultPackMethod.value=val;
+ file.close();
+ return true;
+ }
+ }
+ }
+ file.close();
+ return false;
+}
+
+
+bool X2GoClientConfig::checkGeometryParameter(QVariant value)
+{
+ QString geometry=value.toString();
+ if(geometry.compare("fullscreen", Qt::CaseInsensitive)==0)
+ {
+ defaultSessionGeometryFullScreen.value=(bool)true;
+ return true;
+ }
+ QStringList res=geometry.split ( "x" );
+ if ( res.size() !=2 )
+ return false;
+ bool ok1,ok2;
+ int width=res[0].toInt ( &ok1 );
+ int height=res[1].toInt ( &ok2 );
+ if ( ! ( width >0 && height >0 && ok1 && ok2 ) )
+ return false;
+ defaultSessionGeometryHeight.value=height;
+ defaultSessionGeometryWidth.value=width;
+ return false;
+}
+bool X2GoClientConfig::checkLinkParameter(QVariant value)
+{
+ if(value.toString().compare("modem", Qt::CaseInsensitive)==0)
+ {
+ defaultSpeed.value=(int)Profile::MODEM;
+ return true;
+ }
+ if(value.toString().compare("isdn", Qt::CaseInsensitive)==0)
+ {
+ defaultSpeed.value=(int)Profile::ISDN;
+ return true;
+ }
+ if(value.toString().compare("adsl", Qt::CaseInsensitive)==0)
+ {
+ defaultSpeed.value=(int)Profile::ADSL;
+ return true;
+ }
+ if(value.toString().compare("wan", Qt::CaseInsensitive)==0)
+ {
+ defaultSpeed.value=(int)Profile::WAN;
+ return true;
+ }
+ if(value.toString().compare("lan", Qt::CaseInsensitive)==0)
+ {
+ defaultSpeed.value=(int)Profile::LAN;
+ return true;
+ }
+ return false;
+}
+
+bool X2GoClientConfig::parseCommandLineArguments(QStringList arguments)
+{
+ for(int i=1; i< arguments.size(); ++i)
+ {
+ QString option=arguments[i];
+ if(option.indexOf("--")!=0)
+ return false;
+ bool oldStyle=false;
+ QString argument=QString::null;
+ int delimPosition=option.indexOf("=");
+ if(delimPosition>0)
+ {
+ oldStyle=true;
+ argument=option.mid(delimPosition+1);
+ option=option.mid(0,delimPosition);
+ }
+ X2GoClientConfigDetail* detail=getDetailByCommandLineOption(option);
+ if(!detail)
+ return false;
+ if(!oldStyle && i<arguments.size()-1 && arguments[i+1].indexOf("--")!=0)
+ argument=arguments[++i];
+ if(!detail->parseCommandLineArgument(argument))
+ return false;
+ }
+ return true;
+}
+
+X2GoClientConfigDetail* X2GoClientConfig::getDetailByCommandLineOption(QString commandLineOption)
+{
+ foreach( X2GoClientConfigDetail* detail, configDetails)
+ {
+ if(detail->commandLineParameter==commandLineOption)
+ return detail;
+ }
+ return 0;
+}
+
+void X2GoClientConfig::loadConfigFiles()
+{
+ foreach( X2GoClientConfigDetail* detail, configDetails)
+ {
+ if(detail->configFileParameter==QString::null)
+ continue;
+ QStringList detailConfigPath=detail->configFileParameter.split(".");
+ X2goSettings configFile(detailConfigPath[0]);
+ detail->value=configFile.get_setting()->value(detailConfigPath[1]+"/"+detailConfigPath[2], detail->value);
+ }
+}
diff --git a/x2goclientconfig.h b/x2goclientconfig.h
index 38b2a32..37ee80d 100644
--- a/x2goclientconfig.h
+++ b/x2goclientconfig.h
@@ -23,6 +23,7 @@
#define X2GOCLIENTCONFIG_H
#include <QObject>
+#include <QStringList>
#include "x2goclientconfigdetail.h"
#include "x2goapplication.h"
@@ -69,9 +70,15 @@ class X2GoClientConfig: public QObject
X2GO_RO_PROPERTY(X2GoClientConfigDetail, defaultDpi)
X2GO_RO_PROPERTY(X2GoClientConfigDetail, defaultLink)
+ X2GO_RO_PROPERTY(X2GoClientConfigDetail, defaultSpeed)
X2GO_RO_PROPERTY(X2GoClientConfigDetail, defaultPack)
+ X2GO_RO_PROPERTY(X2GoClientConfigDetail, defaultPackMethod)
+ X2GO_RO_PROPERTY(X2GoClientConfigDetail, defaultPackQuality)
X2GO_RO_PROPERTY(X2GoClientConfigDetail, defaultSound)
X2GO_RO_PROPERTY(X2GoClientConfigDetail, defaultSessionGeometry)
+ X2GO_RO_PROPERTY(X2GoClientConfigDetail, defaultSessionGeometryFullScreen)
+ X2GO_RO_PROPERTY(X2GoClientConfigDetail, defaultSessionGeometryWidth)
+ X2GO_RO_PROPERTY(X2GoClientConfigDetail, defaultSessionGeometryHeight)
X2GO_RO_PROPERTY(X2GoClientConfigDetail, defaultKbdLayout)
X2GO_RO_PROPERTY(X2GoClientConfigDetail, defaultKbdType)
X2GO_RO_PROPERTY(X2GoClientConfigDetail, defaultChangeKbd)
@@ -98,11 +105,17 @@ class X2GoClientConfig: public QObject
X2GO_RO_PROPERTY(X2GoClientConfigDetail, readExportsFrom)
public:
X2GoClientConfig();
+ bool parseCommandLineArguments(QStringList arguments);
+ void loadConfigFiles();
private:
QList<X2GoClientConfigDetail*> configDetails;
private:
void initDetail(X2GoClientConfigDetail* detail, QVariant value, QString commandLineParameter, QString configFileParameter,
- QString description, bool (*checkSanityFunction)(QVariant value)=0);
+ QString description, bool (X2GoClientConfig::*checkSanityFunction)(QVariant value)=0);
+ bool checkLinkParameter(QVariant value);
+ bool checkGeometryParameter(QVariant value);
+ bool checkPackParameter(QVariant value);
+ X2GoClientConfigDetail* getDetailByCommandLineOption(QString commandLineOption);
};
#endif // X2GOCLIENTCONFIG_H
diff --git a/x2goclientconfigdetail.cpp b/x2goclientconfigdetail.cpp
index cba3b29..5b49515 100644
--- a/x2goclientconfigdetail.cpp
+++ b/x2goclientconfigdetail.cpp
@@ -17,27 +17,82 @@
*/
#include "x2goclientconfigdetail.h"
+#include "x2goclientconfig.h"
X2GoClientConfigDetail::X2GoClientConfigDetail()
{
+ parent=0;
+ checkSanityFunction=0;
}
-bool X2GoClientConfigDetail::parseCommandLineArgument(QString argument)
+bool X2GoClientConfigDetail::parseBool(QString argument)
+{
+ if(argument==QString::null)
+ {
+ value=true;
+ return true;
+ }
+ if(argument=="1")
+ {
+ value=true;
+ return true;
+ }
+ if(argument=="0")
+ {
+ value=false;
+ return true;
+ }
+ if(argument.compare("true",Qt::CaseInsensitive)==0)
+ {
+ value=true;
+ return true;
+ }
+ if(argument.compare("false",Qt::CaseInsensitive)==0)
+ {
+ value=false;
+ return true;
+ }
+ return false;
+}
+
+bool X2GoClientConfigDetail::parseInt(QString argument)
{
- /* if(!parseCommandLineArgumentFunction)
- return false;
- ConfigDetailType val;
- bool res=*parseCommandLineArgumentFunction(argument, val);
- if(!res)
- return false;
- if(!checkSanityFunction)
- {
- value=val;
- return true;
- }
- res=checkSanityFunction(val);
- if(!res)
- return false;
- value=val;*/
+ bool convOk;
+ int val=argument.toInt(&convOk,10);
+ if(convOk)
+ {
+ value=val;
+ return true;
+ }
+ return false;
+}
+
+bool X2GoClientConfigDetail::parseString(QString argument)
+{
+ value=argument;
return true;
}
+
+bool X2GoClientConfigDetail::parseCommandLineArgument(QString argument)
+{
+ bool result;
+ switch (value.type())
+ {
+ case QVariant::Int:
+ result= parseInt(argument);
+ break;
+ case QVariant::Bool:
+ result=parseBool(argument);
+ break;
+ case QVariant::String:
+ result= parseString(argument);
+ break;
+ default:
+ return false;
+ }
+ if(!result)
+ return false;
+ if(!checkSanityFunction)
+ return true;
+ return (parent->*checkSanityFunction)(value);
+}
diff --git a/x2goclientconfigdetail.h b/x2goclientconfigdetail.h
index f54a524..b72c5ea 100644
--- a/x2goclientconfigdetail.h
+++ b/x2goclientconfigdetail.h
@@ -27,16 +27,22 @@
class X2GoClientConfigDetail
{
friend class X2GoClientConfig;
+ typedef bool bool (X2GoClientConfig::*CheckSanityFunction)(QVariant value);
X2GO_PROPERTY_GETTER( QVariant, value)
X2GO_PROPERTY_GETTER( QString, commandLineParameter)
X2GO_PROPERTY_GETTER( QString, configFileParameter)
X2GO_PROPERTY_GETTER( QString, description)
private:
- bool (*checkSanityFunction)(QVariant value);
+ CheckSanityFunction checkSanityFunction;
+ X2GoClientConfig* parent;
QVariant value;
QString commandLineParameter;
QString configFileParameter;
QString description;
+private:
+ bool parseBool(QString argument);
+ bool parseInt(QString argument);
+ bool parseString(QString argument);
public:
X2GoClientConfigDetail();
bool parseCommandLineArgument(QString argument);
diff --git a/main.cpp b/x2gosettings.cpp
similarity index 51%
copy from main.cpp
copy to x2gosettings.cpp
index 07debfb..884002d 100644
--- a/main.cpp
+++ b/x2gosettings.cpp
@@ -17,38 +17,57 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+
+#include "x2gosettings.h"
#include "x2goapplication.h"
-#include "mainwindow.h"
-#include <QMessageBox>
+#include "x2goclientconfig.h"
+#include <QTemporaryFile>
+#include <QTextStream>
+#include <QDir>
-int main(int argc, char *argv[])
+X2goSettings::X2goSettings(QString fileContent, QSettings::Format format)
{
+ cfgFile=new QTemporaryFile();
+ cfgFile->open();
+ QTextStream out(cfgFile);
+ out<<fileContent;
+ cfgFile->close();
+ setting=new QSettings ( cfgFile->fileName(), format );
+}
- X2GoApplication app ( argc,argv );
- QStringList args;
- if ( argc > 1 )
- args=app.arguments();
- if ( args.count() >1 && args[1]=="--dialog" )
+X2goSettings::X2goSettings ( QString group )
+{
+ cfgFile=0l;
+ QString sessionCfgFile=X2GoApplication::instance()->get_clientConfig()->get_sessionConfigFile().get_value().toString();
+ if (group=="sessions" && sessionCfgFile.length()>0)
+ {
+ setting=new QSettings ( sessionCfgFile,
+ QSettings::IniFormat );
+ return;
+ }
+#ifndef Q_OS_WIN
+ setting=new QSettings ( QDir::homePath() +
+ "/.x2goclient/"+group,
+ QSettings::NativeFormat );
+#else
+ if ( !X2GoApplication::instance()->get_clientConfig()->get_portableMode().get_value().toBool())
{
- QString type=args[2];
- QString caption=args[4];
- caption=caption.replace ( "NX","X2Go" );
- QString text=args[6];
- if ( type=="error" || type=="panic" )
- return QMessageBox::critical ( 0, caption,text );
- if ( type=="ok" )
- return QMessageBox::information ( 0, caption,text );
- if ( type=="yesno" )
- return QMessageBox::question ( 0, caption,text,
- QMessageBox::Yes,
- QMessageBox::No );
- return -1;
+ setting=new QSettings ( "Obviously Nice","x2goclient" );
+ setting->beginGroup ( group );
}
else
{
- MainWindow* mw = new MainWindow;
- mw->show();
- return app.exec();
+ setting=new QSettings ( QDir::homePath() +
+ "/.x2goclient/"+group,
+ QSettings::IniFormat );
}
- return 0;
+#endif
}
+
+X2goSettings::~X2goSettings()
+{
+ delete setting;
+ if (cfgFile)
+ delete cfgFile;
+}
+
diff --git a/searchbar.h b/x2gosettings.h
similarity index 80%
copy from searchbar.h
copy to x2gosettings.h
index 725e341..8e4e19f 100644
--- a/searchbar.h
+++ b/x2gosettings.h
@@ -18,23 +18,23 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#ifndef SEARCHBAR_H
-#define SEARCHBAR_H
-#include "svgframe.h"
-#include "ui_searchbar.h"
+#ifndef X2GOSETTINGS_H
+#define X2GOSETTINGS_H
-class SearchBar : public SVGFrame, public Ui_searchBar
+#include <QSettings>
+#include "x2goapplication.h"
+
+class QTemporaryFile;
+class X2goSettings
{
- Q_OBJECT
+ X2GO_RO_PROPERTY(QSettings*, setting)
public:
- SearchBar(QWidget* parent = 0, Qt::WindowFlags f = 0);
- ~SearchBar();
- QLineEdit* getLineEdit()
- {
- return lineEdit;
- }
-
+ X2goSettings ( QString group );
+ X2goSettings ( QString fileContent, QSettings::Format format);
+ ~X2goSettings();
+private:
+ QTemporaryFile* cfgFile;
};
-#endif // SEARCHBAR_H
+#endif
hooks/post-receive
--
x2goclient2.git (X2Go Client 2 (rewrite of x2goclient.git))
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2goclient2.git" (X2Go Client 2 (rewrite of x2goclient.git)).