diff options
Diffstat (limited to 'application/pages')
50 files changed, 657 insertions, 1013 deletions
diff --git a/application/pages/BasePage.h b/application/pages/BasePage.h index 1d6e4bd0..63a26239 100644 --- a/application/pages/BasePage.h +++ b/application/pages/BasePage.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,11 +33,15 @@ public: virtual QString helpPage() const { return QString(); } virtual void opened() {} virtual void closed() {} - virtual void setParentContainer(BasePageContainer *) {}; - + virtual void setParentContainer(BasePageContainer * container) + { + m_container = container; + }; public: int stackIndex = -1; int listIndex = -1; +protected: + BasePageContainer * m_container = nullptr; }; typedef std::shared_ptr<BasePage> BasePagePtr; diff --git a/application/pages/BasePageContainer.h b/application/pages/BasePageContainer.h index 660685d3..ff7315c2 100644 --- a/application/pages/BasePageContainer.h +++ b/application/pages/BasePageContainer.h @@ -6,4 +6,5 @@ public: virtual ~BasePageContainer(){}; virtual bool selectPage(QString pageId) = 0; virtual void refreshContainer() = 0; + virtual bool requestClose() = 0; }; diff --git a/application/pages/BasePageProvider.h b/application/pages/BasePageProvider.h index b976bc16..0ebcff7a 100644 --- a/application/pages/BasePageProvider.h +++ b/application/pages/BasePageProvider.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/application/pages/InstanceSettingsPage.cpp b/application/pages/InstanceSettingsPage.cpp index 82438583..71e90a32 100644 --- a/application/pages/InstanceSettingsPage.cpp +++ b/application/pages/InstanceSettingsPage.cpp @@ -11,12 +11,16 @@ #include <java/JavaInstallList.h> #include <FileSystem.h> +#include <sys.h> +#include <widgets/CustomCommands.h> InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent) : QWidget(parent), ui(new Ui::InstanceSettingsPage), m_instance(inst) { m_settings = inst->settings(); ui->setupUi(this); + auto sysMB = Sys::getSystemRam() / Sys::megabyte; + ui->maxMemSpinBox->setMaximum(sysMB); loadSettings(); } @@ -77,8 +81,18 @@ void InstanceSettingsPage::applySettings() m_settings->set("OverrideMemory", memory); if (memory) { - m_settings->set("MinMemAlloc", ui->minMemSpinBox->value()); - m_settings->set("MaxMemAlloc", ui->maxMemSpinBox->value()); + int min = ui->minMemSpinBox->value(); + int max = ui->maxMemSpinBox->value(); + if(min < max) + { + m_settings->set("MinMemAlloc", min); + m_settings->set("MaxMemAlloc", max); + } + else + { + m_settings->set("MinMemAlloc", max); + m_settings->set("MaxMemAlloc", min); + } m_settings->set("PermGen", ui->permGenSpinBox->value()); } else @@ -117,13 +131,13 @@ void InstanceSettingsPage::applySettings() m_settings->reset("OverrideJava"); // Custom Commands - bool custcmd = ui->customCommandsGroupBox->isChecked(); + bool custcmd = ui->customCommands->checked(); m_settings->set("OverrideCommands", custcmd); if (custcmd) { - m_settings->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text()); - m_settings->set("WrapperCommand", ui->wrapperCmdTextBox->text()); - m_settings->set("PostExitCommand", ui->postExitCmdTextBox->text()); + m_settings->set("PreLaunchCommand", ui->customCommands->prelaunchCommand()); + m_settings->set("WrapperCommand", ui->customCommands->wrapperCommand()); + m_settings->set("PostExitCommand", ui->customCommands->postexitCommand()); } else { @@ -149,8 +163,18 @@ void InstanceSettingsPage::loadSettings() // Memory ui->memoryGroupBox->setChecked(m_settings->get("OverrideMemory").toBool()); - ui->minMemSpinBox->setValue(m_settings->get("MinMemAlloc").toInt()); - ui->maxMemSpinBox->setValue(m_settings->get("MaxMemAlloc").toInt()); + int min = m_settings->get("MinMemAlloc").toInt(); + int max = m_settings->get("MaxMemAlloc").toInt(); + if(min < max) + { + ui->minMemSpinBox->setValue(min); + ui->maxMemSpinBox->setValue(max); + } + else + { + ui->minMemSpinBox->setValue(max); + ui->maxMemSpinBox->setValue(min); + } ui->permGenSpinBox->setValue(m_settings->get("PermGen").toInt()); // Java Settings @@ -164,11 +188,14 @@ void InstanceSettingsPage::loadSettings() ui->javaArgumentsGroupBox->setChecked(overrideArgs); ui->jvmArgsTextBox->setPlainText(m_settings->get("JvmArgs").toString()); - // Custom Commands - ui->customCommandsGroupBox->setChecked(m_settings->get("OverrideCommands").toBool()); - ui->preLaunchCmdTextBox->setText(m_settings->get("PreLaunchCommand").toString()); - ui->wrapperCmdTextBox->setText(m_settings->get("WrapperCommand").toString()); - ui->postExitCmdTextBox->setText(m_settings->get("PostExitCommand").toString()); + // Custom commands + ui->customCommands->initialize( + true, + m_settings->get("OverrideCommands").toBool(), + m_settings->get("PreLaunchCommand").toString(), + m_settings->get("WrapperCommand").toString(), + m_settings->get("PostExitCommand").toString() + ); } void InstanceSettingsPage::on_javaDetectBtn_clicked() @@ -189,13 +216,13 @@ void InstanceSettingsPage::on_javaDetectBtn_clicked() void InstanceSettingsPage::on_javaBrowseBtn_clicked() { QString raw_path = QFileDialog::getOpenFileName(this, tr("Find Java executable")); - QString cooked_path = FS::NormalizePath(raw_path); // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if(cooked_path.isEmpty()) + if(raw_path.isEmpty()) { return; } + QString cooked_path = FS::NormalizePath(raw_path); QFileInfo javaInfo(cooked_path);; if(!javaInfo.exists() || !javaInfo.isExecutable()) diff --git a/application/pages/InstanceSettingsPage.h b/application/pages/InstanceSettingsPage.h index 5930a2fd..4959bdbe 100644 --- a/application/pages/InstanceSettingsPage.h +++ b/application/pages/InstanceSettingsPage.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/application/pages/InstanceSettingsPage.ui b/application/pages/InstanceSettingsPage.ui index 6163297f..0c180df3 100644 --- a/application/pages/InstanceSettingsPage.ui +++ b/application/pages/InstanceSettingsPage.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>458</width> - <height>508</height> + <width>553</width> + <height>522</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout"> @@ -42,7 +42,7 @@ <bool>true</bool> </property> <property name="title"> - <string>Java ins&tallation</string> + <string>Java insta&llation</string> </property> <property name="checkable"> <bool>true</bool> @@ -196,7 +196,7 @@ <bool>true</bool> </property> <property name="title"> - <string>Java arguments</string> + <string>Java argumen&ts</string> </property> <property name="checkable"> <bool>true</bool> @@ -211,19 +211,6 @@ </layout> </widget> </item> - <item> - <spacer name="verticalSpacerMinecraft"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - </spacer> - </item> </layout> </widget> <widget class="QWidget" name="javaTab"> @@ -363,81 +350,7 @@ </attribute> <layout class="QVBoxLayout" name="verticalLayout_6"> <item> - <widget class="QGroupBox" name="customCommandsGroupBox"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="title"> - <string>Cus&tom Commands</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - <layout class="QGridLayout" name="gridLayout_4"> - <item row="2" column="0"> - <widget class="QLabel" name="labelPostExitCmd"> - <property name="text"> - <string>Post-exit command:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="preLaunchCmdTextBox"/> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="labelPreLaunchCmd"> - <property name="text"> - <string>Pre-launch command:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="postExitCmdTextBox"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="labelWrapperCmd"> - <property name="text"> - <string>Wrapper command:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="wrapperCmdTextBox"/> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QLabel" name="labelCustomCmdsDescription"> - <property name="text"> - <string><html><head/><body><p>Pre-launch command runs before the instance launches and post-exit command runs after it exits.</p><p>Both will be run in MultiMC's working folder with extra environment variables:</p><ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_NAME - Name of the instance</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_ID - ID of the instance</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_DIR - absolute path of the instance</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_MC_DIR - absolute path of minecraft</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_JAVA - java binary used for launch</li><li style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_JAVA_ARGS - command-line parameters used for launch</li></ul></body></html></string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - <property name="textInteractionFlags"> - <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacerMinecraft_3"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>88</width> - <height>186</height> - </size> - </property> - </spacer> + <widget class="CustomCommands" name="customCommands" native="true"/> </item> </layout> </widget> @@ -445,6 +358,14 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>CustomCommands</class> + <extends>QWidget</extends> + <header>widgets/CustomCommands.h</header> + <container>1</container> + </customwidget> + </customwidgets> <tabstops> <tabstop>settingsTabs</tabstop> <tabstop>javaSettingsGroupBox</tabstop> @@ -466,10 +387,6 @@ <tabstop>showConsoleCheck</tabstop> <tabstop>autoCloseConsoleCheck</tabstop> <tabstop>showConsoleErrorCheck</tabstop> - <tabstop>customCommandsGroupBox</tabstop> - <tabstop>preLaunchCmdTextBox</tabstop> - <tabstop>wrapperCmdTextBox</tabstop> - <tabstop>postExitCmdTextBox</tabstop> </tabstops> <resources/> <connections/> diff --git a/application/pages/LegacyJarModPage.cpp b/application/pages/LegacyJarModPage.cpp deleted file mode 100644 index c13bce8c..00000000 --- a/application/pages/LegacyJarModPage.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* Copyright 2013-2017 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 <QKeyEvent> -#include <QKeyEvent> - -#include "dialogs/VersionSelectDialog.h" -#include "dialogs/ProgressDialog.h" -#include "dialogs/ModEditDialogCommon.h" -#include "minecraft/legacy/LegacyModList.h" -#include "minecraft/legacy/LegacyInstance.h" -#include "Env.h" -#include <DesktopServices.h> -#include "MultiMC.h" -#include <GuiUtil.h> - -LegacyJarModPage::LegacyJarModPage(LegacyInstance *inst, QWidget *parent) - : QWidget(parent), ui(new Ui::LegacyJarModPage), m_inst(inst) -{ - ui->setupUi(this); - ui->tabWidget->tabBar()->hide(); - - 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; -} - -bool LegacyJarModPage::shouldDisplay() const -{ - return !m_inst->isRunning(); -} - -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_addJarBtn_clicked() -{ - auto list = GuiUtil::BrowseForFiles("jarmod", tr("Select jar mods"), tr("Minecraft.jar mods (*.zip *.jar)"), MMC->settings()->get("CentralModsDir").toString(), this->parentWidget()); - if(!list.empty()) - { - m_jarmods->stopWatching(); - for (auto filename : list) - { - m_jarmods->installMod(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() -{ - DesktopServices::openDirectory(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/application/pages/LegacyJarModPage.h b/application/pages/LegacyJarModPage.h deleted file mode 100644 index 2a5ac75f..00000000 --- a/application/pages/LegacyJarModPage.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright 2013-2017 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 "net/NetJob.h" -#include "BasePage.h" -#include <MultiMC.h> - -class LegacyModList; -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() const override - { - return tr("Jar Mods"); - } - virtual QIcon icon() const override - { - return MMC->getThemedIcon("jarmods"); - } - virtual QString id() const override - { - return "jarmods"; - } - virtual QString helpPage() const override - { - return "Legacy-jar-mods"; - } - virtual bool shouldDisplay() const override; - -private -slots: - - void on_addJarBtn_clicked(); - void on_rmJarBtn_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<LegacyModList> m_jarmods; - LegacyInstance *m_inst; - NetJobPtr forgeJob; -}; diff --git a/application/pages/LegacyJarModPage.ui b/application/pages/LegacyJarModPage.ui deleted file mode 100644 index 137a4ae5..00000000 --- a/application/pages/LegacyJarModPage.ui +++ /dev/null @@ -1,162 +0,0 @@ -<?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>659</width> - <height>593</height> - </rect> - </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> - <widget class="QTabWidget" name="tabWidget"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="tab"> - <attribute name="title"> - <string notr="true">Tab 1</string> - </attribute> - <layout class="QVBoxLayout" name="verticalLayout"> - <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> - <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> - </layout> - </widget> - </widget> - </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>widgets/ModListView.h</header> - </customwidget> - <customwidget> - <class>MCModInfoFrame</class> - <extends>QFrame</extends> - <header>widgets/MCModInfoFrame.h</header> - <container>1</container> - </customwidget> - <customwidget> - <class>LineSeparator</class> - <extends>QWidget</extends> - <header>widgets/LineSeparator.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <resources/> - <connections/> -</ui> diff --git a/application/pages/LegacyUpgradePage.cpp b/application/pages/LegacyUpgradePage.cpp index 14cb916d..a8f4a08c 100644 --- a/application/pages/LegacyUpgradePage.cpp +++ b/application/pages/LegacyUpgradePage.cpp @@ -2,8 +2,13 @@ #include "ui_LegacyUpgradePage.h" #include "minecraft/legacy/LegacyInstance.h" +#include "minecraft/legacy/LegacyUpgradeTask.h" +#include "MultiMC.h" +#include "FolderInstanceProvider.h" +#include "dialogs/CustomMessageBox.h" +#include "dialogs/ProgressDialog.h" -LegacyUpgradePage::LegacyUpgradePage(LegacyInstance *inst, QWidget *parent) +LegacyUpgradePage::LegacyUpgradePage(InstancePtr inst, QWidget *parent) : QWidget(parent), ui(new Ui::LegacyUpgradePage), m_inst(inst) { ui->setupUi(this); @@ -14,9 +19,24 @@ LegacyUpgradePage::~LegacyUpgradePage() delete ui; } +void LegacyUpgradePage::runModalTask(Task *task) +{ + connect(task, &Task::failed, [this](QString reason) + { + CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Warning)->show(); + }); + ProgressDialog loadDialog(this); + loadDialog.setSkipButton(true, tr("Abort")); + if(loadDialog.execWithTask(task) == QDialog::Accepted) + { + m_container->requestClose(); + } +} + void LegacyUpgradePage::on_upgradeButton_clicked() { - // now what? + std::unique_ptr<Task> task(MMC->folderProvider()->legacyUpgradeTask(m_inst)); + runModalTask(task.get()); } bool LegacyUpgradePage::shouldDisplay() const diff --git a/application/pages/LegacyUpgradePage.h b/application/pages/LegacyUpgradePage.h index 4731bb82..3e1abe93 100644 --- a/application/pages/LegacyUpgradePage.h +++ b/application/pages/LegacyUpgradePage.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ #include "minecraft/legacy/LegacyInstance.h" #include "pages/BasePage.h" #include <MultiMC.h> +#include "tasks/Task.h" namespace Ui { @@ -31,7 +32,7 @@ class LegacyUpgradePage : public QWidget, public BasePage Q_OBJECT public: - explicit LegacyUpgradePage(LegacyInstance *inst, QWidget *parent = 0); + explicit LegacyUpgradePage(InstancePtr inst, QWidget *parent = 0); virtual ~LegacyUpgradePage(); virtual QString displayName() const override { @@ -50,11 +51,14 @@ public: return "Legacy-upgrade"; } virtual bool shouldDisplay() const override; -private -slots: + +private slots: void on_upgradeButton_clicked(); private: + void runModalTask(Task *task); + +private: Ui::LegacyUpgradePage *ui; - LegacyInstance *m_inst; + InstancePtr m_inst; }; diff --git a/application/pages/LegacyUpgradePage.ui b/application/pages/LegacyUpgradePage.ui index 5e8c74eb..a94ee039 100644 --- a/application/pages/LegacyUpgradePage.ui +++ b/application/pages/LegacyUpgradePage.ui @@ -26,15 +26,7 @@ <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> + <string><html><body><h1>Upgrade is required</h1><p>MultiMC now supports old Minecraft versions and all the required features in the new (OneSix) instance format. As a consequence, the old (Legacy) format has been entirely disabled and old instances need to be upgraded.</p><p>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>Please report any issues on our <a href="https://github.com/MultiMC/MultiMC5/issues">github issues page</a>.</p><p>There is also a <a href="https://discord.gg/GtPmv93">discord channel for testing here</a>.</p></body></html></string> </property> <property name="openExternalLinks"> <bool>true</bool> @@ -44,7 +36,7 @@ p, li { white-space: pre-wrap; } <item> <widget class="QCommandLinkButton" name="upgradeButton"> <property name="text"> - <string>Start the upgrade! (Not Yet Implemented, Coming Soonâ„¢)</string> + <string>Upgrade the instance</string> </property> </widget> </item> diff --git a/application/pages/LogPage.cpp b/application/pages/LogPage.cpp index 75e1df7d..0fa1ee67 100644 --- a/application/pages/LogPage.cpp +++ b/application/pages/LogPage.cpp @@ -141,13 +141,11 @@ LogPage::LogPage(InstancePtr instance, QWidget *parent) auto launchTask = m_instance->getLaunchTask(); if(launchTask) { - on_InstanceLaunchTask_changed(launchTask); + setInstanceLaunchTaskChanged(launchTask, true); } - connect(m_instance.get(), &BaseInstance::launchTaskChanged, this, &LogPage::on_InstanceLaunchTask_changed); + connect(m_instance.get(), &BaseInstance::launchTaskChanged, this, &LogPage::onInstanceLaunchTaskChanged); } - ui->text->setWordWrap(true); - auto findShortcut = new QShortcut(QKeySequence(QKeySequence::Find), this); connect(findShortcut, SIGNAL(activated()), SLOT(findActivated())); auto findNextShortcut = new QShortcut(QKeySequence(QKeySequence::FindNext), this); @@ -162,13 +160,53 @@ LogPage::~LogPage() delete ui; } -void LogPage::on_InstanceLaunchTask_changed(std::shared_ptr<LaunchTask> proc) +void LogPage::modelStateToUI() +{ + if(m_model->wrapLines()) + { + ui->text->setWordWrap(true); + ui->wrapCheckbox->setCheckState(Qt::Checked); + } + else + { + ui->text->setWordWrap(false); + ui->wrapCheckbox->setCheckState(Qt::Unchecked); + } + if(m_model->suspended()) + { + ui->trackLogCheckbox->setCheckState(Qt::Unchecked); + } + else + { + ui->trackLogCheckbox->setCheckState(Qt::Checked); + } +} + +void LogPage::UIToModelState() +{ + if(!m_model) + { + return; + } + m_model->setLineWrap(ui->wrapCheckbox->checkState() == Qt::Checked); + m_model->suspend(ui->trackLogCheckbox->checkState() != Qt::Checked); +} + +void LogPage::setInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc, bool initial) { m_process = proc; if(m_process) { m_model = proc->getLogModel(); m_proxy->setSourceModel(m_model.get()); + if(initial) + { + modelStateToUI(); + } + else + { + UIToModelState(); + } } else { @@ -177,6 +215,11 @@ void LogPage::on_InstanceLaunchTask_changed(std::shared_ptr<LaunchTask> proc) } } +void LogPage::onInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc) +{ + setInstanceLaunchTaskChanged(proc, false); +} + bool LogPage::apply() { return true; @@ -218,7 +261,7 @@ void LogPage::on_btnClear_clicked() if(!m_model) return; m_model->clear(); - m_parentContainer->refreshContainer(); + m_container->refreshContainer(); } void LogPage::on_btnBottom_clicked() @@ -228,12 +271,17 @@ void LogPage::on_btnBottom_clicked() void LogPage::on_trackLogCheckbox_clicked(bool checked) { + if(!m_model) + return; m_model->suspend(!checked); } void LogPage::on_wrapCheckbox_clicked(bool checked) { ui->text->setWordWrap(checked); + if(!m_model) + return; + m_model->setLineWrap(checked); } void LogPage::on_findButton_clicked() @@ -262,8 +310,3 @@ void LogPage::findActivated() ui->searchBar->selectAll(); } } - -void LogPage::setParentContainer(BasePageContainer * container) -{ - m_parentContainer = container; -} diff --git a/application/pages/LogPage.h b/application/pages/LogPage.h index 8dceb94f..b830118e 100644 --- a/application/pages/LogPage.h +++ b/application/pages/LogPage.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,6 @@ public: return "Minecraft-Logs"; } virtual bool shouldDisplay() const override; - virtual void setParentContainer(BasePageContainer *) override; private slots: void on_btnPaste_clicked(); @@ -70,14 +69,18 @@ private slots: void findNextActivated(); void findPreviousActivated(); - void on_InstanceLaunchTask_changed(std::shared_ptr<LaunchTask> proc); + void onInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc); + +private: + void modelStateToUI(); + void UIToModelState(); + void setInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc, bool initial); private: Ui::LogPage *ui; InstancePtr m_instance; std::shared_ptr<LaunchTask> m_process; - BasePageContainer * m_parentContainer; LogFormatProxyModel * m_proxy; shared_qobject_ptr <LogModel> m_model; }; diff --git a/application/pages/ModFolderPage.cpp b/application/pages/ModFolderPage.cpp index 5c60cc7f..2b3f4416 100644 --- a/application/pages/ModFolderPage.cpp +++ b/application/pages/ModFolderPage.cpp @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ #include "minecraft/ModList.h" #include "minecraft/Mod.h" #include "minecraft/VersionFilterData.h" +#include "minecraft/ComponentList.h" #include <DesktopServices.h> ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<ModList> mods, QString id, @@ -99,21 +100,21 @@ bool CoreModFolderPage::shouldDisplay() const { if (ModFolderPage::shouldDisplay()) { - auto inst = dynamic_cast<OneSixInstance *>(m_inst); + auto inst = dynamic_cast<MinecraftInstance *>(m_inst); if (!inst) return true; - auto version = inst->getMinecraftProfile(); + auto version = inst->getComponentList(); if (!version) return true; - if(!version->versionPatch("net.minecraftforge")) + if(!version->getComponent("net.minecraftforge")) { return false; } - if(!version->versionPatch("net.minecraft")) + if(!version->getComponent("net.minecraft")) { return false; } - if(version->versionPatch("net.minecraft")->getReleaseDateTime() < g_VersionFilterData.legacyCutoffDate) + if(version->getComponent("net.minecraft")->getReleaseDateTime() < g_VersionFilterData.legacyCutoffDate) { return true; } diff --git a/application/pages/ModFolderPage.h b/application/pages/ModFolderPage.h index 191fa9dc..02282c41 100644 --- a/application/pages/ModFolderPage.h +++ b/application/pages/ModFolderPage.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ #include <QWidget> -#include "minecraft/onesix/OneSixInstance.h" +#include "minecraft/MinecraftInstance.h" #include "BasePage.h" #include <MultiMC.h> diff --git a/application/pages/NotesPage.h b/application/pages/NotesPage.h index a119142f..eab446ad 100644 --- a/application/pages/NotesPage.h +++ b/application/pages/NotesPage.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/application/pages/OtherLogsPage.cpp b/application/pages/OtherLogsPage.cpp index 3988e939..2141e0cc 100644 --- a/application/pages/OtherLogsPage.cpp +++ b/application/pages/OtherLogsPage.cpp @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ #include "RecursiveFileSystemWatcher.h" #include <GZip.h> #include <FileSystem.h> +#include <QShortcut> OtherLogsPage::OtherLogsPage(QString path, IPathMatcher::Ptr fileFilter, QWidget *parent) : QWidget(parent), ui(new Ui::OtherLogsPage), m_path(path), m_fileFilter(fileFilter), @@ -35,6 +36,17 @@ OtherLogsPage::OtherLogsPage(QString path, IPathMatcher::Ptr fileFilter, QWidget connect(m_watcher, &RecursiveFileSystemWatcher::filesChanged, this, &OtherLogsPage::populateSelectLogBox); populateSelectLogBox(); + + auto findShortcut = new QShortcut(QKeySequence(QKeySequence::Find), this); + connect(findShortcut, &QShortcut::activated, this, &OtherLogsPage::findActivated); + + auto findNextShortcut = new QShortcut(QKeySequence(QKeySequence::FindNext), this); + connect(findNextShortcut, &QShortcut::activated, this, &OtherLogsPage::findNextActivated); + + auto findPreviousShortcut = new QShortcut(QKeySequence(QKeySequence::FindPrevious), this); + connect(findPreviousShortcut, &QShortcut::activated, this, &OtherLogsPage::findPreviousActivated); + + connect(ui->searchBar, &QLineEdit::returnPressed, this, &OtherLogsPage::on_findButton_clicked); } OtherLogsPage::~OtherLogsPage() @@ -115,9 +127,22 @@ void OtherLogsPage::on_btnReload_clicked() } else { + auto setPlainText = [&](const QString & text) + { + QString fontFamily = MMC->settings()->get("ConsoleFont").toString(); + bool conversionOk = false; + int fontSize = MMC->settings()->get("ConsoleFontSize").toInt(&conversionOk); + if(!conversionOk) + { + fontSize = 11; + } + QTextDocument *doc = ui->text->document(); + doc->setDefaultFont(QFont(fontFamily, fontSize)); + ui->text->setPlainText(text); + }; auto showTooBig = [&]() { - ui->text->setPlainText( + setPlainText( tr("The file (%1) is too big. You may want to open it in a viewer optimized " "for large files.").arg(file.fileName())); }; @@ -132,7 +157,7 @@ void OtherLogsPage::on_btnReload_clicked() QByteArray temp; if(!GZip::unzip(file.readAll(), temp)) { - ui->text->setPlainText( + setPlainText( tr("The file (%1) is not readable.").arg(file.fileName())); return; } @@ -147,7 +172,7 @@ void OtherLogsPage::on_btnReload_clicked() showTooBig(); return; } - ui->text->setPlainText(content); + setPlainText(content); } } @@ -200,7 +225,7 @@ void OtherLogsPage::on_btnClean_clicked() } else { - messageBox->setText(tr("Do you really want to these files?\n%1").arg(toDelete.join('\n'))); + messageBox->setText(tr("Do you really want to delete these files?\n%1").arg(toDelete.join('\n'))); } messageBox->setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); messageBox->setDefaultButton(QMessageBox::Ok); @@ -253,3 +278,36 @@ void OtherLogsPage::setControlsEnabled(const bool enabled) ui->text->setEnabled(enabled); ui->btnClean->setEnabled(enabled); } + +// FIXME: HACK, use LogView instead? +static void findNext(QPlainTextEdit * _this, const QString& what, bool reverse) +{ + _this->find(what, reverse ? QTextDocument::FindFlag::FindBackward : QTextDocument::FindFlag(0)); +} + +void OtherLogsPage::on_findButton_clicked() +{ + auto modifiers = QApplication::keyboardModifiers(); + bool reverse = modifiers & Qt::ShiftModifier; + findNext(ui->text, ui->searchBar->text(), reverse); +} + +void OtherLogsPage::findNextActivated() +{ + findNext(ui->text, ui->searchBar->text(), false); +} + +void OtherLogsPage::findPreviousActivated() +{ + findNext(ui->text, ui->searchBar->text(), true); +} + +void OtherLogsPage::findActivated() +{ + // focus the search bar if it doesn't have focus + if (!ui->searchBar->hasFocus()) + { + ui->searchBar->setFocus(); + ui->searchBar->selectAll(); + } +} diff --git a/application/pages/OtherLogsPage.h b/application/pages/OtherLogsPage.h index 9ccf964f..157f5e9d 100644 --- a/application/pages/OtherLogsPage.h +++ b/application/pages/OtherLogsPage.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,6 +64,11 @@ private slots: void on_btnDelete_clicked(); void on_btnClean_clicked(); + void on_findButton_clicked(); + void findActivated(); + void findNextActivated(); + void findPreviousActivated(); + private: void setControlsEnabled(const bool enabled); diff --git a/application/pages/OtherLogsPage.ui b/application/pages/OtherLogsPage.ui index 43d6a35b..56ff3b62 100644 --- a/application/pages/OtherLogsPage.ui +++ b/application/pages/OtherLogsPage.ui @@ -32,8 +32,34 @@ <attribute name="title"> <string notr="true">Tab 1</string> </attribute> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="2" column="1"> + <widget class="QLineEdit" name="searchBar"/> + </item> + <item row="2" column="2"> + <widget class="QPushButton" name="findButton"> + <property name="text"> + <string>Find</string> + </property> + </widget> + </item> + <item row="1" column="0" colspan="4"> + <widget class="QPlainTextEdit" name="text"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="verticalScrollBarPolicy"> + <enum>Qt::ScrollBarAlwaysOn</enum> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + <property name="textInteractionFlags"> + <set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> + </property> + </widget> + </item> + <item row="0" column="0" colspan="4"> <layout class="QGridLayout" name="gridLayout"> <item row="3" column="1"> <widget class="QPushButton" name="btnCopy"> @@ -65,6 +91,16 @@ </property> </widget> </item> + <item row="3" column="4"> + <widget class="QPushButton" name="btnClean"> + <property name="toolTip"> + <string>Clear the log</string> + </property> + <property name="text"> + <string>Clean</string> + </property> + </widget> + </item> <item row="3" column="0"> <widget class="QPushButton" name="btnReload"> <property name="text"> @@ -82,31 +118,12 @@ </property> </widget> </item> - <item row="3" column="4"> - <widget class="QPushButton" name="btnClean"> - <property name="toolTip"> - <string>Clear the log</string> - </property> - <property name="text"> - <string>Clean</string> - </property> - </widget> - </item> </layout> </item> - <item> - <widget class="QPlainTextEdit" name="text"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="verticalScrollBarPolicy"> - <enum>Qt::ScrollBarAlwaysOn</enum> - </property> - <property name="readOnly"> - <bool>true</bool> - </property> - <property name="textInteractionFlags"> - <set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> + <item row="2" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Search:</string> </property> </widget> </item> @@ -117,7 +134,16 @@ </layout> </widget> <tabstops> + <tabstop>tabWidget</tabstop> + <tabstop>selectLogBox</tabstop> + <tabstop>btnReload</tabstop> + <tabstop>btnCopy</tabstop> + <tabstop>btnPaste</tabstop> + <tabstop>btnDelete</tabstop> + <tabstop>btnClean</tabstop> <tabstop>text</tabstop> + <tabstop>searchBar</tabstop> + <tabstop>findButton</tabstop> </tabstops> <resources/> <connections/> diff --git a/application/pages/ScreenshotsPage.cpp b/application/pages/ScreenshotsPage.cpp index a4ee6f9d..7d32576a 100644 --- a/application/pages/ScreenshotsPage.cpp +++ b/application/pages/ScreenshotsPage.cpp @@ -280,7 +280,7 @@ void ScreenshotsPage::on_viewFolderBtn_clicked() void ScreenshotsPage::on_uploadBtn_clicked() { - auto selection = ui->listView->selectionModel()->selectedIndexes(); + auto selection = ui->listView->selectionModel()->selectedRows(); if (selection.isEmpty()) return; diff --git a/application/pages/ScreenshotsPage.h b/application/pages/ScreenshotsPage.h index 4aa16d18..c3ccbdee 100644 --- a/application/pages/ScreenshotsPage.h +++ b/application/pages/ScreenshotsPage.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/application/pages/ScreenshotsPage.ui b/application/pages/ScreenshotsPage.ui index 7b70c07e..d05c4384 100644 --- a/application/pages/ScreenshotsPage.ui +++ b/application/pages/ScreenshotsPage.ui @@ -39,7 +39,7 @@ <enum>QAbstractItemView::ExtendedSelection</enum> </property> <property name="selectionBehavior"> - <enum>QAbstractItemView::SelectItems</enum> + <enum>QAbstractItemView::SelectRows</enum> </property> </widget> </item> diff --git a/application/pages/VersionPage.cpp b/application/pages/VersionPage.cpp index 8c14818f..00ae0a7e 100644 --- a/application/pages/VersionPage.cpp +++ b/application/pages/VersionPage.cpp @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ #include "dialogs/CustomMessageBox.h" #include "dialogs/VersionSelectDialog.h" +#include "dialogs/NewComponentDialog.h" #include "dialogs/ModEditDialogCommon.h" #include "dialogs/ProgressDialog.h" @@ -35,7 +36,7 @@ #include <QString> #include <QUrl> -#include "minecraft/MinecraftProfile.h" +#include "minecraft/ComponentList.h" #include "minecraft/auth/MojangAccountList.h" #include "minecraft/Mod.h" #include "icons/IconList.h" @@ -50,13 +51,13 @@ class IconProxy : public QIdentityProxyModel { Q_OBJECT public: - + IconProxy(QWidget *parentWidget) : QIdentityProxyModel(parentWidget) { connect(parentWidget, &QObject::destroyed, this, &IconProxy::widgetGone); m_parentWidget = parentWidget; } - + virtual QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const override { QVariant var = QIdentityProxyModel::data(mapToSource(proxyIndex), role); @@ -98,20 +99,15 @@ bool VersionPage::shouldDisplay() const return !m_inst->isRunning(); } -void VersionPage::setParentContainer(BasePageContainer * container) -{ - m_container = container; -} - -VersionPage::VersionPage(OneSixInstance *inst, QWidget *parent) +VersionPage::VersionPage(MinecraftInstance *inst, QWidget *parent) : QWidget(parent), ui(new Ui::VersionPage), m_inst(inst) { ui->setupUi(this); ui->tabWidget->tabBar()->hide(); + m_profile = m_inst->getComponentList(); - reloadMinecraftProfile(); + reloadComponentList(); - m_profile = m_inst->getMinecraftProfile(); if (m_profile) { auto proxy = new IconProxy(ui->packageView); @@ -119,10 +115,9 @@ VersionPage::VersionPage(OneSixInstance *inst, QWidget *parent) ui->packageView->setModel(proxy); ui->packageView->installEventFilter(this); ui->packageView->setSelectionMode(QAbstractItemView::SingleSelection); - connect(ui->packageView->selectionModel(), &QItemSelectionModel::currentChanged, - this, &VersionPage::versionCurrent); + connect(ui->packageView->selectionModel(), &QItemSelectionModel::currentChanged, this, &VersionPage::versionCurrent); auto smodel = ui->packageView->selectionModel(); - connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), SLOT(packageCurrent(QModelIndex, QModelIndex))); + connect(smodel, &QItemSelectionModel::currentChanged, this, &VersionPage::packageCurrent); updateVersionControls(); // select first item. preselect(0); @@ -131,7 +126,7 @@ VersionPage::VersionPage(OneSixInstance *inst, QWidget *parent) { disableVersionControls(); } - connect(m_inst, &OneSixInstance::versionReloaded, this, + connect(m_inst, &MinecraftInstance::versionReloaded, this, &VersionPage::updateVersionControls); } @@ -148,7 +143,7 @@ void VersionPage::packageCurrent(const QModelIndex ¤t, const QModelIndex & return; } int row = current.row(); - auto patch = m_profile->versionPatch(row); + auto patch = m_profile->getComponent(row); auto severity = patch->getProblemSeverity(); switch(severity) { @@ -168,15 +163,15 @@ void VersionPage::packageCurrent(const QModelIndex ¤t, const QModelIndex & QString problemOut; for (auto &problem: problems) { - if(problem.getSeverity() == ProblemSeverity::Error) + if(problem.m_severity == ProblemSeverity::Error) { problemOut += tr("Error: "); } - else if(problem.getSeverity() == ProblemSeverity::Warning) + else if(problem.m_severity == ProblemSeverity::Warning) { problemOut += tr("Warning: "); } - problemOut += problem.getDescription(); + problemOut += problem.m_description; problemOut += "\n"; } ui->frame->setModDescription(problemOut); @@ -198,11 +193,11 @@ void VersionPage::disableVersionControls() updateButtons(); } -bool VersionPage::reloadMinecraftProfile() +bool VersionPage::reloadComponentList() { try { - m_inst->reloadProfile(); + m_profile->reload(Net::Mode::Online); return true; } catch (Exception &e) @@ -221,7 +216,7 @@ bool VersionPage::reloadMinecraftProfile() void VersionPage::on_reloadBtn_clicked() { - reloadMinecraftProfile(); + reloadComponentList(); m_container->refreshContainer(); } @@ -236,7 +231,7 @@ void VersionPage::on_removeBtn_clicked() } } updateButtons(); - reloadMinecraftProfile(); + reloadComponentList(); m_container->refreshContainer(); } @@ -250,47 +245,20 @@ void VersionPage::on_modBtn_clicked() void VersionPage::on_jarmodBtn_clicked() { - bool nagShown = false; - if (!m_profile->hasTrait("legacyLaunch") && !m_profile->hasTrait("alphaLaunch")) - { - // not legacy launch... nag - auto seenNag = MMC->settings()->get("JarModNagSeen").toBool(); - if(!seenNag) - { - auto result = QMessageBox::question(this, - tr("Are you sure?"), - tr("This will add mods directly to the Minecraft jar.\n" - "Unless you KNOW that this is what NEEDS to be done, you should just use the mods folder (Loader mods).\n" - "\n" - "Do you want to continue?"), - tr("I understand, continue."), tr("Cancel"), QString(), 1, 1 - ); - if(result != 0) - return; - nagShown = true; - } - } auto list = GuiUtil::BrowseForFiles("jarmod", tr("Select jar mods"), tr("Minecraft.jar mods (*.zip *.jar)"), MMC->settings()->get("CentralModsDir").toString(), this->parentWidget()); if(!list.empty()) { m_profile->installJarMods(list); - if(nagShown) - { - MMC->settings()->set("JarModNagSeen", QVariant(true)); - } } updateButtons(); } -void VersionPage::on_resetOrderBtn_clicked() +void VersionPage::on_jarBtn_clicked() { - try - { - m_profile->resetOrder(); - } - catch (Exception &e) + auto jarPath = GuiUtil::BrowseForFile("jar", tr("Select jar"), tr("Minecraft.jar replacement (*.jar)"), MMC->settings()->get("CentralModsDir").toString(), this->parentWidget()); + if(!jarPath.isEmpty()) { - QMessageBox::critical(this, tr("Error"), e.cause()); + m_profile->installCustomJar(jarPath); } updateButtons(); } @@ -299,7 +267,7 @@ void VersionPage::on_moveUpBtn_clicked() { try { - m_profile->move(currentRow(), MinecraftProfile::MoveUp); + m_profile->move(currentRow(), ComponentList::MoveUp); } catch (Exception &e) { @@ -312,7 +280,7 @@ void VersionPage::on_moveDownBtn_clicked() { try { - m_profile->move(currentRow(), MinecraftProfile::MoveDown); + m_profile->move(currentRow(), ComponentList::MoveDown); } catch (Exception &e) { @@ -328,7 +296,7 @@ void VersionPage::on_changeVersionBtn_clicked() { return; } - auto patch = m_profile->versionPatch(versionRow); + auto patch = m_profile->getComponent(versionRow); auto name = patch->getName(); auto list = patch->getVersionList(); if(!list) @@ -336,10 +304,39 @@ void VersionPage::on_changeVersionBtn_clicked() return; } auto uid = list->uid(); + // FIXME: this is a horrible HACK. Get version filtering information from the actual metadata... + if(uid == "net.minecraftforge") + { + on_forgeBtn_clicked(); + return; + } + else if (uid == "com.mumfrey.liteloader") + { + on_liteloaderBtn_clicked(); + return; + } VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this); + auto currentVersion = patch->getVersion(); + if(!currentVersion.isEmpty()) + { + vselect.setCurrentVersion(currentVersion); + } if (!vselect.exec() || !vselect.selectedVersion()) return; + qDebug() << "Change" << uid << "to" << vselect.selectedVersion()->descriptor(); + bool important = false; + if(uid == "net.minecraft") + { + important = true; + } + m_profile->setComponentVersion(uid, vselect.selectedVersion()->descriptor(), important); + m_profile->resolve(Net::Mode::Online); + m_container->refreshContainer(); +} + +void VersionPage::on_downloadBtn_clicked() +{ if (!MMC->accounts()->anyAccountIsValid()) { CustomMessageBox::selectable( @@ -350,42 +347,17 @@ void VersionPage::on_changeVersionBtn_clicked() return; } - qDebug() << "Change" << uid << "to" << vselect.selectedVersion()->descriptor(); - if(uid == "net.minecraft") - { - if (!m_profile->isVanilla()) - { - auto result = CustomMessageBox::selectable( - this, tr("Are you sure?"), - tr("This will remove any library/version customization you did previously. " - "This includes things like Forge install and similar."), - QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Abort, - QMessageBox::Abort)->exec(); - - if (result != QMessageBox::Ok) - return; - m_profile->revertToVanilla(); - reloadMinecraftProfile(); - } - } - m_inst->setComponentVersion(uid, vselect.selectedVersion()->descriptor()); - doUpdate(); - m_container->refreshContainer(); -} - -int VersionPage::doUpdate() -{ - auto updateTask = m_inst->createUpdateTask(); + auto updateTask = m_inst->createUpdateTask(Net::Mode::Online); if (!updateTask) { - return 1; + return; } ProgressDialog tDialog(this); connect(updateTask.get(), SIGNAL(failed(QString)), SLOT(onGameUpdateError(QString))); - int ret = tDialog.execWithTask(updateTask.get()); + // FIXME: unused return value + tDialog.execWithTask(updateTask.get()); updateButtons(); m_container->refreshContainer(); - return ret; } void VersionPage::on_forgeBtn_clicked() @@ -396,20 +368,45 @@ void VersionPage::on_forgeBtn_clicked() return; } VersionSelectDialog vselect(vlist.get(), tr("Select Forge version"), this); - vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_inst->currentVersionId()); - vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") + m_inst->currentVersionId()); + vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft")); + vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") + m_profile->getComponentVersion("net.minecraft")); vselect.setEmptyErrorString(tr("Couldn't load or download the Forge version lists!")); + + auto currentVersion = m_profile->getComponentVersion("net.minecraftforge"); + if(!currentVersion.isEmpty()) + { + vselect.setCurrentVersion(currentVersion); + } + if (vselect.exec() && vselect.selectedVersion()) { auto vsn = vselect.selectedVersion(); - m_inst->setComponentVersion("net.minecraftforge", vsn->descriptor()); - m_profile->reload(); + m_profile->setComponentVersion("net.minecraftforge", vsn->descriptor()); + m_profile->resolve(Net::Mode::Online); // m_profile->installVersion(); preselect(m_profile->rowCount(QModelIndex())-1); m_container->refreshContainer(); } } +void VersionPage::on_addEmptyBtn_clicked() +{ + NewComponentDialog compdialog(QString(), QString(), this); + QStringList blacklist; + for(int i = 0; i < m_profile->rowCount(); i++) + { + auto comp = m_profile->getComponent(i); + blacklist.push_back(comp->getID()); + } + compdialog.setBlacklist(blacklist); + if (compdialog.exec()) + { + qDebug() << "name:" << compdialog.name(); + qDebug() << "uid:" << compdialog.uid(); + m_profile->installEmpty(compdialog.uid(), compdialog.name()); + } +} + void VersionPage::on_liteloaderBtn_clicked() { auto vlist = ENV.metadataIndex()->get("com.mumfrey.liteloader"); @@ -418,14 +415,21 @@ void VersionPage::on_liteloaderBtn_clicked() return; } VersionSelectDialog vselect(vlist.get(), tr("Select LiteLoader version"), this); - vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_inst->currentVersionId()); - vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") + m_inst->currentVersionId()); + vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft")); + vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") + m_profile->getComponentVersion("net.minecraft")); vselect.setEmptyErrorString(tr("Couldn't load or download the LiteLoader version lists!")); + + auto currentVersion = m_profile->getComponentVersion("com.mumfrey.liteloader"); + if(!currentVersion.isEmpty()) + { + vselect.setCurrentVersion(currentVersion); + } + if (vselect.exec() && vselect.selectedVersion()) { auto vsn = vselect.selectedVersion(); - m_inst->setComponentVersion("com.mumfrey.liteloader", vsn->descriptor()); - m_profile->reload(); + m_profile->setComponentVersion("com.mumfrey.liteloader", vsn->descriptor()); + m_profile->resolve(Net::Mode::Online); // m_profile->installVersion(vselect.selectedVersion()); preselect(m_profile->rowCount(QModelIndex())-1); m_container->refreshContainer(); @@ -461,7 +465,7 @@ void VersionPage::updateButtons(int row) { if(row == -1) row = currentRow(); - auto patch = m_profile->versionPatch(row); + auto patch = m_profile->getComponent(row); if (!patch) { ui->removeBtn->setDisabled(true); @@ -490,14 +494,14 @@ void VersionPage::onGameUpdateError(QString error) QMessageBox::Warning)->show(); } -ProfilePatchPtr VersionPage::current() +Component * VersionPage::current() { auto row = currentRow(); if(row < 0) { return nullptr; } - return m_profile->versionPatch(row); + return m_profile->getComponent(row); } int VersionPage::currentRow() @@ -516,7 +520,7 @@ void VersionPage::on_customizeBtn_clicked() { return; } - auto patch = m_profile->versionPatch(version); + auto patch = m_profile->getComponent(version); if(!patch->getVersionFile()) { // TODO: wait for the update task to finish here... @@ -563,3 +567,4 @@ void VersionPage::on_revertBtn_clicked() } #include "VersionPage.moc" + diff --git a/application/pages/VersionPage.h b/application/pages/VersionPage.h index cc6c0b7b..49620c56 100644 --- a/application/pages/VersionPage.h +++ b/application/pages/VersionPage.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,8 @@ #include <QWidget> -#include "minecraft/onesix/OneSixInstance.h" +#include "minecraft/MinecraftInstance.h" +#include "minecraft/ComponentList.h" #include "BasePage.h" namespace Ui @@ -30,7 +31,7 @@ class VersionPage : public QWidget, public BasePage Q_OBJECT public: - explicit VersionPage(OneSixInstance *inst, QWidget *parent = 0); + explicit VersionPage(MinecraftInstance *inst, QWidget *parent = 0); virtual ~VersionPage(); virtual QString displayName() const override { @@ -43,32 +44,32 @@ public: } virtual QString helpPage() const override { - return "Instance-Versions"; + return "Instance-Version"; } virtual bool shouldDisplay() const override; - virtual void setParentContainer(BasePageContainer *) override; - private slots: void on_forgeBtn_clicked(); + void on_addEmptyBtn_clicked(); void on_liteloaderBtn_clicked(); void on_reloadBtn_clicked(); void on_removeBtn_clicked(); - void on_resetOrderBtn_clicked(); void on_moveUpBtn_clicked(); void on_moveDownBtn_clicked(); void on_jarmodBtn_clicked(); + void on_jarBtn_clicked(); void on_revertBtn_clicked(); void on_editBtn_clicked(); void on_modBtn_clicked(); void on_customizeBtn_clicked(); + void on_downloadBtn_clicked(); void updateVersionControls(); void disableVersionControls(); void on_changeVersionBtn_clicked(); private: - ProfilePatchPtr current(); + Component * current(); int currentRow(); void updateButtons(int row = -1); void preselect(int row = 0); @@ -76,14 +77,13 @@ private: protected: /// FIXME: this shouldn't be necessary! - bool reloadMinecraftProfile(); + bool reloadComponentList(); private: Ui::VersionPage *ui; - std::shared_ptr<MinecraftProfile> m_profile; - OneSixInstance *m_inst; + std::shared_ptr<ComponentList> m_profile; + MinecraftInstance *m_inst; int currentIdx = 0; - BasePageContainer * m_container = nullptr; public slots: void versionCurrent(const QModelIndex ¤t, const QModelIndex &previous); diff --git a/application/pages/VersionPage.ui b/application/pages/VersionPage.ui index c16208db..d54dd840 100644 --- a/application/pages/VersionPage.ui +++ b/application/pages/VersionPage.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>693</width> - <height>750</height> + <width>870</width> + <height>1008</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout"> @@ -206,17 +206,21 @@ <string>Add a mod into the Minecraft jar file.</string> </property> <property name="text"> - <string>Add jar mod</string> + <string>Add to Minecraft.jar</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="resetOrderBtn"> - <property name="toolTip"> - <string>Reset apply order of packages.</string> + <widget class="QPushButton" name="jarBtn"> + <property name="text"> + <string>Replace Minecraft.jar</string> </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="addEmptyBtn"> <property name="text"> - <string>Reset order</string> + <string>Add Empty</string> </property> </widget> </item> @@ -231,6 +235,16 @@ </widget> </item> <item> + <widget class="QPushButton" name="downloadBtn"> + <property name="toolTip"> + <string>Download the files needed to launch the instance now.</string> + </property> + <property name="text"> + <string>Download All</string> + </property> + </widget> + </item> + <item> <spacer name="verticalSpacer_7"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -281,7 +295,6 @@ </customwidget> </customwidgets> <tabstops> - <tabstop>tabWidget</tabstop> <tabstop>packageView</tabstop> <tabstop>changeVersionBtn</tabstop> <tabstop>moveUpBtn</tabstop> @@ -294,8 +307,11 @@ <tabstop>liteloaderBtn</tabstop> <tabstop>modBtn</tabstop> <tabstop>jarmodBtn</tabstop> - <tabstop>resetOrderBtn</tabstop> + <tabstop>jarBtn</tabstop> + <tabstop>addEmptyBtn</tabstop> <tabstop>reloadBtn</tabstop> + <tabstop>downloadBtn</tabstop> + <tabstop>tabWidget</tabstop> </tabstops> <resources/> <connections/> diff --git a/application/pages/WorldListPage.cpp b/application/pages/WorldListPage.cpp index b6195bb3..56a7e791 100644 --- a/application/pages/WorldListPage.cpp +++ b/application/pages/WorldListPage.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 MultiMC Contributors +/* Copyright 2015-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/application/pages/WorldListPage.h b/application/pages/WorldListPage.h index 89d86158..d0aa6150 100644 --- a/application/pages/WorldListPage.h +++ b/application/pages/WorldListPage.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 MultiMC Contributors +/* Copyright 2015-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ #include <QWidget> -#include "minecraft/onesix/OneSixInstance.h" +#include "minecraft/MinecraftInstance.h" #include "BasePage.h" #include <MultiMC.h> #include <LoggedProcess.h> diff --git a/application/pages/global/AccountListPage.cpp b/application/pages/global/AccountListPage.cpp index 8edcad98..63943174 100644 --- a/application/pages/global/AccountListPage.cpp +++ b/application/pages/global/AccountListPage.cpp @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/application/pages/global/AccountListPage.h b/application/pages/global/AccountListPage.h index 52022b6c..fa5561fe 100644 --- a/application/pages/global/AccountListPage.h +++ b/application/pages/global/AccountListPage.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/application/pages/global/CustomCommandsPage.cpp b/application/pages/global/CustomCommandsPage.cpp new file mode 100644 index 00000000..1352b6be --- /dev/null +++ b/application/pages/global/CustomCommandsPage.cpp @@ -0,0 +1,50 @@ +#include "CustomCommandsPage.h" +#include <QVBoxLayout> +#include <QTabWidget> +#include <QTabBar> + +CustomCommandsPage::CustomCommandsPage(QWidget* parent): QWidget(parent) +{ + + auto verticalLayout = new QVBoxLayout(this); + verticalLayout->setObjectName(QStringLiteral("verticalLayout")); + verticalLayout->setContentsMargins(0, 0, 0, 0); + + auto tabWidget = new QTabWidget(this); + tabWidget->setObjectName(QStringLiteral("tabWidget")); + commands = new CustomCommands(this); + tabWidget->addTab(commands, "Foo"); + tabWidget->tabBar()->hide(); + verticalLayout->addWidget(tabWidget); + loadSettings(); +} + +CustomCommandsPage::~CustomCommandsPage() +{ +} + +bool CustomCommandsPage::apply() +{ + applySettings(); + return true; +} + +void CustomCommandsPage::applySettings() +{ + auto s = MMC->settings(); + s->set("PreLaunchCommand", commands->prelaunchCommand()); + s->set("WrapperCommand", commands->wrapperCommand()); + s->set("PostExitCommand", commands->postexitCommand()); +} + +void CustomCommandsPage::loadSettings() +{ + auto s = MMC->settings(); + commands->initialize( + false, + true, + s->get("PreLaunchCommand").toString(), + s->get("WrapperCommand").toString(), + s->get("PostExitCommand").toString() + ); +} diff --git a/application/pages/global/CustomCommandsPage.h b/application/pages/global/CustomCommandsPage.h new file mode 100644 index 00000000..52256ed3 --- /dev/null +++ b/application/pages/global/CustomCommandsPage.h @@ -0,0 +1,55 @@ +/* Copyright 2018-2018 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 <memory> +#include <QDialog> + +#include "pages/BasePage.h" +#include <MultiMC.h> +#include "widgets/CustomCommands.h" + +class CustomCommandsPage : public QWidget, public BasePage +{ + Q_OBJECT + +public: + explicit CustomCommandsPage(QWidget *parent = 0); + ~CustomCommandsPage(); + + QString displayName() const override + { + return tr("Custom Commands"); + } + QIcon icon() const override + { + return MMC->getThemedIcon("custom-commands"); + } + QString id() const override + { + return "custom-commands"; + } + QString helpPage() const override + { + return "Custom-commands"; + } + bool apply() override; + +private: + void applySettings(); + void loadSettings(); + CustomCommands * commands; +}; diff --git a/application/pages/global/ExternalToolsPage.cpp b/application/pages/global/ExternalToolsPage.cpp index b446fc06..ff63ecbb 100644 --- a/application/pages/global/ExternalToolsPage.cpp +++ b/application/pages/global/ExternalToolsPage.cpp @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -206,12 +206,12 @@ void ExternalToolsPage::on_jsonEditorBrowseBtn_clicked() ? QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).first() #endif : ui->jsonEditorTextBox->text()); - QString cooked_file = FS::NormalizePath(raw_file); - if (cooked_file.isEmpty()) + if (raw_file.isEmpty()) { return; } + QString cooked_file = FS::NormalizePath(raw_file); // it has to exist and be an executable if (QFileInfo(cooked_file).exists() && QFileInfo(cooked_file).isExecutable()) diff --git a/application/pages/global/ExternalToolsPage.h b/application/pages/global/ExternalToolsPage.h index b222db5e..de46d8a6 100644 --- a/application/pages/global/ExternalToolsPage.h +++ b/application/pages/global/ExternalToolsPage.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/application/pages/global/ExternalToolsPage.ui b/application/pages/global/ExternalToolsPage.ui index cdb33b35..5f19898b 100644 --- a/application/pages/global/ExternalToolsPage.ui +++ b/application/pages/global/ExternalToolsPage.ui @@ -63,7 +63,7 @@ <item> <widget class="QLabel" name="jprofilerLink"> <property name="text"> - <string notr="true"><html><head/><body><p><a href="http://www.ej-technologies.com/products/jprofiler/overview.html"><span style=" text-decoration: underline; color:#0000ff;">http://www.ej-technologies.com/products/jprofiler/overview.html</span></a></p></body></html></string> + <string notr="true"><html><head/><body><p><a href="http://www.ej-technologies.com/products/jprofiler/overview.html">http://www.ej-technologies.com/products/jprofiler/overview.html</a></p></body></html></string> </property> </widget> </item> @@ -100,7 +100,7 @@ <item> <widget class="QLabel" name="jvisualvmLink"> <property name="text"> - <string notr="true"><html><head/><body><p><a href="http://visualvm.java.net/"><span style=" text-decoration: underline; color:#0000ff;">http://visualvm.java.net/</span></a></p></body></html></string> + <string notr="true"><html><head/><body><p><a href="https://visualvm.github.io/">https://visualvm.github.io/</a></p></body></html></string> </property> </widget> </item> @@ -137,7 +137,7 @@ <item> <widget class="QLabel" name="mceditLink"> <property name="text"> - <string notr="true"><html><head/><body><p><a href="http://www.mcedit.net/"><span style=" text-decoration: underline; color:#0000ff;">http://www.mcedit.net/</span></a></p></body></html></string> + <string notr="true"><html><head/><body><p><a href="http://www.mcedit.net/">http://www.mcedit.net/</a></p></body></html></string> </property> </widget> </item> diff --git a/application/pages/global/JavaPage.cpp b/application/pages/global/JavaPage.cpp index 543cc11f..57250c79 100644 --- a/application/pages/global/JavaPage.cpp +++ b/application/pages/global/JavaPage.cpp @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ #include <QDir> #include "dialogs/VersionSelectDialog.h" -#include <ColumnResizer.h> #include "java/JavaUtils.h" #include "java/JavaInstallList.h" @@ -30,16 +29,15 @@ #include "settings/SettingsObject.h" #include <FileSystem.h> #include "MultiMC.h" +#include <sys.h> JavaPage::JavaPage(QWidget *parent) : QWidget(parent), ui(new Ui::JavaPage) { ui->setupUi(this); ui->tabWidget->tabBar()->hide(); - auto resizer = new ColumnResizer(this); - resizer->addWidgetsFromLayout(ui->javaSettingsGroupBox->layout(), 0); - resizer->addWidgetsFromLayout(ui->customCommandsGroupBox->layout(), 0); - + auto sysMB = Sys::getSystemRam() / Sys::megabyte; + ui->maxMemSpinBox->setMaximum(sysMB); loadSettings(); } @@ -59,36 +57,46 @@ void JavaPage::applySettings() auto s = MMC->settings(); // Memory - s->set("MinMemAlloc", ui->minMemSpinBox->value()); - s->set("MaxMemAlloc", ui->maxMemSpinBox->value()); + int min = ui->minMemSpinBox->value(); + int max = ui->maxMemSpinBox->value(); + if(min < max) + { + s->set("MinMemAlloc", min); + s->set("MaxMemAlloc", max); + } + else + { + s->set("MinMemAlloc", max); + s->set("MaxMemAlloc", min); + } s->set("PermGen", ui->permGenSpinBox->value()); // Java Settings s->set("JavaPath", ui->javaPathTextBox->text()); s->set("JvmArgs", ui->jvmArgsTextBox->text()); JavaCommon::checkJVMArgs(s->get("JvmArgs").toString(), this->parentWidget()); - - // Custom Commands - s->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text()); - s->set("WrapperCommand", ui->wrapperCmdTextBox->text()); - s->set("PostExitCommand", ui->postExitCmdTextBox->text()); } void JavaPage::loadSettings() { auto s = MMC->settings(); // Memory - ui->minMemSpinBox->setValue(s->get("MinMemAlloc").toInt()); - ui->maxMemSpinBox->setValue(s->get("MaxMemAlloc").toInt()); + int min = s->get("MinMemAlloc").toInt(); + int max = s->get("MaxMemAlloc").toInt(); + if(min < max) + { + ui->minMemSpinBox->setValue(min); + ui->maxMemSpinBox->setValue(max); + } + else + { + ui->minMemSpinBox->setValue(max); + ui->maxMemSpinBox->setValue(min); + } ui->permGenSpinBox->setValue(s->get("PermGen").toInt()); // Java Settings ui->javaPathTextBox->setText(s->get("JavaPath").toString()); ui->jvmArgsTextBox->setText(s->get("JvmArgs").toString()); - - // Custom Commands - ui->preLaunchCmdTextBox->setText(s->get("PreLaunchCommand").toString()); - ui->wrapperCmdTextBox->setText(s->get("WrapperCommand").toString()); - ui->postExitCmdTextBox->setText(s->get("PostExitCommand").toString()); } void JavaPage::on_javaDetectBtn_clicked() @@ -108,14 +116,14 @@ void JavaPage::on_javaDetectBtn_clicked() void JavaPage::on_javaBrowseBtn_clicked() { QString raw_path = QFileDialog::getOpenFileName(this, tr("Find Java executable")); - QString cooked_path = FS::NormalizePath(raw_path); // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if(cooked_path.isEmpty()) + if(raw_path.isEmpty()) { return; } + QString cooked_path = FS::NormalizePath(raw_path); QFileInfo javaInfo(cooked_path);; if(!javaInfo.exists() || !javaInfo.isExecutable()) { diff --git a/application/pages/global/JavaPage.h b/application/pages/global/JavaPage.h index 4feec427..e3a9f37f 100644 --- a/application/pages/global/JavaPage.h +++ b/application/pages/global/JavaPage.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/application/pages/global/JavaPage.ui b/application/pages/global/JavaPage.ui index 9023b932..201b310c 100644 --- a/application/pages/global/JavaPage.ui +++ b/application/pages/global/JavaPage.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>545</width> - <height>760</height> + <height>580</height> </rect> </property> <property name="sizePolicy"> @@ -17,7 +17,16 @@ </sizepolicy> </property> <layout class="QVBoxLayout" name="verticalLayout"> - <property name="margin"> + <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> @@ -217,62 +226,17 @@ </widget> </item> <item> - <widget class="QGroupBox" name="customCommandsGroupBox"> - <property name="title"> - <string>Custom Commands</string> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> </property> - <layout class="QGridLayout" name="gridLayout_4"> - <item row="3" column="0"> - <widget class="QLabel" name="labelPostExitCmd"> - <property name="text"> - <string>Post-exit command:</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="labelPreLaunchCmd"> - <property name="text"> - <string>Pre-launch command:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="preLaunchCmdTextBox"/> - </item> - <item row="3" column="1"> - <widget class="QLineEdit" name="postExitCmdTextBox"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="labelWrapperCmd"> - <property name="text"> - <string>Wrapper command:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="wrapperCmdTextBox"/> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QLabel" name="labelCustomCmdsDescription"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> </property> - <property name="text"> - <string><html><head/><body><p>Pre-launch command runs before the instance launches and post-exit command runs after it exits. Both will be run in MultiMC's working folder with INST_ID, INST_DIR, and INST_NAME as environment variables.</p><p>Wrapper command allows running java using an extra wrapper program (like 'optirun' on Linux)</p></body></html></string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> + </spacer> </item> </layout> </widget> @@ -289,9 +253,6 @@ <tabstop>jvmArgsTextBox</tabstop> <tabstop>javaDetectBtn</tabstop> <tabstop>javaTestBtn</tabstop> - <tabstop>preLaunchCmdTextBox</tabstop> - <tabstop>wrapperCmdTextBox</tabstop> - <tabstop>postExitCmdTextBox</tabstop> <tabstop>tabWidget</tabstop> </tabstops> <resources/> diff --git a/application/pages/global/MinecraftPage.cpp b/application/pages/global/MinecraftPage.cpp index b3a56327..aecd8d57 100644 --- a/application/pages/global/MinecraftPage.cpp +++ b/application/pages/global/MinecraftPage.cpp @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/application/pages/global/MinecraftPage.h b/application/pages/global/MinecraftPage.h index 311b0967..d1abd6fe 100644 --- a/application/pages/global/MinecraftPage.h +++ b/application/pages/global/MinecraftPage.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/application/pages/global/MultiMCPage.cpp b/application/pages/global/MultiMCPage.cpp index 4073f6b7..620fc3a3 100644 --- a/application/pages/global/MultiMCPage.cpp +++ b/application/pages/global/MultiMCPage.cpp @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ #include <QDir> #include <QTextCharFormat> -#include <ColumnResizer.h> #include "updater/UpdateChecker.h" #include "settings/SettingsObject.h" @@ -49,10 +48,6 @@ MultiMCPage::MultiMCPage(QWidget *parent) : QWidget(parent), ui(new Ui::MultiMCP ui->sortingModeGroup->setId(ui->sortByNameBtn, Sort_Name); ui->sortingModeGroup->setId(ui->sortLastLaunchedBtn, Sort_LastLaunch); - auto resizer = new ColumnResizer(this); - resizer->addWidgetsFromLayout(ui->groupBox->layout(), 1); - resizer->addWidgetsFromLayout(ui->foldersBox->layout(), 1); - defaultFormat = new QTextCharFormat(ui->fontPreview->currentCharFormat()); m_languageModel = MMC->translations(); @@ -97,40 +92,14 @@ bool MultiMCPage::apply() return true; } -void MultiMCPage::on_ftbLauncherBrowseBtn_clicked() -{ - QString raw_dir = QFileDialog::getExistingDirectory(this, tr("FTB Launcher Folder"), - ui->ftbLauncherBox->text()); - QString cooked_dir = FS::NormalizePath(raw_dir); - - // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists()) - { - ui->ftbLauncherBox->setText(cooked_dir); - } -} -void MultiMCPage::on_ftbBrowseBtn_clicked() -{ - QString raw_dir = - QFileDialog::getExistingDirectory(this, tr("FTB Folder"), ui->ftbBox->text()); - QString cooked_dir = FS::NormalizePath(raw_dir); - - // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists()) - { - ui->ftbBox->setText(cooked_dir); - } -} - void MultiMCPage::on_instDirBrowseBtn_clicked() { - QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Instance Folder"), - ui->instDirTextBox->text()); - QString cooked_dir = FS::NormalizePath(raw_dir); + QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Instance Folder"), ui->instDirTextBox->text()); // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists()) + if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) { + QString cooked_dir = FS::NormalizePath(raw_dir); if (FS::checkProblemticPathJava(QDir(cooked_dir))) { QMessageBox warning; @@ -157,40 +126,26 @@ void MultiMCPage::on_instDirBrowseBtn_clicked() void MultiMCPage::on_iconsDirBrowseBtn_clicked() { - QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Icons Folder"), - ui->iconsDirTextBox->text()); - QString cooked_dir = FS::NormalizePath(raw_dir); + QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Icons Folder"), ui->iconsDirTextBox->text()); // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists()) + if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) { + QString cooked_dir = FS::NormalizePath(raw_dir); ui->iconsDirTextBox->setText(cooked_dir); } } void MultiMCPage::on_modsDirBrowseBtn_clicked() { - QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Mods Folder"), - ui->modsDirTextBox->text()); - QString cooked_dir = FS::NormalizePath(raw_dir); + QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Mods Folder"), ui->modsDirTextBox->text()); // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists()) + if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) { + QString cooked_dir = FS::NormalizePath(raw_dir); ui->modsDirTextBox->setText(cooked_dir); } } -void MultiMCPage::on_lwjglDirBrowseBtn_clicked() -{ - QString raw_dir = QFileDialog::getExistingDirectory(this, tr("LWJGL Folder"), - ui->lwjglDirTextBox->text()); - QString cooked_dir = FS::NormalizePath(raw_dir); - - // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists()) - { - ui->lwjglDirTextBox->setText(cooked_dir); - } -} void MultiMCPage::languageIndexChanged(int index) { @@ -315,6 +270,9 @@ void MultiMCPage::applySettings() s->set("IconTheme", "iOS"); break; case 7: + s->set("IconTheme", "flat"); + break; + case 8: s->set("IconTheme", "custom"); break; case 0: @@ -346,16 +304,10 @@ void MultiMCPage::applySettings() s->set("ConsoleMaxLines", ui->lineLimitSpinBox->value()); s->set("ConsoleOverflowStop", ui->checkStopLogging->checkState() != Qt::Unchecked); - // FTB - s->set("TrackFTBInstances", ui->trackFtbBox->isChecked()); - s->set("FTBLauncherLocal", FS::NormalizePath(ui->ftbLauncherBox->text())); - s->set("FTBRoot", FS::NormalizePath(ui->ftbBox->text())); - // Folders // TODO: Offer to move instances to new instance folder. s->set("InstanceDir", ui->instDirTextBox->text()); s->set("CentralModsDir", ui->modsDirTextBox->text()); - s->set("LWJGLDir", ui->lwjglDirTextBox->text()); s->set("IconsDir", ui->iconsDirTextBox->text()); auto sortMode = (InstSortMode)ui->sortingModeGroup->checkedId(); @@ -414,10 +366,14 @@ void MultiMCPage::loadSettings() { ui->themeComboBox->setCurrentIndex(6); } - else if (theme == "custom") + else if (theme == "flat") { ui->themeComboBox->setCurrentIndex(7); } + else if (theme == "custom") + { + ui->themeComboBox->setCurrentIndex(8); + } else { ui->themeComboBox->setCurrentIndex(0); @@ -457,15 +413,9 @@ void MultiMCPage::loadSettings() ui->lineLimitSpinBox->setValue(s->get("ConsoleMaxLines").toInt()); ui->checkStopLogging->setChecked(s->get("ConsoleOverflowStop").toBool()); - // FTB - ui->trackFtbBox->setChecked(s->get("TrackFTBInstances").toBool()); - ui->ftbLauncherBox->setText(s->get("FTBLauncherLocal").toString()); - ui->ftbBox->setText(s->get("FTBRoot").toString()); - // Folders ui->instDirTextBox->setText(s->get("InstanceDir").toString()); ui->modsDirTextBox->setText(s->get("CentralModsDir").toString()); - ui->lwjglDirTextBox->setText(s->get("LWJGLDir").toString()); ui->iconsDirTextBox->setText(s->get("IconsDir").toString()); QString sortMode = s->get("InstSortMode").toString(); diff --git a/application/pages/global/MultiMCPage.h b/application/pages/global/MultiMCPage.h index 98eb353d..d5194c0e 100644 --- a/application/pages/global/MultiMCPage.h +++ b/application/pages/global/MultiMCPage.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,12 +64,8 @@ private: private slots: - void on_ftbLauncherBrowseBtn_clicked(); - void on_ftbBrowseBtn_clicked(); - void on_instDirBrowseBtn_clicked(); void on_modsDirBrowseBtn_clicked(); - void on_lwjglDirBrowseBtn_clicked(); void on_iconsDirBrowseBtn_clicked(); void languageIndexChanged(int index); diff --git a/application/pages/global/MultiMCPage.ui b/application/pages/global/MultiMCPage.ui index 0b966876..124401c3 100644 --- a/application/pages/global/MultiMCPage.ui +++ b/application/pages/global/MultiMCPage.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>467</width> - <height>614</height> + <height>629</height> </rect> </property> <property name="sizePolicy"> @@ -89,75 +89,6 @@ </widget> </item> <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string notr="true">FTB</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="2" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>&Launcher:</string> - </property> - <property name="buddy"> - <cstring>ftbLauncherBox</cstring> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="ftbLauncherBox"> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLineEdit" name="ftbBox"/> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Files:</string> - </property> - <property name="buddy"> - <cstring>ftbBox</cstring> - </property> - </widget> - </item> - <item row="3" column="2"> - <widget class="QToolButton" name="ftbBrowseBtn"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="text"> - <string notr="true">...</string> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QToolButton" name="ftbLauncherBrowseBtn"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="focusPolicy"> - <enum>Qt::TabFocus</enum> - </property> - <property name="text"> - <string notr="true">...</string> - </property> - </widget> - </item> - <item row="0" column="0" colspan="3"> - <widget class="QCheckBox" name="trackFtbBox"> - <property name="text"> - <string>Track FTB instances</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> <widget class="QGroupBox" name="foldersBox"> <property name="title"> <string>Folders</string> @@ -196,9 +127,6 @@ <item row="1" column="1"> <widget class="QLineEdit" name="modsDirTextBox"/> </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="lwjglDirTextBox"/> - </item> <item row="1" column="2"> <widget class="QToolButton" name="modsDirBrowseBtn"> <property name="text"> @@ -206,27 +134,10 @@ </property> </widget> </item> - <item row="2" column="0"> - <widget class="QLabel" name="labelLWJGLDir"> - <property name="text"> - <string notr="true">LW&JGL:</string> - </property> - <property name="buddy"> - <cstring>lwjglDirTextBox</cstring> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QToolButton" name="lwjglDirBrowseBtn"> - <property name="text"> - <string notr="true">...</string> - </property> - </widget> - </item> - <item row="3" column="1"> + <item row="2" column="1"> <widget class="QLineEdit" name="iconsDirTextBox"/> </item> - <item row="3" column="0"> + <item row="2" column="0"> <widget class="QLabel" name="labelIconsDir"> <property name="text"> <string>&Icons:</string> @@ -236,7 +147,7 @@ </property> </widget> </item> - <item row="3" column="2"> + <item row="2" column="2"> <widget class="QToolButton" name="iconsDirBrowseBtn"> <property name="text"> <string notr="true">...</string> @@ -393,6 +304,11 @@ </item> <item> <property name="text"> + <string notr="true">Flat</string> + </property> + </item> + <item> + <property name="text"> <string>Custom</string> </property> </item> @@ -645,17 +561,10 @@ <tabstop>tabWidget</tabstop> <tabstop>autoUpdateCheckBox</tabstop> <tabstop>updateChannelComboBox</tabstop> - <tabstop>trackFtbBox</tabstop> - <tabstop>ftbLauncherBox</tabstop> - <tabstop>ftbLauncherBrowseBtn</tabstop> - <tabstop>ftbBox</tabstop> - <tabstop>ftbBrowseBtn</tabstop> <tabstop>instDirTextBox</tabstop> <tabstop>instDirBrowseBtn</tabstop> <tabstop>modsDirTextBox</tabstop> <tabstop>modsDirBrowseBtn</tabstop> - <tabstop>lwjglDirTextBox</tabstop> - <tabstop>lwjglDirBrowseBtn</tabstop> <tabstop>iconsDirTextBox</tabstop> <tabstop>iconsDirBrowseBtn</tabstop> <tabstop>resetNotificationsBtn</tabstop> diff --git a/application/pages/global/PackagesPage.cpp b/application/pages/global/PackagesPage.cpp index e15ddbab..5fd4934c 100644 --- a/application/pages/global/PackagesPage.cpp +++ b/application/pages/global/PackagesPage.cpp @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 MultiMC Contributors +/* Copyright 2015-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,10 +38,17 @@ static QString formatRequires(const VersionPtr &version) auto iter = reqs.begin(); while (iter != reqs.end()) { - auto &uid = iter.key(); - auto &version = iter.value(); + auto &uid = iter->uid; + auto &version = iter->equalsVersion; const QString readable = ENV.metadataIndex()->hasUid(uid) ? ENV.metadataIndex()->get(uid)->humanReadable() : uid; - lines.append(QString("%1 (%2)").arg(readable, version)); + if(!version.isEmpty()) + { + lines.append(QString("%1 (%2)").arg(readable, version)); + } + else + { + lines.append(QString("%1").arg(readable)); + } iter++; } return lines.join('\n'); @@ -95,7 +102,7 @@ QIcon PackagesPage::icon() const void PackagesPage::on_refreshIndexBtn_clicked() { - ENV.metadataIndex()->load(); + ENV.metadataIndex()->load(Net::Mode::Online); } void PackagesPage::on_refreshFileBtn_clicked() { @@ -104,7 +111,7 @@ void PackagesPage::on_refreshFileBtn_clicked() { return; } - list->load(); + list->load(Net::Mode::Online); } void PackagesPage::on_refreshVersionBtn_clicked() { @@ -113,7 +120,7 @@ void PackagesPage::on_refreshVersionBtn_clicked() { return; } - version->load(); + version->load(Net::Mode::Online); } void PackagesPage::on_fileSearchEdit_textChanged(const QString &search) @@ -156,7 +163,7 @@ void PackagesPage::updateCurrentVersionList(const QModelIndex &index) ui->fileName->setText(list->name()); m_versionProxy->setSourceModel(list.get()); ui->refreshFileBtn->setText(tr("Refresh %1").arg(list->humanReadable())); - list->load(); + list->load(Net::Mode::Offline); } else { @@ -213,5 +220,5 @@ void PackagesPage::updateVersion() void PackagesPage::opened() { - ENV.metadataIndex()->load(); + ENV.metadataIndex()->load(Net::Mode::Offline); } diff --git a/application/pages/global/PackagesPage.h b/application/pages/global/PackagesPage.h index 80c2886d..2afbcf8e 100644 --- a/application/pages/global/PackagesPage.h +++ b/application/pages/global/PackagesPage.h @@ -1,4 +1,4 @@ -/* Copyright 2015-2017 MultiMC Contributors +/* Copyright 2015-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/application/pages/global/PasteEEPage.cpp b/application/pages/global/PasteEEPage.cpp index 2ceb725f..3d4e3a88 100644 --- a/application/pages/global/PasteEEPage.cpp +++ b/application/pages/global/PasteEEPage.cpp @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,11 +43,7 @@ void PasteEEPage::loadSettings() { auto s = MMC->settings(); QString keyToUse = s->get("PasteEEAPIKey").toString(); - if(keyToUse == "public") - { - ui->publicButton->setChecked(true); - } - else if(keyToUse == "multimc") + if(keyToUse == "multimc") { ui->multimcButton->setChecked(true); } @@ -65,8 +61,6 @@ void PasteEEPage::applySettings() QString pasteKeyToUse; if (ui->customButton->isChecked()) pasteKeyToUse = ui->customAPIkeyEdit->text(); - else if (ui->publicButton->isChecked()) - pasteKeyToUse = "public"; else { pasteKeyToUse = "multimc"; diff --git a/application/pages/global/PasteEEPage.h b/application/pages/global/PasteEEPage.h index 2bd5f2f2..1b152577 100644 --- a/application/pages/global/PasteEEPage.h +++ b/application/pages/global/PasteEEPage.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/application/pages/global/PasteEEPage.ui b/application/pages/global/PasteEEPage.ui index 689c421f..10883781 100644 --- a/application/pages/global/PasteEEPage.ui +++ b/application/pages/global/PasteEEPage.ui @@ -40,16 +40,6 @@ </property> <layout class="QVBoxLayout" name="verticalLayout_10"> <item> - <widget class="QRadioButton" name="publicButton"> - <property name="text"> - <string>No key - &2MB upload limit</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">pasteButtonGroup</string> - </attribute> - </widget> - </item> - <item> <widget class="QRadioButton" name="multimcButton"> <property name="text"> <string>MultiMC key - 12MB &upload limit</string> @@ -89,7 +79,7 @@ <item> <widget class="QLabel" name="label"> <property name="text"> - <string><html><head/><body><p><a href="https://paste.ee"><span style=" text-decoration: underline; color:#2980b9;">paste.ee</span></a> is used by MultiMC for log uploads. If you have a <a href="https://paste.ee"><span style=" text-decoration: underline; color:#2980b9;">paste.ee</span></a> account, you can add your API key here and have your uploaded logs paired with your account.</p></body></html></string> + <string><html><head/><body><p><a href="https://paste.ee">paste.ee</a> is used by MultiMC for log uploads. If you have a <a href="https://paste.ee">paste.ee</a> account, you can add your API key here and have your uploaded logs paired with your account.</p></body></html></string> </property> <property name="textFormat"> <enum>Qt::RichText</enum> @@ -97,6 +87,9 @@ <property name="wordWrap"> <bool>true</bool> </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> </widget> </item> </layout> @@ -123,7 +116,6 @@ </widget> <tabstops> <tabstop>tabWidget</tabstop> - <tabstop>publicButton</tabstop> <tabstop>multimcButton</tabstop> <tabstop>customButton</tabstop> <tabstop>customAPIkeyEdit</tabstop> diff --git a/application/pages/global/ProxyPage.cpp b/application/pages/global/ProxyPage.cpp index a68963ca..1e75bab1 100644 --- a/application/pages/global/ProxyPage.cpp +++ b/application/pages/global/ProxyPage.cpp @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/application/pages/global/ProxyPage.h b/application/pages/global/ProxyPage.h index 1ed53808..565c2857 100644 --- a/application/pages/global/ProxyPage.h +++ b/application/pages/global/ProxyPage.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 MultiMC Contributors +/* Copyright 2013-2018 MultiMC Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. |