#include "dialog.h"
#include "ui_dialog.h"
#include<QMessageBox>
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
progressThread=new Thread(this);
connect(progressThread,SIGNAL(updateValue(int)),this,SLOT(updateProgressBar(int)));
connect(progressThread,SIGNAL(finished()),this,SLOT(updatePushButton()));
}
void Dialog::updateProgressBar(int value)
{
ui->progressBar->setValue(value);
}
void Dialog::updatePushButton()
{
ui->pushButton->setText("Start");
QMessageBox::information(this,"Test progress","Game is over!");
}
void Dialog::startProgress()
{
if(progressThread->isRunning())
{
progressThread->stop();
progressThread->begin=false;
ui->pushButton->setText("Start");
}
else
{
progressThread->start();
progressThread->begin=true;
ui->pushButton->setText("Stop");
}
}
Dialog::~Dialog()
{
delete ui;
delete progressThread;
}