show some progress while logging in
authorKonrad Rosenbaum <konrad@silmor.de>
Fri, 23 Aug 2013 16:32:10 +0000 (18:32 +0200)
committerKonrad Rosenbaum <konrad@silmor.de>
Fri, 23 Aug 2013 16:32:10 +0000 (18:32 +0200)
src/dialogs/login.cpp
src/mwin/overview.cpp
src/mwin/overview.h

index f389c51..badc067 100644 (file)
@@ -29,6 +29,7 @@
 #include <QPushButton>
 #include <QSettings>
 #include <QSizeGrip>
+#include <QProgressDialog>
 
 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
index 4befc1d..4652fd2 100644 (file)
@@ -66,7 +66,7 @@
 #include "MTBackup"
 #include "MTGetAllUsers"
 
-MOverview::MOverview(QString pk)
+MOverview::MOverview(QString pk,std::function<void(int,QString)>initUpdate)
        :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<int>&)), eventtab,SLOT(selectEventIds(QList<int>&)), Qt::DirectConnection);
        
        //Entrance Control Tab
+        if(initUpdate)initUpdate(70,tr("Getting Entrance Data..."));
        entrancetab=new MEntranceTab(pk);
        addTab(entrancetab,tr("Entrance"),entrancetab->menu());
        
index 619e605..380c955 100644 (file)
@@ -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::function<void(int,QString)>initUpdate=nullptr);
                ~MOverview();
        protected:
                /**handle closing the window: close the session too*/