diff --git a/main/LoginTab/loginhandler.cpp b/main/LoginTab/loginhandler.cpp index 8e5a8f4..6b7c2ac 100644 --- a/main/LoginTab/loginhandler.cpp +++ b/main/LoginTab/loginhandler.cpp @@ -24,19 +24,18 @@ bool loginHandler::login(QString username,QString password) logout(); return false; } - statusBar->setIconConnectionStatus(jceStatusBar::Connecting); userPtr->setUsername(username); userPtr->setPassword(password); if (makeConnection() == true) { - statusBar->setIconConnectionStatus(jceStatusBar::LoggedIn); loginButtonPtr->setText(QObject::tr("Logout")); return isLoggedInFlag(); } else { + logout(); return false; } @@ -101,6 +100,7 @@ void loginHandler::readyAfterConnectionLost() { qWarning() << Q_FUNC_INFO; setLoginFlag(false); + statusBar->setIconConnectionStatus(jceStatusBar::Disconnected); login(userPtr->getUsername(),userPtr->getPassword()); } @@ -128,22 +128,32 @@ QString loginHandler::getCurrentPageContect() int loginHandler::makeGradeRequest(int fromYear, int toYear, int fromSemester, int toSemester) { if (isLoggedInFlag()) + { + statusBar->setIconConnectionStatus(jceStatusBar::Sending); return jceLog->getGrades(fromYear, toYear, fromSemester, toSemester); + } else return jceLogin::JCE_NOT_CONNECTED; } int loginHandler::makeCalendarRequest(int year, int semester) { if (isLoggedInFlag()) + { + statusBar->setIconConnectionStatus(jceStatusBar::Sending); return jceLog->getCalendar(year,semester); + } else return jceLogin::JCE_NOT_CONNECTED; } int loginHandler::makeExamsScheduleRequest(int year, int semester) { + if (isLoggedInFlag()) + { + statusBar->setIconConnectionStatus(jceStatusBar::Sending); return jceLog->getExams(year,semester); + } else return jceLogin::JCE_NOT_CONNECTED; } diff --git a/main/jceWidgets/jcestatusbar.cpp b/main/jceWidgets/jcestatusbar.cpp index 9444776..59fe9d7 100644 --- a/main/jceWidgets/jcestatusbar.cpp +++ b/main/jceWidgets/jcestatusbar.cpp @@ -3,8 +3,7 @@ jceStatusBar::jceStatusBar(QWidget *parent) : QStatusBar(parent) { - - this->setStyleSheet("QStatusBar::item { border: 0px solid black };"); + this->setStyleSheet("QStatusBar { border: 0px solid black };"); this->setFixedHeight(STATUS_ICON_HEIGH+5); this->showMessage(tr("Ready")); @@ -20,20 +19,21 @@ jceStatusBar::jceStatusBar(QWidget *parent) : progressBar->setFixedWidth(120); progressBar->setFixedHeight(STATUS_ICON_HEIGH); - progressBar->setStyleSheet("#progressBar::horizontal {" + progressBar->setStyleSheet("QProgressBar {" "border: 1px solid gray;" "border-radius: 3px;" "background: transparent;" "padding: 1px;" "}" - "#progressBar::chunk:horizontal {" - "background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 green, stop: 1 white);" + "QProgressBar::chunk {" + "background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 #b4e391 , stop: 1 #61c419);" "}"); progressBar->setRange(0,100); progressBar->setValue(0); - progressBar->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); + progressBar->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); progressBar->setTextVisible(true); progressBar->setFormat("%p%"); + progressBar->setOrientation(Qt::Horizontal); addPermanentWidget(progressBar,0); @@ -46,39 +46,50 @@ void jceStatusBar::setIconConnectionStatus(jceProgressStatus update) QPixmap iconPix; switch (update) { + case jceProgressStatus::ERROR: + setProgressValue(0); + iconPix.load(":/icons/redStatusIcon.png"); + showMessage(tr("Error")); + break; case jceProgressStatus::Disconnected: + setProgressValue(0); iconPix.load(":/icons/redStatusIcon.png"); showMessage(tr("Disconnected")); break; case jceProgressStatus::Ready: + setProgressValue(100); iconPix.load(":/icons/redStatusIcon.png"); - showMessage(tr("Ready.")); + showMessage(tr("Ready")); break; case jceProgressStatus::Connecting: + setProgressValue(5); iconPix.load(":/icons/blueStatusIcon.png"); showMessage(tr("Connecting...")); break; case jceProgressStatus::Sending: + setProgressValue(10); iconPix.load(":/icons/blueStatusIcon.png"); - showMessage(tr("Sending.")); + showMessage(tr("Sending...")); break; case jceProgressStatus::Recieving: + setProgressValue(15); iconPix.load(":/icons/blueStatusIcon.png"); - showMessage(tr("Recieving.")); + showMessage(tr("Recieving...")); break; case jceProgressStatus::Inserting: + setProgressValue(80); iconPix.load(":/icons/blueStatusIcon.png"); - showMessage(tr("Inserting.")); + showMessage(tr("Inserting")); break; case jceProgressStatus::LoggedIn: setProgressValue(100); iconPix.load(":/icons/greenStatusIcon.png"); - showMessage(tr("LoggedIn.")); + showMessage(tr("Logged In.")); break; case jceProgressStatus::Done: setProgressValue(100); iconPix.load(":/icons/greenStatusIcon.png"); - showMessage(tr("Done.")); + showMessage(tr("Done")); break; case jceProgressStatus::Connected: setProgressValue(100); @@ -97,7 +108,6 @@ void jceStatusBar::setIconConnectionStatus(jceProgressStatus update) */ void jceStatusBar::setProgressValue(int value) { - if (value == 0) { progressBar->setVisible(false); diff --git a/main/jceWidgets/jcestatusbar.h b/main/jceWidgets/jcestatusbar.h index 69d7b3f..bfff49e 100644 --- a/main/jceWidgets/jcestatusbar.h +++ b/main/jceWidgets/jcestatusbar.h @@ -2,7 +2,7 @@ #define JCESTATUSBAR_H - +#include #include #include #include @@ -24,7 +24,8 @@ public: Sending, Recieving, Inserting, - Done + Done, + ERROR }; jceStatusBar(QWidget *parent = 0); diff --git a/main/mainscreen.cpp b/main/mainscreen.cpp index 065ac52..05cbe62 100644 --- a/main/mainscreen.cpp +++ b/main/mainscreen.cpp @@ -6,10 +6,6 @@ MainScreen::MainScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainSc { ui->setupUi(this); - - - ui->labelMadeBy->setOpenExternalLinks(true); - //Login Tab iconPix.load(":/icons/iconX.png"); ui->pswdLineEdit->setEchoMode((QLineEdit::Password)); @@ -129,8 +125,6 @@ void MainScreen::on_usrnmLineEdit_editingFinished() //EVENTS ON GPA TAB void MainScreen::on_ratesButton_clicked() { - -// ui->progressBar->setValue(0); qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); if (!checkIfValidDates()) { @@ -143,27 +137,28 @@ void MainScreen::on_ratesButton_clicked() QApplication::setOverrideCursor(Qt::WaitCursor); if (loginHandel->isLoggedInFlag()) { -// ui->statusBar->showMessage(tr("Getting grades...")); + statusBar->setIconConnectionStatus(jceStatusBar::Ready); if ((status = loginHandel->makeGradeRequest(ui->spinBoxCoursesFromYear->value(), ui->spinBoxCoursesToYear->value(),ui->spinBoxCoursesFromSemester->value(), ui->spinBoxCoursesToSemester->value())) == jceLogin::JCE_PAGE_PASSED) { qDebug() << Q_FUNC_INFO << "grade page is ready"; -// ui->statusBar->showMessage(tr("Done. Inserting data into table..."),1000); + statusBar->setIconConnectionStatus(jceStatusBar::Inserting); pageString = loginHandel->getCurrentPageContect(); courseTableMgr->setCoursesList(pageString); courseTableMgr->insertJceCoursesIntoTable(); -// ui->progressBar->setValue(100); -// ui->statusBar->showMessage(tr("Done")); + statusBar->setIconConnectionStatus(jceStatusBar::Done); } else if (status == jceLogin::JCE_NOT_CONNECTED) { qWarning() << Q_FUNC_INFO << "not connected"; QApplication::restoreOverrideCursor(); QMessageBox::critical(this,tr("Error"),tr("Not Connected")); + statusBar->setIconConnectionStatus(jceStatusBar::Disconnected); } else { + statusBar->setIconConnectionStatus(jceStatusBar::ERROR); qCritical() << Q_FUNC_INFO << "grade get ended with" << status; } } @@ -241,18 +236,16 @@ void MainScreen::on_examsBtn_clicked() } void MainScreen::on_getCalendarBtn_clicked() { -// ui->progressBar->setValue(0); qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); int status = 0; QString page; QApplication::setOverrideCursor(Qt::WaitCursor); if (loginHandel->isLoggedInFlag()) { -// ui->statusBar->showMessage(tr("Getting schedule...")); if ((status = loginHandel->makeCalendarRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_PAGE_PASSED) { + statusBar->setIconConnectionStatus(jceStatusBar::Inserting); calendar->resetTable(); -// ui->statusBar->showMessage(tr("Done. Inserting schdule into table..."),1000); page = loginHandel->getCurrentPageContect(); calendar->setCalendar(page); @@ -261,32 +254,29 @@ void MainScreen::on_getCalendarBtn_clicked() //auto getting exam if (loginHandel->isLoggedInFlag()) { -// ui->statusBar->showMessage(tr("Getting exams...")); if ((status = loginHandel->makeExamsScheduleRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_PAGE_PASSED) { -// ui->statusBar->showMessage(tr("Done."),1000); page = loginHandel->getCurrentPageContect(); calendar->setExamsSchedule(page); qDebug() << Q_FUNC_INFO << "exams schedule is loaded"; + statusBar->setIconConnectionStatus(jceStatusBar::Done); } else if (status == jceLogin::JCE_NOT_CONNECTED) { qWarning() << Q_FUNC_INFO << "not connected"; QApplication::restoreOverrideCursor(); QMessageBox::critical(this,tr("Error"),tr("Not Connected")); + statusBar->setIconConnectionStatus(jceStatusBar::Disconnected); } else qCritical() << Q_FUNC_INFO << "exams request get ended with" << status; - - -// ui->progressBar->setValue(100); -// ui->statusBar->showMessage(tr("Done")); } else if (status == jceLogin::JCE_NOT_CONNECTED) { qWarning() << Q_FUNC_INFO << "not connected"; QApplication::restoreOverrideCursor(); QMessageBox::critical(this,tr("Error"),tr("Not Connected")); + statusBar->setIconConnectionStatus(jceStatusBar::Disconnected); } else qCritical() << Q_FUNC_INFO << "calendar get ended with" << status; @@ -405,8 +395,6 @@ void MainScreen::checkLocale() void MainScreen::on_labelMadeBy_linkActivated(const QString &link) { qDebug() << Q_FUNC_INFO << "link: " << link; - - } diff --git a/main/mainscreen.ui b/main/mainscreen.ui index 767a49a..d0884ab 100644 --- a/main/mainscreen.ui +++ b/main/mainscreen.ui @@ -49,6 +49,16 @@ background: qlineargradient(spread:pad, x1:0.496, y1:0, x2:0.508, y2:1, stop:0 r + + + + <p align="center">Made By <a href="http://liranbg.github.io/JceManager/"><span style=" text-decoration: underline; color:#0000ff;">JceManager</span></a></p> + + + true + + + @@ -899,13 +909,6 @@ font-size: 15px; - - - - <p align="center">Made By <a href="http://liranbg.github.io/JceManager/"><span style=" text-decoration: underline; color:#0000ff;">JceManager</span></a></p> - - - @@ -914,7 +917,7 @@ font-size: 15px; 0 0 1133 - 21 + 22 diff --git a/src/jceConnection/jcesslclient.cpp b/src/jceConnection/jcesslclient.cpp index 2906b8f..b3e4579 100644 --- a/src/jceConnection/jcesslclient.cpp +++ b/src/jceConnection/jcesslclient.cpp @@ -3,10 +3,10 @@ /** * @brief jceSSLClient::jceSSLClient Constructer, setting the signals */ -jceSSLClient::jceSSLClient(jceStatusBar *progressbarPtr) : loggedIAndConnectedFlag(false), readingFlag(false), +jceSSLClient::jceSSLClient(jceStatusBar *statusBar) : loggedIAndConnectedFlag(false), readingFlag(false), reConnectionFlag(false), networkConf(), packet(""), recieveLastPacket(false), packetSizeRecieved(0) { - this->progressBar = progressbarPtr; + this->statusBar = statusBar; //setting signals connect(this,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(checkErrors(QAbstractSocket::SocketError))); connect(this,SIGNAL(connected()),this,SLOT(setConnected())); @@ -131,6 +131,7 @@ bool jceSSLClient::sendData(QString str) int amount = 0; if (isConnected()) //if connected { + statusBar->setIconConnectionStatus(jceStatusBar::Sending); amount = write(str.toStdString().c_str(),str.length()); qDebug() << Q_FUNC_INFO << "lenght send: " << str.length() << "lenght recieved: " << amount; if (amount == -1) @@ -151,6 +152,7 @@ bool jceSSLClient::sendData(QString str) */ bool jceSSLClient::recieveData(QString *str) { + statusBar->setIconConnectionStatus(jceStatusBar::Recieving); qDebug() << Q_FUNC_INFO << "Data receiving!"; str->clear(); packet = ""; @@ -208,7 +210,7 @@ void jceSSLClient::readIt() packet.append("\0"); readerAppendingLocker.unlock(); - emit progressBar->progressHasPacket(6); + emit statusBar->progressHasPacket(10); if (tempPacket.contains("Go_To_system_After_Login.htm") || tempPacket.contains("")) { diff --git a/src/jceConnection/jcesslclient.h b/src/jceConnection/jcesslclient.h index 8f77372..1f2471c 100644 --- a/src/jceConnection/jcesslclient.h +++ b/src/jceConnection/jcesslclient.h @@ -20,7 +20,7 @@ class jceSSLClient : public QSslSocket { Q_OBJECT public: - jceSSLClient(jceStatusBar *progressbarPtr); + jceSSLClient(jceStatusBar *statusBar); bool makeConnect(QString server = "yedion.jce.ac.il", int port = 443); bool makeDiconnect(); @@ -64,7 +64,7 @@ private: - jceStatusBar *progressBar; //progressbar pointer + jceStatusBar *statusBar; //progressbar pointer }; diff --git a/src/jceSettings/jcelogin.cpp b/src/jceSettings/jcelogin.cpp index 656823a..013afe6 100644 --- a/src/jceSettings/jcelogin.cpp +++ b/src/jceSettings/jcelogin.cpp @@ -4,12 +4,12 @@ * @brief jceLogin::jceLogin * @param username pointer to allocated user settings */ -jceLogin::jceLogin(user* username, jceStatusBar *progressbarPtr) +jceLogin::jceLogin(user* username, jceStatusBar *statusBar) { - this->progressBar = progressbarPtr; + this->statusBar = statusBar; this->recieverPage = new QString(); this->jceA = username; - this->JceConnector = new jceSSLClient(progressBar); + this->JceConnector = new jceSSLClient(statusBar); QObject::connect(JceConnector,SIGNAL(serverDisconnectedbyRemote()),this,SLOT(reValidation())); QObject::connect(JceConnector,SIGNAL(noInternetLink()),this,SLOT(reMakeConnection())); } @@ -28,7 +28,7 @@ jceLogin::~jceLogin() */ int jceLogin::makeConnection() { - qDebug() << "jceLogin::makeConnection(); connection to be make"; + qDebug() << Q_FUNC_INFO << "connection to be make"; if (this->recieverPage == NULL) this->recieverPage = new QString(); @@ -40,6 +40,7 @@ int jceLogin::makeConnection() if (returnMode == false) { + statusBar->setIconConnectionStatus(jceStatusBar::Connecting); if (JceConnector->makeConnect(dst_host,dst_port) == false) //couldnt make a connection return jceStatus::ERROR_ON_OPEN_SOCKET; else @@ -48,6 +49,7 @@ int jceLogin::makeConnection() if (returnMode == true) //connected to host { + statusBar->setIconConnectionStatus(jceStatusBar::Connected); returnMode = makeFirstVisit(); if (returnMode == true) //requst and send first validation { @@ -62,6 +64,7 @@ int jceLogin::makeConnection() qDebug() << Q_FUNC_INFO << "Signed in succeesfully"; status = jceStatus::JCE_YOU_ARE_IN; setLoginFlag(true); + statusBar->setIconConnectionStatus(jceStatusBar::LoggedIn); } else if (returnMode == jceLogin::ERROR_ON_GETTING_INFO) { @@ -93,6 +96,8 @@ int jceLogin::makeConnection() else status = jceStatus::JCE_NOT_CONNECTED; + if (status != jceStatus::JCE_YOU_ARE_IN) + statusBar->setIconConnectionStatus(jceStatusBar::ERROR); //we throw status even if we are IN! qDebug() << Q_FUNC_INFO << "return status: " << status; return status; @@ -114,6 +119,7 @@ bool jceLogin::checkConnection() const */ void jceLogin::closeAll() { + statusBar->setIconConnectionStatus(jceStatusBar::Disconnected); this->JceConnector->makeDiconnect(); if ((this->recieverPage != NULL) && (!this->recieverPage->isEmpty())) { @@ -134,7 +140,7 @@ void jceLogin::reMakeConnection() recieverPage = NULL; JceConnector = NULL; this->recieverPage = new QString(); - this->JceConnector = new jceSSLClient(progressBar); + this->JceConnector = new jceSSLClient(statusBar); QObject::connect(JceConnector,SIGNAL(serverDisconnectedbyRemote()),this,SLOT(reValidation())); QObject::connect(JceConnector,SIGNAL(noInternetLink()),this,SLOT(reMakeConnection())); emit connectionReadyAfterDisconnection(); @@ -148,6 +154,7 @@ int jceLogin::makeFirstVisit() { QString usr = jceA->getUsername(); QString psw = jceA->getPassword(); + if (JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getFirstValidationStep(*jceA)))) { if (!JceConnector->recieveData(recieverPage)) diff --git a/src/jceSettings/jcelogin.h b/src/jceSettings/jcelogin.h index 507bc3a..a0443d6 100644 --- a/src/jceSettings/jcelogin.h +++ b/src/jceSettings/jcelogin.h @@ -16,7 +16,7 @@ class jceLogin : public QObject Q_OBJECT public: - jceLogin(user* username,jceStatusBar *progressbarPtr); + jceLogin(user* username, jceStatusBar *statusBar); ~jceLogin(); enum jceStatus { @@ -65,7 +65,7 @@ private: QString * recieverPage; user * jceA; jceSSLClient * JceConnector; - jceStatusBar *progressBar; + jceStatusBar *statusBar; };