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'));