diff --git a/src/createtorrent_imp.cpp b/src/createtorrent_imp.cpp index b336ad46a..b82554e6e 100644 --- a/src/createtorrent_imp.cpp +++ b/src/createtorrent_imp.cpp @@ -188,16 +188,29 @@ void createtorrent::on_createButton_clicked(){ } else { return; } + // Disable dialog + setEnabled(false); + // Set busy cursor + setCursor(QCursor(Qt::WaitCursor)); + // Actually create the torrent QStringList url_seeds = allItems(URLSeeds_list); QString comment = txt_comment->toPlainText(); creatorThread->create(input, destination, trackers, url_seeds, comment, check_private->isChecked(), getPieceSize()); } void createtorrent::handleCreationFailure(QString msg) { + // Enable dialog + setEnabled(true); + // Remove busy cursor + setCursor(QCursor(Qt::ArrowCursor)); QMessageBox::information(0, tr("Torrent creation"), tr("Torrent creation was unsuccessful, reason: %1").arg(msg)); } void createtorrent::handleCreationSuccess(QString path, QString branch_path) { + // Enable Dialog + setEnabled(true); + // Remove busy cursor + setCursor(QCursor(Qt::ArrowCursor)); if(checkStartSeeding->isChecked()) { // Create save path temp data boost::intrusive_ptr t; @@ -219,6 +232,18 @@ void createtorrent::handleCreationSuccess(QString path, QString branch_path) { close(); } +void createtorrent::on_cancelButton_clicked() { + // End torrent creation thread + if(creatorThread->isRunning()) { + creatorThread->abortCreation(); + creatorThread->terminate(); + // Wait for termination + creatorThread->wait(); + } + // Close the dialog + reject(); +} + void createtorrent::updateProgressBar(int progress) { progressBar->setValue(progress); } diff --git a/src/createtorrent_imp.h b/src/createtorrent_imp.h index 76ca17c33..ffee75fae 100644 --- a/src/createtorrent_imp.h +++ b/src/createtorrent_imp.h @@ -58,6 +58,7 @@ class torrentCreatorThread : public QThread { } void create(QString _input_path, QString _save_path, QStringList _trackers, QStringList _url_seeds, QString _comment, bool _is_private, int _piece_size); void sendProgressSignal(int progress); + void abortCreation() { abort = true; } protected: void run(); @@ -87,6 +88,7 @@ class createtorrent : public QDialog, private Ui::createTorrentDialog{ public slots: void updateProgressBar(int progress); + void on_cancelButton_clicked(); protected slots: void on_createButton_clicked(); diff --git a/src/ui/createtorrent.ui b/src/ui/createtorrent.ui index 8be9532a3..798c2f2d5 100644 --- a/src/ui/createtorrent.ui +++ b/src/ui/createtorrent.ui @@ -65,7 +65,7 @@ Add file - + :/Icons/oxygen/document-new.png:/Icons/oxygen/document-new.png @@ -76,7 +76,7 @@ Add folder - + :/Icons/oxygen/folder-new.png:/Icons/oxygen/folder-new.png @@ -202,7 +202,7 @@ - + :/Icons/oxygen/list-add.png:/Icons/oxygen/list-add.png @@ -231,7 +231,7 @@ - + :/Icons/oxygen/list-remove.png:/Icons/oxygen/list-remove.png @@ -313,7 +313,7 @@ - + :/Icons/oxygen/list-add.png:/Icons/oxygen/list-add.png @@ -342,7 +342,7 @@ - + :/Icons/oxygen/list-remove.png:/Icons/oxygen/list-remove.png @@ -539,24 +539,7 @@ - + - - - cancelButton - clicked() - createTorrentDialog - reject() - - - 355 - 275 - - - 179 - 282 - - - - +