From 99ca872011bca74ab0ff4ed1cf11ace72e8263cc Mon Sep 17 00:00:00 2001 From: Thomas Piccirello Date: Mon, 15 Oct 2018 22:48:57 -0400 Subject: [PATCH 01/15] Reorder WebUI options to match GUI --- src/webui/api/appcontroller.cpp | 33 ++--- .../www/private/preferences_content.html | 117 ++++++++++++------ 2 files changed, 95 insertions(+), 55 deletions(-) diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index 7fad40bed..45d172d93 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -84,12 +84,15 @@ void AppController::preferencesAction() QVariantMap data; // Downloads - // Hard Disk + data["preallocate_all"] = session->isPreallocationEnabled(); + data["incomplete_files_ext"] = session->isAppendExtensionEnabled(); + // Saving Management data["save_path"] = Utils::Fs::toNativePath(session->defaultSavePath()); data["temp_path_enabled"] = session->isTempPathEnabled(); data["temp_path"] = Utils::Fs::toNativePath(session->tempPath()); - data["preallocate_all"] = session->isPreallocationEnabled(); - data["incomplete_files_ext"] = session->isAppendExtensionEnabled(); + data["export_dir"] = Utils::Fs::toNativePath(session->torrentExportDirectory()); + data["export_dir_fin"] = Utils::Fs::toNativePath(session->finishedTorrentExportDirectory()); + // Automatically add torrents from const QVariantHash dirs = pref->getScanDirs(); QVariantMap nativeDirs; for (QVariantHash::const_iterator i = dirs.cbegin(), e = dirs.cend(); i != e; ++i) { @@ -99,8 +102,6 @@ void AppController::preferencesAction() nativeDirs.insert(Utils::Fs::toNativePath(i.key()), Utils::Fs::toNativePath(i.value().toString())); } data["scan_dirs"] = nativeDirs; - data["export_dir"] = Utils::Fs::toNativePath(session->torrentExportDirectory()); - data["export_dir_fin"] = Utils::Fs::toNativePath(session->finishedTorrentExportDirectory()); // Email notification upon download completion data["mail_notification_enabled"] = pref->isMailNotificationEnabled(); data["mail_notification_email"] = pref->getMailNotificationEmail(); @@ -232,19 +233,26 @@ void AppController::setPreferencesAction() Preferences *const pref = Preferences::instance(); auto session = BitTorrent::Session::instance(); const QVariantMap m = QJsonDocument::fromJson(params()["json"].toUtf8()).toVariant().toMap(); + QVariantMap::ConstIterator it; // Downloads - // Hard Disk + if ((it = m.find(QLatin1String("preallocate_all"))) != m.constEnd()) + session->setPreallocationEnabled(it.value().toBool()); + if ((it = m.find(QLatin1String("incomplete_files_ext"))) != m.constEnd()) + session->setAppendExtensionEnabled(it.value().toBool()); + + // Saving Management if (m.contains("save_path")) session->setDefaultSavePath(m["save_path"].toString()); if (m.contains("temp_path_enabled")) session->setTempPathEnabled(m["temp_path_enabled"].toBool()); if (m.contains("temp_path")) session->setTempPath(m["temp_path"].toString()); - if (m.contains("preallocate_all")) - session->setPreallocationEnabled(m["preallocate_all"].toBool()); - if (m.contains("incomplete_files_ext")) - session->setAppendExtensionEnabled(m["incomplete_files_ext"].toBool()); + if ((it = m.find(QLatin1String("export_dir"))) != m.constEnd()) + session->setTorrentExportDirectory(it.value().toString()); + if ((it = m.find(QLatin1String("export_dir_fin"))) != m.constEnd()) + session->setFinishedTorrentExportDirectory(it.value().toString()); + // Automatically add torrents from if (m.contains("scan_dirs")) { const QVariantMap nativeDirs = m["scan_dirs"].toMap(); QVariantHash oldScanDirs = pref->getScanDirs(); @@ -288,10 +296,6 @@ void AppController::setPreferencesAction() } pref->setScanDirs(scanDirs); } - if (m.contains("export_dir")) - session->setTorrentExportDirectory(m["export_dir"].toString()); - if (m.contains("export_dir_fin")) - session->setFinishedTorrentExportDirectory(m["export_dir_fin"].toString()); // Email notification upon download completion if (m.contains("mail_notification_enabled")) pref->setMailNotificationEnabled(m["mail_notification_enabled"].toBool()); @@ -505,7 +509,6 @@ void AppController::setPreferencesAction() // Save preferences pref->apply(); - QVariantMap::ConstIterator it; if ((it = m.find(QLatin1String("rss_refresh_interval"))) != m.constEnd()) RSS::Session::instance()->setRefreshInterval(it.value().toUInt()); if ((it = m.find(QLatin1String("rss_max_articles_per_feed"))) != m.constEnd()) diff --git a/src/webui/www/private/preferences_content.html b/src/webui/www/private/preferences_content.html index fd66f593a..630d185c0 100644 --- a/src/webui/www/private/preferences_content.html +++ b/src/webui/www/private/preferences_content.html @@ -1,21 +1,58 @@
-
- QBT_TR(Hard Disk)QBT_TR[CONTEXT=HttpServer] -
- - -
-
- - - -
+
-
+ +
+
-

QBT_TR(Automatically add torrents from:)QBT_TR[CONTEXT=OptionsDialog]
+ +
+ +
+ QBT_TR(Saving Management)QBT_TR[CONTEXT=HttpServer] + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + +
+ + + +
+
+ + + +
+
+
+ +
+ QBT_TR(Automatically add torrents from:)QBT_TR[CONTEXT=OptionsDialog] @@ -40,13 +77,7 @@ -

- -    -
- -    -
+
@@ -767,26 +798,14 @@ onSuccess: function(pref) { if (pref) { // Downloads tab - // Hard Disk + $('preallocateall_checkbox').setProperty('checked', pref.preallocate_all); + $('appendext_checkbox').setProperty('checked', pref.incomplete_files_ext); + + // Saving Managmenet $('savepath_text').setProperty('value', pref.save_path); $('temppath_checkbox').setProperty('checked', pref.temp_path_enabled); $('temppath_text').setProperty('value', pref.temp_path); updateTempDirEnabled(); - $('preallocateall_checkbox').setProperty('checked', pref.preallocate_all); - $('appendext_checkbox').setProperty('checked', pref.incomplete_files_ext); - var i = 0; - for (var folder in pref.scan_dirs) { - var sel; - var other = ""; - if (typeof pref.scan_dirs[folder] == "string") { - other = pref.scan_dirs[folder]; - sel = "other"; - } - else { - sel = (pref.scan_dirs[folder] == 0) ? "watch_folder" : "default_folder"; - } - pushWatchFolder(i++, folder, sel, other); - } if (pref.export_dir != '') { $('exportdir_checkbox').setProperty('checked', true); $('exportdir_text').setProperty('value', pref.export_dir); @@ -806,6 +825,21 @@ } updateExportDirFinEnabled(); + // Automatically add torrents from + var i = 0; + for (var folder in pref.scan_dirs) { + var sel; + var other = ""; + if (typeof pref.scan_dirs[folder] == "string") { + other = pref.scan_dirs[folder]; + sel = "other"; + } + else { + sel = (pref.scan_dirs[folder] == 0) ? "watch_folder" : "default_folder"; + } + pushWatchFolder(i++, folder, sel, other); + } + // Email notification upon download completion $('mail_notification_checkbox').setProperty('checked', pref.mail_notification_enabled); $('dest_email_txt').setProperty('value', pref.mail_notification_email); @@ -1008,13 +1042,13 @@ var settings = new Hash(); // Validate form data // Downloads tab - // Hard Disk + settings.set('preallocate_all', $('preallocateall_checkbox').getProperty('checked')); + settings.set('incomplete_files_ext', $('appendext_checkbox').getProperty('checked')); + + // Saving Management 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')); - settings.set('preallocate_all', $('preallocateall_checkbox').getProperty('checked')); - settings.set('incomplete_files_ext', $('appendext_checkbox').getProperty('checked')); - settings.set('scan_dirs', getWatchedFolders()); if ($('exportdir_checkbox').getProperty('checked')) settings.set('export_dir', $('exportdir_text').getProperty('value')); else @@ -1024,6 +1058,9 @@ else settings.set('export_dir_fin', ''); + // Automatically add torrents from + settings.set('scan_dirs', getWatchedFolders()); + // Email notification upon download completion settings.set('mail_notification_enabled', $('mail_notification_checkbox').getProperty('checked')); settings.set('mail_notification_email', $('dest_email_txt').getProperty('value')); From 66e3be157991da0405d3882667fc92e1f4ee53f9 Mon Sep 17 00:00:00 2001 From: Thomas Piccirello Date: Tue, 16 Oct 2018 00:15:15 -0400 Subject: [PATCH 02/15] Replace WebUI Options fixed-width labels This allows the labels to auto-expand based on the language used, and also removes unnecessary whitespace. Additionally, this results in a look more consistent with the GUI which right-aligns labels. --- src/webui/www/private/css/style.css | 24 -- src/webui/www/private/download.html | 138 ++++++--- .../www/private/preferences_content.html | 270 +++++++++++++----- src/webui/www/private/shareratio.html | 4 +- src/webui/www/private/upload.html | 126 +++++--- 5 files changed, 369 insertions(+), 193 deletions(-) diff --git a/src/webui/www/private/css/style.css b/src/webui/www/private/css/style.css index c47a6a758..12b360888 100644 --- a/src/webui/www/private/css/style.css +++ b/src/webui/www/private/css/style.css @@ -375,30 +375,6 @@ fieldset.settings label { padding: 2px; } -fieldset.settings .leftLabelSmall { - width: 5em; - float: left; - text-align: right; - margin-right: 0.5em; - display: block; -} - -fieldset.settings .leftLabelMedium { - width: 9em; - float: left; - text-align: right; - margin-right: 0.5em; - display: block; -} - -fieldset.settings .leftLabelLarge { - width: 14em; - float: left; - text-align: right; - margin-right: 0.5em; - display: block; -} - div.formRow { clear: left; display: block; diff --git a/src/webui/www/private/download.html b/src/webui/www/private/download.html index a2312ddc8..b95597031 100644 --- a/src/webui/www/private/download.html +++ b/src/webui/www/private/download.html @@ -18,52 +18,98 @@

QBT_TR(Download Torrents from their URLs or Magnet links)QBT_TR[CONTEXT=HttpServer]

QBT_TR(Only one link per line)QBT_TR[CONTEXT=HttpServer]

-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
diff --git a/src/webui/www/private/preferences_content.html b/src/webui/www/private/preferences_content.html index 630d185c0..1820325c0 100644 --- a/src/webui/www/private/preferences_content.html +++ b/src/webui/www/private/preferences_content.html @@ -83,23 +83,47 @@
-
- -
-
- -
+ + + + + + + + + +
+ + + +
+ + + +
-
- -
-
- -
+ + + + + + + + + +
+ + + +
+ + + +
@@ -178,23 +202,33 @@
QBT_TR(Proxy Server)QBT_TR[CONTEXT=OptionsDialog] -
- - -
-
- - -
-
- - -
+ + + + + + + + + +
+ + + + + + + + + + + +
@@ -210,14 +244,24 @@
-
- - -
-
- - -
+ + + + + + + + + +
+ + + +
+ + + +
@@ -321,18 +365,32 @@
-
- - -
-
- - -
-
- - -
+ + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
@@ -440,33 +498,64 @@
QBT_TR(Web User Interface (Remote control))QBT_TR[CONTEXT=OptionsDialog] - -
+ + + + + +
+ + + + +
+

-
- - -
-
- - -
+ + + + + + + + + +
+ + + +
+ + + +
QBT_TR(Authentication)QBT_TR[CONTEXT=OptionsDialog] -
- -
-
- - -
+ + + + + + + + + +
+ + + +
+ + + +
@@ -496,10 +585,16 @@ -
- - -
+ + + + + +
+ + + +
@@ -512,15 +607,32 @@

-
- -
-
- -
-
- -
+ + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
diff --git a/src/webui/www/private/shareratio.html b/src/webui/www/private/shareratio.html index 2c867b0bd..cf8b025c3 100644 --- a/src/webui/www/private/shareratio.html +++ b/src/webui/www/private/shareratio.html @@ -150,12 +150,12 @@
- +
- +
diff --git a/src/webui/www/private/upload.html b/src/webui/www/private/upload.html index ba07e781d..d0d9a7624 100644 --- a/src/webui/www/private/upload.html +++ b/src/webui/www/private/upload.html @@ -16,48 +16,90 @@
-
-
- - -
-
- - -
-
- - -
-
- - - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
From b9229babfc9c7a7f70f55ceea22d8240377c8c4b Mon Sep 17 00:00:00 2001 From: Thomas Piccirello Date: Tue, 16 Oct 2018 00:34:47 -0400 Subject: [PATCH 03/15] Add WebUI Random port button and proxy unencrypted password notice --- src/webui/www/private/preferences_content.html | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/webui/www/private/preferences_content.html b/src/webui/www/private/preferences_content.html index 1820325c0..f73f735e9 100644 --- a/src/webui/www/private/preferences_content.html +++ b/src/webui/www/private/preferences_content.html @@ -159,7 +159,9 @@
QBT_TR(Listening Port)QBT_TR[CONTEXT=OptionsDialog] -
+ + +

@@ -262,6 +264,9 @@ +
+ Info: The password is saved unencrypted +
@@ -891,6 +896,13 @@ } }; + generateRandomPort = function() { + var min = 1024; + var max = 65535; + var port = Math.floor(Math.random() * (max - min + 1) + min); + $('port_value').setProperty('value', port); + }; + time_padding = function(val) { var ret = val.toString(); if (ret.length == 1) From 127e4acb24c46e340baaaa81d6d24d4e65a79e19 Mon Sep 17 00:00:00 2001 From: Thomas Piccirello Date: Tue, 16 Oct 2018 00:41:57 -0400 Subject: [PATCH 04/15] Add speed limit icons to WebUI Speed options --- src/webui/www/private/preferences_content.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/webui/www/private/preferences_content.html b/src/webui/www/private/preferences_content.html index f73f735e9..11bc8d921 100644 --- a/src/webui/www/private/preferences_content.html +++ b/src/webui/www/private/preferences_content.html @@ -291,6 +291,9 @@ QBT_TR(Global Rate Limits)QBT_TR[CONTEXT=OptionsDialog] + @@ -306,6 +309,9 @@ QBT_TR(Alternative Rate Limits)QBT_TR[CONTEXT=OptionsDialog]
+ QBT_TR(Alternative speed limits)QBT_TR[CONTEXT=MainWindow] +   QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]
+ From bf4df54fb8ceafdfe1df3953571aeabc12c8d321 Mon Sep 17 00:00:00 2001 From: Thomas Piccirello Date: Tue, 16 Oct 2018 01:23:53 -0400 Subject: [PATCH 05/15] Replace all line breaks and fix legend code style. --- src/webui/www/private/css/style.css | 4 + .../www/private/preferences_content.html | 216 +++++++++++------- 2 files changed, 138 insertions(+), 82 deletions(-) diff --git a/src/webui/www/private/css/style.css b/src/webui/www/private/css/style.css index 12b360888..8a1555c24 100644 --- a/src/webui/www/private/css/style.css +++ b/src/webui/www/private/css/style.css @@ -375,6 +375,10 @@ fieldset.settings label { padding: 2px; } +fieldset.settings + div.formRow { + margin-top: 10px; +} + div.formRow { clear: left; display: block; diff --git a/src/webui/www/private/preferences_content.html b/src/webui/www/private/preferences_content.html index 11bc8d921..3429fe083 100644 --- a/src/webui/www/private/preferences_content.html +++ b/src/webui/www/private/preferences_content.html @@ -36,7 +36,7 @@ @@ -45,7 +45,7 @@
+ QBT_TR(Alternative speed limits)QBT_TR[CONTEXT=MainWindow] +   QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]
-
+
-
+
@@ -81,8 +81,10 @@
- - + + + +
@@ -105,7 +107,10 @@
- + + + +
@@ -128,9 +133,13 @@
- - -
+ + + + +
+ +
QBT_TR(Supported parameters (case sensitive):)QBT_TR[CONTEXT=OptionsDialog]
  • QBT_TR(%N: Torrent name)QBT_TR[CONTEXT=OptionsDialog]
  • @@ -150,22 +159,29 @@
- - + + + +
@@ -271,12 +289,18 @@
- - - -
- - + + + + +
+ + +
+
+ + +
QBT_TR(Manually banned IP addresses...)QBT_TR[CONTEXT=OptionsDialog] @@ -323,59 +347,80 @@ QBT_TR(0 means unlimited)QBT_TR[CONTEXT=OptionsDialog]
- - - QBT_TR(From:)QBT_TR[CONTEXT=OptionsDialog] - : QBT_TR(To:)QBT_TR[CONTEXT=OptionsDialog] - : -
QBT_TR(When:)QBT_TR[CONTEXT=OptionsDialog] - -
+ + + + +
+ QBT_TR(From:)QBT_TR[CONTEXT=OptionsDialog] + : QBT_TR(To:)QBT_TR[CONTEXT=OptionsDialog] + : +
+
+ QBT_TR(When:)QBT_TR[CONTEXT=OptionsDialog] + +
QBT_TR(Rate Limits Settings)QBT_TR[CONTEXT=OptionsDialog] - -
- -
+
+ + +
+
+ + +