Rename ASM to TMM and related stuff.

This commit is contained in:
sledgehammer999
2016-05-08 22:47:50 +03:00
parent bc270bd801
commit 81ea07abee
11 changed files with 162 additions and 180 deletions

View File

@@ -89,7 +89,9 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent)
auto session = BitTorrent::Session::instance();
ui->startTorrentCheckBox->setChecked(!session->isAddTorrentPaused());
(session->isASMDisabledByDefault() ? ui->simpleModeRadioButton : ui->advancedModeRadioButton)->setChecked(true);
ui->comboTTM->blockSignals(true); //the TreeView size isn't correct if the slot does it job at this point
ui->comboTTM->setCurrentIndex(!session->isAutoTMMDisabledByDefault());
ui->comboTTM->blockSignals(false);
populateSavePathComboBox();
connect(ui->savePathComboBox, SIGNAL(currentIndexChanged(int)), SLOT(onSavePathChanged(int)));
connect(ui->browseButton, SIGNAL(clicked()), SLOT(browseButton_clicked()));
@@ -249,6 +251,7 @@ bool AddNewTorrentDialog::loadTorrent(const QString &torrentPath)
ui->lblhash->setText(m_hash);
setupTreeview();
TMMChanged(ui->comboTTM->currentIndex());
return true;
}
@@ -287,6 +290,7 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri)
setWindowTitle(torrent_name.isEmpty() ? tr("Magnet link") : torrent_name);
setupTreeview();
TMMChanged(ui->comboTTM->currentIndex());
// Set dialog position
setdialogPosition();
@@ -402,7 +406,7 @@ void AddNewTorrentDialog::categoryChanged(int index)
{
Q_UNUSED(index);
if (ui->advancedModeRadioButton->isChecked()) {
if (ui->comboTTM->currentIndex() == 1) {
QString savePath = BitTorrent::Session::instance()->categorySavePath(ui->categoryComboBox->currentText());
ui->savePathComboBox->setItemText(0, Utils::Fs::toNativePath(savePath));
ui->savePathComboBox->setItemData(0, savePath);
@@ -638,7 +642,7 @@ void AddNewTorrentDialog::accept()
params.addPaused = !ui->startTorrentCheckBox->isChecked();
QString savePath = ui->savePathComboBox->itemData(ui->savePathComboBox->currentIndex()).toString();
if (ui->simpleModeRadioButton->isChecked()) {
if (ui->comboTTM->currentIndex() != 1) { // 0 is Manual mode and 1 is Automatic mode. Handle all non 1 values as manual mode.
params.savePath = savePath;
saveSavePathHistory();
if (ui->defaultSavePathCheckBox->isChecked())
@@ -686,6 +690,7 @@ void AddNewTorrentDialog::updateMetadata(const BitTorrent::TorrentInfo &info)
// Update UI
setupTreeview();
TMMChanged(ui->comboTTM->currentIndex());
setMetadataProgressIndicator(false, tr("Metadata retrieval complete"));
}
@@ -770,25 +775,25 @@ void AddNewTorrentDialog::handleDownloadFinished(const QString &url, const QStri
this->deleteLater();
}
void AddNewTorrentDialog::savingModeChanged(bool enabled)
void AddNewTorrentDialog::TMMChanged(int index)
{
if (!enabled) return;
if (ui->simpleModeRadioButton->isChecked()) {
if (index != 1) { // 0 is Manual mode and 1 is Automatic mode. Handle all non 1 values as manual mode.
populateSavePathComboBox();
ui->savePathComboBox->setEnabled(true);
ui->browseButton->setEnabled(true);
ui->groupBoxSavePath->setEnabled(true);
ui->savePathComboBox->blockSignals(false);
ui->savePathComboBox->setCurrentIndex(m_oldIndex < ui->savePathComboBox->count() ? m_oldIndex : ui->savePathComboBox->count() - 1);
ui->adv_button->setEnabled(true);
}
else {
ui->groupBoxSavePath->setEnabled(false);
ui->savePathComboBox->blockSignals(true);
ui->savePathComboBox->clear();
QString savePath = BitTorrent::Session::instance()->categorySavePath(ui->categoryComboBox->currentText());
ui->savePathComboBox->addItem(Utils::Fs::toNativePath(savePath), savePath);
ui->savePathComboBox->setEnabled(false);
ui->browseButton->setEnabled(false);
ui->defaultSavePathCheckBox->setVisible(false);
ui->adv_button->setChecked(true);
ui->adv_button->setEnabled(false);
showAdvancedSettings(true);
}
}

View File

@@ -79,7 +79,7 @@ private slots:
void handleDownloadFailed(const QString &url, const QString &reason);
void handleRedirectedToMagnet(const QString &url, const QString &magnetUri);
void handleDownloadFinished(const QString &url, const QString &filePath);
void savingModeChanged(bool enabled);
void TMMChanged(int index);
void categoryChanged(int index);
void doNotDeleteTorrentClicked(bool checked);

View File

@@ -12,55 +12,52 @@
</property>
<layout class="QVBoxLayout" name="AddNewTorrentDialogLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="labelTorrentManagementMode">
<property name="text">
<string>Torrent Management Mode:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboTTM">
<property name="toolTip">
<string>Automatic mode means that various torrent properties(eg save path) will be decided by the associated category</string>
</property>
<item>
<property name="text">
<string>Manual</string>
</property>
</item>
<item>
<property name="text">
<string>Automatic</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBoxSavePath">
<property name="title">
<string>Save at</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>20</number>
</property>
<item>
<widget class="QLabel" name="savingModeLabel">
<property name="text">
<string>Saving Management:</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="simpleModeRadioButton">
<property name="text">
<string>Simple</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="advancedModeRadioButton">
<property name="text">
<string>Advanced</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
@@ -400,8 +397,6 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>simpleModeRadioButton</tabstop>
<tabstop>advancedModeRadioButton</tabstop>
<tabstop>savePathComboBox</tabstop>
<tabstop>browseButton</tabstop>
<tabstop>defaultSavePathCheckBox</tabstop>
@@ -448,38 +443,6 @@
</hint>
</hints>
</connection>
<connection>
<sender>simpleModeRadioButton</sender>
<signal>toggled(bool)</signal>
<receiver>AddNewTorrentDialog</receiver>
<slot>savingModeChanged(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>154</x>
<y>39</y>
</hint>
<hint type="destinationlabel">
<x>122</x>
<y>6</y>
</hint>
</hints>
</connection>
<connection>
<sender>advancedModeRadioButton</sender>
<signal>toggled(bool)</signal>
<receiver>AddNewTorrentDialog</receiver>
<slot>savingModeChanged(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>218</x>
<y>44</y>
</hint>
<hint type="destinationlabel">
<x>209</x>
<y>7</y>
</hint>
</hints>
</connection>
<connection>
<sender>categoryComboBox</sender>
<signal>currentIndexChanged(int)</signal>
@@ -496,9 +459,26 @@
</hint>
</hints>
</connection>
<connection>
<sender>comboTTM</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>AddNewTorrentDialog</receiver>
<slot>TMMChanged(int)</slot>
<hints>
<hint type="sourcelabel">
<x>200</x>
<y>19</y>
</hint>
<hint type="destinationlabel">
<x>206</x>
<y>294</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>savingModeChanged(bool)</slot>
<slot>categoryChanged(int)</slot>
<slot>TMMChanged(int)</slot>
</slots>
</ui>

View File

@@ -797,7 +797,7 @@
<item row="0" column="0">
<widget class="QLabel" name="label_40">
<property name="text">
<string>Default Saving Mode:</string>
<string>Default Torrent Management Mode:</string>
</property>
</widget>
</item>
@@ -856,7 +856,7 @@
</item>
<item>
<property name="text">
<string>Switch torrent to Simple Mode</string>
<string>Switch torrent to Manual Mode</string>
</property>
</item>
</widget>
@@ -897,7 +897,7 @@
</item>
<item>
<property name="text">
<string>Switch affected torrents to Simple Mode</string>
<string>Switch affected torrents to Manual Mode</string>
</property>
</item>
</widget>
@@ -938,7 +938,7 @@
</item>
<item>
<property name="text">
<string>Switch affected torrents to Simple Mode</string>
<string>Switch affected torrents to Manual Mode</string>
</property>
</item>
</widget>
@@ -1306,10 +1306,6 @@
</widget>
</item>
</layout>
<zorder>gridLayoutWidget</zorder>
<zorder>label_2</zorder>
<zorder>checkSmtpSSL</zorder>
<zorder>groupMailNotifAuth</zorder>
</widget>
</item>
<item>

View File

@@ -496,10 +496,10 @@ void options_imp::saveOptions()
// Downloads preferences
session->setDefaultSavePath(Utils::Fs::expandPathAbs(textSavePath->text()));
session->setSubcategoriesEnabled(checkUseSubcategories->isChecked());
session->setASMDisabledByDefault(comboSavingMode->currentIndex() == 0);
session->setDisableASMWhenCategoryChanged(comboTorrentCategoryChanged->currentIndex() == 1);
session->setDisableASMWhenCategorySavePathChanged(comboCategoryChanged->currentIndex() == 1);
session->setDisableASMWhenDefaultSavePathChanged(comboCategoryDefaultPathChanged->currentIndex() == 1);
session->setAutoTMMDisabledByDefault(comboSavingMode->currentIndex() == 0);
session->setDisableAutoTMMWhenCategoryChanged(comboTorrentCategoryChanged->currentIndex() == 1);
session->setDisableAutoTMMWhenCategorySavePathChanged(comboCategoryChanged->currentIndex() == 1);
session->setDisableAutoTMMWhenDefaultSavePathChanged(comboCategoryDefaultPathChanged->currentIndex() == 1);
session->setTempPathEnabled(checkTempFolder->isChecked());
session->setTempPath(Utils::Fs::expandPathAbs(textTempPath->text()));
pref->useIncompleteFilesExtension(checkAppendqB->isChecked());
@@ -710,10 +710,10 @@ void options_imp::loadOptions()
textSavePath->setText(Utils::Fs::toNativePath(session->defaultSavePath()));
checkUseSubcategories->setChecked(session->isSubcategoriesEnabled());
comboSavingMode->setCurrentIndex(!session->isASMDisabledByDefault());
comboTorrentCategoryChanged->setCurrentIndex(session->isDisableASMWhenCategoryChanged());
comboCategoryChanged->setCurrentIndex(session->isDisableASMWhenCategorySavePathChanged());
comboCategoryDefaultPathChanged->setCurrentIndex(session->isDisableASMWhenDefaultSavePathChanged());
comboSavingMode->setCurrentIndex(!session->isAutoTMMDisabledByDefault());
comboTorrentCategoryChanged->setCurrentIndex(session->isDisableAutoTMMWhenCategoryChanged());
comboCategoryChanged->setCurrentIndex(session->isDisableAutoTMMWhenCategorySavePathChanged());
comboCategoryDefaultPathChanged->setCurrentIndex(session->isDisableAutoTMMWhenDefaultSavePathChanged());
checkTempFolder->setChecked(session->isTempPathEnabled());
textTempPath->setEnabled(checkTempFolder->isChecked());
browseTempDirButton->setEnabled(checkTempFolder->isChecked());

View File

@@ -566,10 +566,10 @@ void TransferListWidget::toggleSelectedFirstLastPiecePrio() const
torrent->toggleFirstLastPiecePriority();
}
void TransferListWidget::setSelectedASMEnabled(bool enabled) const
void TransferListWidget::setSelectedAutoTMMEnabled(bool enabled) const
{
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents())
torrent->setASMEnabled(enabled);
torrent->setAutoTMMEnabled(enabled);
}
void TransferListWidget::askNewCategoryForSelection()
@@ -672,9 +672,10 @@ void TransferListWidget::displayListMenu(const QPoint&)
QAction actionFirstLastPiece_prio(tr("Download first and last pieces first"), 0);
actionFirstLastPiece_prio.setCheckable(true);
connect(&actionFirstLastPiece_prio, SIGNAL(triggered()), this, SLOT(toggleSelectedFirstLastPiecePrio()));
QAction actionEnableASM(tr("Enable Advanced Saving Management"), 0);
actionEnableASM.setCheckable(true);
connect(&actionEnableASM, SIGNAL(triggered(bool)), this, SLOT(setSelectedASMEnabled(bool)));
QAction actionAutoTMM(tr("Automatic Torrent Management"), 0);
actionAutoTMM.setCheckable(true);
actionAutoTMM.setToolTip(tr("Automatic mode means that various torrent properties(eg save path) will be decided by the associated category"));
connect(&actionAutoTMM, SIGNAL(triggered(bool)), this, SLOT(setSelectedAutoTMMEnabled(bool)));
// End of actions
// Enable/disable pause/start action given the DL state
@@ -685,8 +686,8 @@ void TransferListWidget::displayListMenu(const QPoint&)
bool sequential_download_mode = false, prioritize_first_last = false;
bool one_has_metadata = false, one_not_seed = false;
bool allSameCategory = true;
bool allSameASM = true;
bool firstASM = false;
bool allSameAutoTMM = true;
bool firstAutoTMM = false;
QString firstCategory;
bool first = true;
@@ -704,9 +705,9 @@ void TransferListWidget::displayListMenu(const QPoint&)
allSameCategory = false;
if (first)
firstASM = torrent->isASMEnabled();
if (firstASM != torrent->isASMEnabled())
allSameASM = false;
firstAutoTMM = torrent->isAutoTMMEnabled();
if (firstAutoTMM != torrent->isAutoTMMEnabled())
allSameAutoTMM = false;
if (torrent->hasMetadata())
one_has_metadata = true;
@@ -750,7 +751,7 @@ void TransferListWidget::displayListMenu(const QPoint&)
if (one_has_metadata && one_not_seed && !all_same_sequential_download_mode
&& !all_same_prio_firstlast && !all_same_super_seeding && !allSameCategory
&& needs_start && needs_force && needs_pause && needs_preview && !allSameASM) {
&& needs_start && needs_force && needs_pause && needs_preview && !allSameAutoTMM) {
break;
}
}
@@ -786,9 +787,9 @@ void TransferListWidget::displayListMenu(const QPoint&)
categoryActions << cat;
}
if (allSameASM) {
actionEnableASM.setChecked(firstASM);
listMenu.addAction(&actionEnableASM);
if (allSameAutoTMM) {
actionAutoTMM.setChecked(firstAutoTMM);
listMenu.addAction(&actionAutoTMM);
}
listMenu.addSeparator();

View File

@@ -105,7 +105,7 @@ protected slots:
void toggleSelectedTorrentsSuperSeeding() const;
void toggleSelectedTorrentsSequentialDownload() const;
void toggleSelectedFirstLastPiecePrio() const;
void setSelectedASMEnabled(bool enabled) const;
void setSelectedAutoTMMEnabled(bool enabled) const;
void askNewCategoryForSelection();
void saveSettings();