diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/LegacyModEditDialog.cpp | 41 | ||||
-rw-r--r-- | gui/LegacyModEditDialog.h | 2 | ||||
-rw-r--r-- | gui/LegacyModEditDialog.ui | 3 | ||||
-rw-r--r-- | gui/ModListView.cpp | 3 | ||||
-rw-r--r-- | gui/OneSixModEditDialog.cpp | 30 | ||||
-rw-r--r-- | gui/OneSixModEditDialog.h | 2 | ||||
-rw-r--r-- | gui/OneSixModEditDialog.ui | 135 | ||||
-rw-r--r-- | gui/ProgressDialog.cpp (renamed from gui/taskdialog.cpp) | 57 | ||||
-rw-r--r-- | gui/ProgressDialog.h (renamed from gui/taskdialog.h) | 23 | ||||
-rw-r--r-- | gui/ProgressDialog.ui (renamed from gui/taskdialog.ui) | 6 | ||||
-rw-r--r-- | gui/lwjglselectdialog.cpp | 16 | ||||
-rw-r--r-- | gui/mainwindow.cpp | 20 | ||||
-rw-r--r-- | gui/newinstancedialog.cpp | 16 | ||||
-rw-r--r-- | gui/newinstancedialog.h | 8 | ||||
-rw-r--r-- | gui/versionselectdialog.cpp | 31 | ||||
-rw-r--r-- | gui/versionselectdialog.h | 15 | ||||
-rw-r--r-- | gui/versionselectdialog.ui | 69 |
17 files changed, 281 insertions, 196 deletions
diff --git a/gui/LegacyModEditDialog.cpp b/gui/LegacyModEditDialog.cpp index c336f837..ac7f7f25 100644 --- a/gui/LegacyModEditDialog.cpp +++ b/gui/LegacyModEditDialog.cpp @@ -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() { diff --git a/gui/LegacyModEditDialog.h b/gui/LegacyModEditDialog.h index bc9ebac0..b824a86a 100644 --- a/gui/LegacyModEditDialog.h +++ b/gui/LegacyModEditDialog.h @@ -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; }; diff --git a/gui/LegacyModEditDialog.ui b/gui/LegacyModEditDialog.ui index bd147c85..73b767dc 100644 --- a/gui/LegacyModEditDialog.ui +++ b/gui/LegacyModEditDialog.ui @@ -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> diff --git a/gui/ModListView.cpp b/gui/ModListView.cpp index 34bd4af2..1d0e834c 100644 --- a/gui/ModListView.cpp +++ b/gui/ModListView.cpp @@ -30,6 +30,7 @@ void ModListView::setModel ( QAbstractItemModel* model ) auto head = header(); head->setStretchLastSection(false); head->setSectionResizeMode(0, QHeaderView::Stretch); - head->setSectionResizeMode(1, QHeaderView::ResizeToContents); + for(int i = 1; i < head->count(); i++) + head->setSectionResizeMode(i, QHeaderView::ResizeToContents); dropIndicatorPosition(); } diff --git a/gui/OneSixModEditDialog.cpp b/gui/OneSixModEditDialog.cpp index ab6ad5f0..fad9d2e2 100644 --- a/gui/OneSixModEditDialog.cpp +++ b/gui/OneSixModEditDialog.cpp @@ -12,11 +12,16 @@ * 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> @@ -29,9 +34,15 @@ OneSixModEditDialog::OneSixModEditDialog(OneSixInstance * inst, QWidget *parent) ui(new Ui::OneSixModEditDialog) { ui->setupUi(this); - //TODO: libraries! + //libraries! { - // yeah... here be the real dragons. + m_version = m_inst->getFullVersion(); + + auto filter = new EnabledItemFilter(this); + filter->setActive(true); + filter->setSourceModel(m_version.data()); + ui->libraryTreeView->setModel(filter); + ui->libraryTreeView->installEventFilter( this ); } // Loader mods { @@ -58,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()) diff --git a/gui/OneSixModEditDialog.h b/gui/OneSixModEditDialog.h index 3430bd26..d14c842c 100644 --- a/gui/OneSixModEditDialog.h +++ b/gui/OneSixModEditDialog.h @@ -40,12 +40,14 @@ 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 ); bool resourcePackListFilter( QKeyEvent* ev ); private: Ui::OneSixModEditDialog *ui; + QSharedPointer<OneSixVersion> m_version; QSharedPointer<ModList> m_mods; QSharedPointer<ModList> m_resourcepacks; OneSixInstance * m_inst; diff --git a/gui/OneSixModEditDialog.ui b/gui/OneSixModEditDialog.ui index 3feca726..aadaf3ae 100644 --- a/gui/OneSixModEditDialog.ui +++ b/gui/OneSixModEditDialog.ui @@ -6,15 +6,15 @@ <rect> <x>0</x> <y>0</y> - <width>543</width> - <height>423</height> + <width>555</width> + <height>463</height> </rect> </property> <property name="windowTitle"> <string>Dialog</string> </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> <widget class="QTabWidget" name="tabWidget"> <property name="enabled"> <bool>true</bool> @@ -28,26 +28,121 @@ <property name="currentIndex"> <number>0</number> </property> - <property name="elideMode"> - <enum>Qt::ElideNone</enum> - </property> - <property name="tabsClosable"> - <bool>false</bool> - </property> <widget class="QWidget" name="libTab"> <attribute name="title"> - <string>Library</string> + <string>Version</string> </attribute> <layout class="QHBoxLayout" name="horizontalLayout"> <item> - <widget class="ModListView" name="jarModsTreeView"> - <property name="verticalScrollBarPolicy"> - <enum>Qt::ScrollBarAlwaysOn</enum> - </property> - <property name="horizontalScrollBarPolicy"> - <enum>Qt::ScrollBarAlwaysOff</enum> - </property> - </widget> + <layout class="QVBoxLayout" name="verticalLayout_10"> + <item> + <widget class="ModListView" name="libraryTreeView"> + <property name="verticalScrollBarPolicy"> + <enum>Qt::ScrollBarAlwaysOn</enum> + </property> + <property name="horizontalScrollBarPolicy"> + <enum>Qt::ScrollBarAlwaysOff</enum> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_7"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Main Class:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="mainClassEdit"/> + </item> + </layout> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <widget class="QPushButton" name="forgeBtn"> + <property name="toolTip"> + <string>Replace any current custom version with Minecraft Forge</string> + </property> + <property name="text"> + <string>Install Forge</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="customizeBtn"> + <property name="toolTip"> + <string>Create an customized copy of the base version</string> + </property> + <property name="text"> + <string>Customize</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="revertBtn"> + <property name="toolTip"> + <string>Revert to original base version</string> + </property> + <property name="text"> + <string>Revert</string> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line"> + <property name="frameShadow"> + <enum>QFrame::Sunken</enum> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="addLibraryBtn"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip"> + <string>Add new libraries</string> + </property> + <property name="text"> + <string>&Add</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="removeLibraryBtn"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip"> + <string>Remove selected libraries</string> + </property> + <property name="text"> + <string>&Remove</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer_7"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> </item> </layout> </widget> @@ -163,7 +258,7 @@ </widget> </widget> </item> - <item> + <item row="1" column="0"> <widget class="QDialogButtonBox" name="buttonBox"> <property name="autoFillBackground"> <bool>false</bool> diff --git a/gui/taskdialog.cpp b/gui/ProgressDialog.cpp index 8c745b38..154ab1c0 100644 --- a/gui/taskdialog.cpp +++ b/gui/ProgressDialog.cpp @@ -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()) { diff --git a/gui/taskdialog.h b/gui/ProgressDialog.h index 3d31b7be..ac6bb412 100644 --- a/gui/taskdialog.h +++ b/gui/ProgressDialog.h @@ -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 diff --git a/gui/taskdialog.ui b/gui/ProgressDialog.ui index 1cdf7978..a56d2a92 100644 --- a/gui/taskdialog.ui +++ b/gui/ProgressDialog.ui @@ -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"> diff --git a/gui/lwjglselectdialog.cpp b/gui/lwjglselectdialog.cpp index c3215b7b..7c424a6c 100644 --- a/gui/lwjglselectdialog.cpp +++ b/gui/lwjglselectdialog.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#include "MultiMC.h" #include "lwjglselectdialog.h" #include "ui_lwjglselectdialog.h" @@ -24,11 +25,12 @@ LWJGLSelectDialog::LWJGLSelectDialog(QWidget *parent) : { ui->setupUi(this); ui->labelStatus->setVisible(false); - ui->lwjglListView->setModel(&LWJGLVersionList::get()); + auto lwjgllist = MMC->lwjgllist(); + ui->lwjglListView->setModel(lwjgllist); - connect(&LWJGLVersionList::get(), SIGNAL(loadingStateUpdated(bool)), SLOT(loadingStateUpdated(bool))); - connect(&LWJGLVersionList::get(), SIGNAL(loadListFailed(QString)), SLOT(loadingFailed(QString))); - loadingStateUpdated(LWJGLVersionList::get().isLoading()); + connect(lwjgllist, SIGNAL(loadingStateUpdated(bool)), SLOT(loadingStateUpdated(bool))); + connect(lwjgllist, SIGNAL(loadListFailed(QString)), SLOT(loadingFailed(QString))); + loadingStateUpdated(lwjgllist->isLoading()); } LWJGLSelectDialog::~LWJGLSelectDialog() @@ -38,15 +40,15 @@ LWJGLSelectDialog::~LWJGLSelectDialog() QString LWJGLSelectDialog::selectedVersion() const { - return LWJGLVersionList::get().data( + return MMC->lwjgllist()->data( ui->lwjglListView->selectionModel()->currentIndex(), Qt::DisplayRole).toString(); } void LWJGLSelectDialog::on_refreshButton_clicked() { - if (!LWJGLVersionList::get().isLoading()) - LWJGLVersionList::get().loadList(); + if (!MMC->lwjgllist()->isLoading()) + MMC->lwjgllist()->loadList(); } void LWJGLSelectDialog::loadingStateUpdated(bool loading) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 747df047..6f707236 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" @@ -154,14 +154,14 @@ MainWindow::MainWindow ( QWidget *parent ) // 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; @@ -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(); } @@ -604,7 +604,7 @@ void MainWindow::on_actionChangeInstMCVersion_triggered() VersionSelectDialog vselect(m_selectedInstance->versionList(), this); if (vselect.exec() && vselect.selectedVersion()) { - m_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor); + m_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor()); } } diff --git a/gui/newinstancedialog.cpp b/gui/newinstancedialog.cpp index ac3bcd7d..6604d03b 100644 --- a/gui/newinstancedialog.cpp +++ b/gui/newinstancedialog.cpp @@ -18,13 +18,13 @@ #include "ui_newinstancedialog.h" #include "logic/InstanceFactory.h" -#include "logic/InstanceVersion.h" +#include "logic/BaseVersion.h" #include "logic/lists/IconList.h" #include "logic/lists/MinecraftVersionList.h" #include "logic/tasks/Task.h" #include "versionselectdialog.h" -#include "taskdialog.h" +#include "ProgressDialog.h" #include "IconPickerDialog.h" #include <QLayout> @@ -48,7 +48,7 @@ NewInstanceDialog::NewInstanceDialog(QWidget *parent) : taskDlg->exec(loadTask); } */ - setSelectedVersion(MinecraftVersionList::getMainList().getLatestStable()); + setSelectedVersion(MMC->minecraftlist()->getLatestStable()); InstIconKey = "infinity"; ui->iconButton->setIcon(MMC->icons()->getIcon(InstIconKey)); } @@ -63,13 +63,13 @@ void NewInstanceDialog::updateDialogState() ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!instName().isEmpty() && m_selectedVersion); } -void NewInstanceDialog::setSelectedVersion(InstVersionPtr version) +void NewInstanceDialog::setSelectedVersion(BaseVersionPtr version) { m_selectedVersion = version; if (m_selectedVersion) { - ui->versionTextBox->setText(version->name); + ui->versionTextBox->setText(version->name()); } else { @@ -89,18 +89,18 @@ QString NewInstanceDialog::iconKey() const return InstIconKey; } -InstVersionPtr NewInstanceDialog::selectedVersion() const +BaseVersionPtr NewInstanceDialog::selectedVersion() const { return m_selectedVersion; } void NewInstanceDialog::on_btnChangeVersion_clicked() { - VersionSelectDialog vselect(&MinecraftVersionList::getMainList(), this); + VersionSelectDialog vselect(MMC->minecraftlist(), this); vselect.exec(); if (vselect.result() == QDialog::Accepted) { - InstVersionPtr version = vselect.selectedVersion(); + BaseVersionPtr version = vselect.selectedVersion(); if (version) setSelectedVersion(version); } diff --git a/gui/newinstancedialog.h b/gui/newinstancedialog.h index e8c57024..408cf757 100644 --- a/gui/newinstancedialog.h +++ b/gui/newinstancedialog.h @@ -17,7 +17,7 @@ #define NEWINSTANCEDIALOG_H #include <QDialog> -#include "logic/InstanceVersion.h" +#include "logic/BaseVersion.h" namespace Ui { class NewInstanceDialog; @@ -33,13 +33,13 @@ public: void updateDialogState(); - void setSelectedVersion(InstVersionPtr version); + void setSelectedVersion(BaseVersionPtr version); void loadVersionList(); QString instName() const; QString iconKey() const; - InstVersionPtr selectedVersion() const; + BaseVersionPtr selectedVersion() const; private slots: void on_btnChangeVersion_clicked(); @@ -49,7 +49,7 @@ private slots: private: Ui::NewInstanceDialog *ui; - InstVersionPtr m_selectedVersion; + BaseVersionPtr m_selectedVersion; QString InstIconKey; }; diff --git a/gui/versionselectdialog.cpp b/gui/versionselectdialog.cpp index 66d772b0..1e60c7d9 100644 --- a/gui/versionselectdialog.cpp +++ b/gui/versionselectdialog.cpp @@ -20,13 +20,13 @@ #include <QDebug> -#include <gui/taskdialog.h> +#include <gui/ProgressDialog.h> -#include <logic/InstanceVersion.h> -#include <logic/lists/InstVersionList.h> +#include <logic/BaseVersion.h> +#include <logic/lists/BaseVersionList.h> #include <logic/tasks/Task.h> -VersionSelectDialog::VersionSelectDialog(InstVersionList *vlist, QWidget *parent) : +VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QWidget *parent) : QDialog(parent), ui(new Ui::VersionSelectDialog) { @@ -41,11 +41,6 @@ VersionSelectDialog::VersionSelectDialog(InstVersionList *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,17 +58,17 @@ 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); } -InstVersionPtr VersionSelectDialog::selectedVersion() const +BaseVersionPtr VersionSelectDialog::selectedVersion() const { auto currentIndex = ui->listView->selectionModel()->currentIndex(); - auto variant = m_proxyModel->data(currentIndex, InstVersionList::VersionPointerRole); - return variant.value<InstVersionPtr>(); + auto variant = m_proxyModel->data(currentIndex, BaseVersionList::VersionPointerRole); + return variant.value<BaseVersionPtr>(); } void VersionSelectDialog::on_refreshButton_clicked() @@ -81,10 +76,11 @@ void VersionSelectDialog::on_refreshButton_clicked() loadList(); } -void VersionSelectDialog::updateFilterState() +void VersionSelectDialog::setFilter(int column, QString filter) { - m_proxyModel->setFilterKeyColumn(InstVersionList::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); + */ } diff --git a/gui/versionselectdialog.h b/gui/versionselectdialog.h index b864aee1..0bb1745a 100644 --- a/gui/versionselectdialog.h +++ b/gui/versionselectdialog.h @@ -19,9 +19,9 @@ #include <QDialog> #include <QSortFilterProxyModel> -#include "logic/InstanceVersion.h" +#include "logic/BaseVersion.h" -class InstVersionList; +class BaseVersionList; namespace Ui { @@ -33,7 +33,7 @@ class VersionSelectDialog : public QDialog Q_OBJECT public: - explicit VersionSelectDialog(InstVersionList *vlist, QWidget *parent = 0); + explicit VersionSelectDialog(BaseVersionList *vlist, QWidget *parent = 0); ~VersionSelectDialog(); virtual int exec(); @@ -41,17 +41,16 @@ public: //! Starts a task that loads the list. void loadList(); - InstVersionPtr selectedVersion() const; + BaseVersionPtr selectedVersion() const; + + void setFilter(int column, QString filter); private slots: void on_refreshButton_clicked(); - - void updateFilterState(); - private: Ui::VersionSelectDialog *ui; - InstVersionList *m_vlist; + BaseVersionList *m_vlist; QSortFilterProxyModel *m_proxyModel; }; diff --git a/gui/versionselectdialog.ui b/gui/versionselectdialog.ui index 02937794..222f29cf 100644 --- a/gui/versionselectdialog.ui +++ b/gui/versionselectdialog.ui @@ -40,75 +40,6 @@ </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> <widget class="QPushButton" name="refreshButton"> |