Implement legacy forge button!
Many refactors of the task system. Progress dialog now accepts generic ProgressProvider objects
This commit is contained in:
@ -13,10 +13,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "MultiMC.h"
|
||||
#include "LegacyModEditDialog.h"
|
||||
#include "ModEditDialogCommon.h"
|
||||
#include "versionselectdialog.h"
|
||||
#include "ProgressDialog.h"
|
||||
#include "ui_LegacyModEditDialog.h"
|
||||
#include <logic/ModList.h>
|
||||
#include "logic/ModList.h"
|
||||
#include "logic/lists/ForgeVersionList.h"
|
||||
|
||||
#include <pathutils.h>
|
||||
#include <QFileDialog>
|
||||
#include <QDebug>
|
||||
@ -194,7 +199,39 @@ void LegacyModEditDialog::on_addCoreBtn_clicked()
|
||||
}
|
||||
void LegacyModEditDialog::on_addForgeBtn_clicked()
|
||||
{
|
||||
|
||||
VersionSelectDialog vselect(MMC->forgelist(), this);
|
||||
vselect.setFilter(1, m_inst->intendedVersionId());
|
||||
if (vselect.exec() && vselect.selectedVersion())
|
||||
{
|
||||
ForgeVersionPtr forge = vselect.selectedVersion().dynamicCast<ForgeVersion>();
|
||||
if(!forge)
|
||||
return;
|
||||
auto entry = MMC->metacache()->resolveEntry("minecraftforge", forge->filename);
|
||||
if(entry->stale)
|
||||
{
|
||||
DownloadJob * fjob = new DownloadJob("Forge download");
|
||||
fjob->add(forge->universal_url, entry);
|
||||
ProgressDialog dlg(this);
|
||||
dlg.exec(fjob);
|
||||
if(dlg.result() == QDialog::Accepted)
|
||||
{
|
||||
m_jarmods->stopWatching();
|
||||
m_jarmods->installMod(QFileInfo(entry->getFullPath()));
|
||||
m_jarmods->startWatching();
|
||||
}
|
||||
else
|
||||
{
|
||||
// failed to download forge :/
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_jarmods->stopWatching();
|
||||
m_jarmods->installMod(QFileInfo(entry->getFullPath()));
|
||||
m_jarmods->startWatching();
|
||||
}
|
||||
//m_selectedInstance->setIntendedVersionId(->descriptor());
|
||||
}
|
||||
}
|
||||
void LegacyModEditDialog::on_addJarBtn_clicked()
|
||||
{
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include "logic/LegacyInstance.h"
|
||||
#include <logic/net/DownloadJob.h>
|
||||
|
||||
namespace Ui {
|
||||
class LegacyModEditDialog;
|
||||
@ -64,4 +65,5 @@ private:
|
||||
QSharedPointer<ModList> m_jarmods;
|
||||
QSharedPointer<ModList> m_texturepacks;
|
||||
LegacyInstance * m_inst;
|
||||
DownloadJobPtr forgeJob;
|
||||
};
|
||||
|
@ -52,9 +52,6 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="addForgeBtn">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>MCForge</string>
|
||||
</property>
|
||||
|
@ -12,18 +12,21 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "MultiMC.h"
|
||||
#include "OneSixModEditDialog.h"
|
||||
#include "ModEditDialogCommon.h"
|
||||
#include "ui_OneSixModEditDialog.h"
|
||||
#include <logic/ModList.h>
|
||||
#include "logic/ModList.h"
|
||||
#include "logic/OneSixVersion.h"
|
||||
#include "logic/EnabledItemFilter.h"
|
||||
#include "logic/lists/ForgeVersionList.h"
|
||||
#include "gui/versionselectdialog.h"
|
||||
|
||||
#include <pathutils.h>
|
||||
#include <QFileDialog>
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
#include "logic/OneSixVersion.h"
|
||||
#include <logic/EnabledItemFilter.h>
|
||||
|
||||
OneSixModEditDialog::OneSixModEditDialog(OneSixInstance * inst, QWidget *parent):
|
||||
m_inst(inst),
|
||||
@ -66,6 +69,17 @@ OneSixModEditDialog::~OneSixModEditDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void OneSixModEditDialog::on_forgeBtn_clicked()
|
||||
{
|
||||
VersionSelectDialog vselect(MMC->forgelist(), this);
|
||||
vselect.setFilter(1, m_inst->currentVersionId());
|
||||
if (vselect.exec() && vselect.selectedVersion())
|
||||
{
|
||||
//m_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool OneSixModEditDialog::loaderListFilter ( QKeyEvent* keyEvent )
|
||||
{
|
||||
switch(keyEvent->key())
|
||||
|
@ -40,6 +40,7 @@ private slots:
|
||||
void on_viewResPackBtn_clicked();
|
||||
// Questionable: SettingsDialog doesn't need this for some reason?
|
||||
void on_buttonBox_rejected();
|
||||
void on_forgeBtn_clicked();
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *ev);
|
||||
bool loaderListFilter( QKeyEvent* ev );
|
||||
|
@ -64,7 +64,7 @@
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QPushButton" name="forgeBrn">
|
||||
<widget class="QPushButton" name="forgeBtn">
|
||||
<property name="toolTip">
|
||||
<string>Replace any current custom version with Minecraft Forge</string>
|
||||
</property>
|
||||
|
@ -13,88 +13,89 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "taskdialog.h"
|
||||
#include "ui_taskdialog.h"
|
||||
#include "ProgressDialog.h"
|
||||
#include "ui_ProgressDialog.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "logic/tasks/Task.h"
|
||||
|
||||
TaskDialog::TaskDialog(QWidget *parent) :
|
||||
ProgressDialog::ProgressDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::TaskDialog)
|
||||
ui(new Ui::ProgressDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
updateSize();
|
||||
|
||||
changeProgress(0);
|
||||
changeProgress(0,100);
|
||||
}
|
||||
|
||||
TaskDialog::~TaskDialog()
|
||||
ProgressDialog::~ProgressDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TaskDialog::updateSize()
|
||||
void ProgressDialog::updateSize()
|
||||
{
|
||||
resize(QSize(480, minimumSizeHint().height()));
|
||||
}
|
||||
|
||||
void TaskDialog::exec(Task *task)
|
||||
int ProgressDialog::exec(ProgressProvider *task)
|
||||
{
|
||||
this->task = task;
|
||||
|
||||
// Connect signals.
|
||||
connect(task, SIGNAL(started()), SLOT(onTaskStarted()));
|
||||
connect(task, SIGNAL(failed(QString)), SLOT(onTaskEnded()));
|
||||
connect(task, SIGNAL(succeeded()), SLOT(onTaskEnded()));
|
||||
connect(task, SIGNAL(statusChanged(const QString&)), SLOT(changeStatus(const QString&)));
|
||||
connect(task, SIGNAL(progressChanged(int)), SLOT(changeProgress(int)));
|
||||
connect(task, SIGNAL(failed(QString)), SLOT(onTaskFailed(QString)));
|
||||
connect(task, SIGNAL(succeeded()), SLOT(onTaskSucceeded()));
|
||||
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, "startTask", Qt::QueuedConnection);
|
||||
QDialog::exec();
|
||||
QMetaObject::invokeMethod(task, "start", Qt::QueuedConnection);
|
||||
return QDialog::exec();
|
||||
}
|
||||
|
||||
Task* TaskDialog::getTask()
|
||||
ProgressProvider* ProgressDialog::getTask()
|
||||
{
|
||||
return task;
|
||||
}
|
||||
|
||||
void TaskDialog::onTaskStarted()
|
||||
void ProgressDialog::onTaskStarted()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TaskDialog::onTaskEnded()
|
||||
void ProgressDialog::onTaskFailed(QString failure)
|
||||
{
|
||||
close();
|
||||
reject();
|
||||
}
|
||||
|
||||
void TaskDialog::changeStatus(const QString &status)
|
||||
void ProgressDialog::onTaskSucceeded()
|
||||
{
|
||||
accept();
|
||||
}
|
||||
|
||||
void ProgressDialog::changeStatus(const QString &status)
|
||||
{
|
||||
ui->statusLabel->setText(status);
|
||||
updateSize();
|
||||
}
|
||||
|
||||
void TaskDialog::changeProgress(int progress)
|
||||
void ProgressDialog::changeProgress(qint64 current, qint64 total)
|
||||
{
|
||||
if (progress < 0)
|
||||
progress = 0;
|
||||
else if (progress > 100)
|
||||
progress = 100;
|
||||
|
||||
ui->taskProgressBar->setValue(progress);
|
||||
ui->taskProgressBar->setMaximum(total);
|
||||
ui->taskProgressBar->setValue(current);
|
||||
}
|
||||
|
||||
void TaskDialog::keyPressEvent(QKeyEvent* e)
|
||||
void ProgressDialog::keyPressEvent(QKeyEvent* e)
|
||||
{
|
||||
if (e->key() == Qt::Key_Escape)
|
||||
return;
|
||||
QDialog::keyPressEvent(e);
|
||||
}
|
||||
|
||||
void TaskDialog::closeEvent(QCloseEvent* e)
|
||||
void ProgressDialog::closeEvent(QCloseEvent* e)
|
||||
{
|
||||
if (task && task->isRunning())
|
||||
{
|
@ -18,32 +18,33 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class Task;
|
||||
class ProgressProvider;
|
||||
|
||||
namespace Ui {
|
||||
class TaskDialog;
|
||||
class ProgressDialog;
|
||||
}
|
||||
|
||||
class TaskDialog : public QDialog
|
||||
class ProgressDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TaskDialog(QWidget *parent = 0);
|
||||
~TaskDialog();
|
||||
explicit ProgressDialog(QWidget *parent = 0);
|
||||
~ProgressDialog();
|
||||
|
||||
void updateSize();
|
||||
|
||||
void exec(Task* task);
|
||||
int exec(ProgressProvider* task);
|
||||
|
||||
Task* getTask();
|
||||
ProgressProvider* getTask();
|
||||
|
||||
public slots:
|
||||
void onTaskStarted();
|
||||
void onTaskEnded();
|
||||
void onTaskFailed(QString failure);
|
||||
void onTaskSucceeded();
|
||||
|
||||
void changeStatus(const QString& status);
|
||||
void changeProgress(int progress);
|
||||
void changeProgress(qint64 current, qint64 total);
|
||||
|
||||
signals:
|
||||
|
||||
@ -53,9 +54,9 @@ protected:
|
||||
virtual void closeEvent(QCloseEvent* e);
|
||||
|
||||
private:
|
||||
Ui::TaskDialog *ui;
|
||||
Ui::ProgressDialog *ui;
|
||||
|
||||
Task* task;
|
||||
ProgressProvider* task;
|
||||
};
|
||||
|
||||
#endif // TASKDIALOG_H
|
@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TaskDialog</class>
|
||||
<widget class="QDialog" name="TaskDialog">
|
||||
<class>ProgressDialog</class>
|
||||
<widget class="QDialog" name="ProgressDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>58</height>
|
||||
<height>68</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
@ -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"
|
||||
@ -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);
|
||||
@ -512,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);
|
||||
@ -575,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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "logic/tasks/Task.h"
|
||||
|
||||
#include "versionselectdialog.h"
|
||||
#include "taskdialog.h"
|
||||
#include "ProgressDialog.h"
|
||||
#include "IconPickerDialog.h"
|
||||
|
||||
#include <QLayout>
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <gui/taskdialog.h>
|
||||
#include <gui/ProgressDialog.h>
|
||||
|
||||
#include <logic/BaseVersion.h>
|
||||
#include <logic/lists/BaseVersionList.h>
|
||||
@ -41,11 +41,6 @@ VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QWidget *parent
|
||||
ui->listView->setModel(m_proxyModel);
|
||||
ui->listView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
ui->listView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
|
||||
connect(ui->filterSnapshotsCheckbox, SIGNAL(clicked()), SLOT(updateFilterState()));
|
||||
connect(ui->filterMCNostalgiaCheckbox, SIGNAL(clicked()), SLOT(updateFilterState()));
|
||||
|
||||
updateFilterState();
|
||||
}
|
||||
|
||||
VersionSelectDialog::~VersionSelectDialog()
|
||||
@ -63,7 +58,7 @@ int VersionSelectDialog::exec()
|
||||
|
||||
void VersionSelectDialog::loadList()
|
||||
{
|
||||
TaskDialog *taskDlg = new TaskDialog(this);
|
||||
ProgressDialog *taskDlg = new ProgressDialog(this);
|
||||
Task *loadTask = m_vlist->getLoadTask();
|
||||
loadTask->setParent(taskDlg);
|
||||
taskDlg->exec(loadTask);
|
||||
@ -81,10 +76,11 @@ void VersionSelectDialog::on_refreshButton_clicked()
|
||||
loadList();
|
||||
}
|
||||
|
||||
void VersionSelectDialog::updateFilterState()
|
||||
void VersionSelectDialog::setFilter(int column, QString filter)
|
||||
{
|
||||
m_proxyModel->setFilterKeyColumn(BaseVersionList::TypeColumn);
|
||||
|
||||
m_proxyModel->setFilterKeyColumn(column);
|
||||
m_proxyModel->setFilterFixedString(filter);
|
||||
/*
|
||||
QStringList filteredTypes;
|
||||
if (!ui->filterSnapshotsCheckbox->isChecked())
|
||||
filteredTypes += "Snapshot";
|
||||
@ -96,6 +92,5 @@ void VersionSelectDialog::updateFilterState()
|
||||
regexStr = QString("^((?!%1).)*$").arg(filteredTypes.join('|'));
|
||||
|
||||
qDebug() << "Filter:" << regexStr;
|
||||
|
||||
m_proxyModel->setFilterRegExp(regexStr);
|
||||
*/
|
||||
}
|
||||
|
@ -43,11 +43,10 @@ public:
|
||||
|
||||
BaseVersionPtr selectedVersion() const;
|
||||
|
||||
void setFilter(int column, QString filter);
|
||||
|
||||
private slots:
|
||||
void on_refreshButton_clicked();
|
||||
|
||||
void updateFilterState();
|
||||
|
||||
private:
|
||||
Ui::VersionSelectDialog *ui;
|
||||
|
||||
|
@ -39,75 +39,6 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="filterCheckboxLayout1">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="filterSnapshotsCheckbox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show &snapshots?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="filterMCNostalgiaCheckbox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show &Nostalgia?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
|
Reference in New Issue
Block a user