Implemented basic offline mode
This commit is contained in:
parent
d587e7ada4
commit
2acfd00d76
@ -39,7 +39,8 @@ HEADERS += gui/mainwindow.h \
|
|||||||
FORMS += gui/mainwindow.ui \
|
FORMS += gui/mainwindow.ui \
|
||||||
gui/settingsdialog.ui \
|
gui/settingsdialog.ui \
|
||||||
gui/modeditwindow.ui \
|
gui/modeditwindow.ui \
|
||||||
gui/instancesettings.ui
|
gui/instancesettings.ui \
|
||||||
|
gui/logindialog.ui
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
multimc.qrc
|
multimc.qrc
|
||||||
|
@ -24,12 +24,21 @@ LoginDialog::LoginDialog(QWidget *parent, const QString& loginErrMsg) :
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
//TODO: make translateable
|
||||||
|
offlineButton = new QPushButton("Offline Once");
|
||||||
|
|
||||||
|
ui->loginButtonBox->addButton(offlineButton, QDialogButtonBox::ActionRole);
|
||||||
|
|
||||||
blockToggles = false;
|
blockToggles = false;
|
||||||
|
isOnline_ = true;
|
||||||
|
onlineForced = false;
|
||||||
|
|
||||||
//FIXME: translateable?
|
//FIXME: translateable?
|
||||||
ui->usernameTextBox->lineEdit()->setPlaceholderText(QApplication::translate("LoginDialog", "Name", 0));
|
ui->usernameTextBox->lineEdit()->setPlaceholderText(QApplication::translate("LoginDialog", "Name", 0));
|
||||||
|
|
||||||
connect(ui->usernameTextBox, SIGNAL(currentTextChanged(QString)), this, SLOT(userTextChanged(QString)));
|
connect(ui->usernameTextBox, SIGNAL(currentTextChanged(QString)), this, SLOT(userTextChanged(QString)));
|
||||||
connect(ui->forgetButton, SIGNAL(clicked(bool)), this, SLOT(forgetCurrentUser()));
|
connect(ui->forgetButton, SIGNAL(clicked(bool)), this, SLOT(forgetCurrentUser()));
|
||||||
|
connect(offlineButton, SIGNAL(clicked(bool)), this, SLOT(launchOffline()));
|
||||||
|
|
||||||
if (loginErrMsg.isEmpty())
|
if (loginErrMsg.isEmpty())
|
||||||
ui->loginErrorLabel->setVisible(false);
|
ui->loginErrorLabel->setVisible(false);
|
||||||
@ -60,6 +69,7 @@ LoginDialog::LoginDialog(QWidget *parent, const QString& loginErrMsg) :
|
|||||||
|
|
||||||
LoginDialog::~LoginDialog()
|
LoginDialog::~LoginDialog()
|
||||||
{
|
{
|
||||||
|
delete offlineButton;
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,3 +183,15 @@ void LoginDialog::accept()
|
|||||||
}
|
}
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LoginDialog::launchOffline()
|
||||||
|
{
|
||||||
|
isOnline_ = false;
|
||||||
|
QDialog::accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoginDialog::forceOnline()
|
||||||
|
{
|
||||||
|
onlineForced = true;
|
||||||
|
offlineButton->setEnabled(false);
|
||||||
|
}
|
@ -17,6 +17,7 @@
|
|||||||
#define LOGINDIALOG_H
|
#define LOGINDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class LoginDialog;
|
class LoginDialog;
|
||||||
@ -32,6 +33,10 @@ public:
|
|||||||
|
|
||||||
QString getUsername() const;
|
QString getUsername() const;
|
||||||
QString getPassword() const;
|
QString getPassword() const;
|
||||||
|
|
||||||
|
inline bool isOnline() { return isOnline_; }
|
||||||
|
|
||||||
|
void forceOnline();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void accept();
|
virtual void accept();
|
||||||
@ -40,9 +45,13 @@ public slots:
|
|||||||
private slots:
|
private slots:
|
||||||
void usernameToggled ( bool );
|
void usernameToggled ( bool );
|
||||||
void passwordToggled ( bool );
|
void passwordToggled ( bool );
|
||||||
|
void launchOffline();
|
||||||
private:
|
private:
|
||||||
Ui::LoginDialog *ui;
|
Ui::LoginDialog *ui;
|
||||||
bool blockToggles;
|
bool blockToggles;
|
||||||
|
QPushButton *offlineButton;
|
||||||
|
bool isOnline_;
|
||||||
|
bool onlineForced;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LOGINDIALOG_H
|
#endif // LOGINDIALOG_H
|
||||||
|
@ -473,17 +473,29 @@ void MainWindow::doLogin(const QString& errorMsg)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
LoginDialog* loginDlg = new LoginDialog(this, errorMsg);
|
LoginDialog* loginDlg = new LoginDialog(this, errorMsg);
|
||||||
|
if (!m_selectedInstance->lastLaunch())
|
||||||
|
loginDlg->forceOnline();
|
||||||
|
|
||||||
loginDlg->exec();
|
loginDlg->exec();
|
||||||
if(loginDlg->result() == QDialog::Accepted)
|
if(loginDlg->result() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
UserInfo uInfo{loginDlg->getUsername(), loginDlg->getPassword()};
|
if (loginDlg->isOnline())
|
||||||
|
{
|
||||||
|
UserInfo uInfo{loginDlg->getUsername(), loginDlg->getPassword()};
|
||||||
|
|
||||||
TaskDialog* tDialog = new TaskDialog(this);
|
TaskDialog* tDialog = new TaskDialog(this);
|
||||||
LoginTask* loginTask = new LoginTask(uInfo, tDialog);
|
LoginTask* loginTask = new LoginTask(uInfo, tDialog);
|
||||||
connect(loginTask, SIGNAL(succeeded()),SLOT(onLoginComplete()), Qt::QueuedConnection);
|
connect(loginTask, SIGNAL(succeeded()),SLOT(onLoginComplete()), Qt::QueuedConnection);
|
||||||
connect(loginTask, SIGNAL(failed(QString)), SLOT(doLogin(QString)), Qt::QueuedConnection);
|
connect(loginTask, SIGNAL(failed(QString)), SLOT(doLogin(QString)), Qt::QueuedConnection);
|
||||||
m_activeInst = m_selectedInstance;
|
m_activeInst = m_selectedInstance;
|
||||||
tDialog->exec(loginTask);
|
tDialog->exec(loginTask);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_activeLogin = {loginDlg->getUsername(), QString("Offline"), qint64(-1)};
|
||||||
|
m_activeInst = m_selectedInstance;
|
||||||
|
launchInstance(m_activeInst, m_activeLogin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user