Ejemplo n.º 1
0
void MainWindow::on_clear_clicked()
{
	timer->stop();
	uiTimer->stop();
	ui->lcdNumber_4->display(0);
	ui->lcdNumber->display(0);
	ui->lcdNumber_2->display(0);
	ui->lcdNumber_3->display(0);

	ui->lcdNumber_8->display(0);
	ui->lcdNumber_5->display(0);
	ui->lcdNumber_6->display(0);
	ui->lcdNumber_7->display(0);
	isCounting=false;
	firstStart=true;
	currentSegSec=totalMS=0;
	ui->checkBox->setEnabled(true);
	if(ui->listWidget->currentRow()>=0){
		ui->spinBox->setEnabled(true);
		ui->spinBox_2->setEnabled(true);
		ui->spinBox_3->setEnabled(true);
	}
	ui->start->setText(QString::fromLocal8Bit("開始"));
	ui->progressBar->setValue(0);
	ui->progressBar_2->setValue(0);
	currentSegIndex=-1;
	player.pause();
}
Ejemplo n.º 2
0
void MainWindow::on_start_clicked()
{
	if(firstStart){
		if(currentSegSec==0)
			return;
		timer->start(currentSegSec*1000);
		elapsedTimer.start();
		uiTimer->start(50);
		firstStart=false;
		isCounting=true;
		ui->start->setText(QString::fromLocal8Bit("暫停"));
		ui->checkBox->setEnabled(false);
		ui->spinBox->setEnabled(false);
		ui->spinBox_2->setEnabled(false);
		ui->spinBox_3->setEnabled(false);
		currentSegIndex=ui->listWidget->currentRow();
		player.pause();
		return;
	}
	if(isCounting){
		timer->stop();
		uiTimer->stop();
		currentTempTime.ms=ui->lcdNumber_4->value();
		currentTempTime.s=ui->lcdNumber->intValue();
		currentTempTime.m=ui->lcdNumber_2->intValue();
		currentTempTime.h=ui->lcdNumber_3->intValue();

		totalMS=ui->lcdNumber_8->value()+
				(ui->lcdNumber_5->value()+ui->lcdNumber_6->value()*60+ui->lcdNumber_7->value()*3600)*1000;
		ui->start->setText(QString::fromLocal8Bit("繼續"));
	}
	else{
		timer->start((currentTempTime.h*3600+currentTempTime.m*60+currentTempTime.s)*1000+currentTempTime.ms);
		elapsedTimer.start();
		uiTimer->start(50);
		ui->start->setText(QString::fromLocal8Bit("暫停"));
	}
	isCounting=!isCounting;
}