mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 12:59:56 -07:00
Merge pull request #1095 from Gelmir/separators
Use native separators where appropriate
This commit is contained in:
commit
c167b47a2e
32 changed files with 336 additions and 405 deletions
|
@ -68,7 +68,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) :
|
||||||
QIniSettings settings;
|
QIniSettings settings;
|
||||||
Preferences pref;
|
Preferences pref;
|
||||||
ui->start_torrent_cb->setChecked(!pref.addTorrentsInPause());
|
ui->start_torrent_cb->setChecked(!pref.addTorrentsInPause());
|
||||||
ui->save_path_combo->addItem(fsutils::toDisplayPath(pref.getSavePath()), pref.getSavePath());
|
ui->save_path_combo->addItem(fsutils::toNativePath(pref.getSavePath()), pref.getSavePath());
|
||||||
loadSavePathHistory();
|
loadSavePathHistory();
|
||||||
ui->save_path_combo->insertSeparator(ui->save_path_combo->count());
|
ui->save_path_combo->insertSeparator(ui->save_path_combo->count());
|
||||||
ui->save_path_combo->addItem(tr("Other...", "Other save path..."));
|
ui->save_path_combo->addItem(tr("Other...", "Other save path..."));
|
||||||
|
@ -192,7 +192,7 @@ bool AddNewTorrentDialog::loadTorrent(const QString& torrent_path, const QString
|
||||||
m_hasMetadata = true;
|
m_hasMetadata = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
m_torrentInfo = new torrent_info(m_filePath.toUtf8().data());
|
m_torrentInfo = new torrent_info(fsutils::toNativePath(m_filePath).toUtf8().data());
|
||||||
m_hash = misc::toQString(m_torrentInfo->info_hash());
|
m_hash = misc::toQString(m_torrentInfo->info_hash());
|
||||||
} catch(const std::exception& e) {
|
} catch(const std::exception& e) {
|
||||||
QMessageBox::critical(0, tr("Invalid torrent"), tr("Failed to load the torrent: %1").arg(e.what()));
|
QMessageBox::critical(0, tr("Invalid torrent"), tr("Failed to load the torrent: %1").arg(e.what()));
|
||||||
|
@ -242,7 +242,7 @@ bool AddNewTorrentDialog::loadTorrent(const QString& torrent_path, const QString
|
||||||
// Update save paths (append file name to them)
|
// Update save paths (append file name to them)
|
||||||
QString single_file_relpath = misc::toQStringU(fs.file_path(0));
|
QString single_file_relpath = misc::toQStringU(fs.file_path(0));
|
||||||
for (int i=0; i<ui->save_path_combo->count()-1; ++i) {
|
for (int i=0; i<ui->save_path_combo->count()-1; ++i) {
|
||||||
ui->save_path_combo->setItemText(i, fsutils::toDisplayPath(QDir(ui->save_path_combo->itemText(i)).absoluteFilePath(single_file_relpath)));
|
ui->save_path_combo->setItemText(i, fsutils::toNativePath(QDir(ui->save_path_combo->itemText(i)).absoluteFilePath(single_file_relpath)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,9 +281,8 @@ bool AddNewTorrentDialog::loadMagnet(const QString &magnet_uri)
|
||||||
// Set dialog position
|
// Set dialog position
|
||||||
setdialogPosition();
|
setdialogPosition();
|
||||||
|
|
||||||
Preferences pref;
|
|
||||||
// Override save path
|
// Override save path
|
||||||
TorrentTempData::setSavePath(m_hash, QString(QDir::tempPath() + QDir::separator() + m_hash).replace("\\", "/"));
|
TorrentTempData::setSavePath(m_hash, QString(QDir::tempPath() + "/" + m_hash));
|
||||||
HiddenData::addData(m_hash);
|
HiddenData::addData(m_hash);
|
||||||
QBtSession::instance()->addMagnetUri(m_url, false);
|
QBtSession::instance()->addMagnetUri(m_url, false);
|
||||||
setMetadataProgressIndicator(true, tr("Retrieving metadata..."));
|
setMetadataProgressIndicator(true, tr("Retrieving metadata..."));
|
||||||
|
@ -326,7 +325,7 @@ void AddNewTorrentDialog::updateFileNameInSavePaths(const QString &new_filename)
|
||||||
{
|
{
|
||||||
for(int i=0; i<ui->save_path_combo->count()-1; ++i) {
|
for(int i=0; i<ui->save_path_combo->count()-1; ++i) {
|
||||||
const QDir folder(ui->save_path_combo->itemData(i).toString());
|
const QDir folder(ui->save_path_combo->itemData(i).toString());
|
||||||
ui->save_path_combo->setItemText(i, fsutils::toDisplayPath(folder.absoluteFilePath(new_filename)));
|
ui->save_path_combo->setItemText(i, fsutils::toNativePath(folder.absoluteFilePath(new_filename)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,9 +382,9 @@ void AddNewTorrentDialog::onSavePathChanged(int index)
|
||||||
else {
|
else {
|
||||||
// New path, prepend to combo box
|
// New path, prepend to combo box
|
||||||
if (!new_filename.isEmpty())
|
if (!new_filename.isEmpty())
|
||||||
ui->save_path_combo->insertItem(0, fsutils::toDisplayPath(QDir(new_path).absoluteFilePath(new_filename)), new_path);
|
ui->save_path_combo->insertItem(0, fsutils::toNativePath(QDir(new_path).absoluteFilePath(new_filename)), new_path);
|
||||||
else
|
else
|
||||||
ui->save_path_combo->insertItem(0, fsutils::toDisplayPath(new_path), new_path);
|
ui->save_path_combo->insertItem(0, fsutils::toNativePath(new_path), new_path);
|
||||||
ui->save_path_combo->setCurrentIndex(0);
|
ui->save_path_combo->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
// Update file name in all save_paths
|
// Update file name in all save_paths
|
||||||
|
@ -440,8 +439,7 @@ void AddNewTorrentDialog::renameSelectedFile()
|
||||||
if (m_contentModel->itemType(index) == TorrentContentModelItem::FileType) {
|
if (m_contentModel->itemType(index) == TorrentContentModelItem::FileType) {
|
||||||
// File renaming
|
// File renaming
|
||||||
const int file_index = m_contentModel->getFileIndex(index);
|
const int file_index = m_contentModel->getFileIndex(index);
|
||||||
QString old_name = m_filesPath.at(file_index);
|
QString old_name = fsutils::fromNativePath(m_filesPath.at(file_index));
|
||||||
old_name.replace("\\", "/");
|
|
||||||
qDebug("Old name: %s", qPrintable(old_name));
|
qDebug("Old name: %s", qPrintable(old_name));
|
||||||
QStringList path_items = old_name.split("/");
|
QStringList path_items = old_name.split("/");
|
||||||
path_items.removeLast();
|
path_items.removeLast();
|
||||||
|
@ -451,7 +449,7 @@ void AddNewTorrentDialog::renameSelectedFile()
|
||||||
qDebug("Name did not change");
|
qDebug("Name did not change");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new_name = QDir::cleanPath(new_name);
|
new_name = fsutils::expandPathAbs(new_name);
|
||||||
qDebug("New name: %s", qPrintable(new_name));
|
qDebug("New name: %s", qPrintable(new_name));
|
||||||
// Check if that name is already used
|
// Check if that name is already used
|
||||||
for (int i=0; i<m_torrentInfo->num_files(); ++i) {
|
for (int i=0; i<m_torrentInfo->num_files(); ++i) {
|
||||||
|
@ -464,7 +462,6 @@ void AddNewTorrentDialog::renameSelectedFile()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
new_name = QDir::cleanPath(new_name);
|
|
||||||
qDebug("Renaming %s to %s", qPrintable(old_name), qPrintable(new_name));
|
qDebug("Renaming %s to %s", qPrintable(old_name), qPrintable(new_name));
|
||||||
// Rename file in files_path
|
// Rename file in files_path
|
||||||
m_filesPath.replace(file_index, new_name);
|
m_filesPath.replace(file_index, new_name);
|
||||||
|
@ -505,7 +502,7 @@ void AddNewTorrentDialog::renameSelectedFile()
|
||||||
if (current_name.startsWith(old_path)) {
|
if (current_name.startsWith(old_path)) {
|
||||||
QString new_name = current_name;
|
QString new_name = current_name;
|
||||||
new_name.replace(0, old_path.length(), new_path);
|
new_name.replace(0, old_path.length(), new_path);
|
||||||
new_name = QDir::cleanPath(new_name);
|
new_name = fsutils::expandPathAbs(new_name);
|
||||||
qDebug("Rename %s to %s", qPrintable(current_name), qPrintable(new_name));
|
qDebug("Rename %s to %s", qPrintable(current_name), qPrintable(new_name));
|
||||||
// Rename in files_path
|
// Rename in files_path
|
||||||
m_filesPath.replace(i, new_name);
|
m_filesPath.replace(i, new_name);
|
||||||
|
@ -543,7 +540,7 @@ void AddNewTorrentDialog::loadSavePathHistory()
|
||||||
QStringList raw_path_history = settings.value("TorrentAdditionDlg/save_path_history").toStringList();
|
QStringList raw_path_history = settings.value("TorrentAdditionDlg/save_path_history").toStringList();
|
||||||
foreach (const QString &sp, raw_path_history) {
|
foreach (const QString &sp, raw_path_history) {
|
||||||
if (QDir(sp) != default_save_path)
|
if (QDir(sp) != default_save_path)
|
||||||
ui->save_path_combo->addItem(fsutils::toDisplayPath(sp), sp);
|
ui->save_path_combo->addItem(fsutils::toNativePath(sp), sp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -696,7 +693,7 @@ void AddNewTorrentDialog::updateMetadata(const QTorrentHandle &h) {
|
||||||
// Update save paths (append file name to them)
|
// Update save paths (append file name to them)
|
||||||
QString single_file_relpath = misc::toQStringU(fs.file_path(0));
|
QString single_file_relpath = misc::toQStringU(fs.file_path(0));
|
||||||
for (int i=0; i<ui->save_path_combo->count()-1; ++i) {
|
for (int i=0; i<ui->save_path_combo->count()-1; ++i) {
|
||||||
ui->save_path_combo->setItemText(i, fsutils::toDisplayPath(QDir(ui->save_path_combo->itemText(i)).absoluteFilePath(single_file_relpath)));
|
ui->save_path_combo->setItemText(i, fsutils::toNativePath(QDir(ui->save_path_combo->itemText(i)).absoluteFilePath(single_file_relpath)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,8 @@ private:
|
||||||
private:
|
private:
|
||||||
static bool isNetworkFileSystem(QString path) {
|
static bool isNetworkFileSystem(QString path) {
|
||||||
QString file = path;
|
QString file = path;
|
||||||
if (!file.endsWith(QDir::separator()))
|
if (!file.endsWith("/"))
|
||||||
file += QDir::separator();
|
file += "/";
|
||||||
file += ".";
|
file += ".";
|
||||||
struct statfs buf;
|
struct statfs buf;
|
||||||
if (!statfs(file.toLocal8Bit().constData(), &buf)) {
|
if (!statfs(file.toLocal8Bit().constData(), &buf)) {
|
||||||
|
|
100
src/fs_utils.cpp
100
src/fs_utils.cpp
|
@ -71,11 +71,14 @@ using namespace libtorrent;
|
||||||
* This function makes sure the directory separator used is consistent
|
* This function makes sure the directory separator used is consistent
|
||||||
* with the OS being run.
|
* with the OS being run.
|
||||||
*/
|
*/
|
||||||
QString fsutils::toDisplayPath(const QString& path)
|
QString fsutils::toNativePath(const QString& path) {
|
||||||
{
|
|
||||||
return QDir::toNativeSeparators(path);
|
return QDir::toNativeSeparators(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString fsutils::fromNativePath(const QString &path) {
|
||||||
|
return QDir::fromNativeSeparators(path);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the file extension part of a file name.
|
* Returns the file extension part of a file name.
|
||||||
*/
|
*/
|
||||||
|
@ -87,15 +90,16 @@ QString fsutils::fileExtension(const QString &filename)
|
||||||
|
|
||||||
QString fsutils::fileName(const QString& file_path)
|
QString fsutils::fileName(const QString& file_path)
|
||||||
{
|
{
|
||||||
const int slash_index = file_path.lastIndexOf(QRegExp("[/\\\\]"));
|
QString path = fsutils::fromNativePath(file_path);
|
||||||
|
const int slash_index = path.lastIndexOf("/");
|
||||||
if (slash_index == -1)
|
if (slash_index == -1)
|
||||||
return file_path;
|
return path;
|
||||||
return file_path.mid(slash_index + 1);
|
return path.mid(slash_index + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fsutils::isValidTorrentFile(const QString& torrent_path) {
|
bool fsutils::isValidTorrentFile(const QString& torrent_path) {
|
||||||
try {
|
try {
|
||||||
boost::intrusive_ptr<libtorrent::torrent_info> t = new torrent_info(torrent_path.toUtf8().constData());
|
boost::intrusive_ptr<libtorrent::torrent_info> t = new torrent_info(fsutils::toNativePath(torrent_path).toUtf8().constData());
|
||||||
if (!t->is_valid() || t->num_files() == 0)
|
if (!t->is_valid() || t->num_files() == 0)
|
||||||
return false;
|
return false;
|
||||||
} catch(std::exception&) {
|
} catch(std::exception&) {
|
||||||
|
@ -220,14 +224,14 @@ bool fsutils::sameFiles(const QString& path1, const QString& path2)
|
||||||
return same;
|
return same;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString fsutils::updateLabelInSavePath(QString defaultSavePath,QString save_path, const QString& old_label, const QString& new_label) {
|
QString fsutils::updateLabelInSavePath(const QString& defaultSavePath, const QString& save_path, const QString& old_label, const QString& new_label) {
|
||||||
if (old_label == new_label) return save_path;
|
if (old_label == new_label) return fsutils::fromNativePath(save_path);
|
||||||
defaultSavePath.replace("\\", "/");
|
QString defaultPath = fsutils::fromNativePath(defaultSavePath);
|
||||||
save_path.replace("\\", "/");
|
QString path = fsutils::fromNativePath(save_path);
|
||||||
qDebug("UpdateLabelInSavePath(%s, %s, %s)", qPrintable(save_path), qPrintable(old_label), qPrintable(new_label));
|
qDebug("UpdateLabelInSavePath(%s, %s, %s)", qPrintable(path), qPrintable(old_label), qPrintable(new_label));
|
||||||
if (!save_path.startsWith(defaultSavePath)) return save_path;
|
if (!path.startsWith(defaultPath)) return path;
|
||||||
QString new_save_path = save_path;
|
QString new_save_path = path;
|
||||||
new_save_path.replace(defaultSavePath, "");
|
new_save_path.remove(defaultPath);
|
||||||
QStringList path_parts = new_save_path.split("/", QString::SkipEmptyParts);
|
QStringList path_parts = new_save_path.split("/", QString::SkipEmptyParts);
|
||||||
if (path_parts.empty()) {
|
if (path_parts.empty()) {
|
||||||
if (!new_label.isEmpty())
|
if (!new_label.isEmpty())
|
||||||
|
@ -245,9 +249,9 @@ QString fsutils::updateLabelInSavePath(QString defaultSavePath,QString save_path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
new_save_path = defaultSavePath;
|
new_save_path = defaultPath;
|
||||||
if (!new_save_path.endsWith(QDir::separator())) new_save_path += QDir::separator();
|
if (!new_save_path.endsWith("/")) new_save_path += "/";
|
||||||
new_save_path += path_parts.join(QDir::separator());
|
new_save_path += path_parts.join("/");
|
||||||
qDebug("New save path is %s", qPrintable(new_save_path));
|
qDebug("New save path is %s", qPrintable(new_save_path));
|
||||||
return new_save_path;
|
return new_save_path;
|
||||||
}
|
}
|
||||||
|
@ -268,7 +272,6 @@ bool fsutils::isValidFileSystemName(const QString& filename) {
|
||||||
|
|
||||||
long long fsutils::freeDiskSpaceOnPath(QString path) {
|
long long fsutils::freeDiskSpaceOnPath(QString path) {
|
||||||
if (path.isEmpty()) return -1;
|
if (path.isEmpty()) return -1;
|
||||||
path.replace("\\", "/");
|
|
||||||
QDir dir_path(path);
|
QDir dir_path(path);
|
||||||
if (!dir_path.exists()) {
|
if (!dir_path.exists()) {
|
||||||
QStringList parts = path.split("/");
|
QStringList parts = path.split("/");
|
||||||
|
@ -307,7 +310,7 @@ long long fsutils::freeDiskSpaceOnPath(QString path) {
|
||||||
{
|
{
|
||||||
ULARGE_INTEGER bytesFree, bytesTotal;
|
ULARGE_INTEGER bytesFree, bytesTotal;
|
||||||
unsigned long long *ret;
|
unsigned long long *ret;
|
||||||
if (pGetDiskFreeSpaceEx((LPCTSTR)(QDir::toNativeSeparators(dir_path.path())).utf16(), &bytesFree, &bytesTotal, NULL)) {
|
if (pGetDiskFreeSpaceEx((LPCTSTR)(fsutils::toNativePath(dir_path.path())).utf16(), &bytesFree, &bytesTotal, NULL)) {
|
||||||
ret = (unsigned long long*)&bytesFree;
|
ret = (unsigned long long*)&bytesFree;
|
||||||
return *ret;
|
return *ret;
|
||||||
} else {
|
} else {
|
||||||
|
@ -321,10 +324,10 @@ long long fsutils::freeDiskSpaceOnPath(QString path) {
|
||||||
|
|
||||||
QString fsutils::branchPath(const QString& file_path, QString* removed)
|
QString fsutils::branchPath(const QString& file_path, QString* removed)
|
||||||
{
|
{
|
||||||
QString ret = file_path;
|
QString ret = fsutils::fromNativePath(file_path);
|
||||||
if (ret.endsWith("/") || ret.endsWith("\\"))
|
if (ret.endsWith("/"))
|
||||||
ret.chop(1);
|
ret.chop(1);
|
||||||
const int slashIndex = ret.lastIndexOf(QRegExp("[/\\\\]"));
|
const int slashIndex = ret.lastIndexOf("/");
|
||||||
if (slashIndex >= 0) {
|
if (slashIndex >= 0) {
|
||||||
if (removed)
|
if (removed)
|
||||||
*removed = ret.mid(slashIndex + 1);
|
*removed = ret.mid(slashIndex + 1);
|
||||||
|
@ -342,35 +345,33 @@ bool fsutils::sameFileNames(const QString &first, const QString &second)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace ~ in path
|
|
||||||
QString fsutils::expandPath(const QString &path) {
|
QString fsutils::expandPath(const QString &path) {
|
||||||
QString ret = path.trimmed();
|
QString ret = fsutils::fromNativePath(path.trimmed());
|
||||||
if (ret.isEmpty()) return ret;
|
if (ret.isEmpty())
|
||||||
if (ret == "~")
|
return ret;
|
||||||
return QDir::homePath();
|
|
||||||
if (ret[0] == '~' && (ret[1] == '/' || ret[1] == '\\')) {
|
return QDir::cleanPath(ret);
|
||||||
ret.replace(0, 1, QDir::homePath());
|
}
|
||||||
} else {
|
|
||||||
|
QString fsutils::expandPathAbs(const QString& path) {
|
||||||
|
QString ret = fsutils::expandPath(path);
|
||||||
|
|
||||||
if (!QDir::isAbsolutePath(ret))
|
if (!QDir::isAbsolutePath(ret))
|
||||||
ret = QDir(ret).absolutePath();
|
ret = QDir(ret).absolutePath();
|
||||||
}
|
|
||||||
return QDir::cleanPath(path);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString fsutils::QDesktopServicesDataLocation() {
|
QString fsutils::QDesktopServicesDataLocation() {
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
LPWSTR path=new WCHAR[256];
|
LPWSTR path=new WCHAR[256];
|
||||||
QString result;
|
QString result;
|
||||||
#if defined Q_WS_WINCE
|
|
||||||
if (SHGetSpecialFolderPath(0, path, CSIDL_APPDATA, FALSE))
|
|
||||||
#else
|
|
||||||
if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE))
|
if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE))
|
||||||
#endif
|
result = fsutils::fromNativePath(QString::fromWCharArray(path));
|
||||||
result = QString::fromWCharArray(path);
|
|
||||||
if (!QCoreApplication::applicationName().isEmpty())
|
if (!QCoreApplication::applicationName().isEmpty())
|
||||||
result = result + QLatin1String("\\") + qApp->applicationName();
|
result += QLatin1String("/") + qApp->applicationName();
|
||||||
if (!result.endsWith("\\"))
|
if (!result.endsWith("/"))
|
||||||
result += "\\";
|
result += "/";
|
||||||
return result;
|
return result;
|
||||||
#else
|
#else
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
|
@ -397,7 +398,7 @@ QString fsutils::QDesktopServicesDataLocation() {
|
||||||
|
|
||||||
QString fsutils::QDesktopServicesCacheLocation() {
|
QString fsutils::QDesktopServicesCacheLocation() {
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||||
return QDesktopServicesDataLocation() + QLatin1String("\\cache");
|
return QDesktopServicesDataLocation() + QLatin1String("cache");
|
||||||
#else
|
#else
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
// http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
|
// http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
|
||||||
|
@ -427,7 +428,8 @@ QString fsutils::QDesktopServicesDownloadLocation() {
|
||||||
// TODO: Use IKnownFolderManager to get path of FOLDERID_Downloads
|
// TODO: Use IKnownFolderManager to get path of FOLDERID_Downloads
|
||||||
// instead of hardcoding "Downloads"
|
// instead of hardcoding "Downloads"
|
||||||
// Unfortunately, this would break compatibility with WinXP
|
// Unfortunately, this would break compatibility with WinXP
|
||||||
return QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath(tr("Downloads"));
|
return QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath(
|
||||||
|
QCoreApplication::translate("fsutils", "Downloads"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
|
@ -458,7 +460,7 @@ QString fsutils::QDesktopServicesDownloadLocation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (save_path.isEmpty() || !QFile::exists(save_path)) {
|
if (save_path.isEmpty() || !QFile::exists(save_path)) {
|
||||||
save_path = QDir::home().absoluteFilePath(tr("Downloads"));
|
save_path = QDir::home().absoluteFilePath(QCoreApplication::translate("fsutils", "Downloads"));
|
||||||
qDebug() << Q_FUNC_INFO << "using" << save_path << "as fallback since the XDG detection did not work";
|
qDebug() << Q_FUNC_INFO << "using" << save_path << "as fallback since the XDG detection did not work";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,15 +472,15 @@ QString fsutils::QDesktopServicesDownloadLocation() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Fallback
|
// Fallback
|
||||||
return QDir::home().absoluteFilePath(tr("Downloads"));
|
return QDir::home().absoluteFilePath(QCoreApplication::translate("fsutils", "Downloads"));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString fsutils::searchEngineLocation() {
|
QString fsutils::searchEngineLocation() {
|
||||||
QString folder = "nova";
|
QString folder = "nova";
|
||||||
if (misc::pythonVersion() >= 3)
|
if (misc::pythonVersion() >= 3)
|
||||||
folder = "nova3";
|
folder = "nova3";
|
||||||
const QString location = QDir::cleanPath(QDesktopServicesDataLocation()
|
const QString location = fsutils::expandPathAbs(QDesktopServicesDataLocation()
|
||||||
+ QDir::separator() + folder);
|
+ folder);
|
||||||
QDir locationDir(location);
|
QDir locationDir(location);
|
||||||
if (!locationDir.exists())
|
if (!locationDir.exists())
|
||||||
locationDir.mkpath(locationDir.absolutePath());
|
locationDir.mkpath(locationDir.absolutePath());
|
||||||
|
@ -486,8 +488,8 @@ QString fsutils::searchEngineLocation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString fsutils::BTBackupLocation() {
|
QString fsutils::BTBackupLocation() {
|
||||||
const QString location = QDir::cleanPath(QDesktopServicesDataLocation()
|
const QString location = fsutils::expandPathAbs(QDesktopServicesDataLocation()
|
||||||
+ QDir::separator() + "BT_backup");
|
+ "BT_backup");
|
||||||
QDir locationDir(location);
|
QDir locationDir(location);
|
||||||
if (!locationDir.exists())
|
if (!locationDir.exists())
|
||||||
locationDir.mkpath(locationDir.absolutePath());
|
locationDir.mkpath(locationDir.absolutePath());
|
||||||
|
@ -495,7 +497,7 @@ QString fsutils::BTBackupLocation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString fsutils::cacheLocation() {
|
QString fsutils::cacheLocation() {
|
||||||
QString location = QDir::cleanPath(QDesktopServicesCacheLocation());
|
QString location = fsutils::expandPathAbs(QDesktopServicesCacheLocation());
|
||||||
QDir locationDir(location);
|
QDir locationDir(location);
|
||||||
if (!locationDir.exists())
|
if (!locationDir.exists())
|
||||||
locationDir.mkpath(locationDir.absolutePath());
|
locationDir.mkpath(locationDir.absolutePath());
|
||||||
|
|
|
@ -37,37 +37,37 @@
|
||||||
/**
|
/**
|
||||||
* Utility functions related to file system.
|
* Utility functions related to file system.
|
||||||
*/
|
*/
|
||||||
class fsutils
|
namespace fsutils
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(fsutils)
|
|
||||||
|
|
||||||
public:
|
QString toNativePath(const QString& path);
|
||||||
static QString toDisplayPath(const QString& path);
|
QString fromNativePath(const QString& path);
|
||||||
static QString fileExtension(const QString& filename);
|
QString fileExtension(const QString& filename);
|
||||||
static QString fileName(const QString& file_path);
|
QString fileName(const QString& file_path);
|
||||||
static qint64 computePathSize(const QString& path);
|
qint64 computePathSize(const QString& path);
|
||||||
static bool sameFiles(const QString& path1, const QString& path2);
|
bool sameFiles(const QString& path1, const QString& path2);
|
||||||
static QString updateLabelInSavePath(QString defaultSavePath, QString save_path, const QString& old_label, const QString& new_label);
|
QString updateLabelInSavePath(const QString &defaultSavePath, const QString &save_path, const QString& old_label, const QString& new_label);
|
||||||
static QString toValidFileSystemName(QString filename);
|
QString toValidFileSystemName(QString filename);
|
||||||
static bool isValidFileSystemName(const QString& filename);
|
bool isValidFileSystemName(const QString& filename);
|
||||||
static long long freeDiskSpaceOnPath(QString path);
|
long long freeDiskSpaceOnPath(QString path);
|
||||||
static QString branchPath(const QString& file_path, QString* removed = 0);
|
QString branchPath(const QString& file_path, QString* removed = 0);
|
||||||
static bool sameFileNames(const QString& first, const QString& second);
|
bool sameFileNames(const QString& first, const QString& second);
|
||||||
static QString expandPath(const QString& path);
|
QString expandPath(const QString& path);
|
||||||
static bool isValidTorrentFile(const QString& path);
|
QString expandPathAbs(const QString& path);
|
||||||
static bool smartRemoveEmptyFolderTree(const QString& dir_path);
|
bool isValidTorrentFile(const QString& path);
|
||||||
static bool forceRemove(const QString& file_path);
|
bool smartRemoveEmptyFolderTree(const QString& dir_path);
|
||||||
|
bool forceRemove(const QString& file_path);
|
||||||
|
|
||||||
/* Ported from Qt4 to drop dependency on QtGui */
|
/* Ported from Qt4 to drop dependency on QtGui */
|
||||||
static QString QDesktopServicesDataLocation();
|
QString QDesktopServicesDataLocation();
|
||||||
static QString QDesktopServicesCacheLocation();
|
QString QDesktopServicesCacheLocation();
|
||||||
static QString QDesktopServicesDownloadLocation();
|
QString QDesktopServicesDownloadLocation();
|
||||||
/* End of Qt4 code */
|
/* End of Qt4 code */
|
||||||
static QString searchEngineLocation();
|
QString searchEngineLocation();
|
||||||
static QString BTBackupLocation();
|
QString BTBackupLocation();
|
||||||
static QString cacheLocation();
|
QString cacheLocation();
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif // FS_UTILS_H
|
#endif // FS_UTILS_H
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ QString GeoIPManager::geoipFolder(bool embedded) {
|
||||||
#ifdef WITH_GEOIP_EMBEDDED
|
#ifdef WITH_GEOIP_EMBEDDED
|
||||||
if (embedded)
|
if (embedded)
|
||||||
return ":/geoip/";
|
return ":/geoip/";
|
||||||
return fsutils::QDesktopServicesDataLocation()+"geoip"+QDir::separator();
|
return fsutils::QDesktopServicesDataLocation()+"geoip"+"/";
|
||||||
#else
|
#else
|
||||||
Q_UNUSED(embedded);
|
Q_UNUSED(embedded);
|
||||||
if (QFile::exists("/usr/local/share/GeoIP/GeoIP.dat"))
|
if (QFile::exists("/usr/local/share/GeoIP/GeoIP.dat"))
|
||||||
|
|
|
@ -88,7 +88,7 @@ public slots:
|
||||||
// the parameter type.
|
// the parameter type.
|
||||||
void processParams(const QStringList& params) {
|
void processParams(const QStringList& params) {
|
||||||
foreach (QString param, params) {
|
foreach (QString param, params) {
|
||||||
param = param.trimmed();
|
param = fsutils::fromNativePath(param).trimmed();
|
||||||
if (param.startsWith(QString::fromUtf8("http://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("ftp://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("https://"), Qt::CaseInsensitive)) {
|
if (param.startsWith(QString::fromUtf8("http://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("ftp://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("https://"), Qt::CaseInsensitive)) {
|
||||||
QBtSession::instance()->downloadFromUrl(param);
|
QBtSession::instance()->downloadFromUrl(param);
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
class IconProvider
|
class IconProvider
|
||||||
{
|
{
|
||||||
Q_DISABLE_COPY(IconProvider);
|
Q_DISABLE_COPY(IconProvider)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit IconProvider();
|
explicit IconProvider();
|
||||||
|
|
|
@ -943,9 +943,9 @@ void MainWindow::on_actionOpen_triggered() {
|
||||||
QBtSession::instance()->addTorrent(pathsList.at(i));
|
QBtSession::instance()->addTorrent(pathsList.at(i));
|
||||||
}
|
}
|
||||||
// Save last dir to remember it
|
// Save last dir to remember it
|
||||||
QStringList top_dir = pathsList.at(0).split(QDir::separator());
|
QStringList top_dir = fsutils::fromNativePath(pathsList.at(0)).split("/");
|
||||||
top_dir.removeLast();
|
top_dir.removeLast();
|
||||||
settings.setValue(QString::fromUtf8("MainWindowLastDir"), top_dir.join(QDir::separator()));
|
settings.setValue(QString::fromUtf8("MainWindowLastDir"), fsutils::fromNativePath(top_dir.join("/")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -376,17 +376,9 @@ void options_imp::saveOptions() {
|
||||||
// End General preferences
|
// End General preferences
|
||||||
|
|
||||||
// Downloads preferences
|
// Downloads preferences
|
||||||
QString save_path = getSavePath();
|
pref.setSavePath(getSavePath());
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
|
||||||
save_path.replace("\\", "/");
|
|
||||||
#endif
|
|
||||||
pref.setSavePath(save_path);
|
|
||||||
pref.setTempPathEnabled(isTempPathEnabled());
|
pref.setTempPathEnabled(isTempPathEnabled());
|
||||||
QString temp_path = getTempPath();
|
pref.setTempPath(getTempPath());
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
|
||||||
temp_path.replace("\\", "/");
|
|
||||||
#endif
|
|
||||||
pref.setTempPath(temp_path);
|
|
||||||
pref.setAppendTorrentLabel(checkAppendLabel->isChecked());
|
pref.setAppendTorrentLabel(checkAppendLabel->isChecked());
|
||||||
pref.useIncompleteFilesExtension(checkAppendqB->isChecked());
|
pref.useIncompleteFilesExtension(checkAppendqB->isChecked());
|
||||||
pref.preAllocateAllFiles(preAllocateAllFiles());
|
pref.preAllocateAllFiles(preAllocateAllFiles());
|
||||||
|
@ -395,14 +387,8 @@ void options_imp::saveOptions() {
|
||||||
pref.addTorrentsInPause(addTorrentsInPause());
|
pref.addTorrentsInPause(addTorrentsInPause());
|
||||||
ScanFoldersModel::instance()->makePersistent();
|
ScanFoldersModel::instance()->makePersistent();
|
||||||
addedScanDirs.clear();
|
addedScanDirs.clear();
|
||||||
QString export_dir = getTorrentExportDir();
|
pref.setTorrentExportDir(getTorrentExportDir());
|
||||||
QString export_dir_fin = getFinishedTorrentExportDir();
|
pref.setFinishedTorrentExportDir(getFinishedTorrentExportDir());
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
|
||||||
export_dir_fin.replace("\\", "/");
|
|
||||||
export_dir.replace("\\", "/");
|
|
||||||
#endif
|
|
||||||
pref.setTorrentExportDir(export_dir);
|
|
||||||
pref.setFinishedTorrentExportDir(export_dir_fin);
|
|
||||||
pref.setMailNotificationEnabled(groupMailNotification->isChecked());
|
pref.setMailNotificationEnabled(groupMailNotification->isChecked());
|
||||||
pref.setMailNotificationEmail(dest_email_txt->text());
|
pref.setMailNotificationEmail(dest_email_txt->text());
|
||||||
pref.setMailNotificationSMTP(smtp_server_txt->text());
|
pref.setMailNotificationSMTP(smtp_server_txt->text());
|
||||||
|
@ -457,13 +443,8 @@ void options_imp::saveOptions() {
|
||||||
// Misc preferences
|
// Misc preferences
|
||||||
// * IPFilter
|
// * IPFilter
|
||||||
pref.setFilteringEnabled(isFilteringEnabled());
|
pref.setFilteringEnabled(isFilteringEnabled());
|
||||||
if (isFilteringEnabled()) {
|
if (isFilteringEnabled())
|
||||||
QString filter_path = textFilterPath->text();
|
pref.setFilter(textFilterPath->text());
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
|
||||||
filter_path.replace("\\", "/");
|
|
||||||
#endif
|
|
||||||
pref.setFilter(filter_path);
|
|
||||||
}
|
|
||||||
// End IPFilter preferences
|
// End IPFilter preferences
|
||||||
// Queueing system
|
// Queueing system
|
||||||
pref.setQueueingSystemEnabled(isQueueingSystemEnabled());
|
pref.setQueueingSystemEnabled(isQueueingSystemEnabled());
|
||||||
|
@ -551,22 +532,14 @@ void options_imp::loadOptions() {
|
||||||
#endif
|
#endif
|
||||||
// End General preferences
|
// End General preferences
|
||||||
// Downloads preferences
|
// Downloads preferences
|
||||||
QString save_path = pref.getSavePath();
|
textSavePath->setText(fsutils::toNativePath(pref.getSavePath()));
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
|
||||||
save_path.replace("/", "\\");
|
|
||||||
#endif
|
|
||||||
textSavePath->setText(save_path);
|
|
||||||
if (pref.isTempPathEnabled()) {
|
if (pref.isTempPathEnabled()) {
|
||||||
// enable
|
// enable
|
||||||
checkTempFolder->setChecked(true);
|
checkTempFolder->setChecked(true);
|
||||||
} else {
|
} else {
|
||||||
checkTempFolder->setChecked(false);
|
checkTempFolder->setChecked(false);
|
||||||
}
|
}
|
||||||
QString temp_path = pref.getTempPath();
|
textTempPath->setText(fsutils::toNativePath(pref.getTempPath()));
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
|
||||||
temp_path.replace("/", "\\");
|
|
||||||
#endif
|
|
||||||
textTempPath->setText(temp_path);
|
|
||||||
checkAppendLabel->setChecked(pref.appendTorrentLabel());
|
checkAppendLabel->setChecked(pref.appendTorrentLabel());
|
||||||
checkAppendqB->setChecked(pref.useIncompleteFilesExtension());
|
checkAppendqB->setChecked(pref.useIncompleteFilesExtension());
|
||||||
checkPreallocateAll->setChecked(pref.preAllocateAllFiles());
|
checkPreallocateAll->setChecked(pref.preAllocateAllFiles());
|
||||||
|
@ -574,29 +547,22 @@ void options_imp::loadOptions() {
|
||||||
checkAdditionDialogFront->setChecked(pref.AdditionDialogFront());
|
checkAdditionDialogFront->setChecked(pref.AdditionDialogFront());
|
||||||
checkStartPaused->setChecked(pref.addTorrentsInPause());
|
checkStartPaused->setChecked(pref.addTorrentsInPause());
|
||||||
|
|
||||||
strValue = pref.getTorrentExportDir();
|
strValue = fsutils::toNativePath(pref.getTorrentExportDir());
|
||||||
if (strValue.isEmpty()) {
|
if (strValue.isEmpty()) {
|
||||||
// Disable
|
// Disable
|
||||||
checkExportDir->setChecked(false);
|
checkExportDir->setChecked(false);
|
||||||
} else {
|
} else {
|
||||||
// enable
|
// enable
|
||||||
checkExportDir->setChecked(true);
|
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
|
||||||
strValue.replace("/", "\\");
|
|
||||||
#endif
|
|
||||||
textExportDir->setText(strValue);
|
textExportDir->setText(strValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
strValue = pref.getFinishedTorrentExportDir();
|
strValue = fsutils::toNativePath(pref.getFinishedTorrentExportDir());
|
||||||
if (strValue.isEmpty()) {
|
if (strValue.isEmpty()) {
|
||||||
// Disable
|
// Disable
|
||||||
checkExportDirFin->setChecked(false);
|
checkExportDirFin->setChecked(false);
|
||||||
} else {
|
} else {
|
||||||
// enable
|
// enable
|
||||||
checkExportDirFin->setChecked(true);
|
checkExportDirFin->setChecked(true);
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
|
||||||
strValue.replace("/", "\\");
|
|
||||||
#endif
|
|
||||||
textExportDirFin->setText(strValue);
|
textExportDirFin->setText(strValue);
|
||||||
}
|
}
|
||||||
groupMailNotification->setChecked(pref.isMailNotificationEnabled());
|
groupMailNotification->setChecked(pref.isMailNotificationEnabled());
|
||||||
|
@ -756,7 +722,7 @@ void options_imp::loadOptions() {
|
||||||
// Misc preferences
|
// Misc preferences
|
||||||
// * IP Filter
|
// * IP Filter
|
||||||
checkIPFilter->setChecked(pref.isFilteringEnabled());
|
checkIPFilter->setChecked(pref.isFilteringEnabled());
|
||||||
textFilterPath->setText(pref.getFilter());
|
textFilterPath->setText(fsutils::toNativePath(pref.getFilter()));
|
||||||
// End IP Filter
|
// End IP Filter
|
||||||
// Queueing system preferences
|
// Queueing system preferences
|
||||||
checkEnableQueueing->setChecked(pref.isQueueingSystemEnabled());
|
checkEnableQueueing->setChecked(pref.isQueueingSystemEnabled());
|
||||||
|
@ -875,16 +841,13 @@ qreal options_imp::getMaxRatio() const {
|
||||||
QString options_imp::getSavePath() const {
|
QString options_imp::getSavePath() const {
|
||||||
if (textSavePath->text().trimmed().isEmpty()) {
|
if (textSavePath->text().trimmed().isEmpty()) {
|
||||||
QString save_path = Preferences().getSavePath();
|
QString save_path = Preferences().getSavePath();
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
textSavePath->setText(fsutils::toNativePath(save_path));
|
||||||
save_path.replace("/", "\\");
|
|
||||||
#endif
|
|
||||||
textSavePath->setText(save_path);
|
|
||||||
}
|
}
|
||||||
return fsutils::expandPath(textSavePath->text());
|
return fsutils::expandPathAbs(textSavePath->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::getTempPath() const {
|
QString options_imp::getTempPath() const {
|
||||||
return fsutils::expandPath(textTempPath->text());
|
return fsutils::expandPathAbs(textTempPath->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options_imp::isTempPathEnabled() const {
|
bool options_imp::isTempPathEnabled() const {
|
||||||
|
@ -1068,13 +1031,13 @@ void options_imp::setLocale(const QString &localeStr) {
|
||||||
|
|
||||||
QString options_imp::getTorrentExportDir() const {
|
QString options_imp::getTorrentExportDir() const {
|
||||||
if (checkExportDir->isChecked())
|
if (checkExportDir->isChecked())
|
||||||
return fsutils::expandPath(textExportDir->text());
|
return fsutils::expandPathAbs(textExportDir->text());
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString options_imp::getFinishedTorrentExportDir() const {
|
QString options_imp::getFinishedTorrentExportDir() const {
|
||||||
if (checkExportDirFin->isChecked())
|
if (checkExportDirFin->isChecked())
|
||||||
return fsutils::expandPath(textExportDirFin->text());
|
return fsutils::expandPathAbs(textExportDirFin->text());
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1133,7 +1096,7 @@ void options_imp::handleScanFolderViewSelectionChanged() {
|
||||||
|
|
||||||
QString options_imp::askForExportDir(const QString& currentExportPath)
|
QString options_imp::askForExportDir(const QString& currentExportPath)
|
||||||
{
|
{
|
||||||
QDir currentExportDir(fsutils::expandPath(currentExportPath));
|
QDir currentExportDir(fsutils::expandPathAbs(currentExportPath));
|
||||||
QString dir;
|
QString dir;
|
||||||
if (!currentExportPath.isEmpty() && currentExportDir.exists()) {
|
if (!currentExportPath.isEmpty() && currentExportDir.exists()) {
|
||||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), currentExportDir.absolutePath());
|
dir = QFileDialog::getExistingDirectory(this, tr("Choose export directory"), currentExportDir.absolutePath());
|
||||||
|
@ -1146,17 +1109,17 @@ QString options_imp::askForExportDir(const QString& currentExportPath)
|
||||||
void options_imp::on_browseExportDirButton_clicked() {
|
void options_imp::on_browseExportDirButton_clicked() {
|
||||||
const QString newExportDir = askForExportDir(textExportDir->text());
|
const QString newExportDir = askForExportDir(textExportDir->text());
|
||||||
if (!newExportDir.isNull())
|
if (!newExportDir.isNull())
|
||||||
textExportDir->setText(fsutils::toDisplayPath(newExportDir));
|
textExportDir->setText(fsutils::toNativePath(newExportDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_browseExportDirFinButton_clicked() {
|
void options_imp::on_browseExportDirFinButton_clicked() {
|
||||||
const QString newExportDir = askForExportDir(textExportDirFin->text());
|
const QString newExportDir = askForExportDir(textExportDirFin->text());
|
||||||
if (!newExportDir.isNull())
|
if (!newExportDir.isNull())
|
||||||
textExportDirFin->setText(fsutils::toDisplayPath(newExportDir));
|
textExportDirFin->setText(fsutils::toNativePath(newExportDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_browseFilterButton_clicked() {
|
void options_imp::on_browseFilterButton_clicked() {
|
||||||
const QString filter_path = fsutils::expandPath(textFilterPath->text());
|
const QString filter_path = fsutils::expandPathAbs(textFilterPath->text());
|
||||||
QDir filterDir(filter_path);
|
QDir filterDir(filter_path);
|
||||||
QString ipfilter;
|
QString ipfilter;
|
||||||
if (!filter_path.isEmpty() && filterDir.exists()) {
|
if (!filter_path.isEmpty() && filterDir.exists()) {
|
||||||
|
@ -1164,17 +1127,13 @@ void options_imp::on_browseFilterButton_clicked() {
|
||||||
} else {
|
} else {
|
||||||
ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an ip filter file"), QDir::homePath(), tr("Filters")+QString(" (*.dat *.p2p *.p2b)"));
|
ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an ip filter file"), QDir::homePath(), tr("Filters")+QString(" (*.dat *.p2p *.p2b)"));
|
||||||
}
|
}
|
||||||
if (!ipfilter.isNull()) {
|
if (!ipfilter.isNull())
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
textFilterPath->setText(fsutils::toNativePath(ipfilter));
|
||||||
ipfilter.replace("/", "\\");
|
|
||||||
#endif
|
|
||||||
textFilterPath->setText(ipfilter);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display dialog to choose save dir
|
// Display dialog to choose save dir
|
||||||
void options_imp::on_browseSaveDirButton_clicked() {
|
void options_imp::on_browseSaveDirButton_clicked() {
|
||||||
const QString save_path = fsutils::expandPath(textSavePath->text());
|
const QString save_path = fsutils::expandPathAbs(textSavePath->text());
|
||||||
QDir saveDir(save_path);
|
QDir saveDir(save_path);
|
||||||
QString dir;
|
QString dir;
|
||||||
if (!save_path.isEmpty() && saveDir.exists()) {
|
if (!save_path.isEmpty() && saveDir.exists()) {
|
||||||
|
@ -1182,16 +1141,12 @@ void options_imp::on_browseSaveDirButton_clicked() {
|
||||||
} else {
|
} else {
|
||||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
||||||
}
|
}
|
||||||
if (!dir.isNull()) {
|
if (!dir.isNull())
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
textSavePath->setText(fsutils::toNativePath(dir));
|
||||||
dir.replace("/", "\\");
|
|
||||||
#endif
|
|
||||||
textSavePath->setText(dir);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void options_imp::on_browseTempDirButton_clicked() {
|
void options_imp::on_browseTempDirButton_clicked() {
|
||||||
const QString temp_path = fsutils::expandPath(textTempPath->text());
|
const QString temp_path = fsutils::expandPathAbs(textTempPath->text());
|
||||||
QDir tempDir(temp_path);
|
QDir tempDir(temp_path);
|
||||||
QString dir;
|
QString dir;
|
||||||
if (!temp_path.isEmpty() && tempDir.exists()) {
|
if (!temp_path.isEmpty() && tempDir.exists()) {
|
||||||
|
@ -1199,17 +1154,13 @@ void options_imp::on_browseTempDirButton_clicked() {
|
||||||
} else {
|
} else {
|
||||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
||||||
}
|
}
|
||||||
if (!dir.isNull()) {
|
if (!dir.isNull())
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
textTempPath->setText(fsutils::toNativePath(dir));
|
||||||
dir.replace("/", "\\");
|
|
||||||
#endif
|
|
||||||
textTempPath->setText(dir);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return Filter object to apply to BT session
|
// Return Filter object to apply to BT session
|
||||||
QString options_imp::getFilter() const {
|
QString options_imp::getFilter() const {
|
||||||
return textFilterPath->text();
|
return fsutils::fromNativePath(textFilterPath->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Web UI
|
// Web UI
|
||||||
|
|
|
@ -204,7 +204,7 @@ public:
|
||||||
void setStartup(bool b) {
|
void setStartup(bool b) {
|
||||||
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
|
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
|
||||||
if (b) {
|
if (b) {
|
||||||
const QString bin_path = "\""+qApp->applicationFilePath().replace("/", "\\")+"\"";
|
const QString bin_path = "\""+qApp->applicationFilePath()+"\"";
|
||||||
settings.setValue("qBittorrent", bin_path);
|
settings.setValue("qBittorrent", bin_path);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -217,12 +217,12 @@ public:
|
||||||
QString getSavePath() const {
|
QString getSavePath() const {
|
||||||
QString save_path = value(QString::fromUtf8("Preferences/Downloads/SavePath")).toString();
|
QString save_path = value(QString::fromUtf8("Preferences/Downloads/SavePath")).toString();
|
||||||
if (!save_path.isEmpty())
|
if (!save_path.isEmpty())
|
||||||
return save_path;
|
return fsutils::fromNativePath(save_path);
|
||||||
return fsutils::QDesktopServicesDownloadLocation();
|
return fsutils::QDesktopServicesDownloadLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSavePath(const QString &save_path) {
|
void setSavePath(const QString &save_path) {
|
||||||
setValue(QString::fromUtf8("Preferences/Downloads/SavePath"), save_path);
|
setValue(QString::fromUtf8("Preferences/Downloads/SavePath"), fsutils::fromNativePath(save_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isTempPathEnabled() const {
|
bool isTempPathEnabled() const {
|
||||||
|
@ -235,11 +235,11 @@ public:
|
||||||
|
|
||||||
QString getTempPath() const {
|
QString getTempPath() const {
|
||||||
const QString temp = QDir(getSavePath()).absoluteFilePath("temp");
|
const QString temp = QDir(getSavePath()).absoluteFilePath("temp");
|
||||||
return value(QString::fromUtf8("Preferences/Downloads/TempPath"), temp).toString();
|
return fsutils::fromNativePath(value(QString::fromUtf8("Preferences/Downloads/TempPath"), temp).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTempPath(const QString &path) {
|
void setTempPath(const QString &path) {
|
||||||
setValue(QString::fromUtf8("Preferences/Downloads/TempPath"), path);
|
setValue(QString::fromUtf8("Preferences/Downloads/TempPath"), fsutils::fromNativePath(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool useIncompleteFilesExtension() const {
|
bool useIncompleteFilesExtension() const {
|
||||||
|
@ -259,11 +259,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
QString lastLocationPath() const {
|
QString lastLocationPath() const {
|
||||||
return value(QString::fromUtf8("Preferences/Downloads/LastLocationPath"), QString()).toString();
|
return fsutils::fromNativePath(value(QString::fromUtf8("Preferences/Downloads/LastLocationPath"), QString()).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLastLocationPath(const QString &path) {
|
void setLastLocationPath(const QString &path) {
|
||||||
setValue(QString::fromUtf8("Preferences/Downloads/LastLocationPath"), path);
|
setValue(QString::fromUtf8("Preferences/Downloads/LastLocationPath"), fsutils::fromNativePath(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool preAllocateAllFiles() const {
|
bool preAllocateAllFiles() const {
|
||||||
|
@ -299,12 +299,26 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList getScanDirs() const {
|
QStringList getScanDirs() const {
|
||||||
return value(QString::fromUtf8("Preferences/Downloads/ScanDirs"), QStringList()).toStringList();
|
QStringList originalList = value(QString::fromUtf8("Preferences/Downloads/ScanDirs"), QStringList()).toStringList();
|
||||||
|
if (originalList.isEmpty())
|
||||||
|
return originalList;
|
||||||
|
|
||||||
|
QStringList newList;
|
||||||
|
foreach (const QString& s, originalList) {
|
||||||
|
newList << fsutils::fromNativePath(s);
|
||||||
|
}
|
||||||
|
return newList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This must be called somewhere with data from the model
|
// This must be called somewhere with data from the model
|
||||||
void setScanDirs(const QStringList &dirs) {
|
void setScanDirs(const QStringList &dirs) {
|
||||||
setValue(QString::fromUtf8("Preferences/Downloads/ScanDirs"), dirs);
|
QStringList newList;
|
||||||
|
if (!dirs.isEmpty()) {
|
||||||
|
foreach (const QString& s, dirs) {
|
||||||
|
newList << fsutils::fromNativePath(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setValue(QString::fromUtf8("Preferences/Downloads/ScanDirs"), newList);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<bool> getDownloadInScanDirs() const {
|
QList<bool> getDownloadInScanDirs() const {
|
||||||
|
@ -320,14 +334,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getTorrentExportDir() const {
|
QString getTorrentExportDir() const {
|
||||||
return value(QString::fromUtf8("Preferences/Downloads/TorrentExportDir"), QString()).toString();
|
return fsutils::fromNativePath(value(QString::fromUtf8("Preferences/Downloads/TorrentExportDir"), QString()).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTorrentExportDir(QString path) {
|
void setTorrentExportDir(QString path) {
|
||||||
path = path.trimmed();
|
setValue(QString::fromUtf8("Preferences/Downloads/TorrentExportDir"), fsutils::fromNativePath(path.trimmed()));
|
||||||
if (path.isEmpty())
|
|
||||||
path = QString();
|
|
||||||
setValue(QString::fromUtf8("Preferences/Downloads/TorrentExportDir"), path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isFinishedTorrentExportEnabled() const {
|
bool isFinishedTorrentExportEnabled() const {
|
||||||
|
@ -335,14 +346,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getFinishedTorrentExportDir() const {
|
QString getFinishedTorrentExportDir() const {
|
||||||
return value(QString::fromUtf8("Preferences/Downloads/FinishedTorrentExportDir"), QString()).toString();
|
return fsutils::fromNativePath(value(QString::fromUtf8("Preferences/Downloads/FinishedTorrentExportDir"), QString()).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFinishedTorrentExportDir(QString path) {
|
void setFinishedTorrentExportDir(QString path) {
|
||||||
path = path.trimmed();
|
setValue(QString::fromUtf8("Preferences/Downloads/FinishedTorrentExportDir"), fsutils::fromNativePath(path.trimmed()));
|
||||||
if (path.isEmpty())
|
|
||||||
path = QString();
|
|
||||||
setValue(QString::fromUtf8("Preferences/Downloads/FinishedTorrentExportDir"), path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isMailNotificationEnabled() const {
|
bool isMailNotificationEnabled() const {
|
||||||
|
@ -704,11 +712,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getFilter() const {
|
QString getFilter() const {
|
||||||
return value(QString::fromUtf8("Preferences/IPFilter/File"), QString()).toString();
|
return fsutils::fromNativePath(value(QString::fromUtf8("Preferences/IPFilter/File"), QString()).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFilter(const QString &path) {
|
void setFilter(const QString &path) {
|
||||||
setValue(QString::fromUtf8("Preferences/IPFilter/File"), path);
|
setValue(QString::fromUtf8("Preferences/IPFilter/File"), fsutils::fromNativePath(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
void banIP(const QString &ip) {
|
void banIP(const QString &ip) {
|
||||||
|
@ -948,11 +956,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAutoRunProgram(const QString &program) {
|
void setAutoRunProgram(const QString &program) {
|
||||||
setValue("AutoRun/program", program);
|
setValue("AutoRun/program", fsutils::fromNativePath(program));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getAutoRunProgram() const {
|
QString getAutoRunProgram() const {
|
||||||
return value("AutoRun/program", QString()).toString();
|
return fsutils::fromNativePath(value("AutoRun/program", QString()).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shutdownWhenDownloadsComplete() const {
|
bool shutdownWhenDownloadsComplete() const {
|
||||||
|
@ -1173,7 +1181,7 @@ public:
|
||||||
while(!versions.empty()) {
|
while(!versions.empty()) {
|
||||||
const QString version = versions.takeLast();
|
const QString version = versions.takeLast();
|
||||||
qDebug("Detected possible Python v%s location", qPrintable(version));
|
qDebug("Detected possible Python v%s location", qPrintable(version));
|
||||||
QString path = reg_python.value(version+"/InstallPath/Default", "").toString().replace("/", "\\");
|
QString path = reg_python.value(version+"/InstallPath/Default", "").toString();
|
||||||
if (!path.isEmpty() && QDir(path).exists("python.exe")) {
|
if (!path.isEmpty() && QDir(path).exists("python.exe")) {
|
||||||
qDebug("Found python.exe at %s", qPrintable(path));
|
qDebug("Found python.exe at %s", qPrintable(path));
|
||||||
return path;
|
return path;
|
||||||
|
@ -1184,8 +1192,8 @@ public:
|
||||||
supported_versions << "32" << "31" << "30" << "27" << "26" << "25";
|
supported_versions << "32" << "31" << "30" << "27" << "26" << "25";
|
||||||
foreach (const QString &v, supported_versions) {
|
foreach (const QString &v, supported_versions) {
|
||||||
if (QFile::exists("C:/Python"+v+"/python.exe")) {
|
if (QFile::exists("C:/Python"+v+"/python.exe")) {
|
||||||
reg_python.setValue(v[0]+"."+v[1]+"/InstallPath/Default", QString("C:\\Python"+v));
|
reg_python.setValue(v[0]+"."+v[1]+"/InstallPath/Default", QString("C:/Python"+v));
|
||||||
return "C:\\Python"+v;
|
return "C:/Python"+v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QString::null;
|
return QString::null;
|
||||||
|
@ -1206,17 +1214,17 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
qDebug("Checking shell command");
|
qDebug("Checking shell command");
|
||||||
QString shell_command = settings.value("qBittorrent/shell/open/command/Default", "").toString();
|
QString shell_command = fsutils::toNativePath(settings.value("qBittorrent/shell/open/command/Default", "").toString());
|
||||||
qDebug("Shell command is: %s", qPrintable(shell_command));
|
qDebug("Shell command is: %s", qPrintable(shell_command));
|
||||||
QRegExp exe_reg("\"([^\"]+)\".*");
|
QRegExp exe_reg("\"([^\"]+)\".*");
|
||||||
if (exe_reg.indexIn(shell_command) < 0)
|
if (exe_reg.indexIn(shell_command) < 0)
|
||||||
return false;
|
return false;
|
||||||
QString assoc_exe = exe_reg.cap(1);
|
QString assoc_exe = exe_reg.cap(1);
|
||||||
qDebug("exe: %s", qPrintable(assoc_exe));
|
qDebug("exe: %s", qPrintable(assoc_exe));
|
||||||
if (assoc_exe.compare(qApp->applicationFilePath().replace("/", "\\"), Qt::CaseInsensitive) != 0)
|
if (assoc_exe.compare(fsutils::toNativePath(qApp->applicationFilePath()), Qt::CaseInsensitive) != 0)
|
||||||
return false;
|
return false;
|
||||||
// Icon
|
// Icon
|
||||||
const QString icon_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\",1";
|
const QString icon_str = "\""+fsutils::toNativePath(qApp->applicationFilePath())+"\",1";
|
||||||
if (settings.value("qBittorrent/DefaultIcon/Default", icon_str).toString().compare(icon_str, Qt::CaseInsensitive) != 0)
|
if (settings.value("qBittorrent/DefaultIcon/Default", icon_str).toString().compare(icon_str, Qt::CaseInsensitive) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1228,12 +1236,12 @@ public:
|
||||||
|
|
||||||
// Check magnet link assoc
|
// Check magnet link assoc
|
||||||
QRegExp exe_reg("\"([^\"]+)\".*");
|
QRegExp exe_reg("\"([^\"]+)\".*");
|
||||||
QString shell_command = settings.value("Magnet/shell/open/command/Default", "").toString();
|
QString shell_command = fsutils::toNativePath(settings.value("Magnet/shell/open/command/Default", "").toString());
|
||||||
if (exe_reg.indexIn(shell_command) < 0)
|
if (exe_reg.indexIn(shell_command) < 0)
|
||||||
return false;
|
return false;
|
||||||
QString assoc_exe = exe_reg.cap(1);
|
QString assoc_exe = exe_reg.cap(1);
|
||||||
qDebug("exe: %s", qPrintable(assoc_exe));
|
qDebug("exe: %s", qPrintable(assoc_exe));
|
||||||
if (assoc_exe.compare(qApp->applicationFilePath().replace("/", "\\"), Qt::CaseInsensitive) != 0)
|
if (assoc_exe.compare(fsutils::toNativePath(qApp->applicationFilePath()), Qt::CaseInsensitive) != 0)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1243,8 +1251,8 @@ public:
|
||||||
|
|
||||||
// .Torrent association
|
// .Torrent association
|
||||||
if (set) {
|
if (set) {
|
||||||
const QString command_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\" \"%1\"";
|
const QString command_str = "\""+qApp->applicationFilePath()+"\" \"%1\"";
|
||||||
const QString icon_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\",1";
|
const QString icon_str = "\""+qApp->applicationFilePath()+"\",1";
|
||||||
|
|
||||||
settings.setValue(".torrent/Default", "qBittorrent");
|
settings.setValue(".torrent/Default", "qBittorrent");
|
||||||
settings.setValue(".torrent/Content Type", "application/x-bittorrent");
|
settings.setValue(".torrent/Content Type", "application/x-bittorrent");
|
||||||
|
@ -1267,8 +1275,8 @@ public:
|
||||||
|
|
||||||
// Magnet association
|
// Magnet association
|
||||||
if (set) {
|
if (set) {
|
||||||
const QString command_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\" \"%1\"";
|
const QString command_str = "\""+qApp->applicationFilePath()+"\" \"%1\"";
|
||||||
const QString icon_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\",1";
|
const QString icon_str = "\""+qApp->applicationFilePath()+"\",1";
|
||||||
|
|
||||||
settings.setValue("Magnet/Default", "Magnet URI");
|
settings.setValue("Magnet/Default", "Magnet URI");
|
||||||
settings.setValue("Magnet/Content Type", "application/x-magnet");
|
settings.setValue("Magnet/Content Type", "application/x-magnet");
|
||||||
|
|
|
@ -220,7 +220,7 @@ QTorrentHandle PropertiesWidget::getCurrentTorrent() const {
|
||||||
|
|
||||||
void PropertiesWidget::updateSavePath(const QTorrentHandle& _h) {
|
void PropertiesWidget::updateSavePath(const QTorrentHandle& _h) {
|
||||||
if (h.is_valid() && h == _h) {
|
if (h.is_valid() && h == _h) {
|
||||||
save_path->setText(h.save_path_parsed());
|
save_path->setText(fsutils::toNativePath(h.save_path_parsed()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,12 +414,14 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) {
|
||||||
int i = PropListModel->getFileIndex(index);
|
int i = PropListModel->getFileIndex(index);
|
||||||
const QDir saveDir(h.save_path());
|
const QDir saveDir(h.save_path());
|
||||||
const QString filename = h.filepath_at(i);
|
const QString filename = h.filepath_at(i);
|
||||||
const QString file_path = QDir::cleanPath(saveDir.absoluteFilePath(filename));
|
const QString file_path = fsutils::expandPath(saveDir.absoluteFilePath(filename));
|
||||||
qDebug("Trying to open file at %s", qPrintable(file_path));
|
qDebug("Trying to open file at %s", qPrintable(file_path));
|
||||||
// Flush data
|
// Flush data
|
||||||
h.flush_cache();
|
h.flush_cache();
|
||||||
if (QFile::exists(file_path)) {
|
if (QFile::exists(file_path)) {
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(file_path));
|
// Hack to access samba shares with QDesktopServices::openUrl
|
||||||
|
const QString p = file_path.startsWith("//") ? QString("file:") + file_path : file_path;
|
||||||
|
QDesktopServices::openUrl(QUrl::fromLocalFile(p));
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::warning(this, tr("I/O Error"), tr("This file does not exist yet."));
|
QMessageBox::warning(this, tr("I/O Error"), tr("This file does not exist yet."));
|
||||||
}
|
}
|
||||||
|
@ -433,13 +435,15 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) {
|
||||||
parent = PropListModel->parent(parent);
|
parent = PropListModel->parent(parent);
|
||||||
}
|
}
|
||||||
const QDir saveDir(h.save_path());
|
const QDir saveDir(h.save_path());
|
||||||
const QString filename = path_items.join(QDir::separator());
|
const QString filename = path_items.join("/");
|
||||||
const QString file_path = QDir::cleanPath(saveDir.absoluteFilePath(filename));
|
const QString file_path = fsutils::expandPath(saveDir.absoluteFilePath(filename));
|
||||||
qDebug("Trying to open folder at %s", qPrintable(file_path));
|
qDebug("Trying to open folder at %s", qPrintable(file_path));
|
||||||
// Flush data
|
// Flush data
|
||||||
h.flush_cache();
|
h.flush_cache();
|
||||||
if (QFile::exists(file_path)) {
|
if (QFile::exists(file_path)) {
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(file_path));
|
// Hack to access samba shares with QDesktopServices::openUrl
|
||||||
|
const QString p = file_path.startsWith("//") ? QString("file:") + file_path : file_path;
|
||||||
|
QDesktopServices::openUrl(QUrl::fromLocalFile(p));
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::warning(this, tr("I/O Error"), tr("This folder does not exist yet."));
|
QMessageBox::warning(this, tr("I/O Error"), tr("This folder does not exist yet."));
|
||||||
}
|
}
|
||||||
|
@ -541,7 +545,7 @@ void PropertiesWidget::renameSelectedFile() {
|
||||||
// File renaming
|
// File renaming
|
||||||
const int file_index = PropListModel->getFileIndex(index);
|
const int file_index = PropListModel->getFileIndex(index);
|
||||||
if (!h.is_valid() || !h.has_metadata()) return;
|
if (!h.is_valid() || !h.has_metadata()) return;
|
||||||
QString old_name = h.filepath_at(file_index).replace("\\", "/");
|
QString old_name = h.filepath_at(file_index);
|
||||||
if (old_name.endsWith(".!qB") && !new_name_last.endsWith(".!qB")) {
|
if (old_name.endsWith(".!qB") && !new_name_last.endsWith(".!qB")) {
|
||||||
new_name_last += ".!qB";
|
new_name_last += ".!qB";
|
||||||
}
|
}
|
||||||
|
@ -553,7 +557,7 @@ void PropertiesWidget::renameSelectedFile() {
|
||||||
qDebug("Name did not change");
|
qDebug("Name did not change");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new_name = QDir::cleanPath(new_name);
|
new_name = fsutils::expandPathAbs(new_name);
|
||||||
// Check if that name is already used
|
// Check if that name is already used
|
||||||
for (int i=0; i<h.num_files(); ++i) {
|
for (int i=0; i<h.num_files(); ++i) {
|
||||||
if (i == file_index) continue;
|
if (i == file_index) continue;
|
||||||
|
@ -569,7 +573,7 @@ void PropertiesWidget::renameSelectedFile() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const bool force_recheck = QFile::exists(h.save_path()+QDir::separator()+new_name);
|
const bool force_recheck = QFile::exists(h.save_path()+"/"+new_name);
|
||||||
qDebug("Renaming %s to %s", qPrintable(old_name), qPrintable(new_name));
|
qDebug("Renaming %s to %s", qPrintable(old_name), qPrintable(new_name));
|
||||||
h.rename_file(file_index, new_name);
|
h.rename_file(file_index, new_name);
|
||||||
// Force recheck
|
// Force recheck
|
||||||
|
@ -616,7 +620,7 @@ void PropertiesWidget::renameSelectedFile() {
|
||||||
new_name.replace(0, old_path.length(), new_path);
|
new_name.replace(0, old_path.length(), new_path);
|
||||||
if (!force_recheck && QDir(h.save_path()).exists(new_name))
|
if (!force_recheck && QDir(h.save_path()).exists(new_name))
|
||||||
force_recheck = true;
|
force_recheck = true;
|
||||||
new_name = QDir::cleanPath(new_name);
|
new_name = fsutils::expandPathAbs(new_name);
|
||||||
qDebug("Rename %s to %s", qPrintable(current_name), qPrintable(new_name));
|
qDebug("Rename %s to %s", qPrintable(current_name), qPrintable(new_name));
|
||||||
h.rename_file(i, new_name);
|
h.rename_file(i, new_name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ public:
|
||||||
|
|
||||||
void setValue(const QString &key, const QVariant &val) {
|
void setValue(const QString &key, const QVariant &val) {
|
||||||
QString key_tmp(key);
|
QString key_tmp(key);
|
||||||
if (format() == QSettings::NativeFormat)
|
if (format() == QSettings::NativeFormat) // Using registry, don't touch replace here
|
||||||
key_tmp.replace("\\", "/");
|
key_tmp.replace("\\", "/");
|
||||||
QSettings::setValue(key_tmp, val);
|
QSettings::setValue(key_tmp, val);
|
||||||
}
|
}
|
||||||
|
|
|
@ -947,14 +947,14 @@ QTorrentHandle QBtSession::addMagnetUri(QString magnet_uri, bool resumed, bool f
|
||||||
savePath = getSavePath(hash, false);
|
savePath = getSavePath(hash, false);
|
||||||
if (!defaultTempPath.isEmpty() && !TorrentPersistentData::isSeed(hash)) {
|
if (!defaultTempPath.isEmpty() && !TorrentPersistentData::isSeed(hash)) {
|
||||||
qDebug("addMagnetURI: Temp folder is enabled.");
|
qDebug("addMagnetURI: Temp folder is enabled.");
|
||||||
QString torrent_tmp_path = defaultTempPath.replace("\\", "/");
|
QString torrent_tmp_path = defaultTempPath;
|
||||||
p.save_path = torrent_tmp_path.toUtf8().constData();
|
p.save_path = fsutils::toNativePath(torrent_tmp_path).toUtf8().constData();
|
||||||
// Check if save path exists, creating it otherwise
|
// Check if save path exists, creating it otherwise
|
||||||
if (!QDir(torrent_tmp_path).exists())
|
if (!QDir(torrent_tmp_path).exists())
|
||||||
QDir().mkpath(torrent_tmp_path);
|
QDir().mkpath(torrent_tmp_path);
|
||||||
qDebug("addTorrent: using save_path: %s", qPrintable(torrent_tmp_path));
|
qDebug("addTorrent: using save_path: %s", qPrintable(torrent_tmp_path));
|
||||||
} else {
|
} else {
|
||||||
p.save_path = savePath.toUtf8().constData();
|
p.save_path = fsutils::toNativePath(savePath).toUtf8().constData();
|
||||||
// Check if save path exists, creating it otherwise
|
// Check if save path exists, creating it otherwise
|
||||||
if (!QDir(savePath).exists()) QDir().mkpath(savePath);
|
if (!QDir(savePath).exists()) QDir().mkpath(savePath);
|
||||||
qDebug("addTorrent: using save_path: %s", qPrintable(savePath));
|
qDebug("addTorrent: using save_path: %s", qPrintable(savePath));
|
||||||
|
@ -1020,6 +1020,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
|
||||||
if (!torrentBackup.exists()) return h;
|
if (!torrentBackup.exists()) return h;
|
||||||
|
|
||||||
// Fix the input path if necessary
|
// Fix the input path if necessary
|
||||||
|
path = fsutils::fromNativePath(path);
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
// Windows hack
|
// Windows hack
|
||||||
if (!path.endsWith(".torrent"))
|
if (!path.endsWith(".torrent"))
|
||||||
|
@ -1036,7 +1037,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
|
||||||
try {
|
try {
|
||||||
qDebug() << "Loading torrent at" << path;
|
qDebug() << "Loading torrent at" << path;
|
||||||
// Getting torrent file informations
|
// Getting torrent file informations
|
||||||
t = new torrent_info(path.toUtf8().constData());
|
t = new torrent_info(fsutils::toNativePath(path).toUtf8().constData());
|
||||||
if (!t->is_valid())
|
if (!t->is_valid())
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
} catch(std::exception& e) {
|
} catch(std::exception& e) {
|
||||||
|
@ -1046,13 +1047,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
|
||||||
//emit invalidTorrent(from_url);
|
//emit invalidTorrent(from_url);
|
||||||
fsutils::forceRemove(path);
|
fsutils::forceRemove(path);
|
||||||
}else{
|
}else{
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(fsutils::toNativePath(path)), QString::fromUtf8("red"));
|
||||||
QString displayed_path = path;
|
|
||||||
displayed_path.replace("/", "\\");
|
|
||||||
addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(displayed_path), QString::fromUtf8("red"));
|
|
||||||
#else
|
|
||||||
addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(path), QString::fromUtf8("red"));
|
|
||||||
#endif
|
|
||||||
//emit invalidTorrent(path);
|
//emit invalidTorrent(path);
|
||||||
}
|
}
|
||||||
addConsoleMessage(tr("This file is either corrupted or this isn't a torrent."),QString::fromUtf8("red"));
|
addConsoleMessage(tr("This file is either corrupted or this isn't a torrent."),QString::fromUtf8("red"));
|
||||||
|
@ -1075,13 +1070,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
|
||||||
if (!from_url.isNull()) {
|
if (!from_url.isNull()) {
|
||||||
addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(from_url));
|
addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(from_url));
|
||||||
}else{
|
}else{
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(fsutils::toNativePath(path)));
|
||||||
QString displayed_path = path;
|
|
||||||
displayed_path.replace("/", "\\");
|
|
||||||
addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(displayed_path));
|
|
||||||
#else
|
|
||||||
addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(path));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
// Check if the torrent contains trackers or url seeds we don't know about
|
// Check if the torrent contains trackers or url seeds we don't know about
|
||||||
// and add them
|
// and add them
|
||||||
|
@ -1139,13 +1128,13 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
|
||||||
}
|
}
|
||||||
if (!defaultTempPath.isEmpty() && !TorrentPersistentData::isSeed(hash)) {
|
if (!defaultTempPath.isEmpty() && !TorrentPersistentData::isSeed(hash)) {
|
||||||
qDebug("addTorrent::Temp folder is enabled.");
|
qDebug("addTorrent::Temp folder is enabled.");
|
||||||
QString torrent_tmp_path = defaultTempPath.replace("\\", "/");
|
QString torrent_tmp_path = defaultTempPath;
|
||||||
p.save_path = torrent_tmp_path.toUtf8().constData();
|
p.save_path = fsutils::toNativePath(torrent_tmp_path).toUtf8().constData();
|
||||||
// Check if save path exists, creating it otherwise
|
// Check if save path exists, creating it otherwise
|
||||||
if (!QDir(torrent_tmp_path).exists()) QDir().mkpath(torrent_tmp_path);
|
if (!QDir(torrent_tmp_path).exists()) QDir().mkpath(torrent_tmp_path);
|
||||||
qDebug("addTorrent: using save_path: %s", qPrintable(torrent_tmp_path));
|
qDebug("addTorrent: using save_path: %s", qPrintable(torrent_tmp_path));
|
||||||
} else {
|
} else {
|
||||||
p.save_path = savePath.toUtf8().constData();
|
p.save_path = fsutils::toNativePath(savePath).toUtf8().constData();
|
||||||
// Check if save path exists, creating it otherwise
|
// Check if save path exists, creating it otherwise
|
||||||
if (!QDir(savePath).exists()) QDir().mkpath(savePath);
|
if (!QDir(savePath).exists()) QDir().mkpath(savePath);
|
||||||
qDebug("addTorrent: using save_path: %s", qPrintable(savePath));
|
qDebug("addTorrent: using save_path: %s", qPrintable(savePath));
|
||||||
|
@ -1201,9 +1190,9 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
|
||||||
addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(from_url));
|
addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(from_url));
|
||||||
}else{
|
}else{
|
||||||
if (fastResume)
|
if (fastResume)
|
||||||
addConsoleMessage(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(fsutils::toDisplayPath(path)));
|
addConsoleMessage(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(fsutils::toNativePath(path)));
|
||||||
else
|
else
|
||||||
addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(fsutils::toDisplayPath(path)));
|
addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(fsutils::toNativePath(path)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send torrent addition signal
|
// Send torrent addition signal
|
||||||
|
@ -1299,7 +1288,7 @@ void QBtSession::loadTorrentTempData(QTorrentHandle &h, QString savePath, bool m
|
||||||
if (defaultTempPath.isEmpty())
|
if (defaultTempPath.isEmpty())
|
||||||
TorrentPersistentData::saveTorrentPersistentData(h, QString::null, magnet);
|
TorrentPersistentData::saveTorrentPersistentData(h, QString::null, magnet);
|
||||||
else
|
else
|
||||||
TorrentPersistentData::saveTorrentPersistentData(h, savePath, magnet);
|
TorrentPersistentData::saveTorrentPersistentData(h, fsutils::fromNativePath(savePath), magnet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBtSession::mergeTorrents(QTorrentHandle& h_ex, const QString& magnet_uri)
|
void QBtSession::mergeTorrents(QTorrentHandle& h_ex, const QString& magnet_uri)
|
||||||
|
@ -1490,7 +1479,7 @@ void QBtSession::enableLSD(bool b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBtSession::loadSessionState() {
|
void QBtSession::loadSessionState() {
|
||||||
const QString state_path = fsutils::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state");
|
const QString state_path = fsutils::cacheLocation()+"/"+QString::fromUtf8("ses_state");
|
||||||
if (!QFile::exists(state_path)) return;
|
if (!QFile::exists(state_path)) return;
|
||||||
if (QFile(state_path).size() == 0) {
|
if (QFile(state_path).size() == 0) {
|
||||||
// Remove empty invalid state file
|
// Remove empty invalid state file
|
||||||
|
@ -1514,7 +1503,7 @@ void QBtSession::loadSessionState() {
|
||||||
|
|
||||||
void QBtSession::saveSessionState() {
|
void QBtSession::saveSessionState() {
|
||||||
qDebug("Saving session state to disk...");
|
qDebug("Saving session state to disk...");
|
||||||
const QString state_path = fsutils::cacheLocation()+QDir::separator()+QString::fromUtf8("ses_state");
|
const QString state_path = fsutils::cacheLocation()+"/"+QString::fromUtf8("ses_state");
|
||||||
entry session_state;
|
entry session_state;
|
||||||
s->save_state(session_state);
|
s->save_state(session_state);
|
||||||
vector<char> out;
|
vector<char> out;
|
||||||
|
@ -1739,7 +1728,7 @@ void QBtSession::addTorrentsFromScanFolder(QStringList &pathList) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
torrent_info t(file.toUtf8().constData());
|
torrent_info t(fsutils::toNativePath(file).toUtf8().constData());
|
||||||
if (t.is_valid())
|
if (t.is_valid())
|
||||||
addTorrent(file, true);
|
addTorrent(file, true);
|
||||||
} catch(std::exception&) {
|
} catch(std::exception&) {
|
||||||
|
@ -1752,7 +1741,7 @@ void QBtSession::setDefaultSavePath(const QString &savepath) {
|
||||||
if (savepath.isEmpty())
|
if (savepath.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
defaultSavePath = QDir::fromNativeSeparators(savepath);
|
defaultSavePath = fsutils::fromNativePath(savepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBtSession::setDefaultTempPath(const QString &temppath) {
|
void QBtSession::setDefaultTempPath(const QString &temppath) {
|
||||||
|
@ -1782,13 +1771,12 @@ void QBtSession::setDefaultTempPath(const QString &temppath) {
|
||||||
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
||||||
if (!h.is_valid()) continue;
|
if (!h.is_valid()) continue;
|
||||||
if (!h.is_seed()) {
|
if (!h.is_seed()) {
|
||||||
QString torrent_tmp_path = QDir::fromNativeSeparators(temppath);
|
qDebug("Moving torrent to its temp save path: %s", qPrintable(temppath));
|
||||||
qDebug("Moving torrent to its temp save path: %s", qPrintable(fsutils::toDisplayPath(torrent_tmp_path)));
|
h.move_storage(temppath);
|
||||||
h.move_storage(torrent_tmp_path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defaultTempPath = QDir::fromNativeSeparators(temppath);
|
defaultTempPath = fsutils::fromNativePath(temppath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBtSession::appendqBextensionToTorrent(const QTorrentHandle &h, bool append) {
|
void QBtSession::appendqBextensionToTorrent(const QTorrentHandle &h, bool append) {
|
||||||
|
@ -1821,7 +1809,7 @@ void QBtSession::appendqBextensionToTorrent(const QTorrentHandle &h, bool append
|
||||||
void QBtSession::changeLabelInTorrentSavePath(const QTorrentHandle &h, QString old_label, QString new_label) {
|
void QBtSession::changeLabelInTorrentSavePath(const QTorrentHandle &h, QString old_label, QString new_label) {
|
||||||
if (!h.is_valid()) return;
|
if (!h.is_valid()) return;
|
||||||
if (!appendLabelToSavePath) return;
|
if (!appendLabelToSavePath) return;
|
||||||
QString old_save_path = TorrentPersistentData::getSavePath(h.hash());
|
QString old_save_path = fsutils::fromNativePath(TorrentPersistentData::getSavePath(h.hash()));
|
||||||
if (!old_save_path.startsWith(defaultSavePath)) return;
|
if (!old_save_path.startsWith(defaultSavePath)) return;
|
||||||
QString new_save_path = fsutils::updateLabelInSavePath(defaultSavePath, old_save_path, old_label, new_label);
|
QString new_save_path = fsutils::updateLabelInSavePath(defaultSavePath, old_save_path, old_label, new_label);
|
||||||
if (new_save_path != old_save_path) {
|
if (new_save_path != old_save_path) {
|
||||||
|
@ -1837,7 +1825,7 @@ void QBtSession::appendLabelToTorrentSavePath(const QTorrentHandle& h) {
|
||||||
const QString label = TorrentPersistentData::getLabel(h.hash());
|
const QString label = TorrentPersistentData::getLabel(h.hash());
|
||||||
if (label.isEmpty()) return;
|
if (label.isEmpty()) return;
|
||||||
// Current save path
|
// Current save path
|
||||||
QString old_save_path = TorrentPersistentData::getSavePath(h.hash());
|
QString old_save_path = fsutils::fromNativePath(TorrentPersistentData::getSavePath(h.hash()));
|
||||||
QString new_save_path = fsutils::updateLabelInSavePath(defaultSavePath, old_save_path, "", label);
|
QString new_save_path = fsutils::updateLabelInSavePath(defaultSavePath, old_save_path, "", label);
|
||||||
if (old_save_path != new_save_path) {
|
if (old_save_path != new_save_path) {
|
||||||
// Move storage
|
// Move storage
|
||||||
|
@ -2005,9 +1993,9 @@ void QBtSession::enableIPFilter(const QString &filter_path, bool force) {
|
||||||
connect(filterParser.data(), SIGNAL(IPFilterParsed(int)), SLOT(handleIPFilterParsed(int)));
|
connect(filterParser.data(), SIGNAL(IPFilterParsed(int)), SLOT(handleIPFilterParsed(int)));
|
||||||
connect(filterParser.data(), SIGNAL(IPFilterError()), SLOT(handleIPFilterError()));
|
connect(filterParser.data(), SIGNAL(IPFilterError()), SLOT(handleIPFilterError()));
|
||||||
}
|
}
|
||||||
if (filterPath.isEmpty() || filterPath != filter_path || force) {
|
if (filterPath.isEmpty() || filterPath != fsutils::fromNativePath(filter_path) || force) {
|
||||||
filterPath = filter_path;
|
filterPath = fsutils::fromNativePath(filter_path);
|
||||||
filterParser->processFilterFile(filter_path);
|
filterParser->processFilterFile(fsutils::fromNativePath(filter_path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2069,16 +2057,10 @@ void QBtSession::recursiveTorrentDownload(const QTorrentHandle &h) {
|
||||||
for (int i=0; i<h.num_files(); ++i) {
|
for (int i=0; i<h.num_files(); ++i) {
|
||||||
const QString torrent_relpath = h.filepath_at(i);
|
const QString torrent_relpath = h.filepath_at(i);
|
||||||
if (torrent_relpath.endsWith(".torrent")) {
|
if (torrent_relpath.endsWith(".torrent")) {
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
addConsoleMessage(tr("Recursive download of file %1 embedded in torrent %2", "Recursive download of test.torrent embedded in torrent test2").arg(fsutils::toNativePath(torrent_relpath)).arg(h.name()));
|
||||||
QString displayed_relpath = torrent_relpath;
|
const QString torrent_fullpath = h.save_path()+"/"+torrent_relpath;
|
||||||
displayed_relpath.replace("/", "\\");
|
|
||||||
addConsoleMessage(tr("Recursive download of file %1 embedded in torrent %2", "Recursive download of test.torrent embedded in torrent test2").arg(displayed_relpath).arg(h.name()));
|
|
||||||
#else
|
|
||||||
addConsoleMessage(tr("Recursive download of file %1 embedded in torrent %2", "Recursive download of test.torrent embedded in torrent test2").arg(torrent_relpath).arg(h.name()));
|
|
||||||
#endif
|
|
||||||
const QString torrent_fullpath = h.save_path()+QDir::separator()+torrent_relpath;
|
|
||||||
|
|
||||||
boost::intrusive_ptr<torrent_info> t = new torrent_info(torrent_fullpath.toUtf8().constData());
|
boost::intrusive_ptr<torrent_info> t = new torrent_info(fsutils::toNativePath(torrent_fullpath).toUtf8().constData());
|
||||||
const QString sub_hash = misc::toQString(t->info_hash());
|
const QString sub_hash = misc::toQString(t->info_hash());
|
||||||
// Passing the save path along to the sub torrent file
|
// Passing the save path along to the sub torrent file
|
||||||
TorrentTempData::setSavePath(sub_hash, h.save_path());
|
TorrentTempData::setSavePath(sub_hash, h.save_path());
|
||||||
|
@ -2151,14 +2133,14 @@ void QBtSession::readAlerts() {
|
||||||
qDebug("Checking if the torrent contains torrent files to download");
|
qDebug("Checking if the torrent contains torrent files to download");
|
||||||
// Check if there are torrent files inside
|
// Check if there are torrent files inside
|
||||||
for (int i=0; i<h.num_files(); ++i) {
|
for (int i=0; i<h.num_files(); ++i) {
|
||||||
const QString torrent_relpath = h.filepath_at(i).replace("\\", "/");
|
const QString torrent_relpath = h.filepath_at(i);
|
||||||
qDebug() << "File path:" << torrent_relpath;
|
qDebug() << "File path:" << torrent_relpath;
|
||||||
if (torrent_relpath.endsWith(".torrent", Qt::CaseInsensitive)) {
|
if (torrent_relpath.endsWith(".torrent", Qt::CaseInsensitive)) {
|
||||||
qDebug("Found possible recursive torrent download.");
|
qDebug("Found possible recursive torrent download.");
|
||||||
const QString torrent_fullpath = h.save_path()+"/"+torrent_relpath;
|
const QString torrent_fullpath = h.save_path()+"/"+torrent_relpath;
|
||||||
qDebug("Full subtorrent path is %s", qPrintable(torrent_fullpath));
|
qDebug("Full subtorrent path is %s", qPrintable(torrent_fullpath));
|
||||||
try {
|
try {
|
||||||
boost::intrusive_ptr<torrent_info> t = new torrent_info(torrent_fullpath.toUtf8().constData());
|
boost::intrusive_ptr<torrent_info> t = new torrent_info(fsutils::toNativePath(torrent_fullpath).toUtf8().constData());
|
||||||
if (t->is_valid()) {
|
if (t->is_valid()) {
|
||||||
qDebug("emitting recursiveTorrentDownloadPossible()");
|
qDebug("emitting recursiveTorrentDownloadPossible()");
|
||||||
emit recursiveTorrentDownloadPossible(h);
|
emit recursiveTorrentDownloadPossible(h);
|
||||||
|
@ -2166,13 +2148,7 @@ void QBtSession::readAlerts() {
|
||||||
}
|
}
|
||||||
} catch(std::exception&) {
|
} catch(std::exception&) {
|
||||||
qDebug("Caught error loading torrent");
|
qDebug("Caught error loading torrent");
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
addConsoleMessage(tr("Unable to decode %1 torrent file.").arg(fsutils::toNativePath(torrent_fullpath)), QString::fromUtf8("red"));
|
||||||
QString displayed_path = torrent_fullpath;
|
|
||||||
displayed_path.replace("/", "\\");
|
|
||||||
addConsoleMessage(tr("Unable to decode %1 torrent file.").arg(displayed_path), QString::fromUtf8("red"));
|
|
||||||
#else
|
|
||||||
addConsoleMessage(tr("Unable to decode %1 torrent file.").arg(torrent_fullpath), QString::fromUtf8("red"));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2276,7 +2252,7 @@ void QBtSession::readAlerts() {
|
||||||
QStringList old_path_parts = h.orig_filepath_at(p->index).split("/");
|
QStringList old_path_parts = h.orig_filepath_at(p->index).split("/");
|
||||||
old_path_parts.removeLast();
|
old_path_parts.removeLast();
|
||||||
QString old_path = old_path_parts.join("/");
|
QString old_path = old_path_parts.join("/");
|
||||||
QStringList new_path_parts = misc::toQStringU(p->name).split("/");
|
QStringList new_path_parts = fsutils::fromNativePath(misc::toQStringU(p->name)).split("/");
|
||||||
new_path_parts.removeLast();
|
new_path_parts.removeLast();
|
||||||
if (!new_path_parts.isEmpty() && old_path != new_path_parts.join("/")) {
|
if (!new_path_parts.isEmpty() && old_path != new_path_parts.join("/")) {
|
||||||
qDebug("Old_path(%s) != new_path(%s)", qPrintable(old_path), qPrintable(new_path_parts.join("/")));
|
qDebug("Old_path(%s) != new_path(%s)", qPrintable(old_path), qPrintable(new_path_parts.join("/")));
|
||||||
|
@ -2317,8 +2293,8 @@ void QBtSession::readAlerts() {
|
||||||
QTorrentHandle h(p->handle);
|
QTorrentHandle h(p->handle);
|
||||||
if (h.is_valid()) {
|
if (h.is_valid()) {
|
||||||
// Attempt to remove old folder if empty
|
// Attempt to remove old folder if empty
|
||||||
const QString old_save_path = TorrentPersistentData::getPreviousPath(h.hash());
|
const QString old_save_path = fsutils::fromNativePath(TorrentPersistentData::getPreviousPath(h.hash()));
|
||||||
const QString new_save_path = misc::toQStringU(p->path.c_str());
|
const QString new_save_path = fsutils::fromNativePath(misc::toQStringU(p->path.c_str()));
|
||||||
qDebug("Torrent moved from %s to %s", qPrintable(old_save_path), qPrintable(new_save_path));
|
qDebug("Torrent moved from %s to %s", qPrintable(old_save_path), qPrintable(new_save_path));
|
||||||
QDir old_save_dir(old_save_path);
|
QDir old_save_dir(old_save_path);
|
||||||
if (old_save_dir != QDir(defaultSavePath) && old_save_dir != QDir(defaultTempPath)) {
|
if (old_save_dir != QDir(defaultSavePath) && old_save_dir != QDir(defaultTempPath)) {
|
||||||
|
@ -2564,7 +2540,7 @@ void QBtSession::readAlerts() {
|
||||||
const QDir save_dir(getSavePath(h.hash()));
|
const QDir save_dir(getSavePath(h.hash()));
|
||||||
if (current_dir == save_dir) {
|
if (current_dir == save_dir) {
|
||||||
qDebug("Moving the torrent to the temp directory...");
|
qDebug("Moving the torrent to the temp directory...");
|
||||||
QString torrent_tmp_path = defaultTempPath.replace("\\", "/");
|
QString torrent_tmp_path = defaultTempPath;
|
||||||
h.move_storage(torrent_tmp_path);
|
h.move_storage(torrent_tmp_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2617,7 +2593,7 @@ session_status QBtSession::getSessionStatus() const {
|
||||||
QString QBtSession::getSavePath(const QString &hash, bool fromScanDir, QString filePath) {
|
QString QBtSession::getSavePath(const QString &hash, bool fromScanDir, QString filePath) {
|
||||||
QString savePath;
|
QString savePath;
|
||||||
if (TorrentTempData::hasTempData(hash)) {
|
if (TorrentTempData::hasTempData(hash)) {
|
||||||
savePath = TorrentTempData::getSavePath(hash);
|
savePath = fsutils::fromNativePath(TorrentTempData::getSavePath(hash));
|
||||||
if (savePath.isEmpty()) {
|
if (savePath.isEmpty()) {
|
||||||
savePath = defaultSavePath;
|
savePath = defaultSavePath;
|
||||||
}
|
}
|
||||||
|
@ -2630,7 +2606,7 @@ QString QBtSession::getSavePath(const QString &hash, bool fromScanDir, QString f
|
||||||
}
|
}
|
||||||
qDebug("getSavePath, got save_path from temp data: %s", qPrintable(savePath));
|
qDebug("getSavePath, got save_path from temp data: %s", qPrintable(savePath));
|
||||||
} else {
|
} else {
|
||||||
savePath = TorrentPersistentData::getSavePath(hash);
|
savePath = fsutils::fromNativePath(TorrentPersistentData::getSavePath(hash));
|
||||||
qDebug("SavePath got from persistant data is %s", qPrintable(savePath));
|
qDebug("SavePath got from persistant data is %s", qPrintable(savePath));
|
||||||
if (savePath.isEmpty()) {
|
if (savePath.isEmpty()) {
|
||||||
if (fromScanDir && m_scanFolders->downloadInTorrentFolder(filePath)) {
|
if (fromScanDir && m_scanFolders->downloadInTorrentFolder(filePath)) {
|
||||||
|
@ -2649,8 +2625,7 @@ QString QBtSession::getSavePath(const QString &hash, bool fromScanDir, QString f
|
||||||
qDebug("getSavePath, got save_path from persistent data: %s", qPrintable(savePath));
|
qDebug("getSavePath, got save_path from persistent data: %s", qPrintable(savePath));
|
||||||
}
|
}
|
||||||
// Clean path
|
// Clean path
|
||||||
savePath.replace("\\", "/");
|
savePath = fsutils::expandPathAbs(savePath);
|
||||||
savePath = fsutils::expandPath(savePath);
|
|
||||||
if (!savePath.endsWith("/"))
|
if (!savePath.endsWith("/"))
|
||||||
savePath += "/";
|
savePath += "/";
|
||||||
return savePath;
|
return savePath;
|
||||||
|
@ -2684,7 +2659,7 @@ void QBtSession::addMagnetInteractive(const QString& uri)
|
||||||
|
|
||||||
void QBtSession::addMagnetSkipAddDlg(const QString& uri, const QString& save_path, const QString& label) {
|
void QBtSession::addMagnetSkipAddDlg(const QString& uri, const QString& save_path, const QString& label) {
|
||||||
if (!save_path.isEmpty() || !label.isEmpty())
|
if (!save_path.isEmpty() || !label.isEmpty())
|
||||||
savepathLabel_fromurl[uri] = qMakePair(save_path, label);
|
savepathLabel_fromurl[uri] = qMakePair(fsutils::fromNativePath(save_path), label);
|
||||||
addMagnetUri(uri, false);
|
addMagnetUri(uri, false);
|
||||||
emit newDownloadedTorrentFromRss(uri);
|
emit newDownloadedTorrentFromRss(uri);
|
||||||
}
|
}
|
||||||
|
@ -2693,7 +2668,7 @@ void QBtSession::downloadUrlAndSkipDialog(QString url, QString save_path, QStrin
|
||||||
//emit aboutToDownloadFromUrl(url);
|
//emit aboutToDownloadFromUrl(url);
|
||||||
const QUrl qurl = QUrl::fromEncoded(url.toUtf8());
|
const QUrl qurl = QUrl::fromEncoded(url.toUtf8());
|
||||||
if (!save_path.isEmpty() || !label.isEmpty())
|
if (!save_path.isEmpty() || !label.isEmpty())
|
||||||
savepathLabel_fromurl[qurl] = qMakePair(save_path, label);
|
savepathLabel_fromurl[qurl] = qMakePair(fsutils::fromNativePath(save_path), label);
|
||||||
url_skippingDlg << qurl;
|
url_skippingDlg << qurl;
|
||||||
// Launch downloader thread
|
// Launch downloader thread
|
||||||
downloader->downloadTorrentUrl(url, cookies);
|
downloader->downloadTorrentUrl(url, cookies);
|
||||||
|
@ -2705,6 +2680,7 @@ void QBtSession::processDownloadedFile(QString url, QString file_path) {
|
||||||
const int index = url_skippingDlg.indexOf(QUrl::fromEncoded(url.toUtf8()));
|
const int index = url_skippingDlg.indexOf(QUrl::fromEncoded(url.toUtf8()));
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
// Add file to torrent download list
|
// Add file to torrent download list
|
||||||
|
file_path = fsutils::fromNativePath(file_path);
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
// Windows hack
|
// Windows hack
|
||||||
if (!file_path.endsWith(".torrent", Qt::CaseInsensitive)) {
|
if (!file_path.endsWith(".torrent", Qt::CaseInsensitive)) {
|
||||||
|
@ -2766,7 +2742,7 @@ void QBtSession::startUpTorrents() {
|
||||||
if (!known_torrents.contains(hash)) {
|
if (!known_torrents.contains(hash)) {
|
||||||
qDebug("found torrent with hash: %s on hard disk", qPrintable(hash));
|
qDebug("found torrent with hash: %s on hard disk", qPrintable(hash));
|
||||||
std::cerr << "ERROR Detected!!! Adding back torrent " << qPrintable(hash) << " which got lost for some reason." << std::endl;
|
std::cerr << "ERROR Detected!!! Adding back torrent " << qPrintable(hash) << " which got lost for some reason." << std::endl;
|
||||||
addTorrent(torrentBackup.path()+QDir::separator()+hash+".torrent", false, QString(), true);
|
addTorrent(torrentBackup.path()+"/"+hash+".torrent", false, QString(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// End of safety measure
|
// End of safety measure
|
||||||
|
@ -2787,7 +2763,7 @@ void QBtSession::startUpTorrents() {
|
||||||
if (TorrentPersistentData::isMagnet(hash)) {
|
if (TorrentPersistentData::isMagnet(hash)) {
|
||||||
addMagnetUri(TorrentPersistentData::getMagnetUri(hash), true);
|
addMagnetUri(TorrentPersistentData::getMagnetUri(hash), true);
|
||||||
} else {
|
} else {
|
||||||
addTorrent(torrentBackup.path()+QDir::separator()+hash+".torrent", false, QString(), true);
|
addTorrent(torrentBackup.path()+"/"+hash+".torrent", false, QString(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2797,7 +2773,7 @@ void QBtSession::startUpTorrents() {
|
||||||
if (TorrentPersistentData::isMagnet(hash))
|
if (TorrentPersistentData::isMagnet(hash))
|
||||||
addMagnetUri(TorrentPersistentData::getMagnetUri(hash), true);
|
addMagnetUri(TorrentPersistentData::getMagnetUri(hash), true);
|
||||||
else
|
else
|
||||||
addTorrent(torrentBackup.path()+QDir::separator()+hash+".torrent", false, QString(), true);
|
addTorrent(torrentBackup.path()+"/"+hash+".torrent", false, QString(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QIniSettings settings;
|
QIniSettings settings;
|
||||||
|
@ -2857,7 +2833,7 @@ void QBtSession::recoverPersistentData(const QString &hash, const std::vector<ch
|
||||||
if (fast.type() != libtorrent::lazy_entry::dict_t && !ec)
|
if (fast.type() != libtorrent::lazy_entry::dict_t && !ec)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString savePath = QString::fromUtf8(fast.dict_find_string_value("qBt-savePath").c_str());
|
QString savePath = fsutils::fromNativePath(QString::fromUtf8(fast.dict_find_string_value("qBt-savePath").c_str()));
|
||||||
qreal ratioLimit = QString::fromUtf8(fast.dict_find_string_value("qBt-ratioLimit").c_str()).toDouble();
|
qreal ratioLimit = QString::fromUtf8(fast.dict_find_string_value("qBt-ratioLimit").c_str()).toDouble();
|
||||||
QDateTime addedDate = QDateTime::fromTime_t(fast.dict_find_int_value("added_time"));
|
QDateTime addedDate = QDateTime::fromTime_t(fast.dict_find_int_value("added_time"));
|
||||||
QString previousSavePath = QString::fromUtf8(fast.dict_find_string_value("qBt-previousSavePath").c_str());
|
QString previousSavePath = QString::fromUtf8(fast.dict_find_string_value("qBt-previousSavePath").c_str());
|
||||||
|
@ -2877,9 +2853,9 @@ void QBtSession::recoverPersistentData(const QString &hash, const std::vector<ch
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBtSession::backupPersistentData(const QString &hash, boost::shared_ptr<libtorrent::entry> data) {
|
void QBtSession::backupPersistentData(const QString &hash, boost::shared_ptr<libtorrent::entry> data) {
|
||||||
(*data)["qBt-savePath"] = TorrentPersistentData::getSavePath(hash).toUtf8().constData();
|
(*data)["qBt-savePath"] = fsutils::fromNativePath(TorrentPersistentData::getSavePath(hash)).toUtf8().constData();
|
||||||
(*data)["qBt-ratioLimit"] = QString::number(TorrentPersistentData::getRatioLimit(hash)).toUtf8().constData();
|
(*data)["qBt-ratioLimit"] = QString::number(TorrentPersistentData::getRatioLimit(hash)).toUtf8().constData();
|
||||||
(*data)["qBt-previousSavePath"] = TorrentPersistentData::getPreviousPath(hash).toUtf8().constData();
|
(*data)["qBt-previousSavePath"] = fsutils::fromNativePath(TorrentPersistentData::getPreviousPath(hash)).toUtf8().constData();
|
||||||
(*data)["qBt-seedDate"] = TorrentPersistentData::getSeedDate(hash).toTime_t();
|
(*data)["qBt-seedDate"] = TorrentPersistentData::getSeedDate(hash).toTime_t();
|
||||||
(*data)["qBt-label"] = TorrentPersistentData::getLabel(hash).toUtf8().constData();
|
(*data)["qBt-label"] = TorrentPersistentData::getLabel(hash).toUtf8().constData();
|
||||||
(*data)["qBt-queuePosition"] = TorrentPersistentData::getPriority(hash);
|
(*data)["qBt-queuePosition"] = TorrentPersistentData::getPriority(hash);
|
||||||
|
|
|
@ -223,11 +223,9 @@ int QTorrentHandle::num_incomplete() const {
|
||||||
|
|
||||||
QString QTorrentHandle::save_path() const {
|
QString QTorrentHandle::save_path() const {
|
||||||
#if LIBTORRENT_VERSION_NUM < 10000
|
#if LIBTORRENT_VERSION_NUM < 10000
|
||||||
return misc::toQStringU(torrent_handle::save_path())
|
return fsutils::fromNativePath(misc::toQStringU(torrent_handle::save_path()));
|
||||||
.replace("\\", "/");
|
|
||||||
#else
|
#else
|
||||||
return misc::toQStringU(status(torrent_handle::query_save_path).save_path)
|
return fsutils::fromNativePath(misc::toQStringU(status(torrent_handle::query_save_path).save_path));
|
||||||
.replace("\\", "/");
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,13 +234,10 @@ QString QTorrentHandle::save_path_parsed() const {
|
||||||
if (has_metadata() && num_files() == 1) {
|
if (has_metadata() && num_files() == 1) {
|
||||||
p = firstFileSavePath();
|
p = firstFileSavePath();
|
||||||
} else {
|
} else {
|
||||||
p = TorrentPersistentData::getSavePath(hash());
|
p = fsutils::fromNativePath(TorrentPersistentData::getSavePath(hash()));
|
||||||
if (p.isEmpty())
|
if (p.isEmpty())
|
||||||
p = save_path();
|
p = save_path();
|
||||||
}
|
}
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
|
||||||
p.replace("/", "\\");
|
|
||||||
#endif
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,18 +301,19 @@ size_type QTorrentHandle::filesize_at(unsigned int index) const {
|
||||||
|
|
||||||
QString QTorrentHandle::filepath_at(unsigned int index) const {
|
QString QTorrentHandle::filepath_at(unsigned int index) const {
|
||||||
#if LIBTORRENT_VERSION_NUM < 10000
|
#if LIBTORRENT_VERSION_NUM < 10000
|
||||||
return misc::toQStringU(torrent_handle::get_torrent_info().files().file_path(index));
|
return fsutils::fromNativePath(misc::toQStringU(torrent_handle::get_torrent_info().files().file_path(index)));
|
||||||
#else
|
#else
|
||||||
return misc::toQStringU(torrent_handle::torrent_file()->files().file_path(index));
|
return fsutils::fromNativePath(misc::toQStringU(torrent_handle::torrent_file()->files().file_path(index)));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QTorrentHandle::orig_filepath_at(unsigned int index) const {
|
QString QTorrentHandle::orig_filepath_at(unsigned int index) const {
|
||||||
#if LIBTORRENT_VERSION_NUM < 10000
|
#if LIBTORRENT_VERSION_NUM < 10000
|
||||||
return misc::toQStringU(torrent_handle::get_torrent_info().orig_files().file_path(index));
|
return fsutils::fromNativePath(misc::toQStringU(torrent_handle::get_torrent_info().orig_files().file_path(index)));
|
||||||
#else
|
#else
|
||||||
return misc::toQStringU(torrent_handle::torrent_file()->orig_files().file_path(index));
|
return fsutils::fromNativePath(misc::toQStringU(torrent_handle::torrent_file()->orig_files().file_path(index)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
torrent_status::state_t QTorrentHandle::state() const {
|
torrent_status::state_t QTorrentHandle::state() const {
|
||||||
|
@ -379,7 +375,7 @@ QStringList QTorrentHandle::absolute_files_path() const {
|
||||||
QDir saveDir(save_path());
|
QDir saveDir(save_path());
|
||||||
QStringList res;
|
QStringList res;
|
||||||
for (int i = 0; i<num_files(); ++i) {
|
for (int i = 0; i<num_files(); ++i) {
|
||||||
res << QDir::cleanPath(saveDir.absoluteFilePath(filepath_at(i)));
|
res << fsutils::expandPathAbs(saveDir.absoluteFilePath(filepath_at(i)));
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -390,7 +386,7 @@ QStringList QTorrentHandle::absolute_files_path_uneeded() const {
|
||||||
std::vector<int> fp = torrent_handle::file_priorities();
|
std::vector<int> fp = torrent_handle::file_priorities();
|
||||||
for (uint i = 0; i < fp.size(); ++i) {
|
for (uint i = 0; i < fp.size(); ++i) {
|
||||||
if (fp[i] == 0) {
|
if (fp[i] == 0) {
|
||||||
const QString file_path = QDir::cleanPath(saveDir.absoluteFilePath(filepath_at(i)));
|
const QString file_path = fsutils::expandPathAbs(saveDir.absoluteFilePath(filepath_at(i)));
|
||||||
if (file_path.contains(".unwanted"))
|
if (file_path.contains(".unwanted"))
|
||||||
res << file_path;
|
res << file_path;
|
||||||
}
|
}
|
||||||
|
@ -462,10 +458,9 @@ bool QTorrentHandle::priv() const {
|
||||||
|
|
||||||
QString QTorrentHandle::firstFileSavePath() const {
|
QString QTorrentHandle::firstFileSavePath() const {
|
||||||
Q_ASSERT(has_metadata());
|
Q_ASSERT(has_metadata());
|
||||||
QString fsave_path = TorrentPersistentData::getSavePath(hash());
|
QString fsave_path = fsutils::fromNativePath(TorrentPersistentData::getSavePath(hash()));
|
||||||
if (fsave_path.isEmpty())
|
if (fsave_path.isEmpty())
|
||||||
fsave_path = save_path();
|
fsave_path = save_path();
|
||||||
fsave_path.replace("\\", "/");
|
|
||||||
if (!fsave_path.endsWith("/"))
|
if (!fsave_path.endsWith("/"))
|
||||||
fsave_path += "/";
|
fsave_path += "/";
|
||||||
fsave_path += filepath_at(0);
|
fsave_path += filepath_at(0);
|
||||||
|
@ -480,7 +475,7 @@ QString QTorrentHandle::root_path() const
|
||||||
if (num_files() < 2)
|
if (num_files() < 2)
|
||||||
return save_path();
|
return save_path();
|
||||||
QString first_filepath = filepath_at(0);
|
QString first_filepath = filepath_at(0);
|
||||||
const int slashIndex = first_filepath.indexOf(QRegExp("[/\\\\]"));
|
const int slashIndex = first_filepath.indexOf("/");
|
||||||
if (slashIndex >= 0)
|
if (slashIndex >= 0)
|
||||||
return QDir(save_path()).absoluteFilePath(first_filepath.left(slashIndex));
|
return QDir(save_path()).absoluteFilePath(first_filepath.left(slashIndex));
|
||||||
return save_path();
|
return save_path();
|
||||||
|
@ -576,7 +571,7 @@ void QTorrentHandle::move_storage(const QString& new_path) const {
|
||||||
// or move_storage() will fail...
|
// or move_storage() will fail...
|
||||||
QDir().mkpath(new_path);
|
QDir().mkpath(new_path);
|
||||||
// Actually move the storage
|
// Actually move the storage
|
||||||
torrent_handle::move_storage(new_path.toUtf8().constData());
|
torrent_handle::move_storage(fsutils::toNativePath(new_path).toUtf8().constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QTorrentHandle::save_torrent_file(const QString& path) const {
|
bool QTorrentHandle::save_torrent_file(const QString& path) const {
|
||||||
|
@ -651,7 +646,7 @@ void QTorrentHandle::prioritize_files(const vector<int> &files) const {
|
||||||
if (created) {
|
if (created) {
|
||||||
// Hide the folder on Windows
|
// Hide the folder on Windows
|
||||||
qDebug() << "Hiding folder (Windows)";
|
qDebug() << "Hiding folder (Windows)";
|
||||||
wstring win_path = unwanted_abspath.replace("/","\\").toStdWString();
|
wstring win_path = fsutils::toNativePath(unwanted_abspath).toStdWString();
|
||||||
DWORD dwAttrs = GetFileAttributesW(win_path.c_str());
|
DWORD dwAttrs = GetFileAttributesW(win_path.c_str());
|
||||||
bool ret = SetFileAttributesW(win_path.c_str(), dwAttrs|FILE_ATTRIBUTE_HIDDEN);
|
bool ret = SetFileAttributesW(win_path.c_str(), dwAttrs|FILE_ATTRIBUTE_HIDDEN);
|
||||||
Q_ASSERT(ret != 0); Q_UNUSED(ret);
|
Q_ASSERT(ret != 0); Q_UNUSED(ret);
|
||||||
|
@ -676,8 +671,8 @@ void QTorrentHandle::prioritize_files(const vector<int> &files) const {
|
||||||
else
|
else
|
||||||
rename_file(i, QDir(new_relpath).filePath(old_name));
|
rename_file(i, QDir(new_relpath).filePath(old_name));
|
||||||
// Remove .unwanted directory if empty
|
// Remove .unwanted directory if empty
|
||||||
qDebug() << "Attempting to remove .unwanted folder at " << QDir(spath + QDir::separator() + new_relpath).absoluteFilePath(".unwanted");
|
qDebug() << "Attempting to remove .unwanted folder at " << QDir(spath + "/" + new_relpath).absoluteFilePath(".unwanted");
|
||||||
QDir(spath + QDir::separator() + new_relpath).rmdir(".unwanted");
|
QDir(spath + "/" + new_relpath).rmdir(".unwanted");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -727,7 +722,7 @@ void QTorrentHandle::prioritize_first_last_piece(bool b) const {
|
||||||
|
|
||||||
void QTorrentHandle::rename_file(int index, const QString& name) const {
|
void QTorrentHandle::rename_file(int index, const QString& name) const {
|
||||||
qDebug() << Q_FUNC_INFO << index << name;
|
qDebug() << Q_FUNC_INFO << index << name;
|
||||||
torrent_handle::rename_file(index, std::string(name.toUtf8().constData()));
|
torrent_handle::rename_file(index, std::string(fsutils::toNativePath(name).toUtf8().constData()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "torrentmodel.h"
|
#include "torrentmodel.h"
|
||||||
#include "torrentpersistentdata.h"
|
#include "torrentpersistentdata.h"
|
||||||
#include "qbtsession.h"
|
#include "qbtsession.h"
|
||||||
|
#include "fs_utils.h"
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
|
||||||
|
@ -215,7 +216,7 @@ QVariant TorrentModelItem::data(int column, int role) const
|
||||||
case TR_TIME_ELAPSED:
|
case TR_TIME_ELAPSED:
|
||||||
return (role == Qt::DisplayRole) ? m_torrent.active_time() : m_torrent.seeding_time();
|
return (role == Qt::DisplayRole) ? m_torrent.active_time() : m_torrent.seeding_time();
|
||||||
case TR_SAVE_PATH:
|
case TR_SAVE_PATH:
|
||||||
return m_torrent.save_path_parsed();
|
return fsutils::toNativePath(m_torrent.save_path_parsed());
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,7 +225,7 @@ void AutomatedRssDownloader::updateRuleDefinitionBox()
|
||||||
ui->lineContains->setText(rule->mustContain());
|
ui->lineContains->setText(rule->mustContain());
|
||||||
ui->lineNotContains->setText(rule->mustNotContain());
|
ui->lineNotContains->setText(rule->mustNotContain());
|
||||||
ui->saveDiffDir_check->setChecked(!rule->savePath().isEmpty());
|
ui->saveDiffDir_check->setChecked(!rule->savePath().isEmpty());
|
||||||
ui->lineSavePath->setText(rule->savePath());
|
ui->lineSavePath->setText(fsutils::toNativePath(rule->savePath()));
|
||||||
ui->checkRegex->setChecked(rule->useRegex());
|
ui->checkRegex->setChecked(rule->useRegex());
|
||||||
if (rule->label().isEmpty()) {
|
if (rule->label().isEmpty()) {
|
||||||
ui->comboLabel->setCurrentIndex(-1);
|
ui->comboLabel->setCurrentIndex(-1);
|
||||||
|
@ -362,7 +362,7 @@ void AutomatedRssDownloader::on_browseSP_clicked()
|
||||||
{
|
{
|
||||||
QString save_path = QFileDialog::getExistingDirectory(this, tr("Destination directory"), QDir::homePath());
|
QString save_path = QFileDialog::getExistingDirectory(this, tr("Destination directory"), QDir::homePath());
|
||||||
if (!save_path.isEmpty())
|
if (!save_path.isEmpty())
|
||||||
ui->lineSavePath->setText(save_path);
|
ui->lineSavePath->setText(fsutils::toNativePath(save_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutomatedRssDownloader::on_exportBtn_clicked()
|
void AutomatedRssDownloader::on_exportBtn_clicked()
|
||||||
|
|
|
@ -113,7 +113,7 @@ bool RssDownloadRule::operator==(const RssDownloadRule &other) const {
|
||||||
void RssDownloadRule::setSavePath(const QString &save_path)
|
void RssDownloadRule::setSavePath(const QString &save_path)
|
||||||
{
|
{
|
||||||
if (!save_path.isEmpty() && QDir(save_path) != QDir(Preferences().getSavePath()))
|
if (!save_path.isEmpty() && QDir(save_path) != QDir(Preferences().getSavePath()))
|
||||||
m_savePath = save_path;
|
m_savePath = fsutils::fromNativePath(save_path);
|
||||||
else
|
else
|
||||||
m_savePath = QString();
|
m_savePath = QString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,6 +147,7 @@ void RssManager::saveStreamList() const
|
||||||
QStringList aliases;
|
QStringList aliases;
|
||||||
RssFeedList streams = getAllFeeds();
|
RssFeedList streams = getAllFeeds();
|
||||||
foreach (const RssFeedPtr& stream, streams) {
|
foreach (const RssFeedPtr& stream, streams) {
|
||||||
|
// This backslash has nothing to do with path handling
|
||||||
QString stream_path = stream->pathHierarchy().join("\\");
|
QString stream_path = stream->pathHierarchy().join("\\");
|
||||||
if (stream_path.isNull())
|
if (stream_path.isNull())
|
||||||
stream_path = "";
|
stream_path = "";
|
||||||
|
|
|
@ -214,7 +214,7 @@ void RssParser::parseRssFile(const QString& feedUrl, const QString& filePath)
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << feedUrl << filePath;
|
qDebug() << Q_FUNC_INFO << feedUrl << filePath;
|
||||||
m_mutex.lock();
|
m_mutex.lock();
|
||||||
ParsingJob job = {feedUrl, filePath};
|
ParsingJob job = { feedUrl, fsutils::fromNativePath(filePath) };
|
||||||
m_queue.enqueue(job);
|
m_queue.enqueue(job);
|
||||||
// Wake up thread.
|
// Wake up thread.
|
||||||
if (m_queue.count() == 1) {
|
if (m_queue.count() == 1) {
|
||||||
|
|
|
@ -82,12 +82,8 @@ QVariant ScanFoldersModel::data(const QModelIndex &index, int role) const {
|
||||||
|
|
||||||
const PathData* pathData = m_pathList.at(index.row());
|
const PathData* pathData = m_pathList.at(index.row());
|
||||||
if (index.column() == PathColumn && role == Qt::DisplayRole) {
|
if (index.column() == PathColumn && role == Qt::DisplayRole) {
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
|
||||||
QString ret = pathData->path;
|
return fsutils::toNativePath(pathData->path);
|
||||||
return ret.replace("/", "\\");
|
|
||||||
#else
|
|
||||||
return pathData->path;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (index.column() == DownloadAtTorrentColumn && role == Qt::CheckStateRole)
|
if (index.column() == DownloadAtTorrentColumn && role == Qt::CheckStateRole)
|
||||||
return pathData->downloadAtPath ? Qt::Checked : Qt::Unchecked;
|
return pathData->downloadAtPath ? Qt::Checked : Qt::Unchecked;
|
||||||
|
@ -181,7 +177,7 @@ bool ScanFoldersModel::downloadInTorrentFolder(const QString &filePath) const {
|
||||||
int ScanFoldersModel::findPathData(const QString &path) const {
|
int ScanFoldersModel::findPathData(const QString &path) const {
|
||||||
for (int i = 0; i < m_pathList.count(); ++i) {
|
for (int i = 0; i < m_pathList.count(); ++i) {
|
||||||
const PathData* pathData = m_pathList.at(i);
|
const PathData* pathData = m_pathList.at(i);
|
||||||
if (pathData->path == path)
|
if (pathData->path == fsutils::fromNativePath(path))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,7 @@ void engineSelectDlg::on_actionUninstall_triggered() {
|
||||||
}else {
|
}else {
|
||||||
// Proceed with uninstall
|
// Proceed with uninstall
|
||||||
// remove it from hard drive
|
// remove it from hard drive
|
||||||
QDir enginesFolder(fsutils::searchEngineLocation()+QDir::separator()+"engines");
|
QDir enginesFolder(fsutils::searchEngineLocation() + "/engines");
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
filters << id+".*";
|
filters << id+".*";
|
||||||
QStringList files = enginesFolder.entryList(filters, QDir::Files, QDir::Unsorted);
|
QStringList files = enginesFolder.entryList(filters, QDir::Files, QDir::Unsorted);
|
||||||
|
@ -224,7 +224,7 @@ QTreeWidgetItem* engineSelectDlg::findItemWithID(QString id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool engineSelectDlg::isUpdateNeeded(QString plugin_name, qreal new_version) const {
|
bool engineSelectDlg::isUpdateNeeded(QString plugin_name, qreal new_version) const {
|
||||||
qreal old_version = SearchEngine::getPluginVersion(fsutils::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+plugin_name+".py");
|
qreal old_version = SearchEngine::getPluginVersion(fsutils::searchEngineLocation() + "/engines/" + plugin_name + ".py");
|
||||||
qDebug("IsUpdate needed? tobeinstalled: %.2f, alreadyinstalled: %.2f", new_version, old_version);
|
qDebug("IsUpdate needed? tobeinstalled: %.2f, alreadyinstalled: %.2f", new_version, old_version);
|
||||||
return (new_version > old_version);
|
return (new_version > old_version);
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Process with install
|
// Process with install
|
||||||
QString dest_path = fsutils::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+plugin_name+".py";
|
QString dest_path = fsutils::searchEngineLocation() + "/engines/" + plugin_name + ".py";
|
||||||
bool update = false;
|
bool update = false;
|
||||||
if (QFile::exists(dest_path)) {
|
if (QFile::exists(dest_path)) {
|
||||||
// Backup in case install fails
|
// Backup in case install fails
|
||||||
|
@ -304,12 +304,12 @@ void engineSelectDlg::addNewEngine(QString engine_name) {
|
||||||
setRowColor(pluginsTree->indexOfTopLevelItem(item), "red");
|
setRowColor(pluginsTree->indexOfTopLevelItem(item), "red");
|
||||||
}
|
}
|
||||||
// Handle icon
|
// Handle icon
|
||||||
QString iconPath = fsutils::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+engine->getName()+".png";
|
QString iconPath = fsutils::searchEngineLocation() + "/engines/" + engine->getName() + ".png";
|
||||||
if (QFile::exists(iconPath)) {
|
if (QFile::exists(iconPath)) {
|
||||||
// Good, we already have the icon
|
// Good, we already have the icon
|
||||||
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath)));
|
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath)));
|
||||||
} else {
|
} else {
|
||||||
iconPath = fsutils::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+engine->getName()+".ico";
|
iconPath = fsutils::searchEngineLocation() + "/engines/" + engine->getName() + ".ico";
|
||||||
if (QFile::exists(iconPath)) { // ICO support
|
if (QFile::exists(iconPath)) { // ICO support
|
||||||
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath)));
|
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath)));
|
||||||
} else {
|
} else {
|
||||||
|
@ -355,7 +355,7 @@ void engineSelectDlg::askForLocalPlugin() {
|
||||||
QString path;
|
QString path;
|
||||||
foreach (path, pathsList) {
|
foreach (path, pathsList) {
|
||||||
if (path.endsWith(".py", Qt::CaseInsensitive)) {
|
if (path.endsWith(".py", Qt::CaseInsensitive)) {
|
||||||
QString plugin_name = path.split(QDir::separator()).last();
|
QString plugin_name = path.split("/").last();
|
||||||
plugin_name.replace(".py", "", Qt::CaseInsensitive);
|
plugin_name.replace(".py", "", Qt::CaseInsensitive);
|
||||||
installPlugin(path, plugin_name);
|
installPlugin(path, plugin_name);
|
||||||
}
|
}
|
||||||
|
@ -409,6 +409,7 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
|
void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
|
||||||
|
filePath = fsutils::fromNativePath(filePath);
|
||||||
setCursor(QCursor(Qt::ArrowCursor));
|
setCursor(QCursor(Qt::ArrowCursor));
|
||||||
qDebug("engineSelectDlg received %s", qPrintable(url));
|
qDebug("engineSelectDlg received %s", qPrintable(url));
|
||||||
if (url.endsWith("favicon.ico", Qt::CaseInsensitive)) {
|
if (url.endsWith("favicon.ico", Qt::CaseInsensitive)) {
|
||||||
|
@ -423,9 +424,9 @@ void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
|
||||||
QFile icon(filePath);
|
QFile icon(filePath);
|
||||||
icon.open(QIODevice::ReadOnly);
|
icon.open(QIODevice::ReadOnly);
|
||||||
if (ICOHandler::canRead(&icon))
|
if (ICOHandler::canRead(&icon))
|
||||||
iconPath = fsutils::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+id+".ico";
|
iconPath = fsutils::searchEngineLocation() + "/engines/" + id + ".ico";
|
||||||
else
|
else
|
||||||
iconPath = fsutils::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+id+".png";
|
iconPath = fsutils::searchEngineLocation() + "/engines/" + id + ".png";
|
||||||
QFile::copy(filePath, iconPath);
|
QFile::copy(filePath, iconPath);
|
||||||
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath)));
|
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ bool SearchEngine::addPythonPathToEnv() {
|
||||||
}
|
}
|
||||||
path_envar = python_path+";"+path_envar;
|
path_envar = python_path+";"+path_envar;
|
||||||
qDebug("New PATH envvar is: %s", qPrintable(path_envar));
|
qDebug("New PATH envvar is: %s", qPrintable(path_envar));
|
||||||
qputenv("PATH", path_envar.toLocal8Bit());
|
qputenv("PATH", fsutils::toNativePath(path_envar).toLocal8Bit());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -148,7 +148,7 @@ void SearchEngine::pythonDownloadSuccess(QString url, QString file_path) {
|
||||||
QProcess installer;
|
QProcess installer;
|
||||||
qDebug("Launching Python installer in passive mode...");
|
qDebug("Launching Python installer in passive mode...");
|
||||||
|
|
||||||
installer.start("msiexec.exe /passive /i "+file_path.replace("/", "\\")+".msi");
|
installer.start("msiexec.exe /passive /i " + fsutils::toNativePath(file_path) + ".msi");
|
||||||
// Wait for setup to complete
|
// Wait for setup to complete
|
||||||
installer.waitForFinished();
|
installer.waitForFinished();
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ void SearchEngine::on_search_button_clicked() {
|
||||||
// Getting checked search engines
|
// Getting checked search engines
|
||||||
QStringList params;
|
QStringList params;
|
||||||
search_stopped = false;
|
search_stopped = false;
|
||||||
params << fsutils::searchEngineLocation()+QDir::separator()+"nova2.py";
|
params << fsutils::toNativePath(fsutils::searchEngineLocation() + "/nova2.py");
|
||||||
params << supported_engines->enginesEnabled().join(",");
|
params << supported_engines->enginesEnabled().join(",");
|
||||||
qDebug("Search with category: %s", qPrintable(selectedCategory()));
|
qDebug("Search with category: %s", qPrintable(selectedCategory()));
|
||||||
params << selectedCategory();
|
params << selectedCategory();
|
||||||
|
@ -343,7 +343,7 @@ void SearchEngine::downloadTorrent(QString engine_url, QString torrent_url) {
|
||||||
connect(downloadProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(downloadFinished(int,QProcess::ExitStatus)));
|
connect(downloadProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(downloadFinished(int,QProcess::ExitStatus)));
|
||||||
downloaders << downloadProcess;
|
downloaders << downloadProcess;
|
||||||
QStringList params;
|
QStringList params;
|
||||||
params << fsutils::searchEngineLocation()+QDir::separator()+"nova2dl.py";
|
params << fsutils::toNativePath(fsutils::searchEngineLocation() + "/nova2dl.py");
|
||||||
params << engine_url;
|
params << engine_url;
|
||||||
params << torrent_url;
|
params << torrent_url;
|
||||||
// Launch search
|
// Launch search
|
||||||
|
@ -411,7 +411,7 @@ void SearchEngine::updateNova() {
|
||||||
if (!search_dir.exists("engines")) {
|
if (!search_dir.exists("engines")) {
|
||||||
search_dir.mkdir("engines");
|
search_dir.mkdir("engines");
|
||||||
}
|
}
|
||||||
QFile package_file2(search_dir.absolutePath().replace("\\", "/")+"/engines/__init__.py");
|
QFile package_file2(search_dir.absolutePath() + "/engines/__init__.py");
|
||||||
package_file2.open(QIODevice::WriteOnly | QIODevice::Text);
|
package_file2.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||||
package_file2.close();
|
package_file2.close();
|
||||||
// Copy search plugin files (if necessary)
|
// Copy search plugin files (if necessary)
|
||||||
|
|
|
@ -144,7 +144,7 @@ public slots:
|
||||||
QProcess nova;
|
QProcess nova;
|
||||||
nova.setEnvironment(QProcess::systemEnvironment());
|
nova.setEnvironment(QProcess::systemEnvironment());
|
||||||
QStringList params;
|
QStringList params;
|
||||||
params << fsutils::searchEngineLocation()+QDir::separator()+"nova2.py";
|
params << fsutils::toNativePath(fsutils::searchEngineLocation()+"/nova2.py");
|
||||||
params << "--capabilities";
|
params << "--capabilities";
|
||||||
nova.start("python", params, QIODevice::ReadOnly);
|
nova.start("python", params, QIODevice::ReadOnly);
|
||||||
nova.waitForStarted();
|
nova.waitForStarted();
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include "iconprovider.h"
|
#include "iconprovider.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "fs_utils.h"
|
||||||
#include "torrentcontentmodel.h"
|
#include "torrentcontentmodel.h"
|
||||||
#include "torrentcontentmodelitem.h"
|
#include "torrentcontentmodelitem.h"
|
||||||
#include "torrentcontentmodelfolder.h"
|
#include "torrentcontentmodelfolder.h"
|
||||||
|
@ -283,9 +284,9 @@ void TorrentContentModel::setupModelData(const libtorrent::torrent_info& t)
|
||||||
for (int i = 0; i < t.num_files(); ++i) {
|
for (int i = 0; i < t.num_files(); ++i) {
|
||||||
const libtorrent::file_entry& fentry = t.file_at(i);
|
const libtorrent::file_entry& fentry = t.file_at(i);
|
||||||
current_parent = m_rootItem;
|
current_parent = m_rootItem;
|
||||||
QString path = misc::toQStringU(fentry.path);
|
QString path = fsutils::fromNativePath(misc::toQStringU(fentry.path));
|
||||||
// Iterate of parts of the path to create necessary folders
|
// Iterate of parts of the path to create necessary folders
|
||||||
QStringList pathFolders = path.split(QRegExp("[/\\\\]"), QString::SkipEmptyParts);
|
QStringList pathFolders = path.split("/", QString::SkipEmptyParts);
|
||||||
pathFolders.removeLast();
|
pathFolders.removeLast();
|
||||||
foreach (const QString& pathPart, pathFolders) {
|
foreach (const QString& pathPart, pathFolders) {
|
||||||
if (pathPart == ".unwanted")
|
if (pathPart == ".unwanted")
|
||||||
|
|
|
@ -74,10 +74,7 @@ void TorrentCreatorDlg::on_addFolder_button_clicked() {
|
||||||
QString dir = QFileDialog::getExistingDirectory(this, tr("Select a folder to add to the torrent"), last_path, QFileDialog::ShowDirsOnly);
|
QString dir = QFileDialog::getExistingDirectory(this, tr("Select a folder to add to the torrent"), last_path, QFileDialog::ShowDirsOnly);
|
||||||
if (!dir.isEmpty()) {
|
if (!dir.isEmpty()) {
|
||||||
settings.setValue("CreateTorrent/last_add_path", dir);
|
settings.setValue("CreateTorrent/last_add_path", dir);
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
textInputPath->setText(fsutils::toNativePath(dir));
|
||||||
dir.replace("/", "\\");
|
|
||||||
#endif
|
|
||||||
textInputPath->setText(dir);
|
|
||||||
// Update piece size
|
// Update piece size
|
||||||
if (checkAutoPieceSize->isChecked())
|
if (checkAutoPieceSize->isChecked())
|
||||||
updateOptimalPieceSize();
|
updateOptimalPieceSize();
|
||||||
|
@ -90,10 +87,7 @@ void TorrentCreatorDlg::on_addFile_button_clicked() {
|
||||||
QString file = QFileDialog::getOpenFileName(this, tr("Select a file to add to the torrent"), last_path);
|
QString file = QFileDialog::getOpenFileName(this, tr("Select a file to add to the torrent"), last_path);
|
||||||
if (!file.isEmpty()) {
|
if (!file.isEmpty()) {
|
||||||
settings.setValue("CreateTorrent/last_add_path", fsutils::branchPath(file));
|
settings.setValue("CreateTorrent/last_add_path", fsutils::branchPath(file));
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
textInputPath->setText(fsutils::toNativePath(file));
|
||||||
file.replace("/", "\\");
|
|
||||||
#endif
|
|
||||||
textInputPath->setText(file);
|
|
||||||
// Update piece size
|
// Update piece size
|
||||||
if (checkAutoPieceSize->isChecked())
|
if (checkAutoPieceSize->isChecked())
|
||||||
updateOptimalPieceSize();
|
updateOptimalPieceSize();
|
||||||
|
@ -106,8 +100,8 @@ int TorrentCreatorDlg::getPieceSize() const {
|
||||||
|
|
||||||
// Main function that create a .torrent file
|
// Main function that create a .torrent file
|
||||||
void TorrentCreatorDlg::on_createButton_clicked() {
|
void TorrentCreatorDlg::on_createButton_clicked() {
|
||||||
QString input = textInputPath->text().trimmed();
|
QString input = fsutils::fromNativePath(textInputPath->text()).trimmed();
|
||||||
if (input.endsWith(QDir::separator()))
|
if (input.endsWith("/"))
|
||||||
input.chop(1);
|
input.chop(1);
|
||||||
if (input.isEmpty()) {
|
if (input.isEmpty()) {
|
||||||
QMessageBox::critical(0, tr("No input path set"), tr("Please type an input path first"));
|
QMessageBox::critical(0, tr("No input path set"), tr("Please type an input path first"));
|
||||||
|
@ -141,7 +135,7 @@ void TorrentCreatorDlg::on_createButton_clicked() {
|
||||||
connect(creatorThread, SIGNAL(creationSuccess(QString, QString)), this, SLOT(handleCreationSuccess(QString, QString)));
|
connect(creatorThread, SIGNAL(creationSuccess(QString, QString)), this, SLOT(handleCreationSuccess(QString, QString)));
|
||||||
connect(creatorThread, SIGNAL(creationFailure(QString)), this, SLOT(handleCreationFailure(QString)));
|
connect(creatorThread, SIGNAL(creationFailure(QString)), this, SLOT(handleCreationFailure(QString)));
|
||||||
connect(creatorThread, SIGNAL(updateProgress(int)), this, SLOT(updateProgressBar(int)));
|
connect(creatorThread, SIGNAL(updateProgress(int)), this, SLOT(updateProgressBar(int)));
|
||||||
creatorThread->create(input, QDir::toNativeSeparators(destination), trackers, url_seeds, comment, check_private->isChecked(), getPieceSize());
|
creatorThread->create(input, destination, trackers, url_seeds, comment, check_private->isChecked(), getPieceSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentCreatorDlg::handleCreationFailure(QString msg) {
|
void TorrentCreatorDlg::handleCreationFailure(QString msg) {
|
||||||
|
@ -159,7 +153,7 @@ void TorrentCreatorDlg::handleCreationSuccess(QString path, QString branch_path)
|
||||||
// Create save path temp data
|
// Create save path temp data
|
||||||
boost::intrusive_ptr<torrent_info> t;
|
boost::intrusive_ptr<torrent_info> t;
|
||||||
try {
|
try {
|
||||||
t = new torrent_info(path.toUtf8().data());
|
t = new torrent_info(fsutils::toNativePath(path).toUtf8().data());
|
||||||
} catch(std::exception&) {
|
} catch(std::exception&) {
|
||||||
QMessageBox::critical(0, tr("Torrent creation"), tr("Created torrent file is invalid. It won't be added to download list."));
|
QMessageBox::critical(0, tr("Torrent creation"), tr("Created torrent file is invalid. It won't be added to download list."));
|
||||||
return;
|
return;
|
||||||
|
@ -173,7 +167,7 @@ void TorrentCreatorDlg::handleCreationSuccess(QString path, QString branch_path)
|
||||||
if (checkIgnoreShareLimits->isChecked())
|
if (checkIgnoreShareLimits->isChecked())
|
||||||
QBtSession::instance()->setMaxRatioPerTorrent(hash, -1);
|
QBtSession::instance()->setMaxRatioPerTorrent(hash, -1);
|
||||||
}
|
}
|
||||||
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent was created successfully:")+" "+path);
|
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent was created successfully:")+" "+fsutils::toNativePath(path));
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,8 @@ bool file_filter(std::string const& f)
|
||||||
|
|
||||||
void TorrentCreatorThread::create(QString _input_path, QString _save_path, QStringList _trackers, QStringList _url_seeds, QString _comment, bool _is_private, int _piece_size)
|
void TorrentCreatorThread::create(QString _input_path, QString _save_path, QStringList _trackers, QStringList _url_seeds, QString _comment, bool _is_private, int _piece_size)
|
||||||
{
|
{
|
||||||
input_path = _input_path;
|
input_path = fsutils::fromNativePath(_input_path);
|
||||||
save_path = _save_path;
|
save_path = fsutils::fromNativePath(_save_path);
|
||||||
if (QFile(save_path).exists())
|
if (QFile(save_path).exists())
|
||||||
fsutils::forceRemove(save_path);
|
fsutils::forceRemove(save_path);
|
||||||
trackers = _trackers;
|
trackers = _trackers;
|
||||||
|
@ -86,7 +86,7 @@ void TorrentCreatorThread::run() {
|
||||||
try {
|
try {
|
||||||
file_storage fs;
|
file_storage fs;
|
||||||
// Adding files to the torrent
|
// Adding files to the torrent
|
||||||
libtorrent::add_files(fs, input_path.toUtf8().constData(), file_filter);
|
libtorrent::add_files(fs, fsutils::toNativePath(input_path).toUtf8().constData(), file_filter);
|
||||||
if (abort) return;
|
if (abort) return;
|
||||||
create_torrent t(fs, piece_size);
|
create_torrent t(fs, piece_size);
|
||||||
|
|
||||||
|
@ -109,8 +109,8 @@ void TorrentCreatorThread::run() {
|
||||||
}
|
}
|
||||||
if (abort) return;
|
if (abort) return;
|
||||||
// calculate the hash for all pieces
|
// calculate the hash for all pieces
|
||||||
const QString parent_path = fsutils::branchPath(input_path) + QDir::separator();
|
const QString parent_path = fsutils::branchPath(input_path) + "/";
|
||||||
set_piece_hashes(t, parent_path.toUtf8().constData(), boost::bind<void>(&sendProgressUpdateSignal, _1, t.num_pieces(), this));
|
set_piece_hashes(t, fsutils::toNativePath(parent_path).toUtf8().constData(), boost::bind<void>(&sendProgressUpdateSignal, _1, t.num_pieces(), this));
|
||||||
// Set qBittorrent as creator and add user comment to
|
// Set qBittorrent as creator and add user comment to
|
||||||
// torrent_info structure
|
// torrent_info structure
|
||||||
t.set_creator(creator_str.toUtf8().constData());
|
t.set_creator(creator_str.toUtf8().constData());
|
||||||
|
@ -122,12 +122,12 @@ void TorrentCreatorThread::run() {
|
||||||
qDebug("Saving to %s", qPrintable(save_path));
|
qDebug("Saving to %s", qPrintable(save_path));
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
wchar_t *wsave_path = new wchar_t[save_path.length()+1];
|
wchar_t *wsave_path = new wchar_t[save_path.length()+1];
|
||||||
int len = save_path.toWCharArray(wsave_path);
|
int len = fsutils::toNativePath(save_path).toWCharArray(wsave_path);
|
||||||
wsave_path[len] = '\0';
|
wsave_path[len] = '\0';
|
||||||
std::ofstream outfile(wsave_path, std::ios_base::out|std::ios_base::binary);
|
std::ofstream outfile(wsave_path, std::ios_base::out|std::ios_base::binary);
|
||||||
delete[] wsave_path;
|
delete[] wsave_path;
|
||||||
#else
|
#else
|
||||||
std::ofstream outfile(save_path.toLocal8Bit().constData(), std::ios_base::out|std::ios_base::binary);
|
std::ofstream outfile(fsutils::toNativePath(save_path).toLocal8Bit().constData(), std::ios_base::out|std::ios_base::binary);
|
||||||
#endif
|
#endif
|
||||||
if (outfile.fail())
|
if (outfile.fail())
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
|
|
|
@ -96,11 +96,7 @@ void TorrentImportDlg::on_browseContentBtn_clicked()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Update display
|
// Update display
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
ui->lineContent->setText(fsutils::toNativePath(m_contentPath));
|
||||||
ui->lineContent->setText(m_contentPath.replace("/", "\\"));
|
|
||||||
#else
|
|
||||||
ui->lineContent->setText(m_contentPath);
|
|
||||||
#endif
|
|
||||||
// Check file size
|
// Check file size
|
||||||
const qint64 file_size = QFile(m_contentPath).size();
|
const qint64 file_size = QFile(m_contentPath).size();
|
||||||
if (t->file_at(0).size == file_size) {
|
if (t->file_at(0).size == file_size) {
|
||||||
|
@ -112,7 +108,7 @@ void TorrentImportDlg::on_browseContentBtn_clicked()
|
||||||
ui->checkSkipCheck->setEnabled(false);
|
ui->checkSkipCheck->setEnabled(false);
|
||||||
}
|
}
|
||||||
// Handle file renaming
|
// Handle file renaming
|
||||||
QStringList parts = m_contentPath.replace("\\", "/").split("/");
|
QStringList parts = m_contentPath.split("/");
|
||||||
QString new_file_name = parts.takeLast();
|
QString new_file_name = parts.takeLast();
|
||||||
if (new_file_name != file_name) {
|
if (new_file_name != file_name) {
|
||||||
qDebug("The file has been renamed");
|
qDebug("The file has been renamed");
|
||||||
|
@ -132,20 +128,16 @@ void TorrentImportDlg::on_browseContentBtn_clicked()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Update the display
|
// Update the display
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
ui->lineContent->setText(fsutils::toNativePath(m_contentPath));
|
||||||
ui->lineContent->setText(m_contentPath.replace("/", "\\"));
|
|
||||||
#else
|
|
||||||
ui->lineContent->setText(m_contentPath);
|
|
||||||
#endif
|
|
||||||
bool size_mismatch = false;
|
bool size_mismatch = false;
|
||||||
QDir content_dir(m_contentPath);
|
QDir content_dir(m_contentPath);
|
||||||
content_dir.cdUp();
|
content_dir.cdUp();
|
||||||
// Check file sizes
|
// Check file sizes
|
||||||
for (int i=0; i<t->num_files(); ++i) {
|
for (int i=0; i<t->num_files(); ++i) {
|
||||||
const QString rel_path = misc::toQStringU(t->file_at(i).path);
|
const QString rel_path = misc::toQStringU(t->file_at(i).path);
|
||||||
if (QFile(QDir::cleanPath(content_dir.absoluteFilePath(rel_path))).size() != t->file_at(i).size) {
|
if (QFile(fsutils::expandPath(content_dir.absoluteFilePath(rel_path))).size() != t->file_at(i).size) {
|
||||||
qDebug("%s is %lld",
|
qDebug("%s is %lld",
|
||||||
qPrintable(QDir::cleanPath(content_dir.absoluteFilePath(rel_path))), (long long int) QFile(QDir::cleanPath(content_dir.absoluteFilePath(rel_path))).size());
|
qPrintable(fsutils::expandPath(content_dir.absoluteFilePath(rel_path))), (long long int) QFile(fsutils::expandPath(content_dir.absoluteFilePath(rel_path))).size());
|
||||||
qDebug("%s is %lld",
|
qDebug("%s is %lld",
|
||||||
qPrintable(rel_path), (long long int)t->file_at(i).size);
|
qPrintable(rel_path), (long long int)t->file_at(i).size);
|
||||||
size_mismatch = true;
|
size_mismatch = true;
|
||||||
|
@ -206,8 +198,8 @@ void TorrentImportDlg::importTorrent()
|
||||||
QBtSession::instance()->addTorrent(torrent_path);
|
QBtSession::instance()->addTorrent(torrent_path);
|
||||||
// Remember the last opened folder
|
// Remember the last opened folder
|
||||||
QIniSettings settings;
|
QIniSettings settings;
|
||||||
settings.setValue(QString::fromUtf8("MainWindowLastDir"), torrent_path);
|
settings.setValue(QString::fromUtf8("MainWindowLastDir"), fsutils::fromNativePath(torrent_path));
|
||||||
settings.setValue("TorrentImport/LastContentDir", content_path);
|
settings.setValue("TorrentImport/LastContentDir", fsutils::fromNativePath(content_path));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug() << Q_FUNC_INFO << "EXIT";
|
qDebug() << Q_FUNC_INFO << "EXIT";
|
||||||
|
@ -218,7 +210,7 @@ void TorrentImportDlg::loadTorrent(const QString &torrent_path)
|
||||||
{
|
{
|
||||||
// Load the torrent file
|
// Load the torrent file
|
||||||
try {
|
try {
|
||||||
t = new torrent_info(torrent_path.toUtf8().constData());
|
t = new torrent_info(fsutils::toNativePath(torrent_path).toUtf8().constData());
|
||||||
if (!t->is_valid() || t->num_files() == 0)
|
if (!t->is_valid() || t->num_files() == 0)
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
} catch(std::exception&) {
|
} catch(std::exception&) {
|
||||||
|
@ -228,12 +220,7 @@ void TorrentImportDlg::loadTorrent(const QString &torrent_path)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Update display
|
// Update display
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
ui->lineTorrent->setText(fsutils::toNativePath(torrent_path));
|
||||||
QString tmp = torrent_path;
|
|
||||||
ui->lineTorrent->setText(tmp.replace("/", "\\"));
|
|
||||||
#else
|
|
||||||
ui->lineTorrent->setText(torrent_path);
|
|
||||||
#endif
|
|
||||||
ui->browseContentBtn->setEnabled(true);
|
ui->browseContentBtn->setEnabled(true);
|
||||||
// Load the file names
|
// Load the file names
|
||||||
initializeFilesPath();
|
initializeFilesPath();
|
||||||
|
@ -244,7 +231,7 @@ void TorrentImportDlg::initializeFilesPath()
|
||||||
m_filesPath.clear();
|
m_filesPath.clear();
|
||||||
// Loads files path in the torrent
|
// Loads files path in the torrent
|
||||||
for (int i=0; i<t->num_files(); ++i) {
|
for (int i=0; i<t->num_files(); ++i) {
|
||||||
m_filesPath << misc::toQStringU(t->file_at(i).path).replace("\\", "/");
|
m_filesPath << fsutils::fromNativePath(misc::toQStringU(t->file_at(i).path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
class TorrentTempData {
|
class TorrentTempData {
|
||||||
|
// This class stores strings w/o modifying separators
|
||||||
public:
|
public:
|
||||||
static bool hasTempData(const QString &hash) {
|
static bool hasTempData(const QString &hash) {
|
||||||
return data.contains(hash);
|
return data.contains(hash);
|
||||||
|
@ -151,6 +152,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
class TorrentPersistentData {
|
class TorrentPersistentData {
|
||||||
|
// This class stores strings w/o modifying separators
|
||||||
public:
|
public:
|
||||||
enum RatioLimit {
|
enum RatioLimit {
|
||||||
USE_GLOBAL_RATIO = -2,
|
USE_GLOBAL_RATIO = -2,
|
||||||
|
|
|
@ -177,7 +177,7 @@ TorrentModel* TransferListWidget::getSourceModel() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::previewFile(QString filePath) {
|
void TransferListWidget::previewFile(QString filePath) {
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
|
openUrl(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::setRefreshInterval(int t) {
|
void TransferListWidget::setRefreshInterval(int t) {
|
||||||
|
@ -235,8 +235,8 @@ void TransferListWidget::torrentDoubleClicked(const QModelIndex& index) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPEN_DEST:
|
case OPEN_DEST:
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(h.root_path()));
|
const QString path = h.root_path();
|
||||||
break;
|
openUrl(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ void TransferListWidget::setSelectedTorrentsLocation() {
|
||||||
if (!dir.isNull()) {
|
if (!dir.isNull()) {
|
||||||
qDebug("New path is %s", qPrintable(dir));
|
qDebug("New path is %s", qPrintable(dir));
|
||||||
// Check if savePath exists
|
// Check if savePath exists
|
||||||
QDir savePath(fsutils::expandPath(dir));
|
QDir savePath(fsutils::expandPathAbs(dir));
|
||||||
qDebug("New path after clean up is %s", qPrintable(savePath.absolutePath()));
|
qDebug("New path after clean up is %s", qPrintable(savePath.absolutePath()));
|
||||||
foreach (const QString & hash, hashes) {
|
foreach (const QString & hash, hashes) {
|
||||||
// Actually move storage
|
// Actually move storage
|
||||||
|
@ -439,7 +439,7 @@ void TransferListWidget::openSelectedTorrentsFolder() const {
|
||||||
qDebug("Opening path at %s", qPrintable(rootFolder));
|
qDebug("Opening path at %s", qPrintable(rootFolder));
|
||||||
if (!pathsList.contains(rootFolder)) {
|
if (!pathsList.contains(rootFolder)) {
|
||||||
pathsList.insert(rootFolder);
|
pathsList.insert(rootFolder);
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(rootFolder));
|
openUrl(rootFolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -644,6 +644,13 @@ void TransferListWidget::askNewLabelForSelection() {
|
||||||
}while(invalid);
|
}while(invalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TransferListWidget::openUrl(const QString &_path) const {
|
||||||
|
const QString path = fsutils::fromNativePath(_path);
|
||||||
|
// Hack to access samba shares with QDesktopServices::openUrl
|
||||||
|
const QString p = path.startsWith("//") ? QString("file:") + path : path;
|
||||||
|
return QDesktopServices::openUrl(QUrl::fromLocalFile(p));
|
||||||
|
}
|
||||||
|
|
||||||
void TransferListWidget::renameSelectedTorrent() {
|
void TransferListWidget::renameSelectedTorrent() {
|
||||||
const QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
const QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
||||||
if (selectedIndexes.size() != 1) return;
|
if (selectedIndexes.size() != 1) return;
|
||||||
|
|
|
@ -106,6 +106,9 @@ protected slots:
|
||||||
void toggleSelectedFirstLastPiecePrio() const;
|
void toggleSelectedFirstLastPiecePrio() const;
|
||||||
void askNewLabelForSelection();
|
void askNewLabelForSelection();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool openUrl(const QString& _path) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentTorrentChanged(const QTorrentHandle &h);
|
void currentTorrentChanged(const QTorrentHandle &h);
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "jsondict.h"
|
#include "jsondict.h"
|
||||||
#include "jsonlist.h"
|
#include "jsonlist.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "fs_utils.h"
|
||||||
#include "qbtsession.h"
|
#include "qbtsession.h"
|
||||||
#include "torrentpersistentdata.h"
|
#include "torrentpersistentdata.h"
|
||||||
|
|
||||||
|
@ -287,9 +288,9 @@ QString btjson::getPropertiesForTorrent(const QString& hash)
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
// Save path
|
// Save path
|
||||||
QString save_path = TorrentPersistentData::getSavePath(hash);
|
QString save_path = fsutils::toNativePath(TorrentPersistentData::getSavePath(hash));
|
||||||
if (save_path.isEmpty())
|
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_SAVE_PATH, save_path);
|
||||||
data.add(KEY_PROP_CREATION_DATE, h.creation_date());
|
data.add(KEY_PROP_CREATION_DATE, h.creation_date());
|
||||||
data.add(KEY_PROP_PIECE_SIZE, misc::friendlyUnit(h.piece_length()));
|
data.add(KEY_PROP_PIECE_SIZE, misc::friendlyUnit(h.piece_length()));
|
||||||
|
@ -341,7 +342,7 @@ QString btjson::getFilesForTorrent(const QString& hash)
|
||||||
QString fileName = h.filename_at(i);
|
QString fileName = h.filename_at(i);
|
||||||
if (fileName.endsWith(".!qB", Qt::CaseInsensitive))
|
if (fileName.endsWith(".!qB", Qt::CaseInsensitive))
|
||||||
fileName.chop(4);
|
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);
|
const size_type size = h.filesize_at(i);
|
||||||
file_dict.add(KEY_FILE_SIZE, misc::friendlyUnit(size));
|
file_dict.add(KEY_FILE_SIZE, misc::friendlyUnit(size));
|
||||||
file_dict.add(KEY_FILE_PROGRESS, (size > 0) ? (fp[i] / (double) size) : 1.);
|
file_dict.add(KEY_FILE_PROGRESS, (size > 0) ? (fp[i] / (double) size) : 1.);
|
||||||
|
|
|
@ -53,17 +53,21 @@ QString prefjson::getPreferences()
|
||||||
// UI
|
// UI
|
||||||
data.add("locale", pref.getLocale());
|
data.add("locale", pref.getLocale());
|
||||||
// Downloads
|
// 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_enabled", pref.isTempPathEnabled());
|
||||||
data.add("temp_path", pref.getTempPath());
|
data.add("temp_path", fsutils::toNativePath(pref.getTempPath()));
|
||||||
data.add("scan_dirs", pref.getScanDirs());
|
QStringList l;
|
||||||
|
foreach (const QString& s, pref.getScanDirs()) {
|
||||||
|
l << fsutils::toNativePath(s);
|
||||||
|
}
|
||||||
|
data.add("scan_dirs", l);
|
||||||
QVariantList var_list;
|
QVariantList var_list;
|
||||||
foreach (bool b, pref.getDownloadInScanDirs()) {
|
foreach (bool b, pref.getDownloadInScanDirs()) {
|
||||||
var_list << b;
|
var_list << b;
|
||||||
}
|
}
|
||||||
data.add("download_in_scan_dirs", var_list);
|
data.add("download_in_scan_dirs", var_list);
|
||||||
data.add("export_dir_enabled", pref.isTorrentExportEnabled());
|
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_enabled", pref.isMailNotificationEnabled());
|
||||||
data.add("mail_notification_email", pref.getMailNotificationEmail());
|
data.add("mail_notification_email", pref.getMailNotificationEmail());
|
||||||
data.add("mail_notification_smtp", pref.getMailNotificationSMTP());
|
data.add("mail_notification_smtp", pref.getMailNotificationSMTP());
|
||||||
|
@ -72,7 +76,7 @@ QString prefjson::getPreferences()
|
||||||
data.add("mail_notification_username", pref.getMailNotificationSMTPUsername());
|
data.add("mail_notification_username", pref.getMailNotificationSMTPUsername());
|
||||||
data.add("mail_notification_password", pref.getMailNotificationSMTPPassword());
|
data.add("mail_notification_password", pref.getMailNotificationSMTPPassword());
|
||||||
data.add("autorun_enabled", pref.isAutoRunEnabled());
|
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("preallocate_all", pref.preAllocateAllFiles());
|
||||||
data.add("queueing_enabled", pref.isQueueingSystemEnabled());
|
data.add("queueing_enabled", pref.isQueueingSystemEnabled());
|
||||||
data.add("max_active_downloads", pref.getMaxActiveDownloads());
|
data.add("max_active_downloads", pref.getMaxActiveDownloads());
|
||||||
|
@ -119,7 +123,7 @@ QString prefjson::getPreferences()
|
||||||
data.add("proxy_password", pref.getProxyPassword());
|
data.add("proxy_password", pref.getProxyPassword());
|
||||||
// IP Filter
|
// IP Filter
|
||||||
data.add("ip_filter_enabled", pref.isFilteringEnabled());
|
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
|
// Web UI
|
||||||
data.add("web_ui_port", pref.getWebUiPort());
|
data.add("web_ui_port", pref.getWebUiPort());
|
||||||
data.add("web_ui_username", pref.getWebUiUsername());
|
data.add("web_ui_username", pref.getWebUiUsername());
|
||||||
|
@ -186,7 +190,7 @@ void prefjson::setPreferences(const QString& json)
|
||||||
foreach (const QString &new_folder, new_folders) {
|
foreach (const QString &new_folder, new_folders) {
|
||||||
qDebug("New watched folder: %s", qPrintable(new_folder));
|
qDebug("New watched folder: %s", qPrintable(new_folder));
|
||||||
// Update new folders
|
// 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));
|
QBtSession::instance()->getScanFoldersModel()->addPath(new_folder, download_at_path.at(i));
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue