Made the version list load in the background on startup.
Resolves JIRA issue MMC-11: https://jira.forkk.net/browse/MMC-11
This commit is contained in:
parent
2fe6bc47ed
commit
7e3592bee8
@ -56,6 +56,8 @@
|
|||||||
#include "instancemodel.h"
|
#include "instancemodel.h"
|
||||||
#include "instancedelegate.h"
|
#include "instancedelegate.h"
|
||||||
|
|
||||||
|
#include "minecraftversionlist.h"
|
||||||
|
|
||||||
// Opens the given file in the default application.
|
// Opens the given file in the default application.
|
||||||
// TODO: Move this somewhere.
|
// TODO: Move this somewhere.
|
||||||
void openInDefaultProgram ( QString filename );
|
void openInDefaultProgram ( QString filename );
|
||||||
@ -75,16 +77,16 @@ MainWindow::MainWindow ( QWidget *parent ) :
|
|||||||
view->setPalette(pal);
|
view->setPalette(pal);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
view->setStyleSheet(
|
// view->setStyleSheet(
|
||||||
"QListView\
|
// "QListView\
|
||||||
{\
|
// {\
|
||||||
background-image: url(:/backgrounds/kitteh);\
|
// background-image: url(:/backgrounds/kitteh);\
|
||||||
background-attachment: fixed;\
|
// background-attachment: fixed;\
|
||||||
background-clip: padding;\
|
// background-clip: padding;\
|
||||||
background-position: top right;\
|
// background-position: top right;\
|
||||||
background-repeat: none;\
|
// background-repeat: none;\
|
||||||
background-color:palette(base);\
|
// background-color:palette(base);\
|
||||||
}");
|
// }");
|
||||||
|
|
||||||
view->setSelectionMode ( QAbstractItemView::SingleSelection );
|
view->setSelectionMode ( QAbstractItemView::SingleSelection );
|
||||||
//view->setSpacing( KDialog::spacingHint() );
|
//view->setSpacing( KDialog::spacingHint() );
|
||||||
@ -126,6 +128,12 @@ MainWindow::MainWindow ( QWidget *parent ) :
|
|||||||
instList.at(0)->setGroup("TEST GROUP");
|
instList.at(0)->setGroup("TEST GROUP");
|
||||||
instList.at(0)->setName("TEST ITEM");
|
instList.at(0)->setName("TEST ITEM");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (!MinecraftVersionList::getMainList().isLoaded())
|
||||||
|
{
|
||||||
|
m_versionLoadTask = MinecraftVersionList::getMainList().getLoadTask();
|
||||||
|
startTask(m_versionLoadTask);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -146,6 +154,14 @@ void MainWindow::instanceActivated ( QModelIndex index )
|
|||||||
|
|
||||||
void MainWindow::on_actionAddInstance_triggered()
|
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 );
|
NewInstanceDialog *newInstDlg = new NewInstanceDialog ( this );
|
||||||
if (newInstDlg->exec())
|
if (newInstDlg->exec())
|
||||||
{
|
{
|
||||||
@ -347,6 +363,26 @@ void MainWindow::onLoginFailed ( QString inst, const QString& errorMsg )
|
|||||||
doLogin(inst, 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
|
// Create A Desktop Shortcut
|
||||||
void MainWindow::on_actionMakeDesktopShortcut_triggered()
|
void MainWindow::on_actionMakeDesktopShortcut_triggered()
|
||||||
|
@ -88,9 +88,14 @@ private slots:
|
|||||||
void onLoginComplete( QString inst, LoginResponse response );
|
void onLoginComplete( QString inst, LoginResponse response );
|
||||||
void onLoginFailed( QString inst, const QString& errorMsg );
|
void onLoginFailed( QString inst, const QString& errorMsg );
|
||||||
|
|
||||||
|
void taskStart(Task *task);
|
||||||
|
void taskEnd(Task *task);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void instanceActivated ( QModelIndex );
|
void instanceActivated ( QModelIndex );
|
||||||
|
|
||||||
|
void startTask(Task *task);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
KCategoryDrawer * drawer;
|
KCategoryDrawer * drawer;
|
||||||
@ -100,6 +105,8 @@ private:
|
|||||||
InstanceList instList;
|
InstanceList instList;
|
||||||
MinecraftProcess *proc;
|
MinecraftProcess *proc;
|
||||||
ConsoleWindow *console;
|
ConsoleWindow *console;
|
||||||
|
|
||||||
|
Task *m_versionLoadTask;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
@ -45,14 +45,10 @@ void TaskDialog::exec(Task *task)
|
|||||||
this->task = task;
|
this->task = task;
|
||||||
|
|
||||||
// Connect signals.
|
// Connect signals.
|
||||||
connect(task, SIGNAL(taskStarted(Task*)),
|
connect(task, SIGNAL(started(Task*)), SLOT(onTaskStarted(Task*)));
|
||||||
this, SLOT(onTaskStarted(Task*)));
|
connect(task, SIGNAL(ended(Task*)), SLOT(onTaskEnded(Task*)));
|
||||||
connect(task, SIGNAL(taskEnded(Task*)),
|
connect(task, SIGNAL(statusChanged(const QString&)), SLOT(changeStatus(const QString&)));
|
||||||
this, SLOT(onTaskEnded(Task*)));
|
connect(task, SIGNAL(progressChanged(int)), SLOT(changeProgress(int)));
|
||||||
connect(task, SIGNAL(statusChanged(const QString&)),
|
|
||||||
this, SLOT(changeStatus(const QString&)));
|
|
||||||
connect(task, SIGNAL(progressChanged(int)),
|
|
||||||
this, SLOT(changeProgress(int)));
|
|
||||||
|
|
||||||
task->startTask();
|
task->startTask();
|
||||||
QDialog::exec();
|
QDialog::exec();
|
||||||
|
@ -48,8 +48,15 @@ public slots:
|
|||||||
void setProgress(int progress);
|
void setProgress(int progress);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void taskStarted(Task* task);
|
void started(Task* task);
|
||||||
void taskEnded(Task* task);
|
void ended(Task* task);
|
||||||
|
|
||||||
|
void started();
|
||||||
|
void ended();
|
||||||
|
|
||||||
|
|
||||||
|
void statusChanged(Task* task, const QString& status);
|
||||||
|
void progressChanged(Task* task, int progress);
|
||||||
|
|
||||||
void statusChanged(const QString& status);
|
void statusChanged(const QString& status);
|
||||||
void progressChanged(int progress);
|
void progressChanged(int progress);
|
||||||
@ -58,6 +65,12 @@ protected:
|
|||||||
virtual void run();
|
virtual void run();
|
||||||
virtual void executeTask() = 0;
|
virtual void executeTask() = 0;
|
||||||
|
|
||||||
|
virtual void emitStarted();
|
||||||
|
virtual void emitEnded();
|
||||||
|
|
||||||
|
virtual void emitStatusChange(const QString &status);
|
||||||
|
virtual void emitProgressChange(int progress);
|
||||||
|
|
||||||
QString status;
|
QString status;
|
||||||
int progress;
|
int progress;
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,7 @@ QString Task::getStatus() const
|
|||||||
void Task::setStatus(const QString &status)
|
void Task::setStatus(const QString &status)
|
||||||
{
|
{
|
||||||
this->status = status;
|
this->status = status;
|
||||||
emit statusChanged(status);
|
emitStatusChange(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Task::getProgress() const
|
int Task::getProgress() const
|
||||||
@ -45,7 +45,7 @@ void Task::calcProgress(int parts, int whole)
|
|||||||
void Task::setProgress(int progress)
|
void Task::setProgress(int progress)
|
||||||
{
|
{
|
||||||
this->progress = progress;
|
this->progress = progress;
|
||||||
emit progressChanged(progress);
|
emitProgressChange(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Task::startTask()
|
void Task::startTask()
|
||||||
@ -55,7 +55,29 @@ void Task::startTask()
|
|||||||
|
|
||||||
void Task::run()
|
void Task::run()
|
||||||
{
|
{
|
||||||
emit taskStarted(this);
|
emitStarted();
|
||||||
executeTask();
|
executeTask();
|
||||||
emit taskEnded(this);
|
emitEnded();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Task::emitStarted()
|
||||||
|
{
|
||||||
|
emit started();
|
||||||
|
emit started(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Task::emitEnded()
|
||||||
|
{
|
||||||
|
emit ended();
|
||||||
|
emit ended(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Task::emitStatusChange(const QString &status)
|
||||||
|
{
|
||||||
|
emit statusChanged(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Task::emitProgressChange(int progress)
|
||||||
|
{
|
||||||
|
emit progressChanged(progress);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user