Skip to content

Commit 4e8b302

Browse files
committed
Prevent 'finish' button from being clicked prematurely
1 parent 6a8b089 commit 4e8b302

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Diff for: creationpage.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,18 @@ CreationPage::CreationPage(QWidget *parent) :
3535
ui(new Ui::CreationPage)
3636
{
3737
ui->setupUi(this);
38+
torrentDone = false;
3839
}
3940

4041
CreationPage::~CreationPage()
4142
{
4243
delete ui;
4344
}
4445

46+
bool CreationPage::isComplete() const {
47+
return torrentDone;
48+
}
49+
4550
void CreationPage::updateProgress(int i) {
4651
ui->progressBar->setValue(i);
4752
}
@@ -50,15 +55,17 @@ void CreationPage::logAddedFile(QString filename) {
5055
ui->statusLog->appendPlainText(filename);
5156
}
5257

53-
void CreationPage::setFinishedText() {
58+
void CreationPage::triggerFinished() {
5459
ui->titleLabel->setText("Torrent creation completed.");
60+
torrentDone = true;
61+
emit completeChanged();
5562
}
5663

5764
void CreationPage::initializePage() {
5865
CreateTorrent *ctThread = new CreateTorrent(this);
5966
connect(ctThread, SIGNAL(updateProgress(int)), this, SLOT(updateProgress(int)));
6067
connect(ctThread, SIGNAL(logStatusMessage(QString)), this, SLOT(logAddedFile(QString)));
61-
connect(ctThread, SIGNAL(finished()), this, SLOT(setFinishedText()));
68+
connect(ctThread, SIGNAL(finished()), this, SLOT(triggerFinished()));
6269

6370
using namespace libtorrent;
6471

Diff for: creationpage.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ class CreationPage : public QWizardPage
3939
explicit CreationPage(QWidget *parent = 0);
4040
~CreationPage();
4141
void initializePage();
42+
bool isComplete() const;
4243

4344
private:
4445
Ui::CreationPage *ui;
46+
bool torrentDone;
4547

4648
private slots:
4749
void updateProgress(int i);
4850
void logAddedFile(QString filename);
49-
void setFinishedText();
51+
void triggerFinished();
5052
};
5153

5254
#endif // CREATIONPAGE_H

0 commit comments

Comments
 (0)