1
/**************************************************************************
2
* Copyright (C) 2005-2015 by Oleksandr Shneyder *
3
* o.shneyder@phoca-gmbh.de *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
16
***************************************************************************/
18
#include "editconnectiondialog.h"
19
#include "x2goclientconfig.h"
20
#include "x2gologdebug.h"
22
#include "onmainwindow.h"
26
#include "sessionwidget.h"
27
#include "sharewidget.h"
28
#include "connectionwidget.h"
29
#include "settingswidget.h"
30
#include "mediawidget.h"
32
EditConnectionDialog::EditConnectionDialog ( bool newSession, QString id, QWidget * par,
33
int ind,Qt::WFlags f )
36
QVBoxLayout* ml=new QVBoxLayout ( this );
40
fr=new QTabWidget ( this );
42
ONMainWindow* parent= ( ONMainWindow* ) par;
45
if ( parent->retMiniMode() )
47
fnt.setPointSize ( 10 );
49
fnt.setPointSize ( 9 );
53
sessSet=new SessionWidget ( newSession, id,parent );
54
conSet=new ConnectionWidget ( id,parent );
55
otherSet=new SettingsWidget ( id,parent );
56
mediaSet=new MediaWidget ( id,parent );
57
exportDir=new ShareWidget ( id,parent );
59
fr->addTab ( sessSet,tr ( "&Session" ) );
60
fr->addTab ( conSet,tr ( "&Connection" ) );
61
fr->addTab ( otherSet,tr ( "&Input/Output" ) );
62
fr->addTab ( mediaSet,tr ( "&Media" ) );
63
if (! parent->getHideFolderSharing())
64
fr->addTab ( exportDir,tr ( "&Shared folders" ) );
66
QPushButton* ok=new QPushButton ( tr ( "&OK" ),this );
67
QPushButton* cancel=new QPushButton ( tr ( "&Cancel" ),this );
68
QPushButton* def=new QPushButton ( tr ( "Defaults" ),this );
69
QHBoxLayout* bLay=new QHBoxLayout();
70
bLay->setSpacing ( 5 );
72
bLay->addWidget ( ok );
73
bLay->addWidget ( cancel );
74
bLay->addWidget ( def );
75
ml->addLayout ( bLay );
77
bLay->setMargin ( 2 );
80
setSizeGripEnabled ( true );
81
setWindowIcon ( QIcon ( parent->iconsPath ( "/32x32/edit.png" ) ) );
82
connect ( ok,SIGNAL ( clicked() ),this,SLOT ( accept() ) );
83
connect ( cancel,SIGNAL ( clicked() ),this,SLOT ( reject() ) );
84
connect ( def,SIGNAL ( clicked() ),this,SLOT ( slot_default() ) );
85
connect ( sessSet,SIGNAL ( nameChanged ( const QString & ) ),this,
86
SLOT ( slot_changeCaption ( const QString& ) ) );
87
connect ( this,SIGNAL ( accepted() ),this,SLOT ( slot_accepted() ) );
88
connect (sessSet, SIGNAL(directRDP(bool)), this, SLOT(slot_directRDP(bool)));
91
SIGNAL(settingsChanged(QString,QString,QString)), otherSet,
92
SLOT(setServerSettings(QString,QString,QString)));
94
ok->setDefault ( true );
96
QSize sz=ok->sizeHint();
97
sz.setWidth ( ( int ) ( sz.width() /1.5 ) );
98
sz.setHeight ( ( int ) ( sz.height() /1.5 ) );
99
ok->setFixedSize ( sz );
100
sz=cancel->sizeHint();
101
sz.setWidth ( ( int ) ( sz.width() ) );
102
sz.setHeight ( ( int ) ( sz.height() /1.5 ) );
103
cancel->setFixedSize ( sz );
105
sz.setWidth ( ( int ) ( sz.width() ) );
106
sz.setHeight ( ( int ) ( sz.height() /1.5 ) );
107
def->setFixedSize ( sz );
109
if ( parent->retMiniMode() )
110
setContentsMargins ( 3,3,3,3 );
111
fr->setCurrentIndex ( ind );
112
slot_changeCaption(sessSet->sessionName());
114
sessSet->slot_rdpDirectClicked();
119
EditConnectionDialog::~EditConnectionDialog()
124
void EditConnectionDialog::slot_changeCaption ( const QString& newName )
126
setWindowTitle ( tr ( "Session preferences - " ) +newName );
130
void EditConnectionDialog::slot_accepted()
132
conSet->saveSettings();
133
exportDir->saveSettings();
134
otherSet->saveSettings();
135
mediaSet->saveSettings();
136
sessSet->saveSettings();
140
void EditConnectionDialog::slot_default()
142
switch ( fr->currentIndex() )
146
sessSet->setDefaults();
151
conSet->setDefaults();
156
otherSet->setDefaults();
161
mediaSet->setDefaults();
166
exportDir->setDefaults();
173
void EditConnectionDialog::slot_directRDP(bool direct)
175
fr->setTabEnabled(1,!direct);
176
fr->setTabEnabled(3,!direct);
177
fr->setTabEnabled(4,!direct);
178
otherSet->setDirectRdp(direct);