summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-09-06 22:00:19 +0200
committerPetr Mrázek <peterix@gmail.com>2013-09-06 22:00:19 +0200
commite6b8923b23693a10023b3cf4e5573390e5f22d7d (patch)
treeff55f4b0ecbbe497e5f99f756938cb60d07a7d47
parent634e22298b14a8ad09f0d0489cb1c08c97d1f73a (diff)
parent2acfd00d76b79c49b61f651b5459f65803601a95 (diff)
downloadMultiMC-e6b8923b23693a10023b3cf4e5573390e5f22d7d.tar
MultiMC-e6b8923b23693a10023b3cf4e5573390e5f22d7d.tar.gz
MultiMC-e6b8923b23693a10023b3cf4e5573390e5f22d7d.tar.lz
MultiMC-e6b8923b23693a10023b3cf4e5573390e5f22d7d.tar.xz
MultiMC-e6b8923b23693a10023b3cf4e5573390e5f22d7d.zip
Merge https://github.com/Stiepen22/MultiMC5
-rw-r--r--MultiMC.pro3
-rw-r--r--gui/logindialog.cpp22
-rw-r--r--gui/logindialog.h9
-rw-r--r--gui/mainwindow.cpp28
4 files changed, 53 insertions, 9 deletions
diff --git a/MultiMC.pro b/MultiMC.pro
index 6af1ec0d..b3b7faff 100644
--- a/MultiMC.pro
+++ b/MultiMC.pro
@@ -39,7 +39,8 @@ HEADERS += gui/mainwindow.h \
FORMS += gui/mainwindow.ui \
gui/settingsdialog.ui \
gui/modeditwindow.ui \
- gui/instancesettings.ui
+ gui/instancesettings.ui \
+ gui/logindialog.ui
RESOURCES += \
multimc.qrc
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);
+ }
}
}