diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/mainwindow.cpp | 13 | ||||
-rw-r--r-- | gui/mainwindow.h | 2 | ||||
-rw-r--r-- | gui/versionselectdialog.cpp | 62 | ||||
-rw-r--r-- | gui/versionselectdialog.h | 50 | ||||
-rw-r--r-- | gui/versionselectdialog.ui | 100 |
5 files changed, 227 insertions, 0 deletions
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<void *>(); + + 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 <QHeaderView> + +#include <gui/taskdialog.h> + +#include <instversionlist.h> +#include <task.h> + +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 <QDialog> + +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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>VersionSelectDialog</class> + <widget class="QDialog" name="VersionSelectDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QTreeView" name="listView"> + <property name="horizontalScrollBarPolicy"> + <enum>Qt::ScrollBarAlwaysOff</enum> + </property> + <property name="rootIsDecorated"> + <bool>false</bool> + </property> + <property name="itemsExpandable"> + <bool>false</bool> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <attribute name="headerCascadingSectionResizes"> + <bool>true</bool> + </attribute> + <attribute name="headerStretchLastSection"> + <bool>false</bool> + </attribute> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QPushButton" name="refreshButton"> + <property name="toolTip"> + <string>Reloads the version list.</string> + </property> + <property name="text"> + <string>&Refresh</string> + </property> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>VersionSelectDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>257</x> + <y>290</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>VersionSelectDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>325</x> + <y>290</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> |