From: Mike Gelfand Date: Mon, 29 Dec 2014 04:03:56 +0000 (+0000) Subject: Rework torrent options dialog in Qt client to load from .ui X-Git-Tag: 2.90~279 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c64ca900c220e1f47dc950744ef86e507c1e9ea4;p=transmission Rework torrent options dialog in Qt client to load from .ui --- diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt index 9f039fa33..8f816acea 100644 --- a/qt/CMakeLists.txt +++ b/qt/CMakeLists.txt @@ -106,6 +106,7 @@ tr_qt_wrap_ui(${PROJECT_NAME}_UI_SOURCES about.ui details.ui mainwin.ui + options.ui relocate.ui session-dialog.ui stats-dialog.ui diff --git a/qt/app.cc b/qt/app.cc index 883fb43a8..6a88b5089 100644 --- a/qt/app.cc +++ b/qt/app.cc @@ -519,7 +519,7 @@ MyApp::addTorrent (const AddData& addme) } else { - Options * o = new Options (*mySession, *myPrefs, addme, myWindow); + OptionsDialog * o = new OptionsDialog (*mySession, *myPrefs, addme, myWindow); o->show (); } diff --git a/qt/file-tree.cc b/qt/file-tree.cc index ea209ea24..b739c0de4 100644 --- a/qt/file-tree.cc +++ b/qt/file-tree.cc @@ -428,6 +428,12 @@ FileTreeModel::~FileTreeModel() delete myRootItem; } +void +FileTreeModel::setEditable (bool editable) +{ + myIsEditable = editable; +} + FileTreeItem * FileTreeModel::itemFromIndex (const QModelIndex& index) const { @@ -1011,3 +1017,9 @@ FileTreeView::clear () { myModel.clear(); } + +void +FileTreeView::setEditable (bool editable) +{ + myModel.setEditable (editable); +} diff --git a/qt/file-tree.h b/qt/file-tree.h index a1b811238..79ae42ce4 100644 --- a/qt/file-tree.h +++ b/qt/file-tree.h @@ -100,6 +100,8 @@ class FileTreeModel: public QAbstractItemModel FileTreeModel (QObject *parent = 0, bool isEditable = true); ~FileTreeModel (); + void setEditable (bool editable); + public: QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const; Qt::ItemFlags flags (const QModelIndex& index) const; @@ -136,7 +138,7 @@ class FileTreeModel: public QAbstractItemModel private: FileTreeItem * myRootItem; QMap myIndexCache; - const bool myIsEditable; + bool myIsEditable; public slots: void clicked (const QModelIndex & index); @@ -166,6 +168,8 @@ class FileTreeView: public QTreeView void clear (); void update (const FileList& files, bool updateProperties=true); + void setEditable (bool editable); + signals: void priorityChanged (const QSet& fileIndices, int priority); void wantedChanged (const QSet& fileIndices, bool wanted); diff --git a/qt/mainwin.cc b/qt/mainwin.cc index 9e29ecec0..8e7c0fc17 100644 --- a/qt/mainwin.cc +++ b/qt/mainwin.cc @@ -1167,7 +1167,7 @@ TrMainWindow::addTorrent (const AddData& addMe, bool showOptions) { if (showOptions) { - Options * o = new Options (mySession, myPrefs, addMe, this); + OptionsDialog * o = new OptionsDialog (mySession, myPrefs, addMe, this); o->show (); qApp->alert (o); } diff --git a/qt/options.cc b/qt/options.cc index 0ba303d18..2809f1890 100644 --- a/qt/options.cc +++ b/qt/options.cc @@ -7,23 +7,10 @@ * $Id$ */ -#include // std::min() - -#include -#include -#include -#include #include #include #include -#include -#include #include -#include -#include -#include -#include -#include #include #include /* mime64 */ @@ -32,7 +19,6 @@ #include "add-data.h" #include "file-tree.h" #include "freespace-label.h" -#include "hig.h" #include "options.h" #include "prefs.h" #include "session.h" @@ -43,23 +29,17 @@ **** ***/ -Options::Options (Session& session, const Prefs& prefs, const AddData& addme, QWidget * parent): +OptionsDialog::OptionsDialog (Session& session, const Prefs& prefs, const AddData& addme, QWidget * parent): QDialog (parent, Qt::Dialog), mySession (session), myAdd (addme), myHaveInfo (false), - mySourceButton (0), - mySourceEdit (0), - myDestinationButton (0), - myDestinationEdit (0), - myVerifyButton (0), - myVerifyFile (0), + myVerifyButton (nullptr), + myVerifyFile (nullptr), myVerifyHash (QCryptographicHash::Sha1), myEditTimer (this) { - QFontMetrics fontMetrics (font ()); - QGridLayout * layout = new QGridLayout (this); - int row = 0; + ui.setupUi (this); QString title; if (myAdd.type == AddData::FILENAME) @@ -70,128 +50,81 @@ Options::Options (Session& session, const Prefs& prefs, const AddData& addme, QW myEditTimer.setInterval (2000); myEditTimer.setSingleShot (true); - connect (&myEditTimer, SIGNAL (timeout ()), this, SLOT (onDestinationEditedIdle ())); - - const int iconSize (style ()->pixelMetric (QStyle::PM_SmallIconSize)); - QIcon fileIcon = style ()->standardIcon (QStyle::SP_FileIcon); - const QPixmap filePixmap = fileIcon.pixmap (iconSize); - - QLabel * l = new QLabel (tr ("&Source:")); - layout->addWidget (l, row, 0, Qt::AlignLeft); - - QWidget * w; - QPushButton * p; + connect (&myEditTimer, SIGNAL (timeout ()), this, SLOT (onDestinationEdited ())); if (myAdd.type == AddData::FILENAME) { - p = mySourceButton = new QPushButton; - p->setIcon (filePixmap); - p->setStyleSheet (QString::fromUtf8 ("text-align: left; padding-left: 5; padding-right: 5")); - p->installEventFilter (this); - w = p; - connect (p, SIGNAL (clicked (bool)), this, SLOT (onFilenameClicked ())); + ui.sourceStack->setCurrentWidget (ui.sourceButton); + onSourceSelected (myAdd.filename); + connect (ui.sourceButton, SIGNAL (clicked ()), this, SLOT (onSourceClicked ())); } else { - QLineEdit * e = mySourceEdit = new QLineEdit; - e->setText (myAdd.readableName()); - e->setCursorPosition (0); - e->selectAll (); - w = e; - connect (e, SIGNAL(editingFinished()), this, SLOT(onSourceEditingFinished())); + ui.sourceStack->setCurrentWidget (ui.sourceEdit); + ui.sourceEdit->setText (myAdd.readableName ()); + ui.sourceEdit->selectAll (); + connect (ui.sourceEdit, SIGNAL (editingFinished ()), this, SLOT (onSourceEdited ())); } + ui.sourceStack->setFixedHeight (ui.sourceStack->currentWidget ()->sizeHint ().height ()); + ui.sourceLabel->setBuddy (ui.sourceStack->currentWidget ()); + + const QFontMetrics fontMetrics (font ()); const int width = fontMetrics.size (0, QString::fromUtf8 ("This is a pretty long torrent filename indeed.torrent")).width (); - w->setMinimumWidth (width); - layout->addWidget (w, row, 1); - l->setBuddy (w); + ui.sourceStack->setMinimumWidth (width); - l = new QLabel (tr ("&Destination folder:")); - layout->addWidget (l, ++row, 0, Qt::AlignLeft); const QString downloadDir (prefs.getString (Prefs::DOWNLOAD_DIR)); - myFreespaceLabel = new FreespaceLabel (this); - myFreespaceLabel->setSession (mySession); - myFreespaceLabel->setPath (downloadDir); + ui.freeSpaceLabel->setSession (mySession); if (session.isLocal ()) { - const QFileIconProvider iconProvider; - const QIcon folderIcon = iconProvider.icon (QFileIconProvider::Folder); - const QPixmap folderPixmap = folderIcon.pixmap (iconSize); - - myLocalDestination.setPath (downloadDir); - p = myDestinationButton = new QPushButton; - p->setIcon (folderPixmap); - p->setStyleSheet ("text-align: left; padding-left: 5; padding-right: 5"); - p->installEventFilter (this); - layout->addWidget (p, row, 1); - l->setBuddy (p); - connect (p, SIGNAL (clicked (bool)), this, SLOT (onDestinationClicked ())); + ui.destinationStack->setCurrentWidget (ui.destinationButton); + onDestinationSelected (downloadDir); + connect (ui.destinationButton, SIGNAL (clicked ()), this, SLOT (onDestinationClicked ())); } else { - QLineEdit * e = myDestinationEdit = new QLineEdit; - e->setText (downloadDir); - layout->addWidget (e, row, 1); - l->setBuddy (e); - connect (e, SIGNAL (textEdited (QString)), this, SLOT (onDestinationEdited (QString))); + ui.destinationStack->setCurrentWidget (ui.destinationEdit); + ui.destinationEdit->setText (downloadDir); + ui.freeSpaceLabel->setPath (downloadDir); + connect (ui.destinationEdit, SIGNAL (textEdited (QString)), &myEditTimer, SLOT (start ())); + connect (ui.destinationEdit, SIGNAL (editingFinished ()), this, SLOT (onDestinationEdited ())); } - l = myFreespaceLabel; - layout->addWidget (l, ++row, 0, 1, 2, Qt::Alignment (Qt::AlignRight | Qt::AlignTop)); - layout->setRowMinimumHeight (row, l->height () + HIG::PAD_SMALL); + ui.destinationStack->setFixedHeight (ui.destinationStack->currentWidget ()->sizeHint ().height ()); + ui.destinationLabel->setBuddy (ui.destinationStack->currentWidget ()); - myTree = new FileTreeView (0, false); - layout->addWidget (myTree, ++row, 0, 1, 2); + ui.filesView->setEditable (false); if (!session.isLocal ()) - myTree->hideColumn (2); // hide the % done, since we've no way of knowing - - QComboBox * m = new QComboBox; - m->addItem (tr ("High"), TR_PRI_HIGH); - m->addItem (tr ("Normal"), TR_PRI_NORMAL); - m->addItem (tr ("Low"), TR_PRI_LOW); - m->setCurrentIndex (1); // Normal - myPriorityCombo = m; - l = new QLabel (tr ("&Priority:")); - l->setBuddy (m); - layout->addWidget (l, ++row, 0, Qt::AlignLeft); - layout->addWidget (m, row, 1); + ui.filesView->hideColumn (2); // hide the % done, since we've no way of knowing + + ui.priorityCombo->addItem (tr ("High"), TR_PRI_HIGH); + ui.priorityCombo->addItem (tr ("Normal"), TR_PRI_NORMAL); + ui.priorityCombo->addItem (tr ("Low"), TR_PRI_LOW); + ui.priorityCombo->setCurrentIndex (1); // Normal if (session.isLocal ()) { - p = myVerifyButton = new QPushButton (tr ("&Verify Local Data")); - layout->addWidget (p, ++row, 0, Qt::AlignLeft); + myVerifyButton = new QPushButton (tr ("&Verify Local Data"), this); + ui.dialogButtons->addButton (myVerifyButton, QDialogButtonBox::ActionRole); + connect (myVerifyButton, SIGNAL (clicked (bool)), this, SLOT (onVerify ())); } - QCheckBox * c; - c = myStartCheck = new QCheckBox (tr ("S&tart when added")); - c->setChecked (prefs.getBool (Prefs::START)); - layout->addWidget (c, ++row, 0, 1, 2, Qt::AlignLeft); - - c = myTrashCheck = new QCheckBox (tr ("Mo&ve .torrent file to the trash")); - c->setChecked (prefs.getBool (Prefs::TRASH_ORIGINAL)); - layout->addWidget (c, ++row, 0, 1, 2, Qt::AlignLeft); + ui.startCheck->setChecked (prefs.getBool (Prefs::START)); + ui.trashCheck->setChecked (prefs.getBool (Prefs::TRASH_ORIGINAL)); - QDialogButtonBox * b = new QDialogButtonBox (QDialogButtonBox::Open|QDialogButtonBox::Cancel, Qt::Horizontal, this); - connect (b, SIGNAL (rejected ()), this, SLOT (deleteLater ())); - connect (b, SIGNAL (accepted ()), this, SLOT (onAccepted ())); - layout->addWidget (b, ++row, 0, 1, 2); + connect (ui.dialogButtons, SIGNAL (rejected ()), this, SLOT (deleteLater ())); + connect (ui.dialogButtons, SIGNAL (accepted ()), this, SLOT (onAccepted ())); - layout->setRowStretch (3, 2); - layout->setColumnStretch (1, 2); - layout->setSpacing (HIG::PAD); - - connect (myTree, SIGNAL (priorityChanged (QSet, int)), this, SLOT (onPriorityChanged (QSet, int))); - connect (myTree, SIGNAL (wantedChanged (QSet, bool)), this, SLOT (onWantedChanged (QSet, bool))); - if (session.isLocal ()) - connect (myVerifyButton, SIGNAL (clicked (bool)), this, SLOT (onVerify ())); + connect (ui.filesView, SIGNAL (priorityChanged (QSet, int)), this, SLOT (onPriorityChanged (QSet, int))); + connect (ui.filesView, SIGNAL (wantedChanged (QSet, bool)), this, SLOT (onWantedChanged (QSet, bool))); connect (&myVerifyTimer, SIGNAL (timeout ()), this, SLOT (onTimeout ())); reload (); } -Options::~Options () +OptionsDialog::~OptionsDialog () { clearInfo (); } @@ -201,57 +134,7 @@ Options::~Options () ***/ void -Options::refreshButton (QPushButton * p, const QString& text, int width) -{ - if (width <= 0) - width = p->width (); - width -= 15; - QFontMetrics fontMetrics (font ()); - QString str = fontMetrics.elidedText (text, Qt::ElideRight, width); - p->setText (str); -} - -void -Options::refreshSource (int width) -{ - QString text = myAdd.readableName (); - - if (mySourceButton) - refreshButton (mySourceButton, text, width); - - if (mySourceEdit) - mySourceEdit->setText (text); -} - -void -Options::refreshDestinationButton (int width) -{ - if (myDestinationButton != 0) - refreshButton (myDestinationButton, myLocalDestination.absolutePath (), width); -} - - -bool -Options::eventFilter (QObject * o, QEvent * event) -{ - if (event->type() == QEvent::Resize) - { - if (o == mySourceButton) - refreshSource (static_cast (event)->size ().width ()); - - else if (o == myDestinationButton) - refreshDestinationButton (static_cast (event)->size ().width ()); - } - - return false; -} - -/*** -**** -***/ - -void -Options::clearInfo () +OptionsDialog::clearInfo () { if (myHaveInfo) tr_metainfoFree (&myInfo); @@ -261,7 +144,7 @@ Options::clearInfo () } void -Options::reload () +OptionsDialog::reload () { clearInfo (); clearVerify (); @@ -279,7 +162,7 @@ Options::reload () break; case AddData::METAINFO: - tr_ctorSetMetainfo (ctor, (const quint8*)myAdd.metainfo.constData (), myAdd.metainfo.size ()); + tr_ctorSetMetainfo (ctor, reinterpret_cast (myAdd.metainfo.constData ()), myAdd.metainfo.size ()); break; default: @@ -290,21 +173,24 @@ Options::reload () myHaveInfo = !err; tr_ctorFree (ctor); - myTree->clear (); - myTree->setVisible (myHaveInfo && (myInfo.fileCount>0)); + ui.filesView->clear (); myFiles.clear (); myPriorities.clear (); myWanted.clear (); - if (myVerifyButton) - myVerifyButton->setVisible (myHaveInfo && (myInfo.fileCount>0)); + const bool haveFilesToShow = myHaveInfo && myInfo.fileCount > 0; + + ui.filesView->setVisible (haveFilesToShow); + if (myVerifyButton != nullptr) + myVerifyButton->setVisible (haveFilesToShow); + layout ()->setSizeConstraint (haveFilesToShow ? QLayout::SetDefaultConstraint : QLayout::SetFixedSize); if (myHaveInfo) { myPriorities.insert (0, myInfo.fileCount, TR_PRI_NORMAL); myWanted.insert (0, myInfo.fileCount, true); - for (tr_file_index_t i=0; iupdate (myFiles); + ui.filesView->update (myFiles); } void -Options::onPriorityChanged (const QSet& fileIndices, int priority) +OptionsDialog::onPriorityChanged (const QSet& fileIndices, int priority) { foreach (int i, fileIndices) myPriorities[i] = priority; } void -Options::onWantedChanged (const QSet& fileIndices, bool isWanted) +OptionsDialog::onWantedChanged (const QSet& fileIndices, bool isWanted) { foreach (int i, fileIndices) myWanted[i] = isWanted; } void -Options::onAccepted () +OptionsDialog::onAccepted () { // rpc spec section 3.4 "adding a torrent" @@ -344,19 +230,19 @@ Options::onAccepted () QString downloadDir; // "download-dir" - if (myDestinationButton) + if (ui.destinationStack->currentWidget () == ui.destinationButton) downloadDir = myLocalDestination.absolutePath (); else - downloadDir = myDestinationEdit->text (); + downloadDir = ui.destinationEdit->text (); tr_variantDictAddStr (&args, TR_KEY_download_dir, downloadDir.toUtf8 ().constData ()); // paused - tr_variantDictAddBool (&args, TR_KEY_paused, !myStartCheck->isChecked ()); + tr_variantDictAddBool (&args, TR_KEY_paused, !ui.startCheck->isChecked ()); // priority - const int index = myPriorityCombo->currentIndex (); - const int priority = myPriorityCombo->itemData (index).toInt (); + const int index = ui.priorityCombo->currentIndex (); + const int priority = ui.priorityCombo->itemData (index).toInt (); tr_variantDictAddInt (&args, TR_KEY_bandwidthPriority, priority); // files-unwanted @@ -364,9 +250,11 @@ Options::onAccepted () if (count > 0) { tr_variant * l = tr_variantDictAddList (&args, TR_KEY_files_unwanted, count); - for (int i=0, n=myWanted.size (); i 0) { tr_variant * l = tr_variantDictAddList (&args, TR_KEY_priority_low, count); - for (int i=0, n=myPriorities.size (); i 0) { tr_variant * l = tr_variantDictAddList (&args, TR_KEY_priority_high, count); - for (int i=0, n=myPriorities.size (); iisChecked ()); + mySession.addTorrent (myAdd, &args, ui.trashCheck->isChecked ()); deleteLater (); } void -Options::onFilenameClicked () +OptionsDialog::onSourceClicked () { if (myAdd.type == AddData::FILENAME) { @@ -405,62 +297,71 @@ Options::onFilenameClicked () tr ("Torrent Files (*.torrent);;All Files (*.*)")); d->setFileMode (QFileDialog::ExistingFile); d->setAttribute (Qt::WA_DeleteOnClose); - connect (d, SIGNAL (filesSelected (QStringList)), this, SLOT (onFilesSelected (QStringList))); + connect (d, SIGNAL (fileSelected (QString)), this, SLOT (onSourceSelected (QString))); d->show (); } } void -Options::onFilesSelected (const QStringList& files) +OptionsDialog::onSourceSelected (const QString& path) { - if (files.size () == 1) - { - myAdd.set (files.at (0)); - refreshSource (); - reload (); - } + if (path.isEmpty ()) + return; + + myAdd.set (path); + + const QFileInfo pathInfo (path); + + const int iconSize (style ()->pixelMetric (QStyle::PM_SmallIconSize)); + const QFileIconProvider iconProvider; + + ui.sourceButton->setIconSize (QSize (iconSize, iconSize)); + ui.sourceButton->setIcon (iconProvider.icon (path)); + ui.sourceButton->setText (pathInfo.fileName ().isEmpty () ? path : pathInfo.fileName ()); + ui.sourceButton->setToolTip (path); + + reload (); } void -Options::onSourceEditingFinished () +OptionsDialog::onSourceEdited () { - myAdd.set (mySourceEdit->text()); + myAdd.set (ui.sourceEdit->text ()); } void -Options::onDestinationClicked () +OptionsDialog::onDestinationClicked () { QFileDialog * d = new QFileDialog (this, tr ("Select Destination"), myLocalDestination.absolutePath ()); d->setFileMode (QFileDialog::Directory); d->setAttribute (Qt::WA_DeleteOnClose); - connect (d, SIGNAL (filesSelected (QStringList)), this, SLOT (onDestinationsSelected (QStringList))); + connect (d, SIGNAL (fileSelected (QString)), this, SLOT (onDestinationSelected (QString))); d->show (); } void -Options::onDestinationsSelected (const QStringList& destinations) +OptionsDialog::onDestinationSelected (const QString& path) { - if (destinations.size () == 1) - { - QString destination = Utils::removeTrailingDirSeparator (destinations.first ()); - myFreespaceLabel->setPath (destination); - myLocalDestination.setPath (destination); - refreshDestinationButton (); - } -} + if (path.isEmpty ()) + return; -void -Options::onDestinationEdited (const QString& text) -{ - Q_UNUSED (text); + myLocalDestination.setPath (Utils::removeTrailingDirSeparator (path)); + + const int iconSize (style ()->pixelMetric (QStyle::PM_SmallIconSize)); + const QFileIconProvider iconProvider; + + ui.destinationButton->setIconSize (QSize (iconSize, iconSize)); + ui.destinationButton->setIcon (iconProvider.icon (path)); + ui.destinationButton->setText (myLocalDestination.dirName ().isEmpty () ? path : myLocalDestination.dirName ()); + ui.destinationButton->setToolTip (path); - myEditTimer.start (); + ui.freeSpaceLabel->setPath (path); } void -Options::onDestinationEditedIdle () +OptionsDialog::onDestinationEdited () { - myFreespaceLabel->setPath (myDestinationEdit->text()); + ui.freeSpaceLabel->setPath (ui.destinationEdit->text ()); } /*** @@ -470,7 +371,7 @@ Options::onDestinationEditedIdle () ***/ void -Options::clearVerify () +OptionsDialog::clearVerify () { myVerifyHash.reset (); myVerifyFile.close (); @@ -481,14 +382,14 @@ Options::clearVerify () myVerifyPiecePos = 0; myVerifyTimer.stop (); - for (int i=0, n=myFiles.size (); iupdate (myFiles); + ui.filesView->update (myFiles); } void -Options::onVerify () +OptionsDialog::onVerify () { clearVerify (); myVerifyFlags.insert (0, myInfo.pieceCount, false); @@ -507,9 +408,9 @@ namespace } void -Options::onTimeout () +OptionsDialog::onTimeout () { - if (myFiles.isEmpty()) + if (myFiles.isEmpty ()) { myVerifyTimer.stop (); return; @@ -526,8 +427,8 @@ Options::onTimeout () int64_t leftInPiece = getPieceSize (&myInfo, myVerifyPieceIndex) - myVerifyPiecePos; int64_t leftInFile = file->length - myVerifyFilePos; - int64_t bytesThisPass = std::min (leftInFile, leftInPiece); - bytesThisPass = std::min (bytesThisPass, static_cast (sizeof (myVerifyBuf))); + int64_t bytesThisPass = qMin (leftInFile, leftInPiece); + bytesThisPass = qMin (bytesThisPass, static_cast (sizeof (myVerifyBuf))); if (myVerifyFile.isOpen () && myVerifyFile.seek (myVerifyFilePos)) { @@ -557,15 +458,14 @@ Options::onTimeout () FileList changedFiles; if (matches) { - mybins_t::const_iterator i; - for (i=myVerifyBins.begin (); i!=myVerifyBins.end (); ++i) + for (auto i = myVerifyBins.begin (), end = myVerifyBins.end (); i != end; ++i) { TrFile& f (myFiles[i.key ()]); f.have += i.value (); changedFiles.append (f); } } - myTree->update (changedFiles); + ui.filesView->update (changedFiles); myVerifyBins.clear (); } @@ -587,11 +487,10 @@ Options::onTimeout () { // did the user accidentally specify the child directory instead of the parent? const QStringList tokens = QString::fromUtf8 (file->name).split ('/'); - if (!tokens.empty () && myLocalDestination.dirName ()==tokens.at (0)) + if (!tokens.empty () && myLocalDestination.dirName () == tokens.at (0)) { // move up one directory and try again myLocalDestination.cdUp (); - refreshDestinationButton (-1); onVerify (); done = false; } diff --git a/qt/options.h b/qt/options.h index 169ec98c9..0f613f30d 100644 --- a/qt/options.h +++ b/qt/options.h @@ -10,28 +10,21 @@ #ifndef OPTIONS_DIALOG_H #define OPTIONS_DIALOG_H +#include #include -#include -#include #include -#include +#include #include #include -#include -#include -#include +#include #include -#include +#include #include "add-data.h" // AddData #include "file-tree.h" // FileList -class QCheckBox; -class QComboBox; -class QPushButton; +#include "ui_options.h" -class FileTreeView; -class FreespaceLabel; class Prefs; class Session; @@ -40,21 +33,18 @@ extern "C" struct tr_variant; } -class Options: public QDialog +class OptionsDialog: public QDialog { Q_OBJECT public: - Options (Session& session, const Prefs& prefs, const AddData& addme, QWidget * parent = 0); - ~Options (); + OptionsDialog (Session& session, const Prefs& prefs, const AddData& addme, QWidget * parent = 0); + ~OptionsDialog (); private: void reload (); void clearInfo (); - void refreshSource (int width=-1); - void refreshDestinationButton (int width=-1); - void refreshButton (QPushButton *, const QString&, int width=-1); - bool eventFilter (QObject *, QEvent *); + void clearVerify (); private slots: void onAccepted (); @@ -62,13 +52,14 @@ class Options: public QDialog void onWantedChanged (const QSet& fileIndices, bool); void onVerify (); void onTimeout (); - void onFilenameClicked (); + + void onSourceClicked (); + void onSourceSelected (const QString&); + void onSourceEdited (); + void onDestinationClicked (); - void onFilesSelected (const QStringList&); - void onSourceEditingFinished (); - void onDestinationsSelected (const QStringList&); - void onDestinationEdited (const QString&); - void onDestinationEditedIdle (); + void onDestinationSelected (const QString&); + void onDestinationEdited (); private: Session& mySession; @@ -76,15 +67,7 @@ class Options: public QDialog QDir myLocalDestination; bool myHaveInfo; tr_info myInfo; - FileTreeView * myTree; - FreespaceLabel * myFreespaceLabel; - QCheckBox * myStartCheck; - QCheckBox * myTrashCheck; - QComboBox * myPriorityCombo; - QPushButton * mySourceButton; - QLineEdit * mySourceEdit; - QPushButton * myDestinationButton; - QLineEdit * myDestinationEdit; + Ui::OptionsDialog ui; QPushButton * myVerifyButton; QVector myPriorities; QVector myWanted; @@ -92,16 +75,15 @@ class Options: public QDialog private: QTimer myVerifyTimer; - char myVerifyBuf[2048*4]; + char myVerifyBuf[2048 * 4]; QFile myVerifyFile; uint64_t myVerifyFilePos; int myVerifyFileIndex; uint32_t myVerifyPieceIndex; uint32_t myVerifyPiecePos; - void clearVerify (); QVector myVerifyFlags; QCryptographicHash myVerifyHash; - typedef QMap mybins_t; + typedef QMap mybins_t; mybins_t myVerifyBins; QTimer myEditTimer; }; diff --git a/qt/options.ui b/qt/options.ui new file mode 100644 index 000000000..35fa12d22 --- /dev/null +++ b/qt/options.ui @@ -0,0 +1,132 @@ + + + OptionsDialog + + + + 0 + 0 + 418 + 379 + + + + + + + &Source: + + + sourceButton + + + + + + + + 0 + 0 + + + + + Qt::ToolButtonTextBesideIcon + + + + + + + + + &Destination folder: + + + destinationButton + + + + + + + + 0 + 0 + + + + + Qt::ToolButtonTextBesideIcon + + + + + + + + + ... + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + &Priority: + + + priorityCombo + + + + + + + + + + S&tart when added + + + + + + + Mo&ve .torrent file to the trash + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Open + + + + + + + + FileTreeView + QTreeView +
file-tree.h
+
+ + FreespaceLabel + QLabel +
freespace-label.h
+
+
+ + +
diff --git a/qt/qtr.pro b/qt/qtr.pro index 32da39ac6..3846e0e09 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 \ + options.ui \ relocate.ui \ session-dialog.ui \ stats-dialog.ui diff --git a/qt/translations/transmission_en.ts b/qt/translations/transmission_en.ts index f4c8d1dd9..c25f845b9 100644 --- a/qt/translations/transmission_en.ts +++ b/qt/translations/transmission_en.ts @@ -1422,7 +1422,7 @@ To add another primary URL, add it after a blank line. - Options + OptionsDialog Open Torrent diff --git a/qt/translations/transmission_es.ts b/qt/translations/transmission_es.ts index b9655e963..e048cbaf7 100644 --- a/qt/translations/transmission_es.ts +++ b/qt/translations/transmission_es.ts @@ -1424,7 +1424,7 @@ Para agregar otro URL primario, agrueguelo después de una línea en blanco. - Options + OptionsDialog Open Torrent diff --git a/qt/translations/transmission_eu.ts b/qt/translations/transmission_eu.ts index 8e00c08cd..639a70356 100644 --- a/qt/translations/transmission_eu.ts +++ b/qt/translations/transmission_eu.ts @@ -1422,7 +1422,7 @@ Beste lehen URL bat gehitzeko, gehitu hura lerro huts baten ondoren. - Options + OptionsDialog Open Torrent diff --git a/qt/translations/transmission_fr.ts b/qt/translations/transmission_fr.ts index b9687ad4e..e3ba6bed1 100644 --- a/qt/translations/transmission_fr.ts +++ b/qt/translations/transmission_fr.ts @@ -1422,7 +1422,7 @@ Pour ajouter une autre URL primaire, placez-la après une ligne vide. - Options + OptionsDialog Open Torrent diff --git a/qt/translations/transmission_hu.ts b/qt/translations/transmission_hu.ts index ace035154..a4835964a 100644 --- a/qt/translations/transmission_hu.ts +++ b/qt/translations/transmission_hu.ts @@ -1412,7 +1412,7 @@ Másik elsődleges URL-t új sorba írva adhatsz hozzá. - Options + OptionsDialog Open Torrent diff --git a/qt/translations/transmission_kk.ts b/qt/translations/transmission_kk.ts index 477a40631..5d3d9bcec 100644 --- a/qt/translations/transmission_kk.ts +++ b/qt/translations/transmission_kk.ts @@ -1423,7 +1423,7 @@ To add another primary URL, add it after a blank line. - Options + OptionsDialog Open Torrent diff --git a/qt/translations/transmission_lt.ts b/qt/translations/transmission_lt.ts index c95fc38d3..7b095eab6 100644 --- a/qt/translations/transmission_lt.ts +++ b/qt/translations/transmission_lt.ts @@ -1432,7 +1432,7 @@ Papildomą pirminį URL adresą galite įvesti, palikę prieš jį tuščią eil - Options + OptionsDialog &Destination folder: diff --git a/qt/translations/transmission_pt_BR.ts b/qt/translations/transmission_pt_BR.ts index 5fe68776b..2288cc9cd 100644 --- a/qt/translations/transmission_pt_BR.ts +++ b/qt/translations/transmission_pt_BR.ts @@ -1423,7 +1423,7 @@ Adicione outra URL primária depois de uma linha em branco. - Options + OptionsDialog Open Torrent diff --git a/qt/translations/transmission_ru.ts b/qt/translations/transmission_ru.ts index d396666ed..2c0c134f1 100644 --- a/qt/translations/transmission_ru.ts +++ b/qt/translations/transmission_ru.ts @@ -1433,7 +1433,7 @@ To add another primary URL, add it after a blank line. - Options + OptionsDialog Open Torrent diff --git a/qt/translations/transmission_uk.ts b/qt/translations/transmission_uk.ts index 2c8e1253d..cd4472872 100644 --- a/qt/translations/transmission_uk.ts +++ b/qt/translations/transmission_uk.ts @@ -1433,7 +1433,7 @@ To add another primary URL, add it after a blank line. - Options + OptionsDialog Open Torrent