added busy flag into mainscreen

This commit is contained in:
liranbg 2014-10-13 01:43:08 +03:00
parent 71d5e9b8b3
commit cde830dac7
2 changed files with 290 additions and 257 deletions

View file

@ -5,7 +5,7 @@
MainScreen::MainScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainScreen)
{
ui->setupUi(this);
this->isBlocked = false;
//Login Tab
iconPix.load(":/icons/iconX.png");
ui->pswdLineEdit->setEchoMode((QLineEdit::Password));
@ -57,6 +57,9 @@ MainScreen::~MainScreen()
//EVENTS ON LOGIN TAB
void MainScreen::on_loginButton_clicked()
{
if (!isBusy())
{
lock();
qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
if ((ui->usrnmLineEdit->text().isEmpty()) || (ui->pswdLineEdit->text().isEmpty()))
{
@ -82,7 +85,6 @@ void MainScreen::on_loginButton_clicked()
ui->labelPswInputStatus->setVisible(false);
}
qDebug() << Q_FUNC_INFO << "login session start";
QApplication::setOverrideCursor(Qt::WaitCursor);
if (this->loginHandel->login(ui->usrnmLineEdit->text(),ui->pswdLineEdit->text()) == true)
{
qDebug() << Q_FUNC_INFO << "login session end with true";
@ -102,7 +104,10 @@ void MainScreen::on_loginButton_clicked()
ui->usrnmLineEdit->setDisabled(false);
}
QApplication::restoreOverrideCursor();
unlock();
}
}
void MainScreen::on_keepLogin_clicked()
{
@ -126,6 +131,9 @@ void MainScreen::on_usrnmLineEdit_editingFinished()
void MainScreen::on_ratesButton_clicked()
{
qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
if (!isBusy())
{
lock();
if (!checkIfValidDates())
{
qWarning() << Q_FUNC_INFO << "Invalid dates! return";
@ -134,7 +142,6 @@ void MainScreen::on_ratesButton_clicked()
}
QString pageString;
int status = 0;
QApplication::setOverrideCursor(Qt::WaitCursor);
if (loginHandel->isLoggedInFlag())
{
statusBar->setIconConnectionStatus(jceStatusBar::Ready);
@ -162,7 +169,8 @@ void MainScreen::on_ratesButton_clicked()
qCritical() << Q_FUNC_INFO << "grade get ended with" << status;
}
}
QApplication::restoreOverrideCursor();
unlock();
}
}
bool MainScreen::checkIfValidDates()
{
@ -232,14 +240,15 @@ void MainScreen::on_graphButton_clicked()
void MainScreen::on_examsBtn_clicked()
{
calendar->showExamDialog();
}
void MainScreen::on_getCalendarBtn_clicked()
{
qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
if (!isBusy())
{
lock();
int status = 0;
QString page;
QApplication::setOverrideCursor(Qt::WaitCursor);
if (loginHandel->isLoggedInFlag())
{
if ((status = loginHandel->makeCalendarRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_PAGE_PASSED)
@ -282,7 +291,8 @@ void MainScreen::on_getCalendarBtn_clicked()
qCritical() << Q_FUNC_INFO << "calendar get ended with" << status;
}
}
QApplication::restoreOverrideCursor();
unlock();
}
}
void MainScreen::on_exportToCVSBtn_clicked()
{
@ -392,9 +402,26 @@ void MainScreen::checkLocale()
}
}
//MAIN SCREEN
void MainScreen::on_labelMadeBy_linkActivated(const QString &link)
{
qDebug() << Q_FUNC_INFO << "link: " << link;
}
/**
* @brief MainScreen::lock
* turn isblocked into true to avoid multiple requests and to cause errors
*/
void MainScreen::lock()
{
QApplication::setOverrideCursor(Qt::WaitCursor);
this->isBlocked = true;
}
void MainScreen::unlock()
{
QApplication::restoreOverrideCursor();
this->isBlocked = false;
}
bool MainScreen::isBusy()
{
return this->isBlocked;
}

View file

@ -66,8 +66,14 @@ private:
void checkLocale();
bool checkIfValidDates();
bool isBusy();
void lock();
void unlock();
Ui::MainScreen *ui;
bool isBlocked;
QPixmap iconPix;
user *userLoginSetting;
SaveData *data;