source: src-qt4/PCDM/src/pcdm-logindelay.cpp @ 28c79ad

releng/10.0.1releng/10.0.2releng/10.0.3
Last change on this file since 28c79ad was 28c79ad, checked in by Ken Moore <ken@…>, 8 months ago

Add an auto-login delay function for PCDM that defaults to 10 seconds. This will pop-up a window giving the user the specified amount of time to either cancel the auto-login or immediately continue on.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1#include "pcdm-logindelay.h"
2#include "ui_pcdm-logindelay.h"
3
4loginDelay::loginDelay(int seconds, QString username) : QDialog(), ui(new Ui::loginDelay){
5  ui->setupUi(this); //load the designer files
6  continueLogin = false; //in case it is closed early somehow
7  //Now setup the display
8  ui->label_username->setText(username);
9  ui->progressBar->setRange(0,seconds);
10  ui->progressBar->setValue(0);
11  //Now setup the internal timer
12  delay = new QTimer(this);
13        delay->setInterval(1000); //1 second intervals
14        connect(delay, SIGNAL(timeout()), this, SLOT(updateTimer()) );
15  //Now connect the pushbuttons
16  connect(ui->pushCancel, SIGNAL(clicked()), this, SLOT(cancelLogin()) );
17  connect(ui->pushContinue, SIGNAL(clicked()), this, SLOT(startLogin()) );
18}
19
20loginDelay::~loginDelay(){
21       
22}
23
24void loginDelay::start(){
25  this->show();
26  delay->start();
27}
28
29void loginDelay::updateTimer(){
30  ui->progressBar->setValue( ui->progressBar->value()+1 );
31  //Check if the timer reached the end yet
32  if(ui->progressBar->value() >= ui->progressBar->maximum()){
33    delay->stop();
34    startLogin();
35  }
36}
37
38void loginDelay::cancelLogin(){
39  delay->stop();
40  continueLogin = false;
41  this->close();
42}
43
44void loginDelay::startLogin(){
45  delay->stop();
46  continueLogin = true;
47  this->close();       
48}
Note: See TracBrowser for help on using the repository browser.