Browse Source

Update WebUI classes

Guaranteed to show paths with native separators to user
adaptive-webui-19844
Nick Tiskov 11 years ago
parent
commit
cb7f35d994
  1. 7
      src/webui/btjson.cpp
  2. 18
      src/webui/prefjson.cpp

7
src/webui/btjson.cpp

@ -32,6 +32,7 @@ @@ -32,6 +32,7 @@
#include "jsondict.h"
#include "jsonlist.h"
#include "misc.h"
#include "fs_utils.h"
#include "qbtsession.h"
#include "torrentpersistentdata.h"
@ -287,9 +288,9 @@ QString btjson::getPropertiesForTorrent(const QString& hash) @@ -287,9 +288,9 @@ QString btjson::getPropertiesForTorrent(const QString& hash)
return QString();
// Save path
QString save_path = TorrentPersistentData::getSavePath(hash);
QString save_path = fsutils::toNativePath(TorrentPersistentData::getSavePath(hash));
if (save_path.isEmpty())
save_path = h.save_path();
save_path = fsutils::toNativePath(h.save_path());
data.add(KEY_PROP_SAVE_PATH, save_path);
data.add(KEY_PROP_CREATION_DATE, h.creation_date());
data.add(KEY_PROP_PIECE_SIZE, misc::friendlyUnit(h.piece_length()));
@ -341,7 +342,7 @@ QString btjson::getFilesForTorrent(const QString& hash) @@ -341,7 +342,7 @@ QString btjson::getFilesForTorrent(const QString& hash)
QString fileName = h.filename_at(i);
if (fileName.endsWith(".!qB", Qt::CaseInsensitive))
fileName.chop(4);
file_dict.add(KEY_FILE_NAME, fileName);
file_dict.add(KEY_FILE_NAME, fsutils::toNativePath(fileName));
const size_type size = h.filesize_at(i);
file_dict.add(KEY_FILE_SIZE, misc::friendlyUnit(size));
file_dict.add(KEY_FILE_PROGRESS, (size > 0) ? (fp[i] / (double) size) : 1.);

18
src/webui/prefjson.cpp

@ -53,17 +53,21 @@ QString prefjson::getPreferences() @@ -53,17 +53,21 @@ QString prefjson::getPreferences()
// UI
data.add("locale", pref.getLocale());
// Downloads
data.add("save_path", pref.getSavePath());
data.add("save_path", fsutils::toNativePath(pref.getSavePath()));
data.add("temp_path_enabled", pref.isTempPathEnabled());
data.add("temp_path", pref.getTempPath());
data.add("scan_dirs", pref.getScanDirs());
data.add("temp_path", fsutils::toNativePath(pref.getTempPath()));
QStringList l;
foreach (const QString& s, pref.getScanDirs()) {
l << fsutils::toNativePath(s);
}
data.add("scan_dirs", l);
QVariantList var_list;
foreach (bool b, pref.getDownloadInScanDirs()) {
var_list << b;
}
data.add("download_in_scan_dirs", var_list);
data.add("export_dir_enabled", pref.isTorrentExportEnabled());
data.add("export_dir", pref.getTorrentExportDir());
data.add("export_dir", fsutils::toNativePath(pref.getTorrentExportDir()));
data.add("mail_notification_enabled", pref.isMailNotificationEnabled());
data.add("mail_notification_email", pref.getMailNotificationEmail());
data.add("mail_notification_smtp", pref.getMailNotificationSMTP());
@ -72,7 +76,7 @@ QString prefjson::getPreferences() @@ -72,7 +76,7 @@ QString prefjson::getPreferences()
data.add("mail_notification_username", pref.getMailNotificationSMTPUsername());
data.add("mail_notification_password", pref.getMailNotificationSMTPPassword());
data.add("autorun_enabled", pref.isAutoRunEnabled());
data.add("autorun_program", pref.getAutoRunProgram());
data.add("autorun_program", fsutils::toNativePath(pref.getAutoRunProgram()));
data.add("preallocate_all", pref.preAllocateAllFiles());
data.add("queueing_enabled", pref.isQueueingSystemEnabled());
data.add("max_active_downloads", pref.getMaxActiveDownloads());
@ -119,7 +123,7 @@ QString prefjson::getPreferences() @@ -119,7 +123,7 @@ QString prefjson::getPreferences()
data.add("proxy_password", pref.getProxyPassword());
// IP Filter
data.add("ip_filter_enabled", pref.isFilteringEnabled());
data.add("ip_filter_path", pref.getFilter());
data.add("ip_filter_path", fsutils::toNativePath(pref.getFilter()));
// Web UI
data.add("web_ui_port", pref.getWebUiPort());
data.add("web_ui_username", pref.getWebUiUsername());
@ -186,7 +190,7 @@ void prefjson::setPreferences(const QString& json) @@ -186,7 +190,7 @@ void prefjson::setPreferences(const QString& json)
foreach (const QString &new_folder, new_folders) {
qDebug("New watched folder: %s", qPrintable(new_folder));
// Update new folders
if (!old_folders.contains(new_folder)) {
if (!old_folders.contains(fsutils::fromNativePath(new_folder))) {
QBtSession::instance()->getScanFoldersModel()->addPath(new_folder, download_at_path.at(i));
}
++i;

Loading…
Cancel
Save