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
|
//
// C++ Implementation: editconnectiondialog
//
// Description:
//
//
// Author: Oleksandr Shneyder <oleksandr.shneyder@obviously-nice.de>, (C) 2006
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "editconnectiondialog.h"
#include "x2goclientconfig.h"
#include "x2gologdebug.h"
#include "onmainwindow.h"
#include <QBoxLayout>
#include <QTabWidget>
#include "sessionwidget.h"
#include "sharewidget.h"
#include "connectionwidget.h"
#include "settingswidget.h"
EditConnectionDialog::EditConnectionDialog ( QString id, QWidget * par,
int ind,Qt::WFlags f )
: QDialog ( par,f )
{
QVBoxLayout* ml=new QVBoxLayout ( this );
#ifdef Q_WS_HILDON
ml->setMargin ( 2 );
#endif
fr=new QTabWidget ( this );
ml->addWidget ( fr );
ONMainWindow* parent= ( ONMainWindow* ) par;
QFont fnt=font();
if ( parent->retMiniMode() )
#ifdef Q_WS_HILDON
fnt.setPointSize ( 10 );
#else
fnt.setPointSize ( 9 );
#endif
setFont ( fnt );
sessSet=new SessionWidget ( id,parent );
conSet=new ConnectionWidget ( id,parent );
otherSet=new SettingsWidget ( id,parent );
exportDir=new ShareWidget ( id,parent );
fr->addTab ( sessSet,tr ( "&Session" ) );
fr->addTab ( conSet,tr ( "&Connection" ) );
fr->addTab ( otherSet,tr ( "&Settings" ) );
fr->addTab ( exportDir,tr ( "&Shared folders" ) );
QPushButton* ok=new QPushButton ( tr ( "&OK" ),this );
QPushButton* cancel=new QPushButton ( tr ( "&Cancel" ),this );
QPushButton* def=new QPushButton ( tr ( "Defaults" ),this );
QHBoxLayout* bLay=new QHBoxLayout();
bLay->setSpacing ( 5 );
bLay->addStretch();
bLay->addWidget ( ok );
bLay->addWidget ( cancel );
bLay->addWidget ( def );
ml->addLayout ( bLay );
#ifdef Q_WS_HILDON
bLay->setMargin ( 2 );
#endif
setSizeGripEnabled ( true );
setWindowIcon ( QIcon ( parent->iconsPath ( "/32x32/edit.png" ) ) );
connect ( ok,SIGNAL ( clicked() ),this,SLOT ( accept() ) );
connect ( cancel,SIGNAL ( clicked() ),this,SLOT ( reject() ) );
connect ( def,SIGNAL ( clicked() ),this,SLOT ( slot_default() ) );
connect ( sessSet,SIGNAL ( nameChanged ( const QString & ) ),this,
SLOT ( slot_changeCaption ( const QString& ) ) );
connect ( this,SIGNAL ( accepted() ),this,SLOT ( slot_accepted() ) );
ok->setDefault ( true );
#ifdef Q_WS_HILDON
QSize sz=ok->sizeHint();
sz.setWidth ( ( int ) ( sz.width() /1.5 ) );
sz.setHeight ( ( int ) ( sz.height() /1.5 ) );
ok->setFixedSize ( sz );
sz=cancel->sizeHint();
sz.setWidth ( ( int ) ( sz.width() ) );
sz.setHeight ( ( int ) ( sz.height() /1.5 ) );
cancel->setFixedSize ( sz );
sz=def->sizeHint();
sz.setWidth ( ( int ) ( sz.width() ) );
sz.setHeight ( ( int ) ( sz.height() /1.5 ) );
def->setFixedSize ( sz );
#endif
if ( parent->retMiniMode() )
setContentsMargins ( 3,3,3,3 );
fr->setCurrentIndex ( ind );
slot_changeCaption(sessSet->sessionName());
}
EditConnectionDialog::~EditConnectionDialog()
{}
void EditConnectionDialog::slot_changeCaption ( const QString& newName )
{
setWindowTitle ( tr ( "Session preferences - " ) +newName );
}
void EditConnectionDialog::slot_accepted()
{
conSet->saveSettings();
exportDir->saveSettings();
otherSet->saveSettings();
sessSet->saveSettings();
}
void EditConnectionDialog::slot_default()
{
switch ( fr->currentIndex() )
{
case 0:
{
sessSet->setDefaults();
}
break;
case 1:
{
conSet->setDefaults();
}
break;
case 2:
{
otherSet->setDefaults();
}
break;
case 3:
{
exportDir->setDefaults();
}
break;
}
}
|