#include <QPushButton>
#include <QSettings>
#include <QSizeGrip>
+#include <QProgressDialog>
MLogin::MLogin()
{
{
//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
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."));
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
#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);
webSettings(false);
//Event tab
+ if(initUpdate)initUpdate(10,tr("Getting events..."));
eventtab=new MEventsTab(pk);
addTab(eventtab,tr("Events"),eventtab->menu());
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());
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*/