|
|
@ -184,7 +184,6 @@ void createtorrent::on_createButton_clicked(){ |
|
|
|
|
|
|
|
|
|
|
|
void createtorrent::handleCreationFailure(QString msg) { |
|
|
|
void createtorrent::handleCreationFailure(QString msg) { |
|
|
|
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent creation was unsuccessful, reason: %1").arg(msg)); |
|
|
|
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent creation was unsuccessful, reason: %1").arg(msg)); |
|
|
|
hide(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void createtorrent::handleCreationSuccess(QString path, const char* branch_path) { |
|
|
|
void createtorrent::handleCreationSuccess(QString path, const char* branch_path) { |
|
|
@ -205,7 +204,7 @@ void createtorrent::handleCreationSuccess(QString path, const char* branch_path) |
|
|
|
emit torrent_to_seed(path); |
|
|
|
emit torrent_to_seed(path); |
|
|
|
} |
|
|
|
} |
|
|
|
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent was created successfully:")+" "+path); |
|
|
|
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent was created successfully:")+" "+path); |
|
|
|
hide(); |
|
|
|
close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void createtorrent::updateProgressBar(int progress) { |
|
|
|
void createtorrent::updateProgressBar(int progress) { |
|
|
@ -228,8 +227,12 @@ void torrentCreatorThread::create(QString _input_path, QString _save_path, QStri |
|
|
|
start(); |
|
|
|
start(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void sendProgressUpdateSignal(int i, int num, QDialog *parent){ |
|
|
|
void sendProgressUpdateSignal(int i, int num, torrentCreatorThread *parent){ |
|
|
|
((createtorrent*)parent)->updateProgressBar((int)(i*100./(float)num)); |
|
|
|
parent->sendProgressSignal((int)(i*100./(float)num)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void torrentCreatorThread::sendProgressSignal(int progress) { |
|
|
|
|
|
|
|
emit updateProgress(progress); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void torrentCreatorThread::run() { |
|
|
|
void torrentCreatorThread::run() { |
|
|
@ -254,15 +257,13 @@ void torrentCreatorThread::run() { |
|
|
|
} |
|
|
|
} |
|
|
|
if(abort) return; |
|
|
|
if(abort) return; |
|
|
|
// calculate the hash for all pieces
|
|
|
|
// calculate the hash for all pieces
|
|
|
|
set_piece_hashes(t, full_path.branch_path(), boost::bind<void>(&sendProgressUpdateSignal, _1, t.num_pieces(), parent)); |
|
|
|
set_piece_hashes(t, full_path.branch_path(), 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); |
|
|
|
t.set_creator(creator_str); |
|
|
|
t.set_comment((const char*)comment.toLocal8Bit()); |
|
|
|
t.set_comment((const char*)comment.toLocal8Bit()); |
|
|
|
// Is private ?
|
|
|
|
// Is private ?
|
|
|
|
if(is_private){ |
|
|
|
t.set_prive(is_private); |
|
|
|
t.set_priv(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(abort) return; |
|
|
|
if(abort) return; |
|
|
|
// create the torrent and print it to out
|
|
|
|
// create the torrent and print it to out
|
|
|
|
ofstream out(complete(path((const char*)save_path.toLocal8Bit())), std::ios_base::binary); |
|
|
|
ofstream out(complete(path((const char*)save_path.toLocal8Bit())), std::ios_base::binary); |
|
|
|