~x2go/x2go/x2goclient_master

« back to all changes in this revision

Viewing changes to src/editconnectiondialog.cpp

  • Committer: Mihai Moldovan
  • Date: 2015-03-04 20:15:47 UTC
  • Revision ID: git-v1:b7398771a7abd84ddcff407063edb95dd0a205d3
general: move *.cpp and *.h files to src/ and *.ts files to src/i18n/.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************************
 
2
*   Copyright (C) 2005-2015 by Oleksandr Shneyder                         *
 
3
*   o.shneyder@phoca-gmbh.de                                              *
 
4
*                                                                         *
 
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.                          *
 
13
*                                                                         *
 
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
***************************************************************************/
 
17
 
 
18
#include "editconnectiondialog.h"
 
19
#include "x2goclientconfig.h"
 
20
#include "x2gologdebug.h"
 
21
 
 
22
#include "onmainwindow.h"
 
23
#include <QBoxLayout>
 
24
#include <QTabWidget>
 
25
 
 
26
#include "sessionwidget.h"
 
27
#include "sharewidget.h"
 
28
#include "connectionwidget.h"
 
29
#include "settingswidget.h"
 
30
#include "mediawidget.h"
 
31
 
 
32
EditConnectionDialog::EditConnectionDialog ( bool newSession, QString id, QWidget * par,
 
33
        int ind,Qt::WFlags f )
 
34
        : QDialog ( par,f )
 
35
{
 
36
    QVBoxLayout* ml=new QVBoxLayout ( this );
 
37
#ifdef Q_WS_HILDON
 
38
    ml->setMargin ( 2 );
 
39
#endif
 
40
    fr=new QTabWidget ( this );
 
41
    ml->addWidget ( fr );
 
42
    ONMainWindow* parent= ( ONMainWindow* ) par;
 
43
 
 
44
    QFont fnt=font();
 
45
    if ( parent->retMiniMode() )
 
46
#ifdef Q_WS_HILDON
 
47
        fnt.setPointSize ( 10 );
 
48
#else
 
49
        fnt.setPointSize ( 9 );
 
50
#endif
 
51
    setFont ( fnt );
 
52
 
 
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 );
 
58
 
 
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" ) );
 
65
 
 
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 );
 
71
    bLay->addStretch();
 
72
    bLay->addWidget ( ok );
 
73
    bLay->addWidget ( cancel );
 
74
    bLay->addWidget ( def );
 
75
    ml->addLayout ( bLay );
 
76
#ifdef Q_WS_HILDON
 
77
    bLay->setMargin ( 2 );
 
78
#endif
 
79
 
 
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)));
 
89
     
 
90
    connect (sessSet, 
 
91
             SIGNAL(settingsChanged(QString,QString,QString)), otherSet, 
 
92
             SLOT(setServerSettings(QString,QString,QString)));
 
93
 
 
94
    ok->setDefault ( true );
 
95
#ifdef Q_WS_HILDON
 
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 );
 
104
    sz=def->sizeHint();
 
105
    sz.setWidth ( ( int ) ( sz.width() ) );
 
106
    sz.setHeight ( ( int ) ( sz.height() /1.5 ) );
 
107
    def->setFixedSize ( sz );
 
108
#endif
 
109
    if ( parent->retMiniMode() )
 
110
        setContentsMargins ( 3,3,3,3 );
 
111
    fr->setCurrentIndex ( ind );
 
112
    slot_changeCaption(sessSet->sessionName());
 
113
#ifdef Q_OS_LINUX
 
114
    sessSet->slot_rdpDirectClicked();
 
115
#endif
 
116
}
 
117
 
 
118
 
 
119
EditConnectionDialog::~EditConnectionDialog()
 
120
{}
 
121
 
 
122
 
 
123
 
 
124
void EditConnectionDialog::slot_changeCaption ( const QString& newName )
 
125
{
 
126
    setWindowTitle ( tr ( "Session preferences - " ) +newName );
 
127
}
 
128
 
 
129
 
 
130
void EditConnectionDialog::slot_accepted()
 
131
{
 
132
    conSet->saveSettings();
 
133
    exportDir->saveSettings();
 
134
    otherSet->saveSettings();
 
135
    mediaSet->saveSettings();
 
136
    sessSet->saveSettings();
 
137
}
 
138
 
 
139
 
 
140
void EditConnectionDialog::slot_default()
 
141
{
 
142
    switch ( fr->currentIndex() )
 
143
    {
 
144
    case 0:
 
145
    {
 
146
        sessSet->setDefaults();
 
147
    }
 
148
    break;
 
149
    case 1:
 
150
    {
 
151
        conSet->setDefaults();
 
152
    }
 
153
    break;
 
154
    case 2:
 
155
    {
 
156
        otherSet->setDefaults();
 
157
    }
 
158
    break;
 
159
    case 3:
 
160
    {
 
161
        mediaSet->setDefaults();
 
162
    }
 
163
    break;
 
164
    case 4:
 
165
    {
 
166
        exportDir->setDefaults();
 
167
    }
 
168
    break;
 
169
    }
 
170
}
 
171
 
 
172
#ifdef Q_OS_LINUX
 
173
void EditConnectionDialog::slot_directRDP(bool direct)
 
174
{
 
175
    fr->setTabEnabled(1,!direct);
 
176
    fr->setTabEnabled(3,!direct);
 
177
    fr->setTabEnabled(4,!direct);
 
178
    otherSet->setDirectRdp(direct);
 
179
}
 
180
#endif