summaryrefslogtreecommitdiffstats
path: root/gui/dialogs
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-12-08 17:34:45 +0100
committerPetr Mrázek <peterix@gmail.com>2013-12-08 17:34:45 +0100
commit0cb8ff40b26401a707781c2c4171d3ec6c114077 (patch)
tree0e075c830b67f8b15d5359d06d1026987dc5c124 /gui/dialogs
parentf028aa76bc5d28b7fc4d1ea4e194895690e9944e (diff)
downloadMultiMC-0cb8ff40b26401a707781c2c4171d3ec6c114077.tar
MultiMC-0cb8ff40b26401a707781c2c4171d3ec6c114077.tar.gz
MultiMC-0cb8ff40b26401a707781c2c4171d3ec6c114077.tar.lz
MultiMC-0cb8ff40b26401a707781c2c4171d3ec6c114077.tar.xz
MultiMC-0cb8ff40b26401a707781c2c4171d3ec6c114077.zip
Finish preliminary offline support
* ProgressProvider now has an abort() call * Abort button support added to the progress dialog * YggdrasilTask and MojangAccount adapted to support abort YggdrasilTask will time out after 10 seconds of no network activity, or when the user pushes the Play Offline button. In offline mode, all instance update tasks are skipped! This will need further work.
Diffstat (limited to 'gui/dialogs')
-rw-r--r--gui/dialogs/AccountListDialog.cpp12
-rw-r--r--gui/dialogs/ProgressDialog.cpp26
-rw-r--r--gui/dialogs/ProgressDialog.h6
-rw-r--r--gui/dialogs/ProgressDialog.ui21
4 files changed, 50 insertions, 15 deletions
diff --git a/gui/dialogs/AccountListDialog.cpp b/gui/dialogs/AccountListDialog.cpp
index e1f65c16..8dae5f07 100644
--- a/gui/dialogs/AccountListDialog.cpp
+++ b/gui/dialogs/AccountListDialog.cpp
@@ -25,6 +25,7 @@
#include <gui/dialogs/EditAccountDialog.h>
#include <gui/dialogs/ProgressDialog.h>
#include <gui/dialogs/AccountSelectDialog.h>
+#include <logic/tasks/Task.h>
#include <MultiMC.h>
@@ -117,14 +118,14 @@ void AccountListDialog::addAccount(const QString& errMsg)
QString password(loginDialog.password());
MojangAccountPtr account = MojangAccount::createFromUsername(username);
-/*
ProgressDialog progDialog(this);
- AuthenticateTask authTask(account, password, &progDialog);
- if (progDialog.exec(&authTask))
+ auto task = account->login(password);
+ progDialog.exec(task.get());
+ if(task->successful())
{
- // Add the authenticated account to the accounts list.
- MojangAccountPtr account = authTask.getMojangAccount();
m_accounts->addAccount(account);
+ if (m_accounts->count() == 1)
+ m_accounts->setActiveAccount(account->username());
// Grab associated player skins
auto job = new NetJob("Player skins: " + account->username());
@@ -141,6 +142,5 @@ void AccountListDialog::addAccount(const QString& errMsg)
job->start();
}
- */
}
}
diff --git a/gui/dialogs/ProgressDialog.cpp b/gui/dialogs/ProgressDialog.cpp
index ca433dab..ba14cca2 100644
--- a/gui/dialogs/ProgressDialog.cpp
+++ b/gui/dialogs/ProgressDialog.cpp
@@ -25,9 +25,23 @@ ProgressDialog::ProgressDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Pr
{
MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this);
+ this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
+ setSkipButton(false);
+ changeProgress(0, 100);
+}
+
+void ProgressDialog::setSkipButton(bool present, QString label)
+{
+ ui->skipButton->setEnabled(present);
+ ui->skipButton->setVisible(present);
+ ui->skipButton->setText(label);
updateSize();
+}
- changeProgress(0, 100);
+void ProgressDialog::on_skipButton_clicked(bool checked)
+{
+ Q_UNUSED(checked);
+ task->abort();
}
ProgressDialog::~ProgressDialog()
@@ -51,9 +65,13 @@ int ProgressDialog::exec(ProgressProvider *task)
connect(task, SIGNAL(status(QString)), SLOT(changeStatus(const QString &)));
connect(task, SIGNAL(progress(qint64, qint64)), SLOT(changeProgress(qint64, qint64)));
- // this makes sure that the task is started after the dialog is created
- QMetaObject::invokeMethod(task, "start", Qt::QueuedConnection);
- return QDialog::exec();
+ // if this didn't connect to an already running task, invoke start
+ if(!task->isRunning())
+ task->start();
+ if(task->isRunning())
+ return QDialog::exec();
+ else
+ return 0;
}
ProgressProvider *ProgressDialog::getTask()
diff --git a/gui/dialogs/ProgressDialog.h b/gui/dialogs/ProgressDialog.h
index 0029d3ec..fe63a826 100644
--- a/gui/dialogs/ProgressDialog.h
+++ b/gui/dialogs/ProgressDialog.h
@@ -35,6 +35,7 @@ public:
void updateSize();
int exec(ProgressProvider *task);
+ void setSkipButton(bool present, QString label = QString());
ProgressProvider *getTask();
@@ -47,7 +48,10 @@ slots:
void changeStatus(const QString &status);
void changeProgress(qint64 current, qint64 total);
-signals:
+
+private
+slots:
+ void on_skipButton_clicked(bool checked);
protected:
virtual void keyPressEvent(QKeyEvent *e);
diff --git a/gui/dialogs/ProgressDialog.ui b/gui/dialogs/ProgressDialog.ui
index a56d2a92..04b8fef3 100644
--- a/gui/dialogs/ProgressDialog.ui
+++ b/gui/dialogs/ProgressDialog.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>400</width>
- <height>68</height>
+ <height>100</height>
</rect>
</property>
<property name="minimumSize">
@@ -25,8 +25,8 @@
<property name="windowTitle">
<string>Please wait...</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
<widget class="QLabel" name="statusLabel">
<property name="text">
<string>Task Status...</string>
@@ -36,7 +36,7 @@
</property>
</widget>
</item>
- <item>
+ <item row="1" column="0">
<widget class="QProgressBar" name="taskProgressBar">
<property name="value">
<number>24</number>
@@ -46,6 +46,19 @@
</property>
</widget>
</item>
+ <item row="2" column="0">
+ <widget class="QPushButton" name="skipButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Skip</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>