2
* This file Copyright (C) 2009 Charles Kerr <charles@transmissionbt.com>
4
* This file is licensed by the GPL version 2. Works owned by the
5
* Transmission project are granted a special exemption to clause 2(b)
6
* so that the bulk of its code can remain under the MIT license.
7
* This exemption does not extend to derived works not owned by
8
* the Transmission project.
14
#include <QDialogButtonBox>
17
#include <QRadioButton>
19
#include <QVBoxLayout>
24
#include "session-dialog.h"
31
SessionDialog :: onAccepted( )
33
myPrefs.set( Prefs::SESSION_IS_REMOTE, myRemoteRadioButton->isChecked( ) );
34
myPrefs.set( Prefs::SESSION_REMOTE_HOST, myHostLineEdit->text( ) );
35
myPrefs.set( Prefs::SESSION_REMOTE_PORT, myPortSpinBox->value( ) );
36
myPrefs.set( Prefs::SESSION_REMOTE_AUTH, myAuthCheckBox->isChecked( ) );
37
myPrefs.set( Prefs::SESSION_REMOTE_USERNAME, myUsernameLineEdit->text( ) );
38
myPrefs.set( Prefs::SESSION_REMOTE_PASSWORD, myPasswordLineEdit->text( ) );
44
SessionDialog :: resensitize( )
46
const bool isRemote = myRemoteRadioButton->isChecked();
47
const bool useAuth = myAuthCheckBox->isChecked();
49
foreach( QWidget * w, myRemoteWidgets )
50
w->setEnabled( isRemote );
52
foreach( QWidget * w, myAuthWidgets )
53
w->setEnabled( isRemote && useAuth );
60
SessionDialog :: SessionDialog( Session& session, Prefs& prefs, QWidget * parent ):
71
setWindowTitle( tr( "Change Session" ) );
72
QVBoxLayout * top = new QVBoxLayout( this );
73
top->setSpacing( HIG :: PAD );
76
hig->setContentsMargins( 0, 0, 0, 0 );
77
hig->addSectionTitle( tr( "Source" ) );
78
rb = new QRadioButton( tr( "Start &Local Session" ) );
79
rb->setChecked( !prefs.get<bool>(Prefs::SESSION_IS_REMOTE) );
80
connect( rb, SIGNAL(toggled(bool)), this, SLOT(resensitize()));
81
hig->addWideControl( rb );
82
rb = myRemoteRadioButton = new QRadioButton( tr( "Connect to &Remote Session" ) );
83
rb->setChecked( prefs.get<bool>(Prefs::SESSION_IS_REMOTE) );
84
connect( rb, SIGNAL(toggled(bool)), this, SLOT(resensitize()));
85
hig->addWideControl( rb );
86
le = myHostLineEdit = new QLineEdit( );
87
le->setText( prefs.get<QString>(Prefs::SESSION_REMOTE_HOST) );
88
l = hig->addRow( tr( "&Host:" ), le );
89
myRemoteWidgets << l << le;
90
sb = myPortSpinBox = new QSpinBox;
91
sb->setRange( 1, 65535 );
92
sb->setValue( prefs.get<int>(Prefs::SESSION_REMOTE_PORT) );
93
l = hig->addRow( tr( "&Port:" ), sb );
94
myRemoteWidgets << l << sb;
95
cb = myAuthCheckBox = new QCheckBox( tr( "&Authentication required" ) );
96
cb->setChecked( prefs.get<bool>(Prefs::SESSION_REMOTE_AUTH) );
97
connect( cb, SIGNAL(toggled(bool)), this, SLOT(resensitize()));
98
myRemoteWidgets << cb;
99
hig->addWideControl( cb );
100
le = myUsernameLineEdit = new QLineEdit( );
101
le->setText( prefs.get<QString>(Prefs::SESSION_REMOTE_USERNAME) );
102
l = hig->addRow( tr( "&Username:" ), le );
103
myAuthWidgets << l << le;
104
le = myPasswordLineEdit = new QLineEdit( );
105
le->setEchoMode( QLineEdit::Password );
106
le->setText( prefs.get<QString>(Prefs::SESSION_REMOTE_PASSWORD) );
107
l = hig->addRow( tr( "Pass&word:" ), le );
108
myAuthWidgets << l << le;
110
top->addWidget( hig, 1 );
113
QDialogButtonBox * buttons = new QDialogButtonBox( QDialogButtonBox::Cancel|QDialogButtonBox::Ok );
114
connect( buttons, SIGNAL(rejected()), this, SLOT(hide()));
115
connect( buttons, SIGNAL(accepted()), this, SLOT(onAccepted()));
116
top->addWidget( buttons, 0 );