|
|
@ -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(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|