diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-06-08 18:02:20 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-06-09 01:38:31 +0200 |
commit | 84ae67fff5bfa9de011daf4144802569687f1e6b (patch) | |
tree | 47d7ec4b8484b6aa505e8200ba35b3ead60980ab /gui/pages | |
parent | 694067c603ec14eba16e452e77bc7ce442fa36dd (diff) | |
download | MultiMC-84ae67fff5bfa9de011daf4144802569687f1e6b.tar MultiMC-84ae67fff5bfa9de011daf4144802569687f1e6b.tar.gz MultiMC-84ae67fff5bfa9de011daf4144802569687f1e6b.tar.lz MultiMC-84ae67fff5bfa9de011daf4144802569687f1e6b.tar.xz MultiMC-84ae67fff5bfa9de011daf4144802569687f1e6b.zip |
Page dialog for legacy instances.
Diffstat (limited to 'gui/pages')
-rw-r--r-- | gui/pages/LegacyJarModPage.cpp | 203 | ||||
-rw-r--r-- | gui/pages/LegacyJarModPage.h | 61 | ||||
-rw-r--r-- | gui/pages/LegacyJarModPage.ui | 158 | ||||
-rw-r--r-- | gui/pages/LegacyUpgradePage.cpp | 33 | ||||
-rw-r--r-- | gui/pages/LegacyUpgradePage.h | 46 | ||||
-rw-r--r-- | gui/pages/LegacyUpgradePage.ui | 58 | ||||
-rw-r--r-- | gui/pages/ModFolderPage.ui | 128 |
7 files changed, 625 insertions, 62 deletions
diff --git a/gui/pages/LegacyJarModPage.cpp b/gui/pages/LegacyJarModPage.cpp new file mode 100644 index 00000000..7ec53d80 --- /dev/null +++ b/gui/pages/LegacyJarModPage.cpp @@ -0,0 +1,203 @@ +/* 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 "LegacyJarModPage.h" +#include "ui_LegacyJarModPage.h" +#include "gui/dialogs/VersionSelectDialog.h" +#include "gui/dialogs/ProgressDialog.h" +#include "gui/dialogs/ModEditDialogCommon.h" +#include "logic/ModList.h" +#include "logic/LegacyInstance.h" +#include "logic/forge/ForgeVersion.h" +#include "logic/forge/ForgeVersionList.h" +#include "MultiMC.h" +#include <pathutils.h> +#include <QtGui/QKeyEvent> +#include <QFileDialog> +#include <QKeyEvent> + +LegacyJarModPage::LegacyJarModPage(LegacyInstance *inst, QWidget *parent) + : QWidget(parent), ui(new Ui::LegacyJarModPage), m_inst(inst) +{ + ui->setupUi(this); + m_jarmods = m_inst->jarModList(); + ui->jarModsTreeView->setModel(m_jarmods.get()); + ui->jarModsTreeView->setDragDropMode(QAbstractItemView::DragDrop); + ui->jarModsTreeView->setSelectionMode(QAbstractItemView::SingleSelection); + ui->jarModsTreeView->installEventFilter(this); + m_jarmods->startWatching(); + auto smodel = ui->jarModsTreeView->selectionModel(); + connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), + SLOT(jarCurrent(QModelIndex, QModelIndex))); +} + +LegacyJarModPage::~LegacyJarModPage() +{ + m_jarmods->stopWatching(); + delete ui; +} + +QString LegacyJarModPage::displayName() +{ + return tr("Jar Mods"); +} + +QIcon LegacyJarModPage::icon() +{ + return QIcon::fromTheme("settings"); +} + +QString LegacyJarModPage::id() +{ + return "jarmods"; +} + +bool LegacyJarModPage::eventFilter(QObject *obj, QEvent *ev) +{ + if (ev->type() != QEvent::KeyPress || obj != ui->jarModsTreeView) + { + return QWidget::eventFilter(obj, ev); + } + + QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev); + switch (keyEvent->key()) + { + case Qt::Key_Up: + { + if (keyEvent->modifiers() & Qt::ControlModifier) + { + on_moveJarUpBtn_clicked(); + return true; + } + break; + } + case Qt::Key_Down: + { + if (keyEvent->modifiers() & Qt::ControlModifier) + { + on_moveJarDownBtn_clicked(); + return true; + } + break; + } + case Qt::Key_Delete: + on_rmJarBtn_clicked(); + return true; + case Qt::Key_Plus: + on_addJarBtn_clicked(); + return true; + default: + break; + } + return QWidget::eventFilter(obj, ev); +} + +void LegacyJarModPage::on_addForgeBtn_clicked() +{ + VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this); + vselect.setExactFilter(1, m_inst->intendedVersionId()); + if (vselect.exec() && vselect.selectedVersion()) + { + ForgeVersionPtr forge = + std::dynamic_pointer_cast<ForgeVersion>(vselect.selectedVersion()); + if (!forge) + return; + auto entry = MMC->metacache()->resolveEntry("minecraftforge", forge->filename()); + if (entry->stale) + { + NetJob *fjob = new NetJob("Forge download"); + fjob->addNetAction(CacheDownload::make(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(); + } + } +} +void LegacyJarModPage::on_addJarBtn_clicked() +{ + //: Title of jar mod selection dialog + QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Jar Mods")); + for (auto filename : fileNames) + { + m_jarmods->stopWatching(); + m_jarmods->installMod(QFileInfo(filename)); + m_jarmods->startWatching(); + } +} + +void LegacyJarModPage::on_moveJarDownBtn_clicked() +{ + int first, last; + auto list = ui->jarModsTreeView->selectionModel()->selectedRows(); + + if (!lastfirst(list, first, last)) + return; + + m_jarmods->moveModsDown(first, last); +} + +void LegacyJarModPage::on_moveJarUpBtn_clicked() +{ + int first, last; + auto list = ui->jarModsTreeView->selectionModel()->selectedRows(); + + if (!lastfirst(list, first, last)) + return; + m_jarmods->moveModsUp(first, last); +} + +void LegacyJarModPage::on_rmJarBtn_clicked() +{ + int first, last; + auto list = ui->jarModsTreeView->selectionModel()->selectedRows(); + + if (!lastfirst(list, first, last)) + return; + m_jarmods->stopWatching(); + m_jarmods->deleteMods(first, last); + m_jarmods->startWatching(); +} + +void LegacyJarModPage::on_viewJarBtn_clicked() +{ + openDirInDefaultProgram(m_inst->jarModsDir(), true); +} + +void LegacyJarModPage::jarCurrent(QModelIndex current, QModelIndex previous) +{ + if (!current.isValid()) + { + ui->jarMIFrame->clear(); + return; + } + int row = current.row(); + Mod &m = m_jarmods->operator[](row); + ui->jarMIFrame->updateWithMod(m); +} diff --git a/gui/pages/LegacyJarModPage.h b/gui/pages/LegacyJarModPage.h new file mode 100644 index 00000000..a2a7f74e --- /dev/null +++ b/gui/pages/LegacyJarModPage.h @@ -0,0 +1,61 @@ +/* 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. + */ + +#pragma once + +#include <QDialog> +#include <logic/net/NetJob.h> +#include "BasePage.h" + +class ModList; +class LegacyInstance; +namespace Ui +{ +class LegacyJarModPage; +} + +class LegacyJarModPage : public QWidget, public BasePage +{ + Q_OBJECT + +public: + explicit LegacyJarModPage(LegacyInstance *inst, QWidget *parent = 0); + virtual ~LegacyJarModPage(); + + virtual QString displayName(); + virtual QIcon icon(); + virtual QString id(); + +private +slots: + + void on_addJarBtn_clicked(); + void on_rmJarBtn_clicked(); + void on_addForgeBtn_clicked(); + void on_moveJarUpBtn_clicked(); + void on_moveJarDownBtn_clicked(); + void on_viewJarBtn_clicked(); + + void jarCurrent(QModelIndex current, QModelIndex previous); + +protected: + virtual bool eventFilter(QObject *obj, QEvent *ev) override; + +private: + Ui::LegacyJarModPage *ui; + std::shared_ptr<ModList> m_jarmods; + LegacyInstance *m_inst; + NetJobPtr forgeJob; +}; diff --git a/gui/pages/LegacyJarModPage.ui b/gui/pages/LegacyJarModPage.ui new file mode 100644 index 00000000..a1da2b20 --- /dev/null +++ b/gui/pages/LegacyJarModPage.ui @@ -0,0 +1,158 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>LegacyJarModPage</class> + <widget class="QWidget" name="LegacyJarModPage"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>378</width> + <height>324</height> + </rect> + </property> + <property name="windowTitle"> + <string>LegacyJarModPage</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <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> + </item> + <item> + <layout class="QVBoxLayout" name="jarModsButtonBox"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Selection</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="rmJarBtn"> + <property name="text"> + <string>&Remove</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="moveJarUpBtn"> + <property name="text"> + <string>Move &Up</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="moveJarDownBtn"> + <property name="text"> + <string>Move &Down</string> + </property> + </widget> + </item> + <item> + <widget class="LineSeparator" name="separator" native="true"/> + </item> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Install</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="addJarBtn"> + <property name="text"> + <string>&Add jar mod</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="addForgeBtn"> + <property name="text"> + <string>Install Forge</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="viewJarBtn"> + <property name="text"> + <string>&View Folder</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item> + <widget class="MCModInfoFrame" name="jarMIFrame"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>ModListView</class> + <extends>QTreeView</extends> + <header>gui/widgets/ModListView.h</header> + </customwidget> + <customwidget> + <class>MCModInfoFrame</class> + <extends>QFrame</extends> + <header>gui/widgets/MCModInfoFrame.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>LineSeparator</class> + <extends>QWidget</extends> + <header>gui/widgets/LineSeparator.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/gui/pages/LegacyUpgradePage.cpp b/gui/pages/LegacyUpgradePage.cpp new file mode 100644 index 00000000..9aa97543 --- /dev/null +++ b/gui/pages/LegacyUpgradePage.cpp @@ -0,0 +1,33 @@ +#include "LegacyUpgradePage.h" +#include "ui_LegacyUpgradePage.h" + +QString LegacyUpgradePage::displayName() +{ + return tr("Upgrade"); +} + +QIcon LegacyUpgradePage::icon() +{ + return QIcon::fromTheme("bug"); +} + +QString LegacyUpgradePage::id() +{ + return "upgrade"; +} + +LegacyUpgradePage::LegacyUpgradePage(LegacyInstance *inst, QWidget *parent) + : QWidget(parent), ui(new Ui::LegacyUpgradePage), m_inst(inst) +{ + ui->setupUi(this); +} + +LegacyUpgradePage::~LegacyUpgradePage() +{ + delete ui; +} + +void LegacyUpgradePage::on_upgradeButton_clicked() +{ + // now what? +} diff --git a/gui/pages/LegacyUpgradePage.h b/gui/pages/LegacyUpgradePage.h new file mode 100644 index 00000000..549c8bf3 --- /dev/null +++ b/gui/pages/LegacyUpgradePage.h @@ -0,0 +1,46 @@ +/* Copyright 2014 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. + */ + +#pragma once +#include <QWidget> + +#include <logic/OneSixInstance.h> +#include <logic/net/NetJob.h> +#include "BasePage.h" + +class EnabledItemFilter; +namespace Ui +{ +class LegacyUpgradePage; +} + +class LegacyUpgradePage : public QWidget, public BasePage +{ + Q_OBJECT + +public: + explicit LegacyUpgradePage(LegacyInstance *inst, QWidget *parent = 0); + virtual ~LegacyUpgradePage(); + virtual QString displayName() override; + virtual QIcon icon() override; + virtual QString id() override; +private +slots: + void on_upgradeButton_clicked(); + +private: + Ui::LegacyUpgradePage *ui; + LegacyInstance *m_inst; +}; diff --git a/gui/pages/LegacyUpgradePage.ui b/gui/pages/LegacyUpgradePage.ui new file mode 100644 index 00000000..43c3eeda --- /dev/null +++ b/gui/pages/LegacyUpgradePage.ui @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>LegacyUpgradePage</class> + <widget class="QWidget" name="LegacyUpgradePage"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>546</width> + <height>405</height> + </rect> + </property> + <property name="windowTitle"> + <string>Upgrade</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_5"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QTextBrowser" name="textBrowser"> + <property name="html"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Bitstream Vera Sans'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> </p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:18pt; font-weight:600;">New format is available</span> </p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">MultiMC now supports old Minecraft versions in the new (OneSix) instance format. The old format won't be getting any new features and only the most critical bugfixes. As a consequence, you should upgrade this instance. </p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The upgrade will create a new instance with the same contents as the current one, in the new format. The original instance will remain untouched, in case anything goes wrong in the process. </p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Please report any issues on our <a href="https://github.com/MultiMC/MultiMC5/issues"><img src=":/icons/multimc/22x22/bug.png" /></a><a href="https://github.com/MultiMC/MultiMC5/issues"><span style=" text-decoration: underline; color:#68a0df;">github issues page</span></a>.</p></body></html></string> + </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QCommandLinkButton" name="upgradeButton"> + <property name="text"> + <string>Start the upgrade!</string> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/gui/pages/ModFolderPage.ui b/gui/pages/ModFolderPage.ui index 05125be3..eb29a2c0 100644 --- a/gui/pages/ModFolderPage.ui +++ b/gui/pages/ModFolderPage.ui @@ -6,14 +6,14 @@ <rect> <x>0</x> <y>0</y> - <width>540</width> - <height>350</height> + <width>723</width> + <height>532</height> </rect> </property> <property name="windowTitle"> <string>Mods</string> </property> - <layout class="QHBoxLayout" name="horizontalLayout"> + <layout class="QVBoxLayout" name="verticalLayout_3"> <property name="leftMargin"> <number>0</number> </property> @@ -27,72 +27,76 @@ <number>0</number> </property> <item> - <layout class="QVBoxLayout" name="verticalLayout"> + <layout class="QHBoxLayout" name="horizontalLayout"> <item> - <widget class="ModListView" name="modTreeView"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="acceptDrops"> - <bool>true</bool> - </property> - <property name="dragDropMode"> - <enum>QAbstractItemView::DropOnly</enum> - </property> - </widget> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="ModListView" name="modTreeView"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="acceptDrops"> + <bool>true</bool> + </property> + <property name="dragDropMode"> + <enum>QAbstractItemView::DropOnly</enum> + </property> + </widget> + </item> + </layout> </item> <item> - <widget class="MCModInfoFrame" name="frame"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QPushButton" name="addModBtn"> + <property name="text"> + <string>&Add</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="rmModBtn"> + <property name="text"> + <string>&Remove</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="viewModBtn"> + <property name="text"> + <string>&View Folder</string> + </property> + </widget> + </item> + </layout> </item> </layout> </item> <item> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QPushButton" name="addModBtn"> - <property name="text"> - <string>&Add</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="rmModBtn"> - <property name="text"> - <string>&Remove</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="viewModBtn"> - <property name="text"> - <string>&View Folder</string> - </property> - </widget> - </item> - </layout> + <widget class="MCModInfoFrame" name="frame"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> </item> </layout> </widget> |