mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-13 16:53:08 -07:00
Merge pull request #2892 from glassez/bittorrent
Core classes redesign (Issue #2433).
This commit is contained in:
commit
3aa0a845cd
207 changed files with 15273 additions and 13581 deletions
|
@ -42,21 +42,19 @@
|
|||
#include <libtorrent/version.hpp>
|
||||
|
||||
#include "options_imp.h"
|
||||
#include "preferences.h"
|
||||
#include "fs_utils.h"
|
||||
#include "core/preferences.h"
|
||||
#include "core/utils/fs.h"
|
||||
#include "advancedsettings.h"
|
||||
#include "scannedfoldersmodel.h"
|
||||
#include "qbtsession.h"
|
||||
#include "iconprovider.h"
|
||||
#include "dnsupdater.h"
|
||||
#include "core/scanfoldersmodel.h"
|
||||
#include "core/bittorrent/session.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "core/net/dnsupdater.h"
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#include <QSslKey>
|
||||
#include <QSslCertificate>
|
||||
#endif
|
||||
|
||||
using namespace libtorrent;
|
||||
|
||||
// Constructor
|
||||
options_imp::options_imp(QWidget *parent):
|
||||
QDialog(parent), m_refreshingIpFilter(false) {
|
||||
|
@ -65,18 +63,18 @@ options_imp::options_imp(QWidget *parent):
|
|||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setModal(true);
|
||||
// Icons
|
||||
tabSelection->item(TAB_UI)->setIcon(IconProvider::instance()->getIcon("preferences-desktop"));
|
||||
tabSelection->item(TAB_BITTORRENT)->setIcon(IconProvider::instance()->getIcon("preferences-system-network"));
|
||||
tabSelection->item(TAB_CONNECTION)->setIcon(IconProvider::instance()->getIcon("network-wired"));
|
||||
tabSelection->item(TAB_DOWNLOADS)->setIcon(IconProvider::instance()->getIcon("download"));
|
||||
tabSelection->item(TAB_SPEED)->setIcon(IconProvider::instance()->getIcon("chronometer"));
|
||||
tabSelection->item(TAB_UI)->setIcon(GuiIconProvider::instance()->getIcon("preferences-desktop"));
|
||||
tabSelection->item(TAB_BITTORRENT)->setIcon(GuiIconProvider::instance()->getIcon("preferences-system-network"));
|
||||
tabSelection->item(TAB_CONNECTION)->setIcon(GuiIconProvider::instance()->getIcon("network-wired"));
|
||||
tabSelection->item(TAB_DOWNLOADS)->setIcon(GuiIconProvider::instance()->getIcon("download"));
|
||||
tabSelection->item(TAB_SPEED)->setIcon(GuiIconProvider::instance()->getIcon("chronometer"));
|
||||
#ifndef DISABLE_WEBUI
|
||||
tabSelection->item(TAB_WEBUI)->setIcon(IconProvider::instance()->getIcon("network-server"));
|
||||
tabSelection->item(TAB_WEBUI)->setIcon(GuiIconProvider::instance()->getIcon("network-server"));
|
||||
#else
|
||||
tabSelection->item(TAB_WEBUI)->setHidden(true);
|
||||
#endif
|
||||
tabSelection->item(TAB_ADVANCED)->setIcon(IconProvider::instance()->getIcon("preferences-other"));
|
||||
IpFilterRefreshBtn->setIcon(IconProvider::instance()->getIcon("view-refresh"));
|
||||
tabSelection->item(TAB_ADVANCED)->setIcon(GuiIconProvider::instance()->getIcon("preferences-other"));
|
||||
IpFilterRefreshBtn->setIcon(GuiIconProvider::instance()->getIcon("view-refresh"));
|
||||
|
||||
hsplitter->setCollapsible(0, false);
|
||||
hsplitter->setCollapsible(1, false);
|
||||
|
@ -496,7 +494,7 @@ void options_imp::saveOptions() {
|
|||
advancedSettings->saveAdvancedSettings();
|
||||
// Assume that user changed multiple settings
|
||||
// so it's best to save immediately
|
||||
pref->save();
|
||||
pref->apply();
|
||||
}
|
||||
|
||||
bool options_imp::isFilteringEnabled() const {
|
||||
|
@ -553,14 +551,14 @@ void options_imp::loadOptions() {
|
|||
#endif
|
||||
// End General preferences
|
||||
// Downloads preferences
|
||||
textSavePath->setText(fsutils::toNativePath(pref->getSavePath()));
|
||||
textSavePath->setText(Utils::Fs::toNativePath(pref->getSavePath()));
|
||||
if (pref->isTempPathEnabled()) {
|
||||
// enable
|
||||
checkTempFolder->setChecked(true);
|
||||
} else {
|
||||
checkTempFolder->setChecked(false);
|
||||
}
|
||||
textTempPath->setText(fsutils::toNativePath(pref->getTempPath()));
|
||||
textTempPath->setText(Utils::Fs::toNativePath(pref->getTempPath()));
|
||||
checkAppendLabel->setChecked(pref->appendTorrentLabel());
|
||||
checkAppendqB->setChecked(pref->useIncompleteFilesExtension());
|
||||
checkPreallocateAll->setChecked(pref->preAllocateAllFiles());
|
||||
|
@ -568,7 +566,7 @@ void options_imp::loadOptions() {
|
|||
checkAdditionDialogFront->setChecked(pref->additionDialogFront());
|
||||
checkStartPaused->setChecked(pref->addTorrentsInPause());
|
||||
|
||||
strValue = fsutils::toNativePath(pref->getTorrentExportDir());
|
||||
strValue = Utils::Fs::toNativePath(pref->getTorrentExportDir());
|
||||
if (strValue.isEmpty()) {
|
||||
// Disable
|
||||
checkExportDir->setChecked(false);
|
||||
|
@ -578,7 +576,7 @@ void options_imp::loadOptions() {
|
|||
textExportDir->setText(strValue);
|
||||
}
|
||||
|
||||
strValue = fsutils::toNativePath(pref->getFinishedTorrentExportDir());
|
||||
strValue = Utils::Fs::toNativePath(pref->getFinishedTorrentExportDir());
|
||||
if (strValue.isEmpty()) {
|
||||
// Disable
|
||||
checkExportDirFin->setChecked(false);
|
||||
|
@ -764,7 +762,7 @@ void options_imp::loadOptions() {
|
|||
// Misc preferences
|
||||
// * IP Filter
|
||||
checkIPFilter->setChecked(pref->isFilteringEnabled());
|
||||
textFilterPath->setText(fsutils::toNativePath(pref->getFilter()));
|
||||
textFilterPath->setText(Utils::Fs::toNativePath(pref->getFilter()));
|
||||
// End IP Filter
|
||||
// Queueing system preferences
|
||||
checkEnableQueueing->setChecked(pref->isQueueingSystemEnabled());
|
||||
|
@ -892,13 +890,13 @@ qreal options_imp::getMaxRatio() const {
|
|||
QString options_imp::getSavePath() const {
|
||||
if (textSavePath->text().trimmed().isEmpty()) {
|
||||
QString save_path = Preferences::instance()->getSavePath();
|
||||
textSavePath->setText(fsutils::toNativePath(save_path));
|
||||
textSavePath->setText(Utils::Fs::toNativePath(save_path));
|
||||
}
|
||||
return fsutils::expandPathAbs(textSavePath->text());
|
||||
return Utils::Fs::expandPathAbs(textSavePath->text());
|
||||
}
|
||||
|
||||
QString options_imp::getTempPath() const {
|
||||
return fsutils::expandPathAbs(textTempPath->text());
|
||||
return Utils::Fs::expandPathAbs(textTempPath->text());
|
||||
}
|
||||
|
||||
bool options_imp::isTempPathEnabled() const {
|
||||
|
@ -1093,13 +1091,13 @@ void options_imp::setLocale(const QString &localeStr) {
|
|||
|
||||
QString options_imp::getTorrentExportDir() const {
|
||||
if (checkExportDir->isChecked())
|
||||
return fsutils::expandPathAbs(textExportDir->text());
|
||||
return Utils::Fs::expandPathAbs(textExportDir->text());
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString options_imp::getFinishedTorrentExportDir() const {
|
||||
if (checkExportDirFin->isChecked())
|
||||
return fsutils::expandPathAbs(textExportDirFin->text());
|
||||
return Utils::Fs::expandPathAbs(textExportDirFin->text());
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
@ -1120,7 +1118,7 @@ int options_imp::getActionOnDblClOnTorrentFn() const {
|
|||
void options_imp::on_addScanFolderButton_clicked() {
|
||||
Preferences* const pref = Preferences::instance();
|
||||
const QString dir = QFileDialog::getExistingDirectory(this, tr("Add directory to scan"),
|
||||
fsutils::toNativePath(fsutils::folderName(pref->getScanDirsLastPath())));
|
||||
Utils::Fs::toNativePath(Utils::Fs::folderName(pref->getScanDirsLastPath())));
|
||||
if (!dir.isEmpty()) {
|
||||
const ScanFoldersModel::PathStatus status = ScanFoldersModel::instance()->addPath(dir, false);
|
||||
QString error;
|
||||
|
@ -1162,7 +1160,7 @@ void options_imp::handleScanFolderViewSelectionChanged() {
|
|||
|
||||
QString options_imp::askForExportDir(const QString& currentExportPath)
|
||||
{
|
||||
QDir currentExportDir(fsutils::expandPathAbs(currentExportPath));
|
||||
QDir currentExportDir(Utils::Fs::expandPathAbs(currentExportPath));
|
||||
QString dir;
|
||||
if (!currentExportPath.isEmpty() && currentExportDir.exists()) {
|
||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), currentExportDir.absolutePath());
|
||||
|
@ -1175,17 +1173,17 @@ QString options_imp::askForExportDir(const QString& currentExportPath)
|
|||
void options_imp::on_browseExportDirButton_clicked() {
|
||||
const QString newExportDir = askForExportDir(textExportDir->text());
|
||||
if (!newExportDir.isNull())
|
||||
textExportDir->setText(fsutils::toNativePath(newExportDir));
|
||||
textExportDir->setText(Utils::Fs::toNativePath(newExportDir));
|
||||
}
|
||||
|
||||
void options_imp::on_browseExportDirFinButton_clicked() {
|
||||
const QString newExportDir = askForExportDir(textExportDirFin->text());
|
||||
if (!newExportDir.isNull())
|
||||
textExportDirFin->setText(fsutils::toNativePath(newExportDir));
|
||||
textExportDirFin->setText(Utils::Fs::toNativePath(newExportDir));
|
||||
}
|
||||
|
||||
void options_imp::on_browseFilterButton_clicked() {
|
||||
const QString filter_path = fsutils::expandPathAbs(textFilterPath->text());
|
||||
const QString filter_path = Utils::Fs::expandPathAbs(textFilterPath->text());
|
||||
QDir filterDir(filter_path);
|
||||
QString ipfilter;
|
||||
if (!filter_path.isEmpty() && filterDir.exists()) {
|
||||
|
@ -1194,12 +1192,12 @@ void options_imp::on_browseFilterButton_clicked() {
|
|||
ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an ip filter file"), QDir::homePath(), tr("Filters")+QString(" (*.dat *.p2p *.p2b)"));
|
||||
}
|
||||
if (!ipfilter.isNull())
|
||||
textFilterPath->setText(fsutils::toNativePath(ipfilter));
|
||||
textFilterPath->setText(Utils::Fs::toNativePath(ipfilter));
|
||||
}
|
||||
|
||||
// Display dialog to choose save dir
|
||||
void options_imp::on_browseSaveDirButton_clicked() {
|
||||
const QString save_path = fsutils::expandPathAbs(textSavePath->text());
|
||||
const QString save_path = Utils::Fs::expandPathAbs(textSavePath->text());
|
||||
QDir saveDir(save_path);
|
||||
QString dir;
|
||||
if (!save_path.isEmpty() && saveDir.exists()) {
|
||||
|
@ -1208,11 +1206,11 @@ void options_imp::on_browseSaveDirButton_clicked() {
|
|||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
||||
}
|
||||
if (!dir.isNull())
|
||||
textSavePath->setText(fsutils::toNativePath(dir));
|
||||
textSavePath->setText(Utils::Fs::toNativePath(dir));
|
||||
}
|
||||
|
||||
void options_imp::on_browseTempDirButton_clicked() {
|
||||
const QString temp_path = fsutils::expandPathAbs(textTempPath->text());
|
||||
const QString temp_path = Utils::Fs::expandPathAbs(textTempPath->text());
|
||||
QDir tempDir(temp_path);
|
||||
QString dir;
|
||||
if (!temp_path.isEmpty() && tempDir.exists()) {
|
||||
|
@ -1221,12 +1219,12 @@ void options_imp::on_browseTempDirButton_clicked() {
|
|||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
||||
}
|
||||
if (!dir.isNull())
|
||||
textTempPath->setText(fsutils::toNativePath(dir));
|
||||
textTempPath->setText(Utils::Fs::toNativePath(dir));
|
||||
}
|
||||
|
||||
// Return Filter object to apply to BT session
|
||||
QString options_imp::getFilter() const {
|
||||
return fsutils::fromNativePath(textFilterPath->text());
|
||||
return Utils::Fs::fromNativePath(textFilterPath->text());
|
||||
}
|
||||
|
||||
// Web UI
|
||||
|
@ -1279,7 +1277,7 @@ void options_imp::on_btnWebUiKey_clicked() {
|
|||
}
|
||||
|
||||
void options_imp::on_registerDNSBtn_clicked() {
|
||||
QDesktopServices::openUrl(DNSUpdater::getRegistrationUrl(comboDNSService->currentIndex()));
|
||||
QDesktopServices::openUrl(Net::DNSUpdater::getRegistrationUrl(comboDNSService->currentIndex()));
|
||||
}
|
||||
|
||||
void options_imp::on_IpFilterRefreshBtn_clicked() {
|
||||
|
@ -1290,9 +1288,9 @@ void options_imp::on_IpFilterRefreshBtn_clicked() {
|
|||
pref->setFilteringEnabled(true);
|
||||
pref->setFilter(getFilter());
|
||||
// Force refresh
|
||||
connect(QBtSession::instance(), SIGNAL(ipFilterParsed(bool, int)), SLOT(handleIPFilterParsed(bool, int)));
|
||||
connect(BitTorrent::Session::instance(), SIGNAL(ipFilterParsed(bool, int)), SLOT(handleIPFilterParsed(bool, int)));
|
||||
setCursor(QCursor(Qt::WaitCursor));
|
||||
QBtSession::instance()->enableIPFilter(getFilter(), true);
|
||||
BitTorrent::Session::instance()->enableIPFilter(getFilter(), true);
|
||||
}
|
||||
|
||||
void options_imp::handleIPFilterParsed(bool error, int ruleCount)
|
||||
|
@ -1304,7 +1302,7 @@ void options_imp::handleIPFilterParsed(bool error, int ruleCount)
|
|||
QMessageBox::information(this, tr("Successfully refreshed"), tr("Successfully parsed the provided IP filter: %1 rules were applied.", "%1 is a number").arg(ruleCount));
|
||||
}
|
||||
m_refreshingIpFilter = false;
|
||||
disconnect(QBtSession::instance(), SIGNAL(ipFilterParsed(bool, int)), this, SLOT(handleIPFilterParsed(bool, int)));
|
||||
disconnect(BitTorrent::Session::instance(), SIGNAL(ipFilterParsed(bool, int)), this, SLOT(handleIPFilterParsed(bool, int)));
|
||||
}
|
||||
|
||||
QString options_imp::languageToLocalizedString(const QLocale &locale)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue