mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Fix compilation on Win32
Fixes to last commit(hide unwanted files)
This commit is contained in:
parent
f6b96694e0
commit
759fe77e7f
@ -46,7 +46,7 @@
|
|||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
@ -511,17 +511,27 @@ void QTorrentHandle::prioritize_files(const vector<int> &files) const {
|
|||||||
if(prev_priorities[i] > 0 && files[i] == 0) {
|
if(prev_priorities[i] > 0 && files[i] == 0) {
|
||||||
QString old_path = filepath_at(i);
|
QString old_path = filepath_at(i);
|
||||||
QString old_name = filename_at(i);
|
QString old_name = filename_at(i);
|
||||||
QDir parent_path(misc::branchPath(old_path));
|
QString parent_path = misc::branchPath(old_path);
|
||||||
if(parent_path.dirName() != ".unwanted") {
|
if(parent_path.isEmpty() || QDir(parent_path).dirName() != ".unwanted") {
|
||||||
bool created = parent_path.mkdir(".unwanted");
|
QString unwanted_abspath = QDir::cleanPath(save_path()+"/"+parent_path+"/.unwanted");
|
||||||
|
qDebug() << "Unwanted path is" << unwanted_abspath;
|
||||||
|
bool created = QDir().mkpath(unwanted_abspath);
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
// Hide the folder on Windows
|
qDebug() << "unwanted folder was created:" << created;
|
||||||
DWORD dwAttrs = GetFileAttributes(parent_path.absolutePath().toLocal8Bit().data());
|
if(created) {
|
||||||
SetFileAttributes(parent_path.absolutePath().toLocal8Bit().data(), dwAttrs|FILE_ATTRIBUTE_HIDDEN);
|
// Hide the folder on Windows
|
||||||
|
qDebug() << "Hiding folder (Windows)";
|
||||||
|
wstring win_path = unwanted_abspath.replace("/","\\").toStdWString();
|
||||||
|
DWORD dwAttrs = GetFileAttributesW(win_path.c_str());
|
||||||
|
bool ret = SetFileAttributesW(win_path.c_str(), dwAttrs|FILE_ATTRIBUTE_HIDDEN);
|
||||||
|
Q_ASSERT(ret != 0); Q_UNUSED(ret);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
Q_UNUSED(created);
|
Q_UNUSED(created);
|
||||||
#endif
|
#endif
|
||||||
rename_file(i, parent_path.filePath(".unwanted/"+old_name));
|
if(!parent_path.isEmpty() && !parent_path.endsWith("/"))
|
||||||
|
parent_path += "/";
|
||||||
|
rename_file(i, parent_path+".unwanted/"+old_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Move wanted files back to their original folder
|
// Move wanted files back to their original folder
|
||||||
@ -533,7 +543,7 @@ void QTorrentHandle::prioritize_files(const vector<int> &files) const {
|
|||||||
QDir new_path(misc::branchPath(parent_path.path()));
|
QDir new_path(misc::branchPath(parent_path.path()));
|
||||||
rename_file(i, new_path.filePath(old_name));
|
rename_file(i, new_path.filePath(old_name));
|
||||||
// Remove .unwanted directory if empty
|
// Remove .unwanted directory if empty
|
||||||
new_path.rmdir(".unwanted");
|
new_path.rmdir(".unwanted");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -607,6 +617,7 @@ void QTorrentHandle::prioritize_first_last_piece(bool b) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::rename_file(int index, QString name) const {
|
void QTorrentHandle::rename_file(int index, QString name) const {
|
||||||
|
qDebug() << Q_FUNC_INFO << index << name;
|
||||||
torrent_handle::rename_file(index, std::string(name.toUtf8().constData()));
|
torrent_handle::rename_file(index, std::string(name.toUtf8().constData()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,6 +169,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setProgress(qulonglong done) {
|
void setProgress(qulonglong done) {
|
||||||
|
if(getPriority() == 0) return;
|
||||||
total_done = done;
|
total_done = done;
|
||||||
qulonglong size = getSize();
|
qulonglong size = getSize();
|
||||||
Q_ASSERT(total_done <= size);
|
Q_ASSERT(total_done <= size);
|
||||||
@ -188,6 +189,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
float getProgress() const {
|
float getProgress() const {
|
||||||
|
if(getPriority() == 0)
|
||||||
|
return 0.;
|
||||||
qulonglong size = getSize();
|
qulonglong size = getSize();
|
||||||
if(size > 0)
|
if(size > 0)
|
||||||
return total_done/(float)getSize();
|
return total_done/(float)getSize();
|
||||||
@ -216,6 +219,11 @@ public:
|
|||||||
const int old_prio = getPriority();
|
const int old_prio = getPriority();
|
||||||
if(old_prio == new_prio) return;
|
if(old_prio == new_prio) return;
|
||||||
qDebug("setPriority(%s, %d)", qPrintable(getName()), new_prio);
|
qDebug("setPriority(%s, %d)", qPrintable(getName()), new_prio);
|
||||||
|
// Reset progress if priority is 0
|
||||||
|
if(new_prio == 0) {
|
||||||
|
setProgress(0);
|
||||||
|
}
|
||||||
|
|
||||||
itemData.replace(COL_PRIO, new_prio);
|
itemData.replace(COL_PRIO, new_prio);
|
||||||
|
|
||||||
// Update parent
|
// Update parent
|
||||||
|
Loading…
Reference in New Issue
Block a user