mirror of
https://github.com/transmission/transmission
synced 2025-03-03 10:15:45 +00:00
Rework session dialog in Qt client to load from .ui
This commit is contained in:
parent
4ddbd550d8
commit
56c75a13b0
6 changed files with 202 additions and 79 deletions
|
@ -103,6 +103,7 @@ set(${PROJECT_NAME}_HEADERS
|
|||
tr_qt_wrap_ui(${PROJECT_NAME}_UI_SOURCES
|
||||
details.ui
|
||||
mainwin.ui
|
||||
session-dialog.ui
|
||||
stats-dialog.ui
|
||||
)
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ TRANSLATIONS += translations/transmission_en.ts \
|
|||
|
||||
FORMS += details.ui \
|
||||
mainwin.ui \
|
||||
session-dialog.ui \
|
||||
stats-dialog.ui
|
||||
RESOURCES += application.qrc
|
||||
SOURCES += about.cc \
|
||||
|
|
|
@ -7,15 +7,6 @@
|
|||
* $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"
|
||||
|
@ -27,12 +18,12 @@
|
|||
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 ();
|
||||
}
|
||||
|
@ -40,8 +31,8 @@ SessionDialog::onAccepted ()
|
|||
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);
|
||||
|
@ -59,56 +50,32 @@ SessionDialog::SessionDialog (Session& session, Prefs& prefs, QWidget * parent):
|
|||
mySession (session),
|
||||
myPrefs (prefs)
|
||||
{
|
||||
QWidget * l;
|
||||
QSpinBox * sb;
|
||||
QCheckBox * cb;
|
||||
QLineEdit * le;
|
||||
QRadioButton * rb;
|
||||
ui.setupUi (this);
|
||||
|
||||
setWindowTitle (tr ("Change Session"));
|
||||
QVBoxLayout * top = new QVBoxLayout (this);
|
||||
top->setSpacing (HIG::PAD);
|
||||
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;
|
||||
|
||||
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);
|
||||
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 ()));
|
||||
}
|
||||
|
|
|
@ -13,12 +13,10 @@
|
|||
#include <QDialog>
|
||||
#include <QWidgetList>
|
||||
|
||||
#include "ui_session-dialog.h"
|
||||
|
||||
class Prefs;
|
||||
class Session;
|
||||
class QCheckBox;
|
||||
class QLineEdit;
|
||||
class QRadioButton;
|
||||
class QSpinBox;
|
||||
|
||||
class SessionDialog: public QDialog
|
||||
{
|
||||
|
@ -32,18 +30,10 @@ class SessionDialog: public QDialog
|
|||
void onAccepted ();
|
||||
void resensitize ();
|
||||
|
||||
private:
|
||||
QCheckBox * myAuthCheckBox;
|
||||
QRadioButton * myRemoteRadioButton;
|
||||
QLineEdit * myHostLineEdit;
|
||||
QSpinBox * myPortSpinBox;
|
||||
QLineEdit * myUsernameLineEdit;
|
||||
QLineEdit * myPasswordLineEdit;
|
||||
QCheckBox * myAutomaticCheckBox;
|
||||
|
||||
private:
|
||||
Session& mySession;
|
||||
Prefs& myPrefs;
|
||||
Ui::SessionDialog ui;
|
||||
QWidgetList myRemoteWidgets;
|
||||
QWidgetList myAuthWidgets;
|
||||
};
|
||||
|
|
165
qt/session-dialog.ui
Normal file
165
qt/session-dialog.ui
Normal file
|
@ -0,0 +1,165 @@
|
|||
<?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>
|
|
@ -10,7 +10,6 @@
|
|||
#include <QTimer>
|
||||
|
||||
#include "formatter.h"
|
||||
#include "hig.h"
|
||||
#include "session.h"
|
||||
#include "stats-dialog.h"
|
||||
|
||||
|
|
Loading…
Reference in a new issue