]> granicus.if.org Git - transmission/commitdiff
Rework session dialog in Qt client to load from .ui
authorMike Gelfand <mikedld@mikedld.com>
Sun, 21 Dec 2014 23:46:31 +0000 (23:46 +0000)
committerMike Gelfand <mikedld@mikedld.com>
Sun, 21 Dec 2014 23:46:31 +0000 (23:46 +0000)
qt/CMakeLists.txt
qt/qtr.pro
qt/session-dialog.cc
qt/session-dialog.h
qt/session-dialog.ui [new file with mode: 0644]
qt/stats-dialog.cc

index 2b61d1903eb2b4dd9f3181ddb7250d4250906f74..bf5129be8e03c4152f82365bd5d0fbf3a51d7a5f 100644 (file)
@@ -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
 )
 
index 84f0f909e19f2db85f01a47093152da3f3afa4c7..208e3b0613fc0fea486696fa046ed1b57a46adbd 100644 (file)
@@ -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 \
index 156c937b8a4e0cba01cfe8deefd3a50e2bb7e4f2..53991e98524d2bcad36eeac84469a9bddbf81d03 100644 (file)
@@ -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"
 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;
-
-  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 ()));
 }
index 2b50413b0871ca8873888a75d0a47a3da8056c07..b266ccd078dca59e6c19993a0d986e04f50f183c 100644 (file)
 #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;
 };
diff --git a/qt/session-dialog.ui b/qt/session-dialog.ui
new file mode 100644 (file)
index 0000000..1a42aa5
--- /dev/null
@@ -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~=&quot;form-section&quot;]
+{
+  font-weight: bold;
+  margin-top: 12px;
+  margin-bottom: 1px;
+}
+[tr-style~=&quot;form-section&quot;][tr-style~=&quot;first&quot;]
+{
+  margin-top: 0;
+}
+[tr-style~=&quot;form-label&quot;]
+{
+  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 &amp;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 &amp;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>&amp;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>&amp;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>&amp;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>&amp;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&amp;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>
index 50f867f8127e29efa0c0bb58e60927641022854e..80b4fba2677fec083cfc4d94a094997e576ce042 100644 (file)
@@ -10,7 +10,6 @@
 #include <QTimer>
 
 #include "formatter.h"
-#include "hig.h"
 #include "session.h"
 #include "stats-dialog.h"