diff options
Diffstat (limited to 'gui')
48 files changed, 2597 insertions, 2379 deletions
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 5ba05b2a..b8f42dc4 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -56,9 +56,7 @@ #include "gui/dialogs/VersionSelectDialog.h" #include "gui/dialogs/CustomMessageBox.h" #include "gui/dialogs/LwjglSelectDialog.h" -#include "gui/dialogs/InstanceSettings.h" #include "gui/dialogs/IconPickerDialog.h" -#include "gui/dialogs/EditNotesDialog.h" #include "gui/dialogs/CopyInstanceDialog.h" #include "gui/dialogs/AccountListDialog.h" #include "gui/dialogs/AccountSelectDialog.h" @@ -68,12 +66,13 @@ #include "dialogs/ScreenshotDialog.h" #include "gui/ConsoleWindow.h" +#include "pagedialog/PageDialog.h" -#include "logic/lists/InstanceList.h" -#include "logic/lists/MinecraftVersionList.h" -#include "logic/lists/LwjglVersionList.h" +#include "logic/InstanceList.h" +#include "logic/minecraft/MinecraftVersionList.h" +#include "logic/LwjglVersionList.h" #include "logic/icons/IconList.h" -#include "logic/lists/JavaVersionList.h" +#include "logic/java/JavaVersionList.h" #include "logic/auth/flows/AuthenticateTask.h" #include "logic/auth/flows/RefreshTask.h" @@ -91,7 +90,7 @@ #include "logic/InstanceFactory.h" #include "logic/MinecraftProcess.h" #include "logic/OneSixUpdate.h" -#include "logic/JavaUtils.h" +#include "logic/java/JavaUtils.h" #include "logic/NagUtils.h" #include "logic/SkinUtils.h" @@ -870,17 +869,14 @@ void MainWindow::updateInstanceToolIcon(QString new_icon) void MainWindow::setSelectedInstanceById(const QString &id) { - QModelIndex selectionIndex = proxymodel->index(0, 0); - if (!id.isNull()) + if (id.isNull()) + return; + const QModelIndex index = MMC->instances()->getInstanceIndexById(id); + if (index.isValid()) { - const QModelIndex index = MMC->instances()->getInstanceIndexById(id); - if (index.isValid()) - { - selectionIndex = proxymodel->mapFromSource(index); - } + QModelIndex selectionIndex = proxymodel->mapFromSource(index); + view->selectionModel()->setCurrentIndex(selectionIndex, QItemSelectionModel::ClearAndSelect); } - view->selectionModel()->setCurrentIndex(selectionIndex, - QItemSelectionModel::ClearAndSelect); } void MainWindow::on_actionChangeInstGroup_triggered() @@ -944,6 +940,31 @@ void MainWindow::on_actionSettings_triggered() updateToolsMenu(); } +template <typename T> +void ShowPageDialog(T raw_provider, QWidget * parent, QString open_page = QString()) +{ + auto provider = std::dynamic_pointer_cast<BasePageProvider>(raw_provider); + if(!provider) + return; + PageDialog dlg(provider, open_page, parent); + dlg.exec(); +} + +void MainWindow::on_actionInstanceSettings_triggered() +{ + ShowPageDialog(m_selectedInstance, this, "settings"); +} + +void MainWindow::on_actionEditInstNotes_triggered() +{ + ShowPageDialog(m_selectedInstance, this, "notes"); +} + +void MainWindow::on_actionEditInstance_triggered() +{ + ShowPageDialog(m_selectedInstance, this); +} + void MainWindow::on_actionManageAccounts_triggered() { AccountListDialog dialog(this); @@ -1032,17 +1053,6 @@ void MainWindow::on_actionViewSelectedInstFolder_triggered() } } -void MainWindow::on_actionEditInstMods_triggered() -{ - if (m_selectedInstance) - { - auto dialog = m_selectedInstance->createModEditDialog(this); - if (dialog) - dialog->exec(); - dialog->deleteLater(); - } -} - void MainWindow::closeEvent(QCloseEvent *event) { // Save the window state and geometry. @@ -1339,119 +1349,26 @@ void MainWindow::startTask(Task *task) task->start(); } -// Create A Desktop Shortcut -void MainWindow::on_actionMakeDesktopShortcut_triggered() -{ - QString name("Test"); - name = QInputDialog::getText(this, tr("MultiMC Shortcut"), tr("Enter a Shortcut Name."), - QLineEdit::Normal, name); - - Util::createShortCut(Util::getDesktopDir(), QApplication::instance()->applicationFilePath(), - QStringList() << "-dl" << QDir::currentPath() << "test", name, - "application-x-octet-stream"); - - CustomMessageBox::selectable( - this, tr("Not useful"), - tr("A Dummy Shortcut was created. it will not do anything productive"), - QMessageBox::Warning)->show(); -} - // BrowserDialog void MainWindow::openWebPage(QUrl url) { QDesktopServices::openUrl(url); } -void MainWindow::on_actionChangeInstMCVersion_triggered() +void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &previous) { - if (view->selectionModel()->selectedIndexes().count() < 1) - return; - - VersionSelectDialog vselect(m_selectedInstance->versionList().get(), - tr("Change Minecraft version"), this); - vselect.setFuzzyFilter(1, "*OneSix*"); - if (!vselect.exec() || !vselect.selectedVersion()) - return; - - if (!MMC->accounts()->anyAccountIsValid()) + if(!current.isValid()) { - CustomMessageBox::selectable( - this, tr("Error"), - tr("MultiMC cannot download Minecraft or update instances unless you have at least " - "one account added.\nPlease add your Mojang or Minecraft account."), - QMessageBox::Warning)->show(); + MMC->settings()->set("SelectedInstance", QString()); + selectionBad(); return; } - - if (m_selectedInstance->versionIsCustom()) - { - 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_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor()); - - auto updateTask = m_selectedInstance->doUpdate(); - if (!updateTask) - { - return; - } - ProgressDialog tDialog(this); - connect(updateTask.get(), SIGNAL(failed(QString)), SLOT(onGameUpdateError(QString))); - tDialog.exec(updateTask.get()); -} - -void MainWindow::on_actionChangeInstLWJGLVersion_triggered() -{ - if (!m_selectedInstance) - return; - - LWJGLSelectDialog lselect(this); - lselect.exec(); - if (lselect.result() == QDialog::Accepted) - { - auto ptr = std::dynamic_pointer_cast<LegacyInstance>(m_selectedInstance); - if(ptr) - ptr->setLWJGLVersion(lselect.selectedVersion()); - } -} - -void MainWindow::on_actionInstanceSettings_triggered() -{ - if (view->selectionModel()->selectedIndexes().count() < 1) - return; - - InstanceSettings settings(&m_selectedInstance->settings(), this); - settings.setWindowTitle(tr("Instance settings")); - settings.exec(); -} - -void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &previous) -{ - if(!current.isValid()) - { - selectionBad(); - MMC->settings()->set("SelectedInstance", QString()); - return; - } - QString id = current.data(InstanceList::InstanceIDRole).toString(); - m_selectedInstance = MMC->instances()->getInstanceById(id); + QString id = current.data(InstanceList::InstanceIDRole).toString(); + m_selectedInstance = MMC->instances()->getInstanceById(id); if ( m_selectedInstance ) { ui->instanceToolBar->setEnabled(m_selectedInstance->canLaunch()); renameButton->setText(m_selectedInstance->name()); - ui->actionChangeInstLWJGLVersion->setEnabled( - m_selectedInstance->menuActionEnabled("actionChangeInstLWJGLVersion")); - ui->actionEditInstMods->setEnabled( - m_selectedInstance->menuActionEnabled("actionEditInstMods")); - ui->actionChangeInstMCVersion->setEnabled( - m_selectedInstance->menuActionEnabled("actionChangeInstMCVersion")); m_statusLeft->setText(m_selectedInstance->getStatusbarDescription()); updateInstanceToolIcon(m_selectedInstance->iconKey()); @@ -1461,9 +1378,9 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex & } else { - selectionBad(); - MMC->settings()->set("SelectedInstance", QString()); - return; + MMC->settings()->set("SelectedInstance", QString()); + selectionBad(); + return; } } @@ -1481,20 +1398,6 @@ void MainWindow::selectionBad() setSelectedInstanceById(MMC->settings()->get("SelectedInstance").toString()); } -void MainWindow::on_actionEditInstNotes_triggered() -{ - if (!m_selectedInstance) - return; - - EditNotesDialog noteedit(m_selectedInstance->notes(), m_selectedInstance->name(), this); - noteedit.exec(); - if (noteedit.result() == QDialog::Accepted) - { - - m_selectedInstance->setNotes(noteedit.getText()); - } -} - void MainWindow::instanceEnded() { this->show(); diff --git a/gui/MainWindow.h b/gui/MainWindow.h index 69cf11b0..182e9c0c 100644 --- a/gui/MainWindow.h +++ b/gui/MainWindow.h @@ -19,11 +19,10 @@ #include <QProcess> #include <QTimer> -#include "logic/lists/InstanceList.h" +#include "logic/InstanceList.h" #include "logic/BaseInstance.h" - #include "logic/auth/MojangAccount.h" -#include <logic/net/NetJob.h> +#include "logic/net/NetJob.h" class QToolButton; class LabeledToolButton; @@ -81,6 +80,8 @@ slots: void on_actionSettings_triggered(); + void on_actionInstanceSettings_triggered(); + void on_actionManageAccounts_triggered(); void on_actionReportBug_triggered(); @@ -103,11 +104,7 @@ slots: void on_actionRenameInstance_triggered(); - void on_actionMakeDesktopShortcut_triggered(); - - void on_actionChangeInstMCVersion_triggered(); - - void on_actionEditInstMods_triggered(); + void on_actionEditInstance_triggered(); void on_actionEditInstNotes_triggered(); @@ -135,12 +132,8 @@ slots: void taskStart(); void taskEnd(); - void on_actionChangeInstLWJGLVersion_triggered(); - void instanceEnded(); - void on_actionInstanceSettings_triggered(); - // called when an icon is changed in the icon model. void iconUpdated(QString); diff --git a/gui/MainWindow.ui b/gui/MainWindow.ui index 1d7fbec9..c79dc948 100644 --- a/gui/MainWindow.ui +++ b/gui/MainWindow.ui @@ -74,7 +74,7 @@ <addaction name="actionReportBug"/> <addaction name="actionAbout"/> <addaction name="separator"/> - <addaction name="actionPatreon"/> + <addaction name="actionPatreon"/> <addaction name="actionCAT"/> </widget> <widget class="QStatusBar" name="statusBar"/> @@ -115,10 +115,8 @@ <addaction name="separator"/> <addaction name="actionScreenshots"/> <addaction name="separator"/> + <addaction name="actionEditInstance"/> <addaction name="actionInstanceSettings"/> - <addaction name="actionChangeInstMCVersion"/> - <addaction name="actionChangeInstLWJGLVersion"/> - <addaction name="actionEditInstMods"/> <addaction name="actionViewSelectedInstFolder"/> <addaction name="actionConfig_Folder"/> <addaction name="separator"/> @@ -284,7 +282,7 @@ <property name="statusTip"> <string>Open the MultiMC Patreon page.</string> </property> - </action> + </action> <action name="actionMoreNews"> <property name="icon"> <iconset theme="news"> @@ -388,82 +386,18 @@ <string>Edit the notes for the selected instance.</string> </property> </action> - <action name="actionInstanceSettings"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="text"> - <string>Settings</string> - </property> - <property name="toolTip"> - <string>Change settings for the selected instance.</string> - </property> - <property name="statusTip"> - <string>Change settings for the selected instance.</string> - </property> - </action> - <action name="actionMakeDesktopShortcut"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Make Shortcut</string> - </property> - <property name="toolTip"> - <string>Make a shortcut on the desktop for the selected instance.</string> - </property> - <property name="statusTip"> - <string>Make a shortcut on the desktop for the selected instance.</string> - </property> - </action> - <action name="actionManageInstSaves"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Manage Saves</string> - </property> - <property name="toolTip"> - <string>Manage saves for the selected instance.</string> - </property> - <property name="statusTip"> - <string>Manage saves for the selected instance.</string> - </property> - </action> - <action name="actionEditInstMods"> + <action name="actionEditInstance"> <property name="text"> <string>Edit Mods</string> </property> - <property name="toolTip"> - <string>Edit the mods for the selected instance.</string> - </property> - <property name="statusTip"> - <string>Edit the mods for the selected instance.</string> - </property> - </action> - <action name="actionChangeInstMCVersion"> - <property name="text"> - <string>Change Version</string> - </property> - <property name="toolTip"> - <string>Change the selected instance's Minecraft version.</string> - </property> - <property name="statusTip"> - <string>Change the selected instance's Minecraft version.</string> - </property> - </action> - <action name="actionChangeInstLWJGLVersion"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Change LWJGL</string> + <property name="iconText"> + <string>Edit Instance</string> </property> <property name="toolTip"> - <string>Change the version of LWJGL for the selected instance to use.</string> + <string>Change the instance settings, mods and versions.</string> </property> <property name="statusTip"> - <string>Change the version of LWJGL for the selected instance to use.</string> + <string>Change the instance settings, mods and versions.</string> </property> </action> <action name="actionViewSelectedInstFolder"> @@ -555,6 +489,14 @@ <string><html><head/><body><p>View and upload screenshots for this instance</p></body></html></string> </property> </action> + <action name="actionInstanceSettings"> + <property name="text"> + <string>Instance Settings</string> + </property> + <property name="toolTip"> + <string>Change the settings specific to the instance</string> + </property> + </action> </widget> <layoutdefault spacing="6" margin="11"/> <resources> diff --git a/gui/dialogs/CopyInstanceDialog.cpp b/gui/dialogs/CopyInstanceDialog.cpp index 71429367..188cf274 100644 --- a/gui/dialogs/CopyInstanceDialog.cpp +++ b/gui/dialogs/CopyInstanceDialog.cpp @@ -28,7 +28,6 @@ #include "logic/InstanceFactory.h" #include "logic/BaseVersion.h" #include "logic/icons/IconList.h" -#include "logic/lists/MinecraftVersionList.h" #include "logic/tasks/Task.h" #include "logic/BaseInstance.h" diff --git a/gui/dialogs/EditNotesDialog.cpp b/gui/dialogs/EditNotesDialog.cpp deleted file mode 100644 index f2aa029f..00000000 --- a/gui/dialogs/EditNotesDialog.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright 2013 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "EditNotesDialog.h" -#include "ui_EditNotesDialog.h" -#include "gui/Platform.h" - -#include <QIcon> -#include <QApplication> - -EditNotesDialog::EditNotesDialog(QString notes, QString name, QWidget *parent) - : QDialog(parent), ui(new Ui::EditNotesDialog), m_instance_name(name), - m_instance_notes(notes) -{ - MultiMCPlatform::fixWM_CLASS(this); - ui->setupUi(this); - ui->noteEditor->setText(notes); - setWindowTitle(tr("Edit notes of %1").arg(m_instance_name)); - // connect(ui->closeButton, SIGNAL(clicked()), SLOT(close())); -} - -EditNotesDialog::~EditNotesDialog() -{ - delete ui; -} - -QString EditNotesDialog::getText() -{ - QString test = ui->noteEditor->toPlainText(); - return test; -} diff --git a/gui/dialogs/EditNotesDialog.ui b/gui/dialogs/EditNotesDialog.ui deleted file mode 100644 index 487dfb84..00000000 --- a/gui/dialogs/EditNotesDialog.ui +++ /dev/null @@ -1,77 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>EditNotesDialog</class> - <widget class="QDialog" name="EditNotesDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>459</width> - <height>399</height> - </rect> - </property> - <property name="windowTitle"> - <string>Edit Notes</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QTextEdit" name="noteEditor"> - <property name="verticalScrollBarPolicy"> - <enum>Qt::ScrollBarAlwaysOn</enum> - </property> - <property name="acceptRichText"> - <bool>false</bool> - </property> - <property name="textInteractionFlags"> - <set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>EditNotesDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>EditNotesDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/gui/dialogs/InstanceSettings.cpp b/gui/dialogs/InstanceSettings.cpp deleted file mode 100644 index edb4a921..00000000 --- a/gui/dialogs/InstanceSettings.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/* Copyright 2013 MultiMC Contributors - * - * Authors: Andrew Okin - * Peterix - * Orochimarufan <orochimarufan.x3@gmail.com> - * - * 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 "MultiMC.h" -#include "InstanceSettings.h" -#include "ui_InstanceSettings.h" -#include "gui/Platform.h" -#include "gui/dialogs/VersionSelectDialog.h" - -#include "logic/JavaUtils.h" -#include "logic/NagUtils.h" -#include "logic/lists/JavaVersionList.h" -#include "logic/JavaChecker.h" - -#include <QFileDialog> -#include <QMessageBox> - -InstanceSettings::InstanceSettings(SettingsObject *obj, QWidget *parent) - : QDialog(parent), ui(new Ui::InstanceSettings), m_obj(obj) -{ - MultiMCPlatform |
