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 "x2goclientconfig.h"
19
#include "exportdialog.h"
20
#include "editconnectiondialog.h"
23
#include <QPushButton>
25
#include "x2gosettings.h"
28
#include <QStringListModel>
30
#include "sessionbutton.h"
31
#include "onmainwindow.h"
32
#include <QFileDialog>
33
#include "sessionexplorer.h"
35
ExportDialog::ExportDialog ( QString sid,QWidget * par, Qt::WFlags f )
39
QVBoxLayout* ml=new QVBoxLayout ( this );
40
QFrame *fr=new QFrame ( this );
41
QHBoxLayout* frLay=new QHBoxLayout ( fr );
43
parent= ( ONMainWindow* ) par;
45
QPushButton* cancel=new QPushButton ( tr ( "&Cancel" ),this );
46
QHBoxLayout* bLay=new QHBoxLayout();
48
sessions=new QListView ( fr );
49
frLay->addWidget ( sessions );
51
exportDir=new QPushButton ( tr ( "&share" ),fr );
52
editSession=new QPushButton ( tr ( "&Preferences ..." ),fr );
53
newDir=new QPushButton ( tr ( "&Custom folder ..." ),fr );
56
QVBoxLayout* actLay=new QVBoxLayout();
57
actLay->addWidget ( exportDir );
58
actLay->addWidget ( editSession );
59
actLay->addWidget ( newDir );
61
frLay->addLayout ( actLay );
63
QShortcut* sc=new QShortcut ( QKeySequence ( tr ( "Delete","Delete" ) ),
65
connect ( cancel,SIGNAL ( clicked() ),this,SLOT ( close() ) );
66
connect ( sc,SIGNAL ( activated() ),exportDir,SIGNAL ( clicked() ) );
67
connect ( editSession,SIGNAL ( clicked() ),this,SLOT ( slot_edit() ) );
68
connect ( newDir,SIGNAL ( clicked() ),this,SLOT ( slotNew() ) );
69
connect ( exportDir,SIGNAL ( clicked() ),this,SLOT ( slot_accept() ) );
70
bLay->setSpacing ( 5 );
72
bLay->addWidget ( cancel );
74
ml->addLayout ( bLay );
76
fr->setFrameStyle ( QFrame::StyledPanel | QFrame::Raised );
77
fr->setLineWidth ( 2 );
79
setSizeGripEnabled ( true );
80
setWindowTitle ( tr ( "share folders" ) );
81
connect ( sessions,SIGNAL ( clicked ( const QModelIndex& ) ),
82
this,SLOT ( slot_activated ( const QModelIndex& ) ) );
83
connect ( sessions,SIGNAL ( doubleClicked ( const QModelIndex& ) ),
84
this,SLOT ( slot_dclicked ( const QModelIndex& ) ) );
89
ExportDialog::~ExportDialog()
92
void ExportDialog::loadSessions()
94
QStringListModel *model= ( QStringListModel* ) sessions->model();
96
model=new QStringListModel();
97
sessions->setModel ( model );
100
model->setStringList ( dirs );
102
X2goSettings st ( "sessions" );
105
QString exports=st.setting()->value ( sessionId+"/export",
106
( QVariant ) QString::null ).toString();
108
QStringList lst=exports.split ( ";",QString::SkipEmptyParts );
109
for ( int i=0; i<lst.size(); ++i )
112
QStringList tails=lst[i].split ( ":",QString::SkipEmptyParts );
114
QStringList tails=lst[i].split ( "#",QString::SkipEmptyParts );
120
model->setStringList ( dirs );
123
// removeSession->setEnabled(false);
124
exportDir->setEnabled ( false );
125
sessions->setEditTriggers ( QAbstractItemView::NoEditTriggers );
129
void ExportDialog::slot_activated ( const QModelIndex& )
131
// removeSession->setEnabled(true);
132
exportDir->setEnabled ( true );
135
void ExportDialog::slot_dclicked ( const QModelIndex& )
141
void ExportDialog::slotNew()
143
directory=QString::null;
144
directory= QFileDialog::getExistingDirectory (
146
tr ( "Select folder" ),
149
if ( directory!=QString::null )
155
void ExportDialog::slot_edit()
157
const QList<SessionButton*>* sess=parent->getSessionExplorer()->getSessionsList();
158
for ( int i=0; i< sess->size(); ++i )
160
if ( sess->at ( i )->id() ==sessionId )
162
parent->getSessionExplorer()->exportsEdit ( sess->at ( i ) );
171
void ExportDialog::slot_accept()
173
int ind=sessions->currentIndex().row();
176
QStringListModel *model= ( QStringListModel* ) sessions->model();
177
directory=model->stringList() [ind];