Browse Source

Allow to change the save path of torrents after addition

adaptive-webui-19844
Christophe Dumez 16 years ago
parent
commit
b0a0abd764
  1. 1
      Changelog
  2. 282
      src/properties.ui
  3. 30
      src/properties_imp.cpp
  4. 1
      src/properties_imp.h
  5. 5
      src/qtorrenthandle.cpp
  6. 1
      src/qtorrenthandle.h

1
Changelog

@ -8,6 +8,7 @@
- FEATURE: ETA calculation now relies on average speed over all sessions - FEATURE: ETA calculation now relies on average speed over all sessions
- FEATURE: Allow to force rechecking torrents - FEATURE: Allow to force rechecking torrents
- FEATURE: Added support for 2 new extensions (uTorrent metadata and smart ban plugin) - FEATURE: Added support for 2 new extensions (uTorrent metadata and smart ban plugin)
- FEATURE: Allow to change the save path of torrents after addition
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.2.1 * Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.2.1
- BUGFIX: Fixed possible crash when deleting a torrent permanently - BUGFIX: Fixed possible crash when deleting a torrent permanently

282
src/properties.ui

@ -16,16 +16,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number> <number>9</number>
</property> </property>
<item> <item>
@ -37,7 +28,7 @@
<attribute name="title" > <attribute name="title" >
<string>Main infos</string> <string>Main infos</string>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" name="verticalLayout_3" >
<item> <item>
<widget class="QLabel" name="fileName" > <widget class="QLabel" name="fileName" >
<property name="maximumSize" > <property name="maximumSize" >
@ -83,54 +74,15 @@
<property name="title" > <property name="title" >
<string>Torrent infos</string> <string>Torrent infos</string>
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" name="verticalLayout_2" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" name="horizontalLayout_2" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -218,34 +170,42 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" name="verticalLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="save_path" > <layout class="QHBoxLayout" name="horizontalLayout" >
<property name="minimumSize" > <item>
<size> <widget class="QLabel" name="save_path" >
<width>0</width> <property name="minimumSize" >
<height>29</height> <size>
</size> <width>0</width>
</property> <height>29</height>
<property name="text" > </size>
<string/> </property>
</property> <property name="text" >
</widget> <string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="changeSavePathButton" >
<property name="minimumSize" >
<size>
<width>21</width>
<height>0</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>21</width>
<height>16777215</height>
</size>
</property>
<property name="text" >
<string>...</string>
</property>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="QLabel" name="creator" > <widget class="QLabel" name="creator" >
@ -299,7 +259,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -363,16 +323,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number> <number>9</number>
</property> </property>
<item> <item>
@ -380,16 +331,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -397,16 +339,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -488,16 +421,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -535,7 +459,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>181</width> <width>181</width>
<height>20</height> <height>20</height>
@ -578,16 +502,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -613,16 +528,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -643,16 +549,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -660,7 +557,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -711,7 +608,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -728,16 +625,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -745,7 +633,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>20</width> <width>20</width>
<height>40</height> <height>40</height>
@ -796,7 +684,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>20</width> <width>20</width>
<height>40</height> <height>40</height>
@ -813,16 +701,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -867,7 +746,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -885,7 +764,7 @@
<property name="sizeType" > <property name="sizeType" >
<enum>QSizePolicy::Minimum</enum> <enum>QSizePolicy::Minimum</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>20</width> <width>20</width>
<height>40</height> <height>40</height>
@ -903,16 +782,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number> <number>9</number>
</property> </property>
<item> <item>
@ -936,16 +806,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -953,7 +814,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -992,7 +853,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1007,7 +868,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>20</width> <width>20</width>
<height>40</height> <height>40</height>
@ -1066,7 +927,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1093,7 +954,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1136,16 +997,7 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" > <property name="margin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -1153,7 +1005,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>
@ -1173,7 +1025,7 @@
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>40</width>
<height>20</height> <height>20</height>

30
src/properties_imp.cpp

@ -35,6 +35,7 @@
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QSettings> #include <QSettings>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QFileDialog>
// Constructor // Constructor
properties::properties(QWidget *parent, bittorrent *BTSession, QTorrentHandle &h): QDialog(parent), h(h), BTSession(BTSession), changedFilteredfiles(false), hash(h.hash()) { properties::properties(QWidget *parent, bittorrent *BTSession, QTorrentHandle &h): QDialog(parent), h(h), BTSession(BTSession), changedFilteredfiles(false), hash(h.hash()) {
@ -677,6 +678,35 @@ void properties::on_incrementalDownload_stateChanged(int){
} }
} }
void properties::on_changeSavePathButton_clicked() {
QString dir;
QDir saveDir(h.save_path());
if(saveDir.exists()){
dir = QFileDialog::getExistingDirectory(this, tr("Choose save path"), h.save_path());
}else{
dir = QFileDialog::getExistingDirectory(this, tr("Choose save path"), QDir::homePath());
}
if(!dir.isNull()){
// Check if savePath exists
QDir savePath(dir);
if(!savePath.exists()){
if(!savePath.mkpath(savePath.path())){
QMessageBox::critical(0, tr("Save path creation error"), tr("Could not create the save path"));
return;
}
}
// Save savepath
QFile savepath_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".savepath"));
savepath_file.open(QIODevice::WriteOnly | QIODevice::Text);
savepath_file.write(savePath.path().toUtf8());
savepath_file.close();
// Actually move storage
h.move_storage(savePath.path());
// Update save_path in dialog
save_path->setText(savePath.path());
}
}
void properties::on_okButton_clicked(){ void properties::on_okButton_clicked(){
if(savePiecesPriorities()) if(savePiecesPriorities())
close(); close();

1
src/properties_imp.h

@ -80,6 +80,7 @@ class properties : public QDialog, private Ui::properties{
void addTrackerList(QStringList myTrackers); void addTrackerList(QStringList myTrackers);
void writeSettings(); void writeSettings();
void loadSettings(); void loadSettings();
void on_changeSavePathButton_clicked();
signals: signals:
void filteredFilesChanged(QString hash); void filteredFilesChanged(QString hash);

5
src/qtorrenthandle.cpp

@ -393,6 +393,11 @@ void QTorrentHandle::force_recheck() const {
h.force_recheck(); h.force_recheck();
} }
void QTorrentHandle::move_storage(QString new_path) const {
Q_ASSERT(h.is_valid());
h.move_storage(new_path.toUtf8().data());
}
// //
// Operators // Operators
// //

1
src/qtorrenthandle.h

@ -119,6 +119,7 @@ class QTorrentHandle {
void queue_position_up() const; void queue_position_up() const;
void auto_managed(bool) const; void auto_managed(bool) const;
void force_recheck() const; void force_recheck() const;
void move_storage(QString path) const;
// //
// Operators // Operators

Loading…
Cancel
Save