From d336c7c02c0e996a1d5635a6726d553f94524fe8 Mon Sep 17 00:00:00 2001 From: takiz Date: Tue, 3 Nov 2015 20:05:15 +0500 Subject: [PATCH] "Set as default label" option --- src/core/preferences.cpp | 10 ++++++++++ src/core/preferences.h | 2 ++ src/gui/addnewtorrentdialog.cpp | 12 +++++++++++- src/gui/addnewtorrentdialog.ui | 7 +++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/core/preferences.cpp b/src/core/preferences.cpp index 4ede40b1c..385d3da0c 100644 --- a/src/core/preferences.cpp +++ b/src/core/preferences.cpp @@ -1643,6 +1643,16 @@ void Preferences::removeTorrentLabel(const QString& label) setValue("TransferListFilters/customLabels", labels); } +QString Preferences::getDefaultLabel() const +{ + return value("Preferences/Downloads/DefaultLabel").toString(); +} + +void Preferences::setDefaultLabel(const QString &defaultLabel) +{ + setValue("Preferences/Downloads/DefaultLabel", defaultLabel); +} + bool Preferences::recursiveDownloadDisabled() const { return value("Preferences/Advanced/DisableRecursiveDownload", false).toBool(); diff --git a/src/core/preferences.h b/src/core/preferences.h index 546abb54d..478600a3d 100644 --- a/src/core/preferences.h +++ b/src/core/preferences.h @@ -160,6 +160,8 @@ public: void setTempPathEnabled(bool enabled); QString getTempPath() const; void setTempPath(const QString &path); + QString getDefaultLabel() const; + void setDefaultLabel(const QString &defaultLabel); bool useIncompleteFilesExtension() const; void useIncompleteFilesExtension(bool enabled); bool appendTorrentLabel() const; diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index a2662ea92..8583ed478 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -77,9 +77,16 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) // Load labels const QStringList customLabels = pref->getTorrentLabels(); + const QString defaultLabel = pref->getDefaultLabel(); + + if (!defaultLabel.isEmpty()) + ui->label_combo->addItem(defaultLabel); ui->label_combo->addItem(""); + foreach (const QString& label, customLabels) - ui->label_combo->addItem(label); + if (label != defaultLabel) + ui->label_combo->addItem(label); + ui->label_combo->model()->sort(0); ui->content_tree->header()->setSortIndicator(0, Qt::AscendingOrder); loadState(); @@ -587,6 +594,9 @@ void AddNewTorrentDialog::accept() // Label params.label = ui->label_combo->currentText(); + if (ui->defaultLabel->isChecked()) + pref->setDefaultLabel(params.label); + // Save file priorities if (m_contentModel) params.filePriorities = m_contentModel->model()->getFilePriorities(); diff --git a/src/gui/addnewtorrentdialog.ui b/src/gui/addnewtorrentdialog.ui index 98690ae24..79c2e0840 100644 --- a/src/gui/addnewtorrentdialog.ui +++ b/src/gui/addnewtorrentdialog.ui @@ -127,6 +127,13 @@ + + + + Set as default label + + +