Browse Source

Reorder WebUI options to match GUI

adaptive-webui-19844
Thomas Piccirello 6 years ago
parent
commit
99ca872011
  1. 33
      src/webui/api/appcontroller.cpp
  2. 117
      src/webui/www/private/preferences_content.html

33
src/webui/api/appcontroller.cpp

@ -84,12 +84,15 @@ void AppController::preferencesAction() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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())

117
src/webui/www/private/preferences_content.html

@ -1,21 +1,58 @@ @@ -1,21 +1,58 @@
<div id="DownloadsTab" class="PrefTab">
<fieldset class="settings">
<legend>QBT_TR(Hard Disk)QBT_TR[CONTEXT=HttpServer]</legend>
<div class="formRow">
<label for="savepath_text">QBT_TR(Save files to location:)QBT_TR[CONTEXT=HttpServer]</label>
<input type="text" id="savepath_text" />
</div>
<div class="formRow">
<input type="checkbox" id="temppath_checkbox" onclick="updateTempDirEnabled();" />
<label for="temppath_checkbox">QBT_TR(Keep incomplete torrents in:)QBT_TR[CONTEXT=OptionsDialog]</label>
<input type="text" id="temppath_text" />
</div>
<div class="formRow">
<input type="checkbox" id="preallocateall_checkbox" />
<label for="preallocateall_checkbox">QBT_TR(Pre-allocate disk space for all files)QBT_TR[CONTEXT=OptionsDialog]</label><br/>
<label for="preallocateall_checkbox">QBT_TR(Pre-allocate disk space for all files)QBT_TR[CONTEXT=OptionsDialog]</label>
</div>
<div class="formRow">
<span id="appendexttr">
<input type="checkbox" id="appendext_checkbox"/>
<label for="appendext_checkbox">QBT_TR(Append .!qB extension to incomplete files)QBT_TR[CONTEXT=OptionsDialog]</label>
</span><br/><br/> QBT_TR(Automatically add torrents from:)QBT_TR[CONTEXT=OptionsDialog]<br/>
</span>
</div>
<fieldset class="settings">
<legend>QBT_TR(Saving Management)QBT_TR[CONTEXT=HttpServer]</legend>
<table>
<tr>
<td>
<label for="savepath_text">QBT_TR(Default Save Path:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<input type="text" id="savepath_text" />
</td>
</tr>
<tr>
<td>
<input type="checkbox" id="temppath_checkbox" onclick="updateTempDirEnabled();" />
<label for="temppath_checkbox" >QBT_TR(Keep incomplete torrents in:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<input type="text" id="temppath_text" />
</td>
</tr>
<tr>
<td>
<input type="checkbox" id="exportdir_checkbox" onclick="updateExportDirEnabled();" />
<label for="exportdir_checkbox" >QBT_TR(Copy .torrent files to:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<input type="text" id="exportdir_text" /><br/>
</td>
</tr>
<tr>
<td>
<input type="checkbox" id="exportdirfin_checkbox" onclick="updateExportDirFinEnabled();" />
<label for="exportdirfin_checkbox" >QBT_TR(Copy .torrent files for finished downloads to:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<input type="text" id="exportdirfin_text" /><br/>
</td>
</tr>
</table>
</fieldset>
<fieldset class="settings">
<legend>QBT_TR(Automatically add torrents from:)QBT_TR[CONTEXT=OptionsDialog]</legend>
<table id="watched_folders_tab" style="border: 1px solid black;">
<thead>
<tr>
@ -40,13 +77,7 @@ @@ -40,13 +77,7 @@
</td>
</tr>
</tfoot>
</table><br/>
<input type="checkbox" id="exportdir_checkbox" onclick="updateExportDirEnabled();" />
<label for="exportdir_checkbox">QBT_TR(Copy .torrent files to:)QBT_TR[CONTEXT=OptionsDialog]</label>&nbsp;&nbsp;
<input type="text" id="exportdir_text" /><br/>
<input type="checkbox" id="exportdirfin_checkbox" onclick="updateExportDirFinEnabled();" />
<label for="exportdirfin_checkbox">QBT_TR(Copy .torrent files for finished downloads to:)QBT_TR[CONTEXT=OptionsDialog]</label>&nbsp;&nbsp;
<input type="text" id="exportdirfin_text" /><br/>
</table>
</fieldset>
<fieldset class="settings">
@ -767,26 +798,14 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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'));

Loading…
Cancel
Save