From 168ed3e8e58a8e5065ffa720f8d45f4cee0f2069 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 28 Mar 2013 11:33:31 -0500 Subject: Implemented version lists. Further work on this is still needed. Currently there is no sorting or filtering of any kind. In addition, changes need to be made to fix issues with bad ETags since the current system here is based on MultiMC 4's version list system before it was fixed. --- gui/mainwindow.cpp | 13 ++++++ gui/mainwindow.h | 2 + gui/versionselectdialog.cpp | 62 +++++++++++++++++++++++++++ gui/versionselectdialog.h | 50 ++++++++++++++++++++++ gui/versionselectdialog.ui | 100 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 227 insertions(+) create mode 100644 gui/versionselectdialog.cpp create mode 100644 gui/versionselectdialog.h create mode 100644 gui/versionselectdialog.ui (limited to 'gui') diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index e691c8c4..ca681098 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -39,6 +39,7 @@ #include "gui/taskdialog.h" #include "gui/browserdialog.h" #include "gui/aboutdialog.h" +#include "gui/versionselectdialog.h" #include "kcategorizedview.h" #include "kcategorydrawer.h" @@ -260,3 +261,15 @@ void openInDefaultProgram ( QString filename ) { QDesktopServices::openUrl ( "file:///" + QFileInfo ( filename ).absolutePath() ); } + +void MainWindow::on_actionChangeInstMCVersion_triggered() +{ + if (view->selectionModel()->selectedIndexes().count() < 1) + return; + + QModelIndex index = view->selectionModel()->selectedIndexes().at(0); + Instance *inst = (Instance *)index.data(InstanceModel::InstancePointerRole).value(); + + VersionSelectDialog *vselect = new VersionSelectDialog(inst->versionList(), this); + vselect->exec(); +} diff --git a/gui/mainwindow.h b/gui/mainwindow.h index c2dedf74..53df9f02 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -73,6 +73,8 @@ private slots: void on_actionMakeDesktopShortcut_triggered(); + void on_actionChangeInstMCVersion_triggered(); + void doLogin( QString inst, const QString& errorMsg = "" ); diff --git a/gui/versionselectdialog.cpp b/gui/versionselectdialog.cpp new file mode 100644 index 00000000..b55c106c --- /dev/null +++ b/gui/versionselectdialog.cpp @@ -0,0 +1,62 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "versionselectdialog.h" +#include "ui_versionselectdialog.h" + +#include + +#include + +#include +#include + +VersionSelectDialog::VersionSelectDialog(InstVersionList *vlist, QWidget *parent) : + QDialog(parent), + ui(new Ui::VersionSelectDialog) +{ + ui->setupUi(this); + + m_vlist = vlist; + ui->listView->setModel(m_vlist); + ui->listView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); + ui->listView->header()->setSectionResizeMode(0, QHeaderView::Stretch); +} + +VersionSelectDialog::~VersionSelectDialog() +{ + delete ui; +} + +int VersionSelectDialog::exec() +{ + QDialog::open(); + if (!m_vlist->isLoaded()) + loadList(); + return QDialog::exec(); +} + +void VersionSelectDialog::loadList() +{ + TaskDialog *taskDlg = new TaskDialog(this); + Task *loadTask = m_vlist->getLoadTask(); + loadTask->setParent(taskDlg); + taskDlg->exec(loadTask); +} + +void VersionSelectDialog::on_refreshButton_clicked() +{ + loadList(); +} diff --git a/gui/versionselectdialog.h b/gui/versionselectdialog.h new file mode 100644 index 00000000..ad28b720 --- /dev/null +++ b/gui/versionselectdialog.h @@ -0,0 +1,50 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef VERSIONSELECTDIALOG_H +#define VERSIONSELECTDIALOG_H + +#include + +class InstVersionList; + +namespace Ui +{ +class VersionSelectDialog; +} + +class VersionSelectDialog : public QDialog +{ + Q_OBJECT + +public: + explicit VersionSelectDialog(InstVersionList *vlist, QWidget *parent = 0); + ~VersionSelectDialog(); + + virtual int exec(); + + //! Starts a task that loads the list. + void loadList(); + +private slots: + void on_refreshButton_clicked(); + +private: + Ui::VersionSelectDialog *ui; + + InstVersionList *m_vlist; +}; + +#endif // VERSIONSELECTDIALOG_H diff --git a/gui/versionselectdialog.ui b/gui/versionselectdialog.ui new file mode 100644 index 00000000..7b94817a --- /dev/null +++ b/gui/versionselectdialog.ui @@ -0,0 +1,100 @@ + + + VersionSelectDialog + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + + Qt::ScrollBarAlwaysOff + + + false + + + false + + + true + + + true + + + false + + + + + + + + + Reloads the version list. + + + &Refresh + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + VersionSelectDialog + accept() + + + 257 + 290 + + + 157 + 274 + + + + + buttonBox + rejected() + VersionSelectDialog + reject() + + + 325 + 290 + + + 286 + 274 + + + + + -- cgit v1.2.3