Changeset 14418


Ignore:
Timestamp:
Jan 1, 2015, 5:02:13 AM (7 years ago)
Author:
mikedld
Message:

Make use of path button in relocate dialog (Qt client)

Location:
trunk/qt
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/mainwin.cc

    r14415 r14418  
    555555{
    556556  QDialog * d = new RelocateDialog (mySession, myModel, getSelectedTorrents (), this);
     557  d->setAttribute (Qt::WA_DeleteOnClose, true);
    557558  d->show ();
    558559}
  • trunk/qt/make-dialog.ui

    r14415 r14418  
    5858   </item>
    5959   <item row="1" column="1">
    60     <widget class="TrPathButton" name="destinationButton">
    61      <property name="toolButtonStyle">
    62       <enum>Qt::ToolButtonTextBesideIcon</enum>
    63      </property>
    64     </widget>
     60    <widget class="TrPathButton" name="destinationButton"/>
    6561   </item>
    6662   <item row="2" column="0">
     
    7975      <bool>false</bool>
    8076     </property>
    81      <property name="toolButtonStyle">
    82       <enum>Qt::ToolButtonTextBesideIcon</enum>
    83      </property>
    8477    </widget>
    8578   </item>
     
    9891   </item>
    9992   <item row="3" column="1">
    100     <widget class="TrPathButton" name="sourceFileButton">
    101      <property name="toolButtonStyle">
    102       <enum>Qt::ToolButtonTextBesideIcon</enum>
    103      </property>
    104     </widget>
     93    <widget class="TrPathButton" name="sourceFileButton"/>
    10594   </item>
    10695   <item row="4" column="1">
  • trunk/qt/options.ui

    r14414 r14418  
    3030      </sizepolicy>
    3131     </property>
    32      <widget class="TrPathButton" name="sourceButton">
    33       <property name="toolButtonStyle">
    34        <enum>Qt::ToolButtonTextBesideIcon</enum>
    35       </property>
    36      </widget>
     32     <widget class="TrPathButton" name="sourceButton"/>
    3733     <widget class="QLineEdit" name="sourceEdit"/>
    3834    </widget>
     
    5652      </sizepolicy>
    5753     </property>
    58      <widget class="TrPathButton" name="destinationButton">
    59       <property name="toolButtonStyle">
    60        <enum>Qt::ToolButtonTextBesideIcon</enum>
    61       </property>
    62      </widget>
     54     <widget class="TrPathButton" name="destinationButton"/>
    6355     <widget class="QLineEdit" name="destinationEdit"/>
    6456    </widget>
  • trunk/qt/path-button.cc

    r14416 r14418  
    2727{
    2828  setSizePolicy(QSizePolicy (QSizePolicy::Preferred, QSizePolicy::Fixed));
     29  setToolButtonStyle (Qt::ToolButtonTextBesideIcon);
    2930  setText (tr ("(None)")); // for minimum width
    3031
     
    105106  if (isDirMode ())
    106107    dialog->setOption (QFileDialog::ShowDirsOnly);
    107   dialog->setNameFilter (myNameFilter);
     108  if (!myNameFilter.isEmpty ())
     109    dialog->setNameFilter (myNameFilter);
    108110  dialog->selectFile (myPath);
    109111
  • trunk/qt/relocate.cc

    r14412 r14418  
    99
    1010#include <QDir>
    11 #include <QFileIconProvider>
    12 #include <QFileInfo>
    1311
    1412#include "relocate.h"
     
    1614#include "torrent.h"
    1715#include "torrent-model.h"
    18 #include "utils.h"
    1916
    2017bool RelocateDialog::myMoveFlag = true;
     
    2320RelocateDialog::onSetLocation ()
    2421{
    25   mySession.torrentSetLocation (myIds, myPath, myMoveFlag);
     22  mySession.torrentSetLocation (myIds, newLocation (), myMoveFlag);
    2623  close ();
    27 }
    28 
    29 void
    30 RelocateDialog::onFileSelected (const QString& path)
    31 {
    32   myPath = path;
    33 
    34   const int iconSize = style ()->pixelMetric (QStyle::PM_SmallIconSize);
    35 
    36   const QFileInfo pathInfo (path);
    37   const QString absolutePath = pathInfo.absoluteFilePath ();
    38   const QFileIconProvider iconProvider;
    39 
    40   ui.newLocationButton->setIcon (mySession.isLocal () ?
    41                                  iconProvider.icon (pathInfo) :
    42                                  iconProvider.icon (QFileIconProvider::Folder));
    43   ui.newLocationButton->setIconSize (QSize (iconSize, iconSize));
    44   ui.newLocationButton->setText (pathInfo.fileName ().isEmpty () ? absolutePath : pathInfo.fileName ());
    45   ui.newLocationButton->setToolTip (absolutePath);
    46 }
    47 
    48 void
    49 RelocateDialog::onDirButtonClicked ()
    50 {
    51   const QString title = tr ("Select Location");
    52   const QString path = Utils::remoteFileChooser (this, title, myPath, true, mySession.isServer ());
    53 
    54   if (!path.isEmpty ())
    55     onFileSelected (path);
    5624}
    5725
     
    7240  ui.setupUi (this);
    7341
     42  QString path;
    7443  foreach (int id, myIds)
    7544    {
    7645      const Torrent * tor = model.getTorrentFromId (id);
    7746
    78       if (myPath.isEmpty ())
     47      if (path.isEmpty ())
    7948        {
    80           myPath = tor->getPath ();
     49          path = tor->getPath ();
    8150        }
    82       else if (myPath != tor->getPath ())
     51      else if (path != tor->getPath ())
    8352        {
    8453          if (mySession.isServer ())
    85             myPath = QDir::homePath ();
     54            path = QDir::homePath ();
    8655          else
    87             myPath = QDir::rootPath ();
     56            path = QDir::rootPath ();
    8857          break;
    8958        }
    9059    }
    9160
    92   onFileSelected (myPath);
     61  if (mySession.isServer ())
     62    {
     63      ui.newLocationStack->setCurrentWidget (ui.newLocationButton);
     64      ui.newLocationButton->setMode (TrPathButton::DirectoryMode);
     65      ui.newLocationButton->setTitle (tr ("Select Location"));
     66      ui.newLocationButton->setPath (path);
     67    }
     68  else
     69    {
     70      ui.newLocationStack->setCurrentWidget (ui.newLocationEdit);
     71      ui.newLocationEdit->setText (path);
     72      ui.newLocationEdit->selectAll ();
     73    }
     74
     75  ui.newLocationStack->setFixedHeight (ui.newLocationStack->currentWidget ()->sizeHint ().height ());
     76  ui.newLocationLabel->setBuddy (ui.newLocationStack->currentWidget ());
    9377
    9478  if (myMoveFlag)
     
    9882
    9983  connect (ui.moveDataRadio, SIGNAL (toggled (bool)), this, SLOT (onMoveToggled (bool)));
    100   connect (ui.newLocationButton, SIGNAL (clicked ()), this, SLOT (onDirButtonClicked ()));
    10184  connect (ui.dialogButtons, SIGNAL (rejected ()), this, SLOT (close ()));
    10285  connect (ui.dialogButtons, SIGNAL (accepted ()), this, SLOT (onSetLocation ()));
     86}
    10387
    104   setAttribute (Qt::WA_DeleteOnClose, true);
     88QString
     89RelocateDialog::newLocation () const
     90{
     91  return ui.newLocationStack->currentWidget () == ui.newLocationButton ?
     92         ui.newLocationButton->path () : ui.newLocationEdit->text ();
    10593}
  • trunk/qt/relocate.h

    r14400 r14418  
    1313#include <QDialog>
    1414#include <QSet>
    15 #include <QString>
    1615
    1716#include "ui_relocate.h"
     
    2928
    3029  private slots:
    31     void onFileSelected (const QString& path);
    32     void onDirButtonClicked ();
    3330    void onSetLocation ();
    3431    void onMoveToggled (bool);
     32
     33  private:
     34    QString newLocation () const;
    3535
    3636  private:
     
    3838    const QSet<int> myIds;
    3939    Ui::RelocateDialog ui;
    40     QString myPath;
    4140
    4241    static bool myMoveFlag;
  • trunk/qt/relocate.ui

    r14412 r14418  
    77    <x>0</x>
    88    <y>0</y>
    9     <width>225</width>
    10     <height>155</height>
     9    <width>339</width>
     10    <height>151</height>
    1111   </rect>
    1212  </property>
     
    2828{
    2929  margin-left: 18px;
     30}
     31#newLocationStack
     32{
     33  min-width: 15em;
    3034}</string>
    3135  </property>
     
    4953      <string>New &amp;location:</string>
    5054     </property>
    51      <property name="buddy">
    52       <cstring>newLocationButton</cstring>
    53      </property>
    5455     <property name="tr-style" stdset="0">
    5556      <string notr="true">form-label</string>
     
    5859   </item>
    5960   <item row="1" column="1">
    60     <widget class="QToolButton" name="newLocationButton">
    61      <property name="sizePolicy">
    62       <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
    63        <horstretch>0</horstretch>
    64        <verstretch>0</verstretch>
    65       </sizepolicy>
    66      </property>
    67      <property name="styleSheet">
    68       <string notr="true">text-align:left</string>
    69      </property>
    70      <property name="toolButtonStyle">
    71       <enum>Qt::ToolButtonTextBesideIcon</enum>
    72      </property>
     61    <widget class="QStackedWidget" name="newLocationStack">
     62     <widget class="TrPathButton" name="newLocationButton"/>
     63     <widget class="QLineEdit" name="newLocationEdit"/>
    7364    </widget>
    7465   </item>
     
    10596  </layout>
    10697 </widget>
     98 <customwidgets>
     99  <customwidget>
     100   <class>TrPathButton</class>
     101   <extends>QToolButton</extends>
     102   <header>path-button.h</header>
     103  </customwidget>
     104 </customwidgets>
    107105 <resources/>
    108106 <connections/>
Note: See TracChangeset for help on using the changeset viewer.