summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-05-06 17:19:20 -0500
committerAndrew <forkk@forkk.net>2013-05-06 17:19:20 -0500
commit7e3592bee891e78c9d42dcd84bc9c1ac7a3e7688 (patch)
tree4fb1ac88b2aa5daa10b6bde4764453623c3ac4f5 /gui
parent2fe6bc47ed5f3d52d33d164af9a2176eb7d29026 (diff)
downloadMultiMC-7e3592bee891e78c9d42dcd84bc9c1ac7a3e7688.tar
MultiMC-7e3592bee891e78c9d42dcd84bc9c1ac7a3e7688.tar.gz
MultiMC-7e3592bee891e78c9d42dcd84bc9c1ac7a3e7688.tar.lz
MultiMC-7e3592bee891e78c9d42dcd84bc9c1ac7a3e7688.tar.xz
MultiMC-7e3592bee891e78c9d42dcd84bc9c1ac7a3e7688.zip
Made the version list load in the background on startup.
Resolves JIRA issue MMC-11: https://jira.forkk.net/browse/MMC-11
Diffstat (limited to 'gui')
-rw-r--r--gui/mainwindow.cpp56
-rw-r--r--gui/mainwindow.h7
-rw-r--r--gui/taskdialog.cpp12
3 files changed, 57 insertions, 18 deletions
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index 750610c5..96609531 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -56,6 +56,8 @@
#include "instancemodel.h"
#include "instancedelegate.h"
+#include "minecraftversionlist.h"
+
// Opens the given file in the default application.
// TODO: Move this somewhere.
void openInDefaultProgram ( QString filename );
@@ -75,16 +77,16 @@ MainWindow::MainWindow ( QWidget *parent ) :
view->setPalette(pal);
*/
- view->setStyleSheet(
- "QListView\
- {\
- background-image: url(:/backgrounds/kitteh);\
- background-attachment: fixed;\
- background-clip: padding;\
- background-position: top right;\
- background-repeat: none;\
- background-color:palette(base);\
- }");
+// view->setStyleSheet(
+// "QListView\
+// {\
+// background-image: url(:/backgrounds/kitteh);\
+// background-attachment: fixed;\
+// background-clip: padding;\
+// background-position: top right;\
+// background-repeat: none;\
+// background-color:palette(base);\
+// }");
view->setSelectionMode ( QAbstractItemView::SingleSelection );
//view->setSpacing( KDialog::spacingHint() );
@@ -126,6 +128,12 @@ MainWindow::MainWindow ( QWidget *parent ) :
instList.at(0)->setGroup("TEST GROUP");
instList.at(0)->setName("TEST ITEM");
*/
+
+ if (!MinecraftVersionList::getMainList().isLoaded())
+ {
+ m_versionLoadTask = MinecraftVersionList::getMainList().getLoadTask();
+ startTask(m_versionLoadTask);
+ }
}
MainWindow::~MainWindow()
@@ -146,6 +154,14 @@ void MainWindow::instanceActivated ( QModelIndex index )
void MainWindow::on_actionAddInstance_triggered()
{
+ if (!MinecraftVersionList::getMainList().isLoaded() &&
+ m_versionLoadTask && m_versionLoadTask->isRunning())
+ {
+ QEventLoop waitLoop;
+ waitLoop.connect(m_versionLoadTask, SIGNAL(ended()), SLOT(quit()));
+ waitLoop.exec();
+ }
+
NewInstanceDialog *newInstDlg = new NewInstanceDialog ( this );
if (newInstDlg->exec())
{
@@ -347,6 +363,26 @@ void MainWindow::onLoginFailed ( QString inst, const QString& errorMsg )
doLogin(inst, errorMsg);
}
+void MainWindow::taskStart(Task *task)
+{
+ // Nothing to do here yet.
+}
+
+void MainWindow::taskEnd(Task *task)
+{
+ if (task == m_versionLoadTask)
+ m_versionLoadTask = NULL;
+
+ delete task;
+}
+
+void MainWindow::startTask(Task *task)
+{
+ connect(task, SIGNAL(started(Task*)), SLOT(taskStart(Task*)));
+ connect(task, SIGNAL(ended(Task*)), SLOT(taskEnd(Task*)));
+ task->startTask();
+}
+
// Create A Desktop Shortcut
void MainWindow::on_actionMakeDesktopShortcut_triggered()
diff --git a/gui/mainwindow.h b/gui/mainwindow.h
index 896fe9f1..bc35038e 100644
--- a/gui/mainwindow.h
+++ b/gui/mainwindow.h
@@ -87,9 +87,14 @@ private slots:
void onLoginComplete( QString inst, LoginResponse response );
void onLoginFailed( QString inst, const QString& errorMsg );
+
+ void taskStart(Task *task);
+ void taskEnd(Task *task);
public slots:
void instanceActivated ( QModelIndex );
+
+ void startTask(Task *task);
private:
Ui::MainWindow *ui;
@@ -100,6 +105,8 @@ private:
InstanceList instList;
MinecraftProcess *proc;
ConsoleWindow *console;
+
+ Task *m_versionLoadTask;
};
#endif // MAINWINDOW_H
diff --git a/gui/taskdialog.cpp b/gui/taskdialog.cpp
index 9b1ddf23..a74b7718 100644
--- a/gui/taskdialog.cpp
+++ b/gui/taskdialog.cpp
@@ -45,14 +45,10 @@ void TaskDialog::exec(Task *task)
this->task = task;
// Connect signals.
- connect(task, SIGNAL(taskStarted(Task*)),
- this, SLOT(onTaskStarted(Task*)));
- connect(task, SIGNAL(taskEnded(Task*)),
- this, SLOT(onTaskEnded(Task*)));
- connect(task, SIGNAL(statusChanged(const QString&)),
- this, SLOT(changeStatus(const QString&)));
- connect(task, SIGNAL(progressChanged(int)),
- this, SLOT(changeProgress(int)));
+ connect(task, SIGNAL(started(Task*)), SLOT(onTaskStarted(Task*)));
+ connect(task, SIGNAL(ended(Task*)), SLOT(onTaskEnded(Task*)));
+ connect(task, SIGNAL(statusChanged(const QString&)), SLOT(changeStatus(const QString&)));
+ connect(task, SIGNAL(progressChanged(int)), SLOT(changeProgress(int)));
task->startTask();
QDialog::exec();