From b55d4b17335df3fe39d47d2f27acbaf143e371ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartu=20=C3=96zen?= <15032958+Bartuzen@users.noreply.github.com> Date: Sun, 2 Apr 2023 11:02:22 +0300 Subject: [PATCH] WebUI: Implement subcategories PR #18740. --- src/webui/api/appcontroller.cpp | 3 ++ src/webui/api/synccontroller.cpp | 3 ++ src/webui/www/private/index.html | 1 + src/webui/www/private/newcategory.html | 5 +++ src/webui/www/private/scripts/client.js | 33 ++++++++++++++++--- src/webui/www/private/scripts/contextmenu.js | 7 ++++ src/webui/www/private/scripts/dynamicTable.js | 12 +++++-- src/webui/www/private/scripts/mocha-init.js | 20 +++++++++++ src/webui/www/private/views/filters.html | 3 ++ src/webui/www/private/views/preferences.html | 6 ++++ 10 files changed, 86 insertions(+), 7 deletions(-) diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index 889689876..562380a5e 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -134,6 +134,7 @@ void AppController::preferencesAction() data[u"torrent_changed_tmm_enabled"_qs] = !session->isDisableAutoTMMWhenCategoryChanged(); data[u"save_path_changed_tmm_enabled"_qs] = !session->isDisableAutoTMMWhenDefaultSavePathChanged(); data[u"category_changed_tmm_enabled"_qs] = !session->isDisableAutoTMMWhenCategorySavePathChanged(); + data[u"use_subcategories"] = session->isSubcategoriesEnabled(); data[u"save_path"_qs] = session->savePath().toString(); data[u"temp_path_enabled"_qs] = session->isDownloadPathEnabled(); data[u"temp_path"_qs] = session->downloadPath().toString(); @@ -489,6 +490,8 @@ void AppController::setPreferencesAction() session->setDisableAutoTMMWhenDefaultSavePathChanged(!it.value().toBool()); if (hasKey(u"category_changed_tmm_enabled"_qs)) session->setDisableAutoTMMWhenCategorySavePathChanged(!it.value().toBool()); + if (hasKey(u"use_subcategories"_qs)) + session->setSubcategoriesEnabled(it.value().toBool()); if (hasKey(u"save_path"_qs)) session->setSavePath(Path(it.value().toString())); if (hasKey(u"temp_path_enabled"_qs)) diff --git a/src/webui/api/synccontroller.cpp b/src/webui/api/synccontroller.cpp index d11ee8a93..6e77396ce 100644 --- a/src/webui/api/synccontroller.cpp +++ b/src/webui/api/synccontroller.cpp @@ -61,6 +61,7 @@ namespace const QString KEY_SYNC_MAINDATA_QUEUEING = u"queueing"_qs; const QString KEY_SYNC_MAINDATA_REFRESH_INTERVAL = u"refresh_interval"_qs; const QString KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS = u"use_alt_speed_limits"_qs; + const QString KEY_SYNC_MAINDATA_USE_SUBCATEGORIES = u"use_subcategories"_qs; // Sync torrent peers keys const QString KEY_SYNC_TORRENT_PEERS_SHOW_FLAGS = u"show_flags"_qs; @@ -549,6 +550,7 @@ void SyncController::makeMaindataSnapshot() m_maindataSnapshot.serverState[KEY_SYNC_MAINDATA_QUEUEING] = session->isQueueingSystemEnabled(); m_maindataSnapshot.serverState[KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS] = session->isAltGlobalSpeedLimitEnabled(); m_maindataSnapshot.serverState[KEY_SYNC_MAINDATA_REFRESH_INTERVAL] = session->refreshInterval(); + m_maindataSnapshot.serverState[KEY_SYNC_MAINDATA_USE_SUBCATEGORIES] = session->isSubcategoriesEnabled(); } QJsonObject SyncController::generateMaindataSyncData(const int id, const bool fullUpdate) @@ -657,6 +659,7 @@ QJsonObject SyncController::generateMaindataSyncData(const int id, const bool fu serverState[KEY_SYNC_MAINDATA_QUEUEING] = session->isQueueingSystemEnabled(); serverState[KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS] = session->isAltGlobalSpeedLimitEnabled(); serverState[KEY_SYNC_MAINDATA_REFRESH_INTERVAL] = session->refreshInterval(); + serverState[KEY_SYNC_MAINDATA_USE_SUBCATEGORIES] = session->isSubcategoriesEnabled(); processMap(m_maindataSnapshot.serverState, serverState, m_maindataSyncBuf.serverState); m_maindataSnapshot.serverState = serverState; diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html index 94e83f062..d9c0c60e8 100644 --- a/src/webui/www/private/index.html +++ b/src/webui/www/private/index.html @@ -188,6 +188,7 @@
@@ -1844,6 +1848,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD $('torrent_changed_tmm_combobox').setProperty('value', pref.torrent_changed_tmm_enabled); $('save_path_changed_tmm_combobox').setProperty('value', pref.save_path_changed_tmm_enabled); $('category_changed_tmm_combobox').setProperty('value', pref.category_changed_tmm_enabled); + $('use_subcategories_checkbox').setProperty('checked', pref.use_subcategories); $('savepath_text').setProperty('value', pref.save_path); $('temppath_checkbox').setProperty('checked', pref.temp_path_enabled); $('temppath_text').setProperty('value', pref.temp_path); @@ -2199,6 +2204,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD settings.set('torrent_changed_tmm_enabled', $('torrent_changed_tmm_combobox').getProperty('value')); settings.set('save_path_changed_tmm_enabled', $('save_path_changed_tmm_combobox').getProperty('value')); settings.set('category_changed_tmm_enabled', $('category_changed_tmm_combobox').getProperty('value')); + settings.set('use_subcategories', $('use_subcategories_checkbox').getProperty('checked')); settings.set('save_path', $('savepath_text').getProperty('value')); settings.set('temp_path_enabled', $('temppath_checkbox').getProperty('checked')); settings.set('temp_path', $('temppath_text').getProperty('value')); |