mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-13 00:33:09 -07:00
Add option to automatically remove .torrent files upon adding
Some browsers do not download files, intended for immediate opening, into a temporary directory, and thus a regular download directories accumulate those unneeded files. The option allows qBittorrent to clean after itself and delete those files whether they were succesfully added or not (user-selectable policy).
This commit is contained in:
parent
35c51ad3b1
commit
6e73fa80b8
10 changed files with 391 additions and 49 deletions
|
@ -52,6 +52,7 @@ qinisettings.h
|
||||||
scanfoldersmodel.h
|
scanfoldersmodel.h
|
||||||
searchengine.h
|
searchengine.h
|
||||||
settingsstorage.h
|
settingsstorage.h
|
||||||
|
torrentfileguard.h
|
||||||
torrentfilter.h
|
torrentfilter.h
|
||||||
tristatebool.h
|
tristatebool.h
|
||||||
types.h
|
types.h
|
||||||
|
@ -107,6 +108,7 @@ preferences.cpp
|
||||||
scanfoldersmodel.cpp
|
scanfoldersmodel.cpp
|
||||||
searchengine.cpp
|
searchengine.cpp
|
||||||
settingsstorage.cpp
|
settingsstorage.cpp
|
||||||
|
torrentfileguard.cpp
|
||||||
torrentfilter.cpp
|
torrentfilter.cpp
|
||||||
tristatebool.cpp
|
tristatebool.cpp
|
||||||
)
|
)
|
||||||
|
|
|
@ -51,6 +51,7 @@ HEADERS += \
|
||||||
$$PWD/utils/misc.h \
|
$$PWD/utils/misc.h \
|
||||||
$$PWD/utils/string.h \
|
$$PWD/utils/string.h \
|
||||||
$$PWD/unicodestrings.h \
|
$$PWD/unicodestrings.h \
|
||||||
|
$$PWD/torrentfileguard.h \
|
||||||
$$PWD/torrentfilter.h \
|
$$PWD/torrentfilter.h \
|
||||||
$$PWD/scanfoldersmodel.h \
|
$$PWD/scanfoldersmodel.h \
|
||||||
$$PWD/searchengine.h
|
$$PWD/searchengine.h
|
||||||
|
@ -103,6 +104,7 @@ SOURCES += \
|
||||||
$$PWD/utils/gzip.cpp \
|
$$PWD/utils/gzip.cpp \
|
||||||
$$PWD/utils/misc.cpp \
|
$$PWD/utils/misc.cpp \
|
||||||
$$PWD/utils/string.cpp \
|
$$PWD/utils/string.cpp \
|
||||||
|
$$PWD/torrentfileguard.cpp \
|
||||||
$$PWD/torrentfilter.cpp \
|
$$PWD/torrentfilter.cpp \
|
||||||
$$PWD/scanfoldersmodel.cpp \
|
$$PWD/scanfoldersmodel.cpp \
|
||||||
$$PWD/searchengine.cpp
|
$$PWD/searchengine.cpp
|
||||||
|
|
|
@ -70,6 +70,7 @@
|
||||||
#include "base/net/portforwarder.h"
|
#include "base/net/portforwarder.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
#include "base/settingsstorage.h"
|
#include "base/settingsstorage.h"
|
||||||
|
#include "base/torrentfileguard.h"
|
||||||
#include "base/torrentfilter.h"
|
#include "base/torrentfilter.h"
|
||||||
#include "base/unicodestrings.h"
|
#include "base/unicodestrings.h"
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
|
@ -1229,6 +1230,8 @@ bool Session::addTorrent(QString source, const AddTorrentParams ¶ms)
|
||||||
m_downloadedTorrents[handler->url()] = params;
|
m_downloadedTorrents[handler->url()] = params;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
TorrentFileGuard guard(source);
|
||||||
|
guard.markAsAddedToSession();
|
||||||
return addTorrent_impl(params, MagnetUri(), TorrentInfo::loadFromFile(source));
|
return addTorrent_impl(params, MagnetUri(), TorrentInfo::loadFromFile(source));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
100
src/base/torrentfileguard.cpp
Normal file
100
src/base/torrentfileguard.cpp
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
/*
|
||||||
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
|
* Copyright (C) 2016 Eugene Shalygin <eugene.shalygin@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give permission to
|
||||||
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||||
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||||
|
* and distribute the linked executables. You must obey the GNU General Public
|
||||||
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||||
|
* modify file(s), you may extend this exception to your version of the file(s),
|
||||||
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||||
|
* exception statement from your version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "torrentfileguard.h"
|
||||||
|
|
||||||
|
#include <QMetaEnum>
|
||||||
|
#include "settingsstorage.h"
|
||||||
|
#include "utils/fs.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const QLatin1String KEY_AUTO_DELETE_ENABLED ("Core/AutoDeleteAddedTorrentFile");
|
||||||
|
}
|
||||||
|
|
||||||
|
FileGuard::FileGuard(const QString &path)
|
||||||
|
: m_path {path}
|
||||||
|
, m_remove {true}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileGuard::setAutoRemove(bool remove) noexcept
|
||||||
|
{
|
||||||
|
m_remove = remove;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileGuard::~FileGuard()
|
||||||
|
{
|
||||||
|
if (m_remove && !m_path.isEmpty())
|
||||||
|
Utils::Fs::forceRemove(m_path); // forceRemove() checks for file existence
|
||||||
|
}
|
||||||
|
|
||||||
|
TorrentFileGuard::TorrentFileGuard(const QString &path)
|
||||||
|
: m_mode {autoDeleteMode()}
|
||||||
|
, m_wasAdded {false}
|
||||||
|
, m_guard {m_mode != Never ? path : QString()}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TorrentFileGuard::~TorrentFileGuard()
|
||||||
|
{
|
||||||
|
if (!m_wasAdded && (m_mode != Always))
|
||||||
|
m_guard.setAutoRemove(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TorrentFileGuard::markAsAddedToSession()
|
||||||
|
{
|
||||||
|
m_wasAdded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TorrentFileGuard::setAutoRemove(bool remove)
|
||||||
|
{
|
||||||
|
m_guard.setAutoRemove(remove);
|
||||||
|
}
|
||||||
|
|
||||||
|
TorrentFileGuard::AutoDeleteMode TorrentFileGuard::autoDeleteMode()
|
||||||
|
{
|
||||||
|
QMetaEnum meta {modeMetaEnum()};
|
||||||
|
return static_cast<AutoDeleteMode>(meta.keyToValue(SettingsStorage::instance()->loadValue(
|
||||||
|
KEY_AUTO_DELETE_ENABLED, meta.valueToKey(Never)).toByteArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TorrentFileGuard::setautoDeleteMode(TorrentFileGuard::AutoDeleteMode mode)
|
||||||
|
{
|
||||||
|
QMetaEnum meta {modeMetaEnum()};
|
||||||
|
SettingsStorage::instance()->storeValue(KEY_AUTO_DELETE_ENABLED, meta.valueToKey(mode));
|
||||||
|
}
|
||||||
|
|
||||||
|
QMetaEnum TorrentFileGuard::modeMetaEnum()
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
|
||||||
|
return QMetaEnum::fromType<AutoDeleteMode>();
|
||||||
|
#else
|
||||||
|
return staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("AutoDeleteMode"));
|
||||||
|
#endif
|
||||||
|
}
|
95
src/base/torrentfileguard.h
Normal file
95
src/base/torrentfileguard.h
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
/*
|
||||||
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
|
* Copyright (C) 2016 Eugene Shalygin <eugene.shalygin@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give permission to
|
||||||
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||||
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||||
|
* and distribute the linked executables. You must obey the GNU General Public
|
||||||
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||||
|
* modify file(s), you may extend this exception to your version of the file(s),
|
||||||
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||||
|
* exception statement from your version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QMetaType>
|
||||||
|
|
||||||
|
class QMetaEnum;
|
||||||
|
/// Utility class to defer file deletion
|
||||||
|
class FileGuard
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FileGuard(const QString &path = QString());
|
||||||
|
~FileGuard();
|
||||||
|
|
||||||
|
/// Cancels or re-enables deferred file deletion
|
||||||
|
void setAutoRemove(bool remove) noexcept;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_path;
|
||||||
|
bool m_remove;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Reads settings for .torrent files from preferences
|
||||||
|
/// and sets the file guard up accordingly
|
||||||
|
class TorrentFileGuard
|
||||||
|
{
|
||||||
|
Q_GADGET
|
||||||
|
|
||||||
|
public:
|
||||||
|
TorrentFileGuard(const QString &path = QString());
|
||||||
|
~TorrentFileGuard();
|
||||||
|
|
||||||
|
/// marks the torrent file as loaded (added) into the BitTorrent::Session
|
||||||
|
void markAsAddedToSession();
|
||||||
|
void setAutoRemove(bool remove);
|
||||||
|
|
||||||
|
enum AutoDeleteMode // do not change these names: they are stored in config file
|
||||||
|
{
|
||||||
|
Never,
|
||||||
|
IfAdded,
|
||||||
|
Always
|
||||||
|
};
|
||||||
|
|
||||||
|
// static interface to get/set preferences
|
||||||
|
static AutoDeleteMode autoDeleteMode();
|
||||||
|
static void setautoDeleteMode(AutoDeleteMode mode);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static QMetaEnum modeMetaEnum();
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
|
Q_ENUMS(AutoDeleteMode)
|
||||||
|
#else
|
||||||
|
Q_ENUM(AutoDeleteMode)
|
||||||
|
#endif
|
||||||
|
AutoDeleteMode m_mode;
|
||||||
|
bool m_wasAdded;
|
||||||
|
// Qt 4 moc has troubles with Q_GADGET: if Q_GADGET is present in a class, moc unconditionally
|
||||||
|
// references in the generated code the statiMetaObject from the class ancestor.
|
||||||
|
// Moreover, if the ancestor class has Q_GADGET but does not have other
|
||||||
|
// Q_ declarations, moc does not generate staticMetaObject for it. These results
|
||||||
|
// in referencing the non existent staticMetaObject and such code fails to compile.
|
||||||
|
// This problem is NOT present in Qt 5.7.0 and maybe in some older Qt 5 versions too
|
||||||
|
// Qt 4.8.7 has it.
|
||||||
|
// Therefore, we can't inherit FileGuard :(
|
||||||
|
FileGuard m_guard;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
|
Q_DECLARE_METATYPE(TorrentFileGuard::AutoDeleteMode)
|
||||||
|
#endif
|
|
@ -45,6 +45,7 @@
|
||||||
#include "base/utils/fs.h"
|
#include "base/utils/fs.h"
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
#include "base/utils/string.h"
|
#include "base/utils/string.h"
|
||||||
|
#include "base/torrentfileguard.h"
|
||||||
#include "base/unicodestrings.h"
|
#include "base/unicodestrings.h"
|
||||||
#include "guiiconprovider.h"
|
#include "guiiconprovider.h"
|
||||||
#include "autoexpandabledialog.h"
|
#include "autoexpandabledialog.h"
|
||||||
|
@ -94,6 +95,8 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent)
|
||||||
connect(ui->browseButton, SIGNAL(clicked()), SLOT(browseButton_clicked()));
|
connect(ui->browseButton, SIGNAL(clicked()), SLOT(browseButton_clicked()));
|
||||||
ui->defaultSavePathCheckBox->setVisible(false); // Default path is selected by default
|
ui->defaultSavePathCheckBox->setVisible(false); // Default path is selected by default
|
||||||
|
|
||||||
|
ui->doNotDeleteTorrentCheckBox->setVisible(TorrentFileGuard::autoDeleteMode() != TorrentFileGuard::Never);
|
||||||
|
|
||||||
// Load categories
|
// Load categories
|
||||||
QStringList categories = session->categories();
|
QStringList categories = session->categories();
|
||||||
std::sort(categories.begin(), categories.end(), Utils::String::naturalCompareCaseInsensitive);
|
std::sort(categories.begin(), categories.end(), Utils::String::naturalCompareCaseInsensitive);
|
||||||
|
@ -112,6 +115,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent)
|
||||||
loadState();
|
loadState();
|
||||||
// Signal / slots
|
// Signal / slots
|
||||||
connect(ui->adv_button, SIGNAL(clicked(bool)), SLOT(showAdvancedSettings(bool)));
|
connect(ui->adv_button, SIGNAL(clicked(bool)), SLOT(showAdvancedSettings(bool)));
|
||||||
|
connect(ui->doNotDeleteTorrentCheckBox, SIGNAL(clicked(bool)), SLOT(doNotDeleteTorrentClicked(bool)));
|
||||||
editHotkey = new QShortcut(QKeySequence("F2"), ui->contentTreeView, 0, 0, Qt::WidgetShortcut);
|
editHotkey = new QShortcut(QKeySequence("F2"), ui->contentTreeView, 0, 0, Qt::WidgetShortcut);
|
||||||
connect(editHotkey, SIGNAL(activated()), SLOT(renameSelectedFile()));
|
connect(editHotkey, SIGNAL(activated()), SLOT(renameSelectedFile()));
|
||||||
connect(ui->contentTreeView, SIGNAL(doubleClicked(QModelIndex)), SLOT(renameSelectedFile()));
|
connect(ui->contentTreeView, SIGNAL(doubleClicked(QModelIndex)), SLOT(renameSelectedFile()));
|
||||||
|
@ -221,6 +225,7 @@ bool AddNewTorrentDialog::loadTorrent(const QString &torrentPath)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_torrentGuard.reset(new TorrentFileGuard(m_filePath));
|
||||||
m_hash = m_torrentInfo.hash();
|
m_hash = m_torrentInfo.hash();
|
||||||
|
|
||||||
// Prevent showing the dialog if download is already present
|
// Prevent showing the dialog if download is already present
|
||||||
|
@ -647,6 +652,7 @@ void AddNewTorrentDialog::accept()
|
||||||
else
|
else
|
||||||
BitTorrent::Session::instance()->addTorrent(m_torrentInfo, params);
|
BitTorrent::Session::instance()->addTorrent(m_torrentInfo, params);
|
||||||
|
|
||||||
|
m_torrentGuard->markAsAddedToSession();
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -795,3 +801,8 @@ void AddNewTorrentDialog::setCommentText(const QString &str) const
|
||||||
int height = lineHeight * lines;
|
int height = lineHeight * lines;
|
||||||
ui->scrollArea->setMaximumHeight(height);
|
ui->scrollArea->setMaximumHeight(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddNewTorrentDialog::doNotDeleteTorrentClicked(bool checked)
|
||||||
|
{
|
||||||
|
m_torrentGuard->setAutoRemove(!checked);
|
||||||
|
}
|
||||||
|
|
|
@ -31,8 +31,9 @@
|
||||||
#ifndef ADDNEWTORRENTDIALOG_H
|
#ifndef ADDNEWTORRENTDIALOG_H
|
||||||
#define ADDNEWTORRENTDIALOG_H
|
#define ADDNEWTORRENTDIALOG_H
|
||||||
|
|
||||||
#include <QShortcut>
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
#include <QShortcut>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include "base/bittorrent/infohash.h"
|
#include "base/bittorrent/infohash.h"
|
||||||
|
@ -49,6 +50,7 @@ namespace Ui
|
||||||
}
|
}
|
||||||
|
|
||||||
class TorrentContentFilterModel;
|
class TorrentContentFilterModel;
|
||||||
|
class TorrentFileGuard;
|
||||||
class PropListDelegate;
|
class PropListDelegate;
|
||||||
|
|
||||||
class AddNewTorrentDialog: public QDialog
|
class AddNewTorrentDialog: public QDialog
|
||||||
|
@ -79,6 +81,7 @@ private slots:
|
||||||
void handleDownloadFinished(const QString &url, const QString &filePath);
|
void handleDownloadFinished(const QString &url, const QString &filePath);
|
||||||
void savingModeChanged(bool enabled);
|
void savingModeChanged(bool enabled);
|
||||||
void categoryChanged(int index);
|
void categoryChanged(int index);
|
||||||
|
void doNotDeleteTorrentClicked(bool checked);
|
||||||
|
|
||||||
void accept() override;
|
void accept() override;
|
||||||
void reject() override;
|
void reject() override;
|
||||||
|
@ -109,6 +112,7 @@ private:
|
||||||
QShortcut *editHotkey;
|
QShortcut *editHotkey;
|
||||||
QByteArray m_headerState;
|
QByteArray m_headerState;
|
||||||
int m_oldIndex;
|
int m_oldIndex;
|
||||||
|
QScopedPointer<TorrentFileGuard> m_torrentGuard;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ADDNEWTORRENTDIALOG_H
|
#endif // ADDNEWTORRENTDIALOG_H
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>414</width>
|
<width>414</width>
|
||||||
<height>590</height>
|
<height>661</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="AddNewTorrentDialogLayout">
|
<layout class="QVBoxLayout" name="AddNewTorrentDialogLayout">
|
||||||
|
@ -95,6 +95,16 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="doNotDeleteTorrentCheckBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>When checked, the .torrent file will not be deleted despite the settings at the "Download" page of the options dialog</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Do not delete .torrent file</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="never_show_cb">
|
<widget class="QCheckBox" name="never_show_cb">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -278,8 +288,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>301</width>
|
<width>308</width>
|
||||||
<height>73</height>
|
<height>74</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
|
|
@ -113,9 +113,9 @@
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>-190</y>
|
<y>0</y>
|
||||||
<width>486</width>
|
<width>514</width>
|
||||||
<height>732</height>
|
<height>968</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||||
|
@ -670,8 +670,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>487</width>
|
<width>514</width>
|
||||||
<height>1334</height>
|
<height>1537</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
@ -719,6 +719,64 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QGroupBox" name="deleteTorrentBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Should the .torrent file be deleted after adding it</string>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Delete .torrent files afterwards </string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_17">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="deleteCancelledTorrentBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Also delete .torrent files whose addition was cancelled</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Also when addition is cancelled</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="deleteTorrentWarningIcon">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true"><></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="deleteTorrentWarningLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Warning! Data loss possible!</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -1364,8 +1422,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>450</width>
|
<width>457</width>
|
||||||
<height>658</height>
|
<height>713</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_20">
|
<layout class="QVBoxLayout" name="verticalLayout_20">
|
||||||
|
@ -1894,8 +1952,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>376</width>
|
<width>362</width>
|
||||||
<height>444</height>
|
<height>484</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
|
@ -2281,8 +2339,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>555</width>
|
<width>587</width>
|
||||||
<height>527</height>
|
<height>578</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
|
@ -2678,8 +2736,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>419</width>
|
<width>460</width>
|
||||||
<height>537</height>
|
<height>562</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_23">
|
<layout class="QVBoxLayout" name="verticalLayout_23">
|
||||||
|
@ -3130,12 +3188,12 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>544</x>
|
<x>604</x>
|
||||||
<y>172</y>
|
<y>205</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>603</x>
|
<x>677</x>
|
||||||
<y>171</y>
|
<y>206</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -3146,12 +3204,12 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>544</x>
|
<x>604</x>
|
||||||
<y>198</y>
|
<y>238</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>603</x>
|
<x>677</x>
|
||||||
<y>197</y>
|
<y>239</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -3162,12 +3220,12 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>544</x>
|
<x>604</x>
|
||||||
<y>250</y>
|
<y>304</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>603</x>
|
<x>677</x>
|
||||||
<y>249</y>
|
<y>305</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -3178,12 +3236,12 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>509</x>
|
<x>547</x>
|
||||||
<y>372</y>
|
<y>415</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>584</x>
|
<x>642</x>
|
||||||
<y>373</y>
|
<y>414</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -3194,12 +3252,12 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>509</x>
|
<x>547</x>
|
||||||
<y>372</y>
|
<y>415</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>721</x>
|
<x>815</x>
|
||||||
<y>373</y>
|
<y>413</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -3210,12 +3268,12 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>423</x>
|
<x>604</x>
|
||||||
<y>224</y>
|
<y>271</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>571</x>
|
<x>677</x>
|
||||||
<y>224</y>
|
<y>272</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -3226,12 +3284,12 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>398</x>
|
<x>395</x>
|
||||||
<y>292</y>
|
<y>203</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>477</x>
|
<x>496</x>
|
||||||
<y>292</y>
|
<y>204</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -3242,12 +3300,44 @@
|
||||||
<slot>setEnabled(bool)</slot>
|
<slot>setEnabled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>398</x>
|
<x>395</x>
|
||||||
<y>263</y>
|
<y>170</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>477</x>
|
<x>496</x>
|
||||||
<y>263</y>
|
<y>171</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>deleteTorrentBox</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>deleteTorrentWarningIcon</receiver>
|
||||||
|
<slot>setVisible(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>554</x>
|
||||||
|
<y>153</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>324</x>
|
||||||
|
<y>214</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>deleteTorrentBox</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>deleteTorrentWarningLabel</receiver>
|
||||||
|
<slot>setVisible(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>646</x>
|
||||||
|
<y>158</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>629</x>
|
||||||
|
<y>207</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
#include "base/net/dnsupdater.h"
|
#include "base/net/dnsupdater.h"
|
||||||
#include "base/unicodestrings.h"
|
#include "base/unicodestrings.h"
|
||||||
|
#include "base/torrentfileguard.h"
|
||||||
#include "advancedsettings.h"
|
#include "advancedsettings.h"
|
||||||
#include "guiiconprovider.h"
|
#include "guiiconprovider.h"
|
||||||
#include "scanfoldersdelegate.h"
|
#include "scanfoldersdelegate.h"
|
||||||
|
@ -88,6 +89,22 @@ options_imp::options_imp(QWidget *parent)
|
||||||
|
|
||||||
IpFilterRefreshBtn->setIcon(GuiIconProvider::instance()->getIcon("view-refresh"));
|
IpFilterRefreshBtn->setIcon(GuiIconProvider::instance()->getIcon("view-refresh"));
|
||||||
|
|
||||||
|
deleteTorrentWarningIcon->setPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical).pixmap(16, 16));
|
||||||
|
deleteTorrentWarningIcon->hide();
|
||||||
|
deleteTorrentWarningLabel->hide();
|
||||||
|
deleteTorrentWarningLabel->setToolTip(QLatin1String("<html><body><p>") +
|
||||||
|
tr("By enabling these options, you can <strong>irrevocably lose</strong> your .torrent files!") +
|
||||||
|
QLatin1String("</p><p>") +
|
||||||
|
tr("When these options are enabled, qBittorent will <strong>delete</strong> .torrent files "
|
||||||
|
"after they were successfully (the first option) or not (the second option) added to its "
|
||||||
|
"download queue. This will be applied <strong>not only</strong> to the files opened via "
|
||||||
|
"“Add torrent” menu action but to those opened via <strong>file type association</strong> as well") +
|
||||||
|
QLatin1String("</p><p>") +
|
||||||
|
tr("If you enable the second option (“Also when addition is cancelled”) the "
|
||||||
|
".torrent file <strong>will be deleted</strong> even if you press “<strong>Cancel</strong>” in "
|
||||||
|
"the “Add torrent” dialog") +
|
||||||
|
QLatin1String("</p></body></html>"));
|
||||||
|
|
||||||
hsplitter->setCollapsible(0, false);
|
hsplitter->setCollapsible(0, false);
|
||||||
hsplitter->setCollapsible(1, false);
|
hsplitter->setCollapsible(1, false);
|
||||||
// Get apply button in button box
|
// Get apply button in button box
|
||||||
|
@ -193,6 +210,8 @@ options_imp::options_imp(QWidget *parent)
|
||||||
connect(checkAdditionDialog, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
connect(checkAdditionDialog, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||||
connect(checkAdditionDialogFront, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
connect(checkAdditionDialogFront, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||||
connect(checkStartPaused, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
connect(checkStartPaused, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||||
|
connect(deleteTorrentBox, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||||
|
connect(deleteCancelledTorrentBox, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||||
connect(checkExportDir, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
connect(checkExportDir, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||||
connect(checkExportDirFin, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
connect(checkExportDirFin, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||||
connect(textExportDir, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
|
connect(textExportDir, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
|
||||||
|
@ -500,6 +519,9 @@ void options_imp::saveOptions()
|
||||||
pref->setAutoRunProgram(autoRun_txt->text().trimmed());
|
pref->setAutoRunProgram(autoRun_txt->text().trimmed());
|
||||||
pref->setActionOnDblClOnTorrentDl(getActionOnDblClOnTorrentDl());
|
pref->setActionOnDblClOnTorrentDl(getActionOnDblClOnTorrentDl());
|
||||||
pref->setActionOnDblClOnTorrentFn(getActionOnDblClOnTorrentFn());
|
pref->setActionOnDblClOnTorrentFn(getActionOnDblClOnTorrentFn());
|
||||||
|
TorrentFileGuard::setautoDeleteMode(!deleteTorrentBox->isChecked() ? TorrentFileGuard::Never
|
||||||
|
: !deleteCancelledTorrentBox->isChecked() ? TorrentFileGuard::IfAdded
|
||||||
|
: TorrentFileGuard::Always);
|
||||||
// End Downloads preferences
|
// End Downloads preferences
|
||||||
|
|
||||||
// Connection preferences
|
// Connection preferences
|
||||||
|
@ -676,6 +698,9 @@ void options_imp::loadOptions()
|
||||||
checkAdditionDialog->setChecked(AddNewTorrentDialog::isEnabled());
|
checkAdditionDialog->setChecked(AddNewTorrentDialog::isEnabled());
|
||||||
checkAdditionDialogFront->setChecked(AddNewTorrentDialog::isTopLevel());
|
checkAdditionDialogFront->setChecked(AddNewTorrentDialog::isTopLevel());
|
||||||
checkStartPaused->setChecked(session->isAddTorrentPaused());
|
checkStartPaused->setChecked(session->isAddTorrentPaused());
|
||||||
|
const TorrentFileGuard::AutoDeleteMode autoDeleteMode = TorrentFileGuard::autoDeleteMode();
|
||||||
|
deleteTorrentBox->setChecked(autoDeleteMode != TorrentFileGuard::Never);
|
||||||
|
deleteCancelledTorrentBox->setChecked(autoDeleteMode == TorrentFileGuard::Always);
|
||||||
|
|
||||||
textSavePath->setText(Utils::Fs::toNativePath(session->defaultSavePath()));
|
textSavePath->setText(Utils::Fs::toNativePath(session->defaultSavePath()));
|
||||||
(session->isSubcategoriesEnabled() ? radioBtnEnableSubcategories : radioBtnDisableSubcategories)->setChecked(true);
|
(session->isSubcategoriesEnabled() ? radioBtnEnableSubcategories : radioBtnDisableSubcategories)->setChecked(true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue