mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-05 07:02:31 -06:00
Update dialogs
This commit is contained in:
@@ -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);
|
||||
if (!dir.isEmpty()) {
|
||||
settings.setValue("CreateTorrent/last_add_path", dir);
|
||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||
dir.replace("/", "\\");
|
||||
#endif
|
||||
textInputPath->setText(dir);
|
||||
textInputPath->setText(fsutils::toNativePath(dir));
|
||||
// Update piece size
|
||||
if (checkAutoPieceSize->isChecked())
|
||||
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);
|
||||
if (!file.isEmpty()) {
|
||||
settings.setValue("CreateTorrent/last_add_path", fsutils::branchPath(file));
|
||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||
file.replace("/", "\\");
|
||||
#endif
|
||||
textInputPath->setText(file);
|
||||
textInputPath->setText(fsutils::toNativePath(file));
|
||||
// Update piece size
|
||||
if (checkAutoPieceSize->isChecked())
|
||||
updateOptimalPieceSize();
|
||||
@@ -106,8 +100,8 @@ int TorrentCreatorDlg::getPieceSize() const {
|
||||
|
||||
// Main function that create a .torrent file
|
||||
void TorrentCreatorDlg::on_createButton_clicked() {
|
||||
QString input = textInputPath->text().trimmed();
|
||||
if (input.endsWith(QDir::separator()))
|
||||
QString input = fsutils::fromNativePath(textInputPath->text()).trimmed();
|
||||
if (input.endsWith("/"))
|
||||
input.chop(1);
|
||||
if (input.isEmpty()) {
|
||||
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(creationFailure(QString)), this, SLOT(handleCreationFailure(QString)));
|
||||
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) {
|
||||
@@ -159,7 +153,7 @@ void TorrentCreatorDlg::handleCreationSuccess(QString path, QString branch_path)
|
||||
// Create save path temp data
|
||||
boost::intrusive_ptr<torrent_info> t;
|
||||
try {
|
||||
t = new torrent_info(path.toUtf8().data());
|
||||
t = new torrent_info(fsutils::toNativePath(path).toUtf8().data());
|
||||
} catch(std::exception&) {
|
||||
QMessageBox::critical(0, tr("Torrent creation"), tr("Created torrent file is invalid. It won't be added to download list."));
|
||||
return;
|
||||
@@ -173,7 +167,7 @@ void TorrentCreatorDlg::handleCreationSuccess(QString path, QString branch_path)
|
||||
if (checkIgnoreShareLimits->isChecked())
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
input_path = _input_path;
|
||||
save_path = _save_path;
|
||||
input_path = fsutils::fromNativePath(_input_path);
|
||||
save_path = fsutils::fromNativePath(_save_path);
|
||||
if (QFile(save_path).exists())
|
||||
fsutils::forceRemove(save_path);
|
||||
trackers = _trackers;
|
||||
@@ -86,7 +86,7 @@ void TorrentCreatorThread::run() {
|
||||
try {
|
||||
file_storage fs;
|
||||
// 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;
|
||||
create_torrent t(fs, piece_size);
|
||||
|
||||
@@ -109,8 +109,8 @@ void TorrentCreatorThread::run() {
|
||||
}
|
||||
if (abort) return;
|
||||
// calculate the hash for all pieces
|
||||
const QString parent_path = fsutils::branchPath(input_path) + QDir::separator();
|
||||
set_piece_hashes(t, parent_path.toUtf8().constData(), boost::bind<void>(&sendProgressUpdateSignal, _1, t.num_pieces(), this));
|
||||
const QString parent_path = fsutils::branchPath(input_path) + "/";
|
||||
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
|
||||
// torrent_info structure
|
||||
t.set_creator(creator_str.toUtf8().constData());
|
||||
@@ -122,12 +122,12 @@ void TorrentCreatorThread::run() {
|
||||
qDebug("Saving to %s", qPrintable(save_path));
|
||||
#ifdef _MSC_VER
|
||||
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';
|
||||
std::ofstream outfile(wsave_path, std::ios_base::out|std::ios_base::binary);
|
||||
delete[] wsave_path;
|
||||
#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
|
||||
if (outfile.fail())
|
||||
throw std::exception();
|
||||
|
||||
Reference in New Issue
Block a user