From 22178f9997d3840d36cd069d5ee4024af93c3901 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Sat, 15 Apr 2017 17:21:24 +0300 Subject: [PATCH] Fix strip torrent root folder --- src/base/bittorrent/session.cpp | 11 +++++++++++ src/base/bittorrent/session.h | 3 +++ src/base/preferences.cpp | 10 ---------- src/base/preferences.h | 2 -- src/gui/addnewtorrentdialog.cpp | 6 +++--- src/gui/addnewtorrentdialog.ui | 12 ++++++------ src/gui/optionsdlg.cpp | 4 ++-- 7 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 47972500c..c6a489933 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -244,6 +244,7 @@ Session::Session(QObject *parent) , m_additionalTrackers(BITTORRENT_SESSION_KEY("AdditionalTrackers")) , m_globalMaxRatio(BITTORRENT_SESSION_KEY("GlobalMaxRatio"), -1, [](qreal r) { return r < 0 ? -1. : r;}) , m_isAddTorrentPaused(BITTORRENT_SESSION_KEY("AddTorrentPaused"), false) + , m_isCreateTorrentSubfolder(BITTORRENT_SESSION_KEY("CreateTorrentSubfolder"), true) , m_isAppendExtensionEnabled(BITTORRENT_SESSION_KEY("AddExtensionToIncompleteFiles"), false) , m_refreshInterval(BITTORRENT_SESSION_KEY("RefreshInterval"), 1500) , m_isPreallocationEnabled(BITTORRENT_SESSION_KEY("Preallocation"), false) @@ -3253,6 +3254,16 @@ void Session::getPendingAlerts(std::vector &out, ulong time) #endif } +bool Session::isCreateTorrentSubfolder() const +{ + return m_isCreateTorrentSubfolder; +} + +void Session::setCreateTorrentSubfolder(bool value) +{ + m_isCreateTorrentSubfolder = value; +} + // Read alerts sent by the BitTorrent session void Session::readAlerts() { diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index 86c0a3973..0af2500ca 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -222,6 +222,8 @@ namespace BitTorrent void setPeXEnabled(bool enabled); bool isAddTorrentPaused() const; void setAddTorrentPaused(bool value); + bool isCreateTorrentSubfolder() const; + void setCreateTorrentSubfolder(bool value); bool isTrackerEnabled() const; void setTrackerEnabled(bool enabled); bool isAppendExtensionEnabled() const; @@ -539,6 +541,7 @@ namespace BitTorrent CachedSettingValue m_additionalTrackers; CachedSettingValue m_globalMaxRatio; CachedSettingValue m_isAddTorrentPaused; + CachedSettingValue m_isCreateTorrentSubfolder; CachedSettingValue m_isAppendExtensionEnabled; CachedSettingValue m_refreshInterval; CachedSettingValue m_isPreallocationEnabled; diff --git a/src/base/preferences.cpp b/src/base/preferences.cpp index 3f34c84b7..630dbe4f8 100644 --- a/src/base/preferences.cpp +++ b/src/base/preferences.cpp @@ -263,16 +263,6 @@ void Preferences::setLastLocationPath(const QString &path) setValue("Preferences/Downloads/LastLocationPath", Utils::Fs::fromNativePath(path)); } -bool Preferences::getTorrentCreateSubfolder() const -{ - return value("Preferences/Downloads/CreateSubfolder", true).toBool(); -} - -void Preferences::setTorrentCreateSubfolder(bool b) -{ - setValue("Preferences/Downloads/CreateSubfolder", b); -} - QVariantHash Preferences::getScanDirs() const { return value("Preferences/Downloads/ScanDirsV2").toHash(); diff --git a/src/base/preferences.h b/src/base/preferences.h index 4b06ae3d5..ec328f264 100644 --- a/src/base/preferences.h +++ b/src/base/preferences.h @@ -138,8 +138,6 @@ public: void setLastLocationPath(const QString &path); QVariantHash getScanDirs() const; void setScanDirs(const QVariantHash &dirs); - bool getTorrentCreateSubfolder() const; - void setTorrentCreateSubfolder(bool b); QString getScanDirsLastPath() const; void setScanDirsLastPath(const QString &path); bool isMailNotificationEnabled() const; diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index ff3d4c789..7cecb3ec7 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -96,7 +96,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) connect(ui->savePathComboBox, SIGNAL(currentIndexChanged(int)), SLOT(onSavePathChanged(int))); connect(ui->browseButton, SIGNAL(clicked()), SLOT(browseButton_clicked())); ui->defaultSavePathCheckBox->setVisible(false); // Default path is selected by default - ui->createSubfolderComboBox->setChecked(Preferences::instance()->getTorrentCreateSubfolder()); + ui->createSubfolderCheckBox->setChecked(session->isCreateTorrentSubfolder()); ui->doNotDeleteTorrentCheckBox->setVisible(TorrentFileGuard::autoDeleteMode() != TorrentFileGuard::Never); @@ -627,7 +627,7 @@ void AddNewTorrentDialog::accept() BitTorrent::AddTorrentParams params; // TODO: Check if destination actually exists - params.skipChecking = ui->skip_check_cb->isChecked(); + params.skipChecking = ui->skipCheckingCheckBox->isChecked(); // Category params.category = ui->categoryComboBox->currentText(); @@ -640,7 +640,7 @@ void AddNewTorrentDialog::accept() params.filePriorities = m_contentModel->model()->getFilePriorities(); params.addPaused = !ui->startTorrentCheckBox->isChecked(); - params.createSubfolder = ui->createSubfolderComboBox->isChecked(); + params.createSubfolder = ui->createSubfolderCheckBox->isChecked(); QString savePath = ui->savePathComboBox->itemData(ui->savePathComboBox->currentIndex()).toString(); if (ui->comboTTM->currentIndex() != 1) { // 0 is Manual mode and 1 is Automatic mode. Handle all non 1 values as manual mode. diff --git a/src/gui/addnewtorrentdialog.ui b/src/gui/addnewtorrentdialog.ui index 5aff7281b..e010403b0 100644 --- a/src/gui/addnewtorrentdialog.ui +++ b/src/gui/addnewtorrentdialog.ui @@ -170,7 +170,7 @@ - + Skip hash check @@ -193,7 +193,7 @@ - + Start torrent @@ -203,7 +203,7 @@ - + Create subfolder @@ -305,8 +305,8 @@ 0 0 - 308 - 74 + 321 + 69 @@ -423,7 +423,7 @@ never_show_cb adv_button startTorrentCheckBox - skip_check_cb + skipCheckingCheckBox categoryComboBox defaultCategoryCheckbox scrollArea diff --git a/src/gui/optionsdlg.cpp b/src/gui/optionsdlg.cpp index 78f488bc7..03abb20be 100644 --- a/src/gui/optionsdlg.cpp +++ b/src/gui/optionsdlg.cpp @@ -516,7 +516,7 @@ void OptionsDialog::saveOptions() AddNewTorrentDialog::setEnabled(useAdditionDialog()); AddNewTorrentDialog::setTopLevel(m_ui->checkAdditionDialogFront->isChecked()); session->setAddTorrentPaused(addTorrentsInPause()); - pref->setTorrentCreateSubfolder(m_ui->checkCreateSubfolder->isChecked()); + session->setCreateTorrentSubfolder(m_ui->checkCreateSubfolder->isChecked()); ScanFoldersModel::instance()->removeFromFSWatcher(removedScanDirs); ScanFoldersModel::instance()->addToFSWatcher(addedScanDirs); ScanFoldersModel::instance()->makePersistent(); @@ -718,7 +718,7 @@ void OptionsDialog::loadOptions() m_ui->checkAdditionDialog->setChecked(AddNewTorrentDialog::isEnabled()); m_ui->checkAdditionDialogFront->setChecked(AddNewTorrentDialog::isTopLevel()); m_ui->checkStartPaused->setChecked(session->isAddTorrentPaused()); - m_ui->checkCreateSubfolder->setChecked(pref->getTorrentCreateSubfolder()); + m_ui->checkCreateSubfolder->setChecked(session->isCreateTorrentSubfolder()); const TorrentFileGuard::AutoDeleteMode autoDeleteMode = TorrentFileGuard::autoDeleteMode(); m_ui->deleteTorrentBox->setChecked(autoDeleteMode != TorrentFileGuard::Never); m_ui->deleteCancelledTorrentBox->setChecked(autoDeleteMode == TorrentFileGuard::Always);