* $Id$
*/
-#include <QCheckBox>
-#include <QDialogButtonBox>
-#include <QLabel>
-#include <QLineEdit>
-#include <QRadioButton>
-#include <QSpinBox>
-#include <QVBoxLayout>
-
-#include "hig.h"
#include "prefs.h"
#include "session.h"
#include "session-dialog.h"
void
SessionDialog::onAccepted ()
{
- myPrefs.set (Prefs::SESSION_IS_REMOTE, myRemoteRadioButton->isChecked ());
- myPrefs.set (Prefs::SESSION_REMOTE_HOST, myHostLineEdit->text ());
- myPrefs.set (Prefs::SESSION_REMOTE_PORT, myPortSpinBox->value ());
- myPrefs.set (Prefs::SESSION_REMOTE_AUTH, myAuthCheckBox->isChecked ());
- myPrefs.set (Prefs::SESSION_REMOTE_USERNAME, myUsernameLineEdit->text ());
- myPrefs.set (Prefs::SESSION_REMOTE_PASSWORD, myPasswordLineEdit->text ());
+ myPrefs.set (Prefs::SESSION_IS_REMOTE, ui.remoteSessionRadio->isChecked ());
+ myPrefs.set (Prefs::SESSION_REMOTE_HOST, ui.hostEdit->text ());
+ myPrefs.set (Prefs::SESSION_REMOTE_PORT, ui.portSpin->value ());
+ myPrefs.set (Prefs::SESSION_REMOTE_AUTH, ui.authCheck->isChecked ());
+ myPrefs.set (Prefs::SESSION_REMOTE_USERNAME, ui.usernameEdit->text ());
+ myPrefs.set (Prefs::SESSION_REMOTE_PASSWORD, ui.passwordEdit->text ());
mySession.restart ();
hide ();
}
void
SessionDialog::resensitize ()
{
- const bool isRemote = myRemoteRadioButton->isChecked();
- const bool useAuth = myAuthCheckBox->isChecked();
+ const bool isRemote = ui.remoteSessionRadio->isChecked ();
+ const bool useAuth = ui.authCheck->isChecked ();
foreach (QWidget * w, myRemoteWidgets)
w->setEnabled (isRemote);
mySession (session),
myPrefs (prefs)
{
- QWidget * l;
- QSpinBox * sb;
- QCheckBox * cb;
- QLineEdit * le;
- QRadioButton * rb;
-
- setWindowTitle (tr ("Change Session"));
- QVBoxLayout * top = new QVBoxLayout (this);
- top->setSpacing (HIG::PAD);
-
- HIG * hig = new HIG;
- hig->setContentsMargins (0, 0, 0, 0);
- hig->addSectionTitle (tr ("Source"));
- rb = new QRadioButton (tr ("Start &Local Session"));
- rb->setChecked (!prefs.get<bool>(Prefs::SESSION_IS_REMOTE));
- connect (rb, SIGNAL(toggled(bool)), this, SLOT(resensitize()));
- hig->addWideControl (rb);
- rb = myRemoteRadioButton = new QRadioButton (tr ("Connect to &Remote Session"));
- rb->setChecked (prefs.get<bool>(Prefs::SESSION_IS_REMOTE));
- connect (rb, SIGNAL(toggled(bool)), this, SLOT(resensitize()));
- hig->addWideControl (rb);
- le = myHostLineEdit = new QLineEdit ();
- le->setText (prefs.get<QString>(Prefs::SESSION_REMOTE_HOST));
- l = hig->addRow (tr ("&Host:"), le);
- myRemoteWidgets << l << le;
- sb = myPortSpinBox = new QSpinBox;
- sb->setRange (1, 65535);
- sb->setValue (prefs.get<int>(Prefs::SESSION_REMOTE_PORT));
- l = hig->addRow (tr ("&Port:"), sb);
- myRemoteWidgets << l << sb;
- cb = myAuthCheckBox = new QCheckBox (tr ("&Authentication required"));
- cb->setChecked (prefs.get<bool>(Prefs::SESSION_REMOTE_AUTH));
- connect (cb, SIGNAL(toggled(bool)), this, SLOT(resensitize()));
- myRemoteWidgets << cb;
- hig->addWideControl (cb);
- le = myUsernameLineEdit = new QLineEdit ();
- le->setText (prefs.get<QString>(Prefs::SESSION_REMOTE_USERNAME));
- l = hig->addRow (tr ("&Username:"), le);
- myAuthWidgets << l << le;
- le = myPasswordLineEdit = new QLineEdit ();
- le->setEchoMode (QLineEdit::Password);
- le->setText (prefs.get<QString>(Prefs::SESSION_REMOTE_PASSWORD));
- l = hig->addRow (tr ("Pass&word:"), le);
- myAuthWidgets << l << le;
- hig->finish ();
- top->addWidget (hig, 1);
+ ui.setupUi (this);
+
+ ui.localSessionRadio->setChecked (!prefs.get<bool> (Prefs::SESSION_IS_REMOTE));
+ connect (ui.localSessionRadio, SIGNAL (toggled (bool)), this, SLOT (resensitize ()));
+
+ ui.remoteSessionRadio->setChecked (prefs.get<bool> (Prefs::SESSION_IS_REMOTE));
+ connect (ui.remoteSessionRadio, SIGNAL (toggled (bool)), this, SLOT (resensitize ()));
+
+ ui.hostEdit->setText (prefs.get<QString> (Prefs::SESSION_REMOTE_HOST));
+ myRemoteWidgets << ui.hostLabel << ui.hostEdit;
+
+ ui.portSpin->setValue (prefs.get<int> (Prefs::SESSION_REMOTE_PORT));
+ myRemoteWidgets << ui.portLabel << ui.portSpin;
+
+ ui.authCheck->setChecked (prefs.get<bool> (Prefs::SESSION_REMOTE_AUTH));
+ connect (ui.authCheck, SIGNAL (toggled (bool)), this, SLOT (resensitize ()));
+ myRemoteWidgets << ui.authCheck;
+
+ ui.usernameEdit->setText (prefs.get<QString> (Prefs::SESSION_REMOTE_USERNAME));
+ myAuthWidgets << ui.usernameLabel << ui.usernameEdit;
+
+ ui.passwordEdit->setText (prefs.get<QString> (Prefs::SESSION_REMOTE_PASSWORD));
+ myAuthWidgets << ui.passwordLabel << ui.passwordEdit;
+
resensitize ();
- QDialogButtonBox * buttons = new QDialogButtonBox (QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
- connect (buttons, SIGNAL(rejected()), this, SLOT(hide()));
- connect (buttons, SIGNAL(accepted()), this, SLOT(onAccepted()));
- top->addWidget (buttons, 0);
+ connect (ui.dialogButtons, SIGNAL (rejected ()), this, SLOT (hide ()));
+ connect (ui.dialogButtons, SIGNAL (accepted ()), this, SLOT (onAccepted ()));
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SessionDialog</class>
+ <widget class="QDialog" name="SessionDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>248</width>
+ <height>263</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Change Session</string>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">[tr-style~="form-section"]
+{
+ font-weight: bold;
+ margin-top: 12px;
+ margin-bottom: 1px;
+}
+[tr-style~="form-section"][tr-style~="first"]
+{
+ margin-top: 0;
+}
+[tr-style~="form-label"]
+{
+ margin-left: 18px;
+}</string>
+ </property>
+ <layout class="QGridLayout" name="dialogLayout">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetFixedSize</enum>
+ </property>
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="sourceSectionLabel">
+ <property name="text">
+ <string>Source</string>
+ </property>
+ <property name="tr-style" stdset="0">
+ <string notr="true">form-section first</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QRadioButton" name="localSessionRadio">
+ <property name="text">
+ <string>Start &Local Session</string>
+ </property>
+ <property name="tr-style" stdset="0">
+ <string notr="true">form-label</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QRadioButton" name="remoteSessionRadio">
+ <property name="text">
+ <string>Connect to &Remote Session</string>
+ </property>
+ <property name="tr-style" stdset="0">
+ <string notr="true">form-label</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="hostLabel">
+ <property name="text">
+ <string>&Host:</string>
+ </property>
+ <property name="buddy">
+ <cstring>hostEdit</cstring>
+ </property>
+ <property name="tr-style" stdset="0">
+ <string notr="true">form-label</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLineEdit" name="hostEdit"/>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="portLabel">
+ <property name="text">
+ <string>&Port:</string>
+ </property>
+ <property name="buddy">
+ <cstring>portSpin</cstring>
+ </property>
+ <property name="tr-style" stdset="0">
+ <string notr="true">form-label</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QSpinBox" name="portSpin">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>65535</number>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" colspan="2">
+ <widget class="QCheckBox" name="authCheck">
+ <property name="text">
+ <string>&Authentication required</string>
+ </property>
+ <property name="tr-style" stdset="0">
+ <string notr="true">form-label</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="usernameLabel">
+ <property name="text">
+ <string>&Username:</string>
+ </property>
+ <property name="buddy">
+ <cstring>usernameEdit</cstring>
+ </property>
+ <property name="tr-style" stdset="0">
+ <string notr="true">form-label</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1">
+ <widget class="QLineEdit" name="usernameEdit"/>
+ </item>
+ <item row="7" column="0">
+ <widget class="QLabel" name="passwordLabel">
+ <property name="text">
+ <string>Pass&word:</string>
+ </property>
+ <property name="buddy">
+ <cstring>passwordEdit</cstring>
+ </property>
+ <property name="tr-style" stdset="0">
+ <string notr="true">form-label</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="1">
+ <widget class="QLineEdit" name="passwordEdit">
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="0" colspan="2">
+ <widget class="QDialogButtonBox" name="dialogButtons">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>