diff options
Diffstat (limited to 'gui/mainwindow.cpp')
-rw-r--r-- | gui/mainwindow.cpp | 61 |
1 files changed, 41 insertions, 20 deletions
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 82483bf2..d7b77c8b 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -42,7 +42,7 @@ #include "gui/settingsdialog.h" #include "gui/newinstancedialog.h" #include "gui/logindialog.h" -#include "gui/taskdialog.h" +#include "gui/ProgressDialog.h" #include "gui/aboutdialog.h" #include "gui/versionselectdialog.h" #include "gui/lwjglselectdialog.h" @@ -54,7 +54,7 @@ #include "logic/lists/LwjglVersionList.h" #include "logic/lists/IconList.h" -#include "logic/tasks/LoginTask.h" +#include "logic/net/LoginTask.h" #include "logic/BaseInstance.h" #include "logic/InstanceFactory.h" #include "logic/MinecraftProcess.h" @@ -124,7 +124,7 @@ MainWindow::MainWindow ( QWidget *parent ) //proxymodel->setDynamicSortFilter ( true ); // FIXME: instList should be global-ish, or at least not tied to the main window... maybe the application itself? - proxymodel->setSourceModel ( MMC->instances() ); + proxymodel->setSourceModel ( MMC->instances().data() ); proxymodel->sort ( 0 ); view->setFrameShape ( QFrame::NoFrame ); view->setModel ( proxymodel ); @@ -149,19 +149,19 @@ MainWindow::MainWindow ( QWidget *parent ) ); // model reset -> selection is invalid. All the instance pointers are wrong. // FIXME: stop using POINTERS everywhere - connect(MMC->instances() ,SIGNAL(dataIsInvalid()),SLOT(selectionBad())); + connect(MMC->instances().data() ,SIGNAL(dataIsInvalid()),SLOT(selectionBad())); // run the things that load and download other things... FIXME: this is NOT the place // FIXME: invisible actions in the background = NOPE. { - if (!MinecraftVersionList::getMainList().isLoaded()) + if (!MMC->minecraftlist()->isLoaded()) { - m_versionLoadTask = MinecraftVersionList::getMainList().getLoadTask(); + m_versionLoadTask = MMC->minecraftlist()->getLoadTask(); startTask(m_versionLoadTask); } - if (!LWJGLVersionList::get().isLoaded()) + if (!MMC->lwjgllist()->isLoaded()) { - LWJGLVersionList::get().loadList(); + MMC->lwjgllist()->loadList(); } assets_downloader = new OneSixAssets(); assets_downloader->start(); @@ -245,7 +245,7 @@ void MainWindow::instanceActivated ( QModelIndex index ) void MainWindow::on_actionAddInstance_triggered() { - if (!MinecraftVersionList::getMainList().isLoaded() && + if (!MMC->minecraftlist()->isLoaded() && m_versionLoadTask && m_versionLoadTask->isRunning()) { QEventLoop waitLoop; @@ -361,7 +361,7 @@ void MainWindow::on_actionSettings_triggered() void MainWindow::on_actionReportBug_triggered() { - openWebPage ( QUrl ( "http://jira.forkk.net/browse/MMC" ) ); + openWebPage ( QUrl ( "http://multimc.myjetbrains.com/youtrack/dashboard#newissue=yes" ) ); } void MainWindow::on_actionNews_triggered() @@ -479,7 +479,7 @@ void MainWindow::doLogin(const QString& errorMsg) { UserInfo uInfo{loginDlg->getUsername(), loginDlg->getPassword()}; - TaskDialog* tDialog = new TaskDialog(this); + ProgressDialog* tDialog = new ProgressDialog(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); @@ -488,7 +488,10 @@ void MainWindow::doLogin(const QString& errorMsg) } else { - m_activeLogin = {loginDlg->getUsername(), QString("Offline"), qint64(-1)}; + QString user = loginDlg->getUsername(); + if (user.length() == 0) + user = QString("Offline"); + m_activeLogin = {user, QString("Offline"), QString(), QString()}; m_activeInst = m_selectedInstance; launchInstance(m_activeInst, m_activeLogin); } @@ -509,7 +512,7 @@ void MainWindow::onLoginComplete() } else { - TaskDialog *tDialog = new TaskDialog(this); + ProgressDialog *tDialog = new ProgressDialog(this); connect(updateTask, SIGNAL(succeeded()),SLOT(onGameUpdateComplete())); connect(updateTask, SIGNAL(failed(QString)), SLOT(onGameUpdateError(QString))); tDialog->exec(updateTask); @@ -530,14 +533,26 @@ void MainWindow::launchInstance(BaseInstance *instance, LoginResponse response) { Q_ASSERT_X(instance != NULL, "launchInstance", "instance is NULL"); - proc = instance->prepareForLaunch(response.username, response.sessionID); + proc = instance->prepareForLaunch(response); if(!proc) return; - console = new ConsoleWindow(); + // Prepare GUI: If it shall stay open disable the required parts + if (MMC->settings()->get("NoHide").toBool()) + { + ui->actionLaunchInstance->setEnabled(false); + } + else + { + this->hide(); + } + + console = new ConsoleWindow(proc); console->show(); connect(proc, SIGNAL(log(QString, MessageLevel::Enum)), console, SLOT(write(QString, MessageLevel::Enum))); + connect(proc, SIGNAL(ended()), this, SLOT(instanceEnded())); + proc->setLogin(response.username, response.session_id); proc->launch(); } @@ -560,7 +575,7 @@ void MainWindow::startTask(Task *task) connect(task, SIGNAL(started()), SLOT(taskStart())); connect(task, SIGNAL(succeeded()), SLOT(taskEnd())); connect(task, SIGNAL(failed(QString)), SLOT(taskEnd())); - task->startTask(); + task->start(); } @@ -572,7 +587,7 @@ void MainWindow::on_actionMakeDesktopShortcut_triggered() Util::createShortCut ( Util::getDesktopDir(), QApplication::instance()->applicationFilePath(), QStringList() << "-dl" << QDir::currentPath() << "test", name, "application-x-octet-stream" ); - QMessageBox::warning ( this, "Not useful", "A Dummy Shortcut was created. it will not do anything productive" ); + QMessageBox::warning ( this, tr("Not useful"), tr("A Dummy Shortcut was created. it will not do anything productive") ); } // BrowserDialog @@ -586,10 +601,10 @@ void MainWindow::on_actionChangeInstMCVersion_triggered() if (view->selectionModel()->selectedIndexes().count() < 1) return; - VersionSelectDialog vselect(m_selectedInstance->versionList(), this); + VersionSelectDialog vselect(m_selectedInstance->versionList().data(), this); if (vselect.exec() && vselect.selectedVersion()) { - m_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor); + m_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor()); } } @@ -643,7 +658,7 @@ void MainWindow::selectionBad() QString iconKey = "infinity"; statusBar()->clearMessage(); ui->instanceToolBar->setEnabled(false); - renameButton->setText("Rename Instance"); + renameButton->setText(tr("Rename Instance")); auto ico = MMC->icons()->getIcon(iconKey); ui->actionChangeInstIcon->setIcon(ico); } @@ -664,3 +679,9 @@ void MainWindow::on_actionEditInstNotes_triggered() linst->setNotes(noteedit.getText()); } } + +void MainWindow::instanceEnded() +{ + this->show(); + ui->actionLaunchInstance->setEnabled(m_selectedInstance); +} |