1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
//
// C++ Implementation: exportdialog
//
// Description:
//
//
// Author: Oleksandr Shneyder <oleksandr.shneyder@obviously-nice.de>, (C) 2006
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "x2goclientconfig.h"
#include "exportdialog.h"
#include "editconnectiondialog.h"
#include <QBoxLayout>
#include <QGroupBox>
#include <QPushButton>
#include <QLabel>
#include "x2gosettings.h"
#include <QListView>
#include <QDir>
#include <QStringListModel>
#include <QShortcut>
#include "sessionbutton.h"
#include "onmainwindow.h"
#include <QFileDialog>
ExportDialog::ExportDialog ( QString sid,QWidget * par, Qt::WFlags f )
: QDialog ( par,f )
{
sessionId=sid;
QVBoxLayout* ml=new QVBoxLayout ( this );
QFrame *fr=new QFrame ( this );
QHBoxLayout* frLay=new QHBoxLayout ( fr );
parent= ( ONMainWindow* ) par;
QPushButton* cancel=new QPushButton ( tr ( "&Cancel" ),this );
QHBoxLayout* bLay=new QHBoxLayout();
sessions=new QListView ( fr );
frLay->addWidget ( sessions );
exportDir=new QPushButton ( tr ( "&share" ),fr );
editSession=new QPushButton ( tr ( "&Preferences ..." ),fr );
newDir=new QPushButton ( tr ( "&Custom folder ..." ),fr );
QVBoxLayout* actLay=new QVBoxLayout();
actLay->addWidget ( exportDir );
actLay->addWidget ( editSession );
actLay->addWidget ( newDir );
actLay->addStretch();
frLay->addLayout ( actLay );
QShortcut* sc=new QShortcut ( QKeySequence ( tr ( "Delete","Delete" ) ),
this );
connect ( cancel,SIGNAL ( clicked() ),this,SLOT ( close() ) );
connect ( sc,SIGNAL ( activated() ),exportDir,SIGNAL ( clicked() ) );
connect ( editSession,SIGNAL ( clicked() ),this,SLOT ( slot_edit() ) );
connect ( newDir,SIGNAL ( clicked() ),this,SLOT ( slotNew() ) );
connect ( exportDir,SIGNAL ( clicked() ),this,SLOT ( slot_accept() ) );
bLay->setSpacing ( 5 );
bLay->addStretch();
bLay->addWidget ( cancel );
ml->addWidget ( fr );
ml->addLayout ( bLay );
fr->setFrameStyle ( QFrame::StyledPanel | QFrame::Raised );
fr->setLineWidth ( 2 );
setSizeGripEnabled ( true );
setWindowTitle ( tr ( "share folders" ) );
connect ( sessions,SIGNAL ( clicked ( const QModelIndex& ) ),
this,SLOT ( slot_activated ( const QModelIndex& ) ) );
connect ( sessions,SIGNAL ( doubleClicked ( const QModelIndex& ) ),
this,SLOT ( slot_dclicked ( const QModelIndex& ) ) );
loadSessions();
}
ExportDialog::~ExportDialog()
{}
void ExportDialog::loadSessions()
{
QStringListModel *model= ( QStringListModel* ) sessions->model();
if ( !model )
model=new QStringListModel();
sessions->setModel ( model );
QStringList dirs;
model->setStringList ( dirs );
X2goSettings st ( "sessions" );
QString exports=st.setting()->value ( sessionId+"/export",
( QVariant ) QString::null ).toString();
QStringList lst=exports.split ( ";",QString::SkipEmptyParts );
for ( int i=0;i<lst.size();++i )
{
#ifndef Q_OS_WIN
QStringList tails=lst[i].split ( ":",QString::SkipEmptyParts );
#else
QStringList tails=lst[i].split ( "#",QString::SkipEmptyParts );
#endif
dirs<<tails[0];
}
model->setStringList ( dirs );
// removeSession->setEnabled(false);
exportDir->setEnabled ( false );
sessions->setEditTriggers ( QAbstractItemView::NoEditTriggers );
}
void ExportDialog::slot_activated ( const QModelIndex& )
{
// removeSession->setEnabled(true);
exportDir->setEnabled ( true );
}
void ExportDialog::slot_dclicked ( const QModelIndex& )
{
slot_accept();
}
void ExportDialog::slotNew()
{
directory=QString::null;
directory= QFileDialog::getExistingDirectory (
this,
tr ( "Select folder" ),
QDir::homePath() );
if ( directory!=QString::null )
accept();
}
void ExportDialog::slot_edit()
{
const QList<SessionButton*>* sess=parent->getSessionsList();
for ( int i=0;i< sess->size();++i )
{
if ( sess->at ( i )->id() ==sessionId )
{
parent->exportsEdit ( sess->at ( i ) );
break;
}
}
loadSessions();
}
void ExportDialog::slot_accept()
{
int ind=sessions->currentIndex().row();
if ( ind<0 )
return;
QStringListModel *model= ( QStringListModel* ) sessions->model();
directory=model->stringList() [ind];
accept();
}
|