Browse Source

Fix strip torrent root folder

adaptive-webui-19844
Vladimir Golovnev (Glassez) 8 years ago
parent
commit
22178f9997
  1. 11
      src/base/bittorrent/session.cpp
  2. 3
      src/base/bittorrent/session.h
  3. 10
      src/base/preferences.cpp
  4. 2
      src/base/preferences.h
  5. 6
      src/gui/addnewtorrentdialog.cpp
  6. 12
      src/gui/addnewtorrentdialog.ui
  7. 4
      src/gui/optionsdlg.cpp

11
src/base/bittorrent/session.cpp

@ -244,6 +244,7 @@ Session::Session(QObject *parent)
, m_additionalTrackers(BITTORRENT_SESSION_KEY("AdditionalTrackers")) , m_additionalTrackers(BITTORRENT_SESSION_KEY("AdditionalTrackers"))
, m_globalMaxRatio(BITTORRENT_SESSION_KEY("GlobalMaxRatio"), -1, [](qreal r) { return r < 0 ? -1. : r;}) , m_globalMaxRatio(BITTORRENT_SESSION_KEY("GlobalMaxRatio"), -1, [](qreal r) { return r < 0 ? -1. : r;})
, m_isAddTorrentPaused(BITTORRENT_SESSION_KEY("AddTorrentPaused"), false) , m_isAddTorrentPaused(BITTORRENT_SESSION_KEY("AddTorrentPaused"), false)
, m_isCreateTorrentSubfolder(BITTORRENT_SESSION_KEY("CreateTorrentSubfolder"), true)
, m_isAppendExtensionEnabled(BITTORRENT_SESSION_KEY("AddExtensionToIncompleteFiles"), false) , m_isAppendExtensionEnabled(BITTORRENT_SESSION_KEY("AddExtensionToIncompleteFiles"), false)
, m_refreshInterval(BITTORRENT_SESSION_KEY("RefreshInterval"), 1500) , m_refreshInterval(BITTORRENT_SESSION_KEY("RefreshInterval"), 1500)
, m_isPreallocationEnabled(BITTORRENT_SESSION_KEY("Preallocation"), false) , m_isPreallocationEnabled(BITTORRENT_SESSION_KEY("Preallocation"), false)
@ -3253,6 +3254,16 @@ void Session::getPendingAlerts(std::vector<libt::alert *> &out, ulong time)
#endif #endif
} }
bool Session::isCreateTorrentSubfolder() const
{
return m_isCreateTorrentSubfolder;
}
void Session::setCreateTorrentSubfolder(bool value)
{
m_isCreateTorrentSubfolder = value;
}
// Read alerts sent by the BitTorrent session // Read alerts sent by the BitTorrent session
void Session::readAlerts() void Session::readAlerts()
{ {

3
src/base/bittorrent/session.h

@ -222,6 +222,8 @@ namespace BitTorrent
void setPeXEnabled(bool enabled); void setPeXEnabled(bool enabled);
bool isAddTorrentPaused() const; bool isAddTorrentPaused() const;
void setAddTorrentPaused(bool value); void setAddTorrentPaused(bool value);
bool isCreateTorrentSubfolder() const;
void setCreateTorrentSubfolder(bool value);
bool isTrackerEnabled() const; bool isTrackerEnabled() const;
void setTrackerEnabled(bool enabled); void setTrackerEnabled(bool enabled);
bool isAppendExtensionEnabled() const; bool isAppendExtensionEnabled() const;
@ -539,6 +541,7 @@ namespace BitTorrent
CachedSettingValue<QString> m_additionalTrackers; CachedSettingValue<QString> m_additionalTrackers;
CachedSettingValue<qreal> m_globalMaxRatio; CachedSettingValue<qreal> m_globalMaxRatio;
CachedSettingValue<bool> m_isAddTorrentPaused; CachedSettingValue<bool> m_isAddTorrentPaused;
CachedSettingValue<bool> m_isCreateTorrentSubfolder;
CachedSettingValue<bool> m_isAppendExtensionEnabled; CachedSettingValue<bool> m_isAppendExtensionEnabled;
CachedSettingValue<uint> m_refreshInterval; CachedSettingValue<uint> m_refreshInterval;
CachedSettingValue<bool> m_isPreallocationEnabled; CachedSettingValue<bool> m_isPreallocationEnabled;

10
src/base/preferences.cpp

@ -263,16 +263,6 @@ void Preferences::setLastLocationPath(const QString &path)
setValue("Preferences/Downloads/LastLocationPath", Utils::Fs::fromNativePath(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 QVariantHash Preferences::getScanDirs() const
{ {
return value("Preferences/Downloads/ScanDirsV2").toHash(); return value("Preferences/Downloads/ScanDirsV2").toHash();

2
src/base/preferences.h

@ -138,8 +138,6 @@ public:
void setLastLocationPath(const QString &path); void setLastLocationPath(const QString &path);
QVariantHash getScanDirs() const; QVariantHash getScanDirs() const;
void setScanDirs(const QVariantHash &dirs); void setScanDirs(const QVariantHash &dirs);
bool getTorrentCreateSubfolder() const;
void setTorrentCreateSubfolder(bool b);
QString getScanDirsLastPath() const; QString getScanDirsLastPath() const;
void setScanDirsLastPath(const QString &path); void setScanDirsLastPath(const QString &path);
bool isMailNotificationEnabled() const; bool isMailNotificationEnabled() const;

6
src/gui/addnewtorrentdialog.cpp

@ -96,7 +96,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent)
connect(ui->savePathComboBox, SIGNAL(currentIndexChanged(int)), SLOT(onSavePathChanged(int))); connect(ui->savePathComboBox, SIGNAL(currentIndexChanged(int)), SLOT(onSavePathChanged(int)));
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->createSubfolderComboBox->setChecked(Preferences::instance()->getTorrentCreateSubfolder()); ui->createSubfolderCheckBox->setChecked(session->isCreateTorrentSubfolder());
ui->doNotDeleteTorrentCheckBox->setVisible(TorrentFileGuard::autoDeleteMode() != TorrentFileGuard::Never); ui->doNotDeleteTorrentCheckBox->setVisible(TorrentFileGuard::autoDeleteMode() != TorrentFileGuard::Never);
@ -627,7 +627,7 @@ void AddNewTorrentDialog::accept()
BitTorrent::AddTorrentParams params; BitTorrent::AddTorrentParams params;
// TODO: Check if destination actually exists // TODO: Check if destination actually exists
params.skipChecking = ui->skip_check_cb->isChecked(); params.skipChecking = ui->skipCheckingCheckBox->isChecked();
// Category // Category
params.category = ui->categoryComboBox->currentText(); params.category = ui->categoryComboBox->currentText();
@ -640,7 +640,7 @@ void AddNewTorrentDialog::accept()
params.filePriorities = m_contentModel->model()->getFilePriorities(); params.filePriorities = m_contentModel->model()->getFilePriorities();
params.addPaused = !ui->startTorrentCheckBox->isChecked(); params.addPaused = !ui->startTorrentCheckBox->isChecked();
params.createSubfolder = ui->createSubfolderComboBox->isChecked(); params.createSubfolder = ui->createSubfolderCheckBox->isChecked();
QString savePath = ui->savePathComboBox->itemData(ui->savePathComboBox->currentIndex()).toString(); 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. if (ui->comboTTM->currentIndex() != 1) { // 0 is Manual mode and 1 is Automatic mode. Handle all non 1 values as manual mode.

12
src/gui/addnewtorrentdialog.ui

@ -170,7 +170,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QCheckBox" name="skip_check_cb"> <widget class="QCheckBox" name="skipCheckingCheckBox">
<property name="text"> <property name="text">
<string>Skip hash check</string> <string>Skip hash check</string>
</property> </property>
@ -193,7 +193,7 @@
</spacer> </spacer>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QCheckBox" name="start_torrent_cb"> <widget class="QCheckBox" name="startTorrentCheckBox_2">
<property name="text"> <property name="text">
<string>Start torrent</string> <string>Start torrent</string>
</property> </property>
@ -203,7 +203,7 @@
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QCheckBox" name="createSubfolderComboBox"> <widget class="QCheckBox" name="createSubfolderCheckBox">
<property name="text"> <property name="text">
<string>Create subfolder</string> <string>Create subfolder</string>
</property> </property>
@ -305,8 +305,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>308</width> <width>321</width>
<height>74</height> <height>69</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
@ -423,7 +423,7 @@
<tabstop>never_show_cb</tabstop> <tabstop>never_show_cb</tabstop>
<tabstop>adv_button</tabstop> <tabstop>adv_button</tabstop>
<tabstop>startTorrentCheckBox</tabstop> <tabstop>startTorrentCheckBox</tabstop>
<tabstop>skip_check_cb</tabstop> <tabstop>skipCheckingCheckBox</tabstop>
<tabstop>categoryComboBox</tabstop> <tabstop>categoryComboBox</tabstop>
<tabstop>defaultCategoryCheckbox</tabstop> <tabstop>defaultCategoryCheckbox</tabstop>
<tabstop>scrollArea</tabstop> <tabstop>scrollArea</tabstop>

4
src/gui/optionsdlg.cpp

@ -516,7 +516,7 @@ void OptionsDialog::saveOptions()
AddNewTorrentDialog::setEnabled(useAdditionDialog()); AddNewTorrentDialog::setEnabled(useAdditionDialog());
AddNewTorrentDialog::setTopLevel(m_ui->checkAdditionDialogFront->isChecked()); AddNewTorrentDialog::setTopLevel(m_ui->checkAdditionDialogFront->isChecked());
session->setAddTorrentPaused(addTorrentsInPause()); session->setAddTorrentPaused(addTorrentsInPause());
pref->setTorrentCreateSubfolder(m_ui->checkCreateSubfolder->isChecked()); session->setCreateTorrentSubfolder(m_ui->checkCreateSubfolder->isChecked());
ScanFoldersModel::instance()->removeFromFSWatcher(removedScanDirs); ScanFoldersModel::instance()->removeFromFSWatcher(removedScanDirs);
ScanFoldersModel::instance()->addToFSWatcher(addedScanDirs); ScanFoldersModel::instance()->addToFSWatcher(addedScanDirs);
ScanFoldersModel::instance()->makePersistent(); ScanFoldersModel::instance()->makePersistent();
@ -718,7 +718,7 @@ void OptionsDialog::loadOptions()
m_ui->checkAdditionDialog->setChecked(AddNewTorrentDialog::isEnabled()); m_ui->checkAdditionDialog->setChecked(AddNewTorrentDialog::isEnabled());
m_ui->checkAdditionDialogFront->setChecked(AddNewTorrentDialog::isTopLevel()); m_ui->checkAdditionDialogFront->setChecked(AddNewTorrentDialog::isTopLevel());
m_ui->checkStartPaused->setChecked(session->isAddTorrentPaused()); m_ui->checkStartPaused->setChecked(session->isAddTorrentPaused());
m_ui->checkCreateSubfolder->setChecked(pref->getTorrentCreateSubfolder()); m_ui->checkCreateSubfolder->setChecked(session->isCreateTorrentSubfolder());
const TorrentFileGuard::AutoDeleteMode autoDeleteMode = TorrentFileGuard::autoDeleteMode(); const TorrentFileGuard::AutoDeleteMode autoDeleteMode = TorrentFileGuard::autoDeleteMode();
m_ui->deleteTorrentBox->setChecked(autoDeleteMode != TorrentFileGuard::Never); m_ui->deleteTorrentBox->setChecked(autoDeleteMode != TorrentFileGuard::Never);
m_ui->deleteCancelledTorrentBox->setChecked(autoDeleteMode == TorrentFileGuard::Always); m_ui->deleteCancelledTorrentBox->setChecked(autoDeleteMode == TorrentFileGuard::Always);

Loading…
Cancel
Save