From 8a4f8b9e15e0480cd7d678bd2636f853c344acae Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Fri, 26 Dec 2014 10:35:00 +0000 Subject: [PATCH] Rework relocate dialog in Qt client to load from .ui --- qt/CMakeLists.txt | 1 + qt/qtr.pro | 1 + qt/relocate.cc | 68 +++++++---------- qt/relocate.h | 28 +++---- qt/relocate.ui | 103 ++++++++++++++++++++++++++ qt/translations/transmission_en.ts | 14 ++-- qt/translations/transmission_es.ts | 14 ++-- qt/translations/transmission_eu.ts | 14 ++-- qt/translations/transmission_fr.ts | 14 ++-- qt/translations/transmission_hu.ts | 14 ++-- qt/translations/transmission_kk.ts | 14 ++-- qt/translations/transmission_lt.ts | 14 ++-- qt/translations/transmission_pt_BR.ts | 14 ++-- qt/translations/transmission_ru.ts | 14 ++-- qt/translations/transmission_uk.ts | 14 ++-- 15 files changed, 213 insertions(+), 128 deletions(-) create mode 100644 qt/relocate.ui diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt index 5ce3154f5..662fb9f2f 100644 --- a/qt/CMakeLists.txt +++ b/qt/CMakeLists.txt @@ -104,6 +104,7 @@ tr_qt_wrap_ui(${PROJECT_NAME}_UI_SOURCES about.ui details.ui mainwin.ui + relocate.ui session-dialog.ui stats-dialog.ui ) diff --git a/qt/qtr.pro b/qt/qtr.pro index 662d63d4f..95de8d1eb 100644 --- a/qt/qtr.pro +++ b/qt/qtr.pro @@ -49,6 +49,7 @@ TRANSLATIONS += translations/transmission_en.ts \ FORMS += about.ui \ details.ui \ mainwin.ui \ + relocate.ui \ session-dialog.ui \ stats-dialog.ui RESOURCES += application.qrc diff --git a/qt/relocate.cc b/qt/relocate.cc index 5ce0e6371..09842a409 100644 --- a/qt/relocate.cc +++ b/qt/relocate.cc @@ -7,19 +7,10 @@ * $Id$ */ -#include -#include #include #include -#include -#include -#include -#include -#include -#include -#include +#include -#include "hig.h" #include "relocate.h" #include "session.h" #include "torrent.h" @@ -32,14 +23,22 @@ void RelocateDialog::onSetLocation () { mySession.torrentSetLocation (myIds, myPath, myMoveFlag); - deleteLater (); + close (); } void RelocateDialog::onFileSelected (const QString& path) { myPath = path; - myDirButton->setText (myPath); + + const QFileInfo pathInfo (path); + const QFileIconProvider iconProvider; + + ui.newLocationButton->setIcon (mySession.isLocal () ? + iconProvider.icon (pathInfo) : + iconProvider.icon (QFileIconProvider::Folder)); + ui.newLocationButton->setText (pathInfo.baseName ()); + ui.newLocationButton->setToolTip (path); } void @@ -58,26 +57,19 @@ RelocateDialog::onMoveToggled (bool b) myMoveFlag = b; } -RelocateDialog::RelocateDialog (Session & session, - TorrentModel & model, - const QSet & ids, - QWidget * parent): +RelocateDialog::RelocateDialog (Session & session, + const TorrentModel & model, + const QSet & ids, + QWidget * parent): QDialog (parent), mySession (session), - myModel (model), myIds (ids) { - const int iconSize (style ()->pixelMetric (QStyle::PM_SmallIconSize)); - const QFileIconProvider iconProvider; - const QIcon folderIcon = iconProvider.icon (QFileIconProvider::Folder); - const QPixmap folderPixmap = folderIcon.pixmap (iconSize); - - QRadioButton * find_rb; - setWindowTitle (tr ("Set Torrent Location")); + ui.setupUi (this); foreach (int id, myIds) { - const Torrent * tor = myModel.getTorrentFromId (id); + const Torrent * tor = model.getTorrentFromId (id); if (myPath.isEmpty ()) { @@ -89,29 +81,21 @@ RelocateDialog::RelocateDialog (Session & session, myPath = QDir::homePath (); else myPath = QDir::rootPath (); + break; } } - HIG * hig = new HIG (); - hig->addSectionTitle (tr ("Set Location")); - hig->addRow (tr ("New &location:"), myDirButton = new QPushButton (folderPixmap, myPath)); - hig->addWideControl (myMoveRadio = new QRadioButton (tr ("&Move from the current folder"), this)); - hig->addWideControl (find_rb = new QRadioButton (tr ("Local data is &already there"), this)); - hig->finish (); + onFileSelected (myPath); if (myMoveFlag) - myMoveRadio->setChecked (true); + ui.moveDataRadio->setChecked (true); else - find_rb->setChecked (true); + ui.findDataRadio->setChecked (true); - connect (myMoveRadio, SIGNAL (toggled (bool)), this, SLOT (onMoveToggled (bool))); - connect (myDirButton, SIGNAL (clicked (bool)), this, SLOT (onDirButtonClicked ())); + connect (ui.moveDataRadio, SIGNAL (toggled (bool)), this, SLOT (onMoveToggled (bool))); + connect (ui.newLocationButton, SIGNAL (clicked ()), this, SLOT (onDirButtonClicked ())); + connect (ui.dialogButtons, SIGNAL (rejected ()), this, SLOT (close ())); + connect (ui.dialogButtons, SIGNAL (accepted ()), this, SLOT (onSetLocation ())); - QLayout * layout = new QVBoxLayout (this); - layout->addWidget (hig); - QDialogButtonBox * buttons = new QDialogButtonBox (QDialogButtonBox::Ok|QDialogButtonBox::Cancel); - connect (buttons, SIGNAL (rejected ()), this, SLOT (deleteLater ())); - connect (buttons, SIGNAL (accepted ()), this, SLOT (onSetLocation ())); - layout->addWidget (buttons); - QWidget::setAttribute (Qt::WA_DeleteOnClose, true); + setAttribute (Qt::WA_DeleteOnClose, true); } diff --git a/qt/relocate.h b/qt/relocate.h index 9e21075ad..de68577f7 100644 --- a/qt/relocate.h +++ b/qt/relocate.h @@ -14,26 +14,18 @@ #include #include -class QPushButton; -class QRadioButton; +#include "ui_relocate.h" + class Session; -class Torrent; class TorrentModel; class RelocateDialog: public QDialog { Q_OBJECT - private: - QString myPath; - static bool myMoveFlag; - - private: - Session & mySession; - TorrentModel& myModel; - QSet myIds; - QPushButton * myDirButton; - QRadioButton * myMoveRadio; + public: + RelocateDialog (Session&, const TorrentModel&, const QSet& ids, QWidget * parent = 0); + ~RelocateDialog () {} private slots: void onFileSelected (const QString& path); @@ -41,9 +33,13 @@ class RelocateDialog: public QDialog void onSetLocation (); void onMoveToggled (bool); - public: - RelocateDialog (Session&, TorrentModel&, const QSet& ids, QWidget * parent = 0); - ~RelocateDialog () {} + private: + Session& mySession; + const QSet myIds; + Ui::RelocateDialog ui; + QString myPath; + + static bool myMoveFlag; }; #endif diff --git a/qt/relocate.ui b/qt/relocate.ui new file mode 100644 index 000000000..08b38d3c3 --- /dev/null +++ b/qt/relocate.ui @@ -0,0 +1,103 @@ + + + RelocateDialog + + + + 0 + 0 + 225 + 155 + + + + Set Torrent Location + + + [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; +} + + + + QLayout::SetFixedSize + + + + + Set Location + + + form-section first + + + + + + + New &location: + + + newLocationButton + + + form-label + + + + + + + text-align:left + + + false + + + + + + + &Move from the current folder + + + form-label + + + + + + + Local data is &already there + + + form-label + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + diff --git a/qt/translations/transmission_en.ts b/qt/translations/transmission_en.ts index 8a05f53ad..f4c8d1dd9 100644 --- a/qt/translations/transmission_en.ts +++ b/qt/translations/transmission_en.ts @@ -10,7 +10,7 @@ - + <big><b>Transmission %1</b></big> @@ -2009,32 +2009,32 @@ To add another primary URL, add it after a blank line. RelocateDialog - + Select Location - + Set Torrent Location - + Set Location - + New &location: - + &Move from the current folder - + Local data is &already there diff --git a/qt/translations/transmission_es.ts b/qt/translations/transmission_es.ts index 2d8999c69..b9655e963 100644 --- a/qt/translations/transmission_es.ts +++ b/qt/translations/transmission_es.ts @@ -10,7 +10,7 @@ Acerca de Transmission - + <big><b>Transmission %1</b></big> <big><b>Transmission %1</b></big> @@ -2012,32 +2012,32 @@ Para agregar otro URL primario, agrueguelo después de una línea en blanco. RelocateDialog - + Select Location Seleccione localización - + Set Torrent Location Defina localización del torrent - + Set Location Definir localización - + New &location: Nueva &localización: - + &Move from the current folder &Mover del directorio actual - + Local data is &already there Los datos locales &ya están ahí diff --git a/qt/translations/transmission_eu.ts b/qt/translations/transmission_eu.ts index 5eadd9d26..8e00c08cd 100644 --- a/qt/translations/transmission_eu.ts +++ b/qt/translations/transmission_eu.ts @@ -10,7 +10,7 @@ Transmissioni buruz - + <big><b>Transmission %1</b></big> <big><b>Transmission %1</b></big> @@ -2009,32 +2009,32 @@ Beste lehen URL bat gehitzeko, gehitu hura lerro huts baten ondoren. RelocateDialog - + Select Location Hautatu Kokalekua - + Set Torrent Location Ezarri Torrentaren Kokalekua - + Set Location Ezarri Kokalekua - + New &location: &Kokaleku berria: - + &Move from the current folder &Mugitu oraingo agiritegitik - + Local data is &already there &Tokiko datuak jadanik hor daude diff --git a/qt/translations/transmission_fr.ts b/qt/translations/transmission_fr.ts index cf86422ef..b9687ad4e 100644 --- a/qt/translations/transmission_fr.ts +++ b/qt/translations/transmission_fr.ts @@ -10,7 +10,7 @@ Transmission - + <big><b>Transmission %1</b></big> <big><b>Transmission %1</b></big> @@ -2009,32 +2009,32 @@ Pour ajouter une autre URL primaire, placez-la après une ligne vide. RelocateDialog - + Select Location Séléctionner l'emplacement - + Set Torrent Location Définir l'emplacement du torrent - + Set Location Définir l'emplacement - + New &location: Nouvel emp&lacement: - + &Move from the current folder &Déplacer depuis le dossier courant - + Local data is &already there Les données locales sont &déjà là diff --git a/qt/translations/transmission_hu.ts b/qt/translations/transmission_hu.ts index 281cdc569..ace035154 100644 --- a/qt/translations/transmission_hu.ts +++ b/qt/translations/transmission_hu.ts @@ -10,7 +10,7 @@ A Transmission-ről - + <big><b>Transmission %1</b></big> <big><b>Transmission %1</b></big> @@ -1996,32 +1996,32 @@ Másik elsődleges URL-t új sorba írva adhatsz hozzá. RelocateDialog - + Select Location Válaszd ki a mappát - + Set Torrent Location Válaszd ki a torrentet - + Set Location Válaszd ki a mappát - + New &location: Új &hely: - + &Move from the current folder Áthelyezés a &jelenlegi mappából - + Local data is &already there A letöltött adat &már itt van diff --git a/qt/translations/transmission_kk.ts b/qt/translations/transmission_kk.ts index bb350fb49..477a40631 100644 --- a/qt/translations/transmission_kk.ts +++ b/qt/translations/transmission_kk.ts @@ -10,7 +10,7 @@ - + <big><b>Transmission %1</b></big> @@ -2010,32 +2010,32 @@ To add another primary URL, add it after a blank line. RelocateDialog - + Select Location - + Set Torrent Location Торрент орналасуын көрсетіңіз - + Set Location Орналасуын көрсету - + New &location: - + &Move from the current folder &Ағымдағы бумадан жылжыту - + Local data is &already there Жергілікті мәліметтер ол жерде &болып тұр diff --git a/qt/translations/transmission_lt.ts b/qt/translations/transmission_lt.ts index f9d142ebd..c95fc38d3 100644 --- a/qt/translations/transmission_lt.ts +++ b/qt/translations/transmission_lt.ts @@ -5,7 +5,7 @@ AboutDialog - + &License &Licencija @@ -2022,32 +2022,32 @@ Papildomą pirminį URL adresą galite įvesti, palikę prieš jį tuščią eil RelocateDialog - + &Move from the current folder &Perkelti iš dabartinio aplanko - + Local data is &already there Vietiniai duomenys jau yra &ten - + New &location: Nauja &vieta: - + Select Location Parinkite vietą - + Set Location Nustatyti vietą - + Set Torrent Location Torento vietos nustatymas diff --git a/qt/translations/transmission_pt_BR.ts b/qt/translations/transmission_pt_BR.ts index 87bec3467..5fe68776b 100644 --- a/qt/translations/transmission_pt_BR.ts +++ b/qt/translations/transmission_pt_BR.ts @@ -10,7 +10,7 @@ Sobre o Transmission - + <big><b>Transmission %1</b></big> @@ -2010,32 +2010,32 @@ Adicione outra URL primária depois de uma linha em branco. RelocateDialog - + Select Location Selecionar local - + Set Torrent Location Definir Local do Torrent - + Set Location Definir Local - + New &location: Novo local: - + &Move from the current folder Mover da pasta atual - + Local data is &already there Os dados locais já estão lá diff --git a/qt/translations/transmission_ru.ts b/qt/translations/transmission_ru.ts index 62c287f14..d396666ed 100644 --- a/qt/translations/transmission_ru.ts +++ b/qt/translations/transmission_ru.ts @@ -10,7 +10,7 @@ О программе "Transmission" - + <big><b>Transmission %1</b></big> @@ -2023,32 +2023,32 @@ To add another primary URL, add it after a blank line. RelocateDialog - + Select Location Выберите местоположение - + Set Torrent Location Указать местоположение торрента - + Set Location Указать местоположение - + New &location: Новое &местоположение: - + &Move from the current folder &Переместить из текущей папки - + Local data is &already there &Локальные данные уже там diff --git a/qt/translations/transmission_uk.ts b/qt/translations/transmission_uk.ts index 749367f63..2c8e1253d 100644 --- a/qt/translations/transmission_uk.ts +++ b/qt/translations/transmission_uk.ts @@ -10,7 +10,7 @@ Про Transmission - + <big><b>Transmission %1</b></big> <big><b>Transmission %1</b></big> @@ -2023,32 +2023,32 @@ To add another primary URL, add it after a blank line. RelocateDialog - + Select Location Обрати розташування - + Set Torrent Location Встановити розташування торенту - + Set Location Встановити розташування - + New &location: Но&ве розташування: - + &Move from the current folder &Перенести зі старої теки у вказану - + Local data is &already there &Локальні дані вже перенесено