From: Konrad Rosenbaum Date: Fri, 23 Aug 2013 16:32:10 +0000 (+0200) Subject: show some progress while logging in X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=dd0ac9ed94d53f276085931122f22237f80b3ad7;p=web%2Fkonrad%2Fsmoke.git show some progress while logging in --- diff --git a/src/dialogs/login.cpp b/src/dialogs/login.cpp index f389c51..badc067 100644 --- a/src/dialogs/login.cpp +++ b/src/dialogs/login.cpp @@ -29,6 +29,7 @@ #include #include #include +#include MLogin::MLogin() { @@ -107,6 +108,13 @@ void MLogin::startLogin() { //make it impossible for the user to interfere setEnabled(false); + QProgressDialog pd(this); + pd.setWindowTitle(tr("Login")); + pd.setLabelText(tr("Logging in...")); + pd.setCancelButton(nullptr); + pd.setRange(-30,100); + pd.setValue(-30); + pd.setVisible(true); //create request object MSInterface *mw=new MSInterface(profiles->itemData(profiles->currentIndex()).toString()); //check server version @@ -116,6 +124,7 @@ void MLogin::startLogin() setEnabled(true); return; } + pd.setValue(-20); //start login request if(!mw->login(username->text(),password->text())){ QMessageBox::warning(this,tr("Warning"),tr("Unable to log in.")); @@ -123,10 +132,18 @@ void MLogin::startLogin() setEnabled(true); return; } + pd.setValue(-10); + pd.setLabelText(tr("Getting data...")); //initialize mw->initialize(); + pd.setValue(0); //open window - MOverview *mo=new MOverview(profiles->itemData(profiles->currentIndex()).toString()); + MOverview *mo=new MOverview(profiles->itemData(profiles->currentIndex()).toString(), + [&pd](int val,QString txt){ + pd.setValue(val); + pd.setLabelText(txt); + } + ); mo->show(); //make sure the application exits (only) after everything is cleaned up diff --git a/src/mwin/overview.cpp b/src/mwin/overview.cpp index 4befc1d..4652fd2 100644 --- a/src/mwin/overview.cpp +++ b/src/mwin/overview.cpp @@ -66,7 +66,7 @@ #include "MTBackup" #include "MTGetAllUsers" -MOverview::MOverview(QString pk) +MOverview::MOverview(QString pk,std::functioninitUpdate) :MTabWin(pk),entrancetab(nullptr) { rtimer.setInterval(QSettings().value("profiles/"+pk+"/refresh",300).toInt()*1000); @@ -149,6 +149,7 @@ MOverview::MOverview(QString pk) webSettings(false); //Event tab + if(initUpdate)initUpdate(10,tr("Getting events...")); eventtab=new MEventsTab(pk); addTab(eventtab,tr("Events"),eventtab->menu()); @@ -163,10 +164,12 @@ MOverview::MOverview(QString pk) connect(carttab,SIGNAL(requestFocus()), this,SLOT(switchToCartTab())); //Order List Tab + if(initUpdate)initUpdate(40,tr("Getting Orders...")); addTab(ordertab=new MOrdersTab(pk),tr("Order List")); connect(ordertab,SIGNAL(selectEventIds(QList&)), eventtab,SLOT(selectEventIds(QList&)), Qt::DirectConnection); //Entrance Control Tab + if(initUpdate)initUpdate(70,tr("Getting Entrance Data...")); entrancetab=new MEntranceTab(pk); addTab(entrancetab,tr("Entrance"),entrancetab->menu()); diff --git a/src/mwin/overview.h b/src/mwin/overview.h index 619e605..380c955 100644 --- a/src/mwin/overview.h +++ b/src/mwin/overview.h @@ -47,7 +47,7 @@ class MOverview:public MTabWin Q_OBJECT public: /**construct the window with web-request/session handler and QSettings-key for current profile*/ - MOverview(QString); + MOverview(QString,std::functioninitUpdate=nullptr); ~MOverview(); protected: /**handle closing the window: close the session too*/