summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/logindialog.cpp22
-rw-r--r--gui/logindialog.h9
-rw-r--r--gui/mainwindow.cpp28
3 files changed, 51 insertions, 8 deletions
diff --git a/gui/logindialog.cpp b/gui/logindialog.cpp
index 3b44c440..a4dad1c1 100644
--- a/gui/logindialog.cpp
+++ b/gui/logindialog.cpp
@@ -24,12 +24,21 @@ LoginDialog::LoginDialog(QWidget *parent, const QString& loginErrMsg) :
{
ui->setupUi(this);
+ //TODO: make translateable
+ offlineButton = new QPushButton("Offline Once");
+
+ ui->loginButtonBox->addButton(offlineButton, QDialogButtonBox::ActionRole);
+
blockToggles = false;
+ isOnline_ = true;
+ onlineForced = false;
+
//FIXME: translateable?
ui->usernameTextBox->lineEdit()->setPlaceholderText(QApplication::translate("LoginDialog", "Name", 0));
connect(ui->usernameTextBox, SIGNAL(currentTextChanged(QString)), this, SLOT(userTextChanged(QString)));
connect(ui->forgetButton, SIGNAL(clicked(bool)), this, SLOT(forgetCurrentUser()));
+ connect(offlineButton, SIGNAL(clicked(bool)), this, SLOT(launchOffline()));
if (loginErrMsg.isEmpty())
ui->loginErrorLabel->setVisible(false);
@@ -60,6 +69,7 @@ LoginDialog::LoginDialog(QWidget *parent, const QString& loginErrMsg) :
LoginDialog::~LoginDialog()
{
+ delete offlineButton;
delete ui;
}
@@ -173,3 +183,15 @@ void LoginDialog::accept()
}
QDialog::accept();
}
+
+void LoginDialog::launchOffline()
+{
+ isOnline_ = false;
+ QDialog::accept();
+}
+
+void LoginDialog::forceOnline()
+{
+ onlineForced = true;
+ offlineButton->setEnabled(false);
+} \ No newline at end of file
diff --git a/gui/logindialog.h b/gui/logindialog.h
index 3bb45753..f7c0e930 100644
--- a/gui/logindialog.h
+++ b/gui/logindialog.h
@@ -17,6 +17,7 @@
#define LOGINDIALOG_H
#include <QDialog>
+#include <QPushButton>
namespace Ui {
class LoginDialog;
@@ -32,6 +33,10 @@ public:
QString getUsername() const;
QString getPassword() const;
+
+ inline bool isOnline() { return isOnline_; }
+
+ void forceOnline();
public slots:
virtual void accept();
@@ -40,9 +45,13 @@ public slots:
private slots:
void usernameToggled ( bool );
void passwordToggled ( bool );
+ void launchOffline();
private:
Ui::LoginDialog *ui;
bool blockToggles;
+ QPushButton *offlineButton;
+ bool isOnline_;
+ bool onlineForced;
};
#endif // LOGINDIALOG_H
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index 7cdf93ad..4ccc12b6 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -473,17 +473,29 @@ void MainWindow::doLogin(const QString& errorMsg)
return;
LoginDialog* loginDlg = new LoginDialog(this, errorMsg);
+ if (!m_selectedInstance->lastLaunch())
+ loginDlg->forceOnline();
+
loginDlg->exec();
if(loginDlg->result() == QDialog::Accepted)
{
- UserInfo uInfo{loginDlg->getUsername(), loginDlg->getPassword()};
-
- TaskDialog* tDialog = new TaskDialog(this);
- LoginTask* loginTask = new LoginTask(uInfo, tDialog);
- connect(loginTask, SIGNAL(succeeded()),SLOT(onLoginComplete()), Qt::QueuedConnection);
- connect(loginTask, SIGNAL(failed(QString)), SLOT(doLogin(QString)), Qt::QueuedConnection);
- m_activeInst = m_selectedInstance;
- tDialog->exec(loginTask);
+ if (loginDlg->isOnline())
+ {
+ UserInfo uInfo{loginDlg->getUsername(), loginDlg->getPassword()};
+
+ TaskDialog* tDialog = new TaskDialog(this);
+ LoginTask* loginTask = new LoginTask(uInfo, tDialog);
+ connect(loginTask, SIGNAL(succeeded()),SLOT(onLoginComplete()), Qt::QueuedConnection);
+ connect(loginTask, SIGNAL(failed(QString)), SLOT(doLogin(QString)), Qt::QueuedConnection);
+ m_activeInst = m_selectedInstance;
+ tDialog->exec(loginTask);
+ }
+ else
+ {
+ m_activeLogin = {loginDlg->getUsername(), QString("Offline"), qint64(-1)};
+ m_activeInst = m_selectedInstance;
+ launchInstance(m_activeInst, m_activeLogin);
+ }
}
}