diff --git a/src/webui/api/synccontroller.cpp b/src/webui/api/synccontroller.cpp index dac4fb316..cb8a038c0 100644 --- a/src/webui/api/synccontroller.cpp +++ b/src/webui/api/synccontroller.cpp @@ -445,6 +445,12 @@ void SyncController::maindataAction() data["categories"] = categories; + QVariantList tags; + for (const QString &tag : asConst(session->tags())) + tags << tag; + + data["tags"] = tags; + QVariantMap serverState = getTranserInfo(); serverState[KEY_TRANSFER_FREESPACEONDISK] = getFreeDiskSpace(); serverState[KEY_SYNC_MAINDATA_QUEUEING] = session->isQueueingSystemEnabled(); diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index 35561b10e..0a965bf28 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -1041,3 +1041,67 @@ void TorrentsController::categoriesAction() setResult(categories); } + +void TorrentsController::addTagsAction() +{ + checkParams({"hashes", "tags"}); + + const QStringList hashes {params()["hashes"].split('|')}; + const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)}; + + for (const QString &tag : tags) { + const QString tagTrimmed {tag.trimmed()}; + applyToTorrents(hashes, [&tagTrimmed](BitTorrent::TorrentHandle *const torrent) + { + torrent->addTag(tagTrimmed); + }); + } +} + +void TorrentsController::removeTagsAction() +{ + checkParams({"hashes"}); + + const QStringList hashes {params()["hashes"].split('|')}; + const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)}; + + for (const QString &tag : tags) { + const QString tagTrimmed {tag.trimmed()}; + applyToTorrents(hashes, [&tagTrimmed](BitTorrent::TorrentHandle *const torrent) + { + torrent->removeTag(tagTrimmed); + }); + } + + if (tags.isEmpty()) { + applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) + { + torrent->removeAllTags(); + }); + } +} + +void TorrentsController::createTagsAction() +{ + checkParams({"tags"}); + + const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)}; + + for (const QString &tag : tags) + BitTorrent::Session::instance()->addTag(tag.trimmed()); +} + +void TorrentsController::deleteTagsAction() +{ + checkParams({"tags"}); + + const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)}; + for (const QString &tag : tags) + BitTorrent::Session::instance()->removeTag(tag.trimmed()); +} + +void TorrentsController::tagsAction() +{ + const QStringList tags = BitTorrent::Session::instance()->tags().toList(); + setResult(QJsonArray::fromStringList(tags)); +} diff --git a/src/webui/api/torrentscontroller.h b/src/webui/api/torrentscontroller.h index 2f467a22e..61bf4e14f 100644 --- a/src/webui/api/torrentscontroller.h +++ b/src/webui/api/torrentscontroller.h @@ -56,6 +56,11 @@ private slots: void editCategoryAction(); void removeCategoriesAction(); void categoriesAction(); + void addTagsAction(); + void removeTagsAction(); + void createTagsAction(); + void deleteTagsAction(); + void tagsAction(); void addAction(); void deleteAction(); void addTrackersAction(); diff --git a/src/webui/www/private/css/style.css b/src/webui/www/private/css/style.css index 3200778ce..b625af7ab 100644 --- a/src/webui/www/private/css/style.css +++ b/src/webui/www/private/css/style.css @@ -258,6 +258,11 @@ a.propButton img { -ms-interpolation-mode: bicubic; } +.contextMenu li input[type=checkbox] { + position: relative; + top: 3px; +} + /* Sliders */ .slider { diff --git a/src/webui/www/private/filters.html b/src/webui/www/private/filters.html index 112a20356..d74c66b15 100644 --- a/src/webui/www/private/filters.html +++ b/src/webui/www/private/filters.html @@ -21,6 +21,13 @@ +
+ + QBT_TR(Tags)QBT_TR[CONTEXT=TransferListFiltersWidget] + + +
diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html index 0fd0e8076..89fc2c68e 100644 --- a/src/webui/www/private/index.html +++ b/src/webui/www/private/index.html @@ -132,6 +132,10 @@ QBT_TR(Category)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(Category)QBT_TR[CONTEXT=TransferListWidget] +
  • + QBT_TR(Tags)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(Tags)QBT_TR[CONTEXT=TransferListWidget] + +
  • QBT_TR(Automatic Torrent Management)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(Automatic Torrent Management)QBT_TR[CONTEXT=TransferListWidget]
  • @@ -170,6 +174,14 @@
  • QBT_TR(Pause torrents)QBT_TR[CONTEXT=CategoryFilterWidget] QBT_TR(Pause torrents)QBT_TR[CONTEXT=CategoryFilterWidget]
  • QBT_TR(Delete torrents)QBT_TR[CONTEXT=CategoryFilterWidget] QBT_TR(Delete torrents)QBT_TR[CONTEXT=CategoryFilterWidget]
  • +