From bb7e8985f6d189de0acac6a1c3033cb16378c1fb Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Mon, 4 Nov 2013 02:53:05 +0100 Subject: Reformat and (slightly) decruft all the things. --- gui/ConsoleWindow.cpp | 135 +++++ gui/ConsoleWindow.h | 79 +++ gui/ConsoleWindow.ui | 85 ++++ gui/CopyInstanceDialog.cpp | 84 ---- gui/CopyInstanceDialog.h | 50 -- gui/CopyInstanceDialog.ui | 134 ----- gui/CustomMessageBox.cpp | 19 - gui/CustomMessageBox.h | 11 - gui/EditNotesDialog.cpp | 29 -- gui/EditNotesDialog.h | 20 - gui/EditNotesDialog.ui | 77 --- gui/IconPickerDialog.cpp | 147 ------ gui/IconPickerDialog.h | 29 -- gui/IconPickerDialog.ui | 67 --- gui/LabeledToolButton.cpp | 72 --- gui/LabeledToolButton.h | 22 - gui/LegacyModEditDialog.cpp | 393 --------------- gui/LegacyModEditDialog.h | 78 --- gui/LegacyModEditDialog.ui | 321 ------------ gui/MCModInfoFrame.cpp | 109 ---- gui/MCModInfoFrame.h | 46 -- gui/MCModInfoFrame.ui | 68 --- gui/MainWindow.cpp | 976 ++++++++++++++++++++++++++++++++++++ gui/MainWindow.h | 167 ++++++ gui/MainWindow.ui | 474 +++++++++++++++++ gui/ModEditDialogCommon.cpp | 41 -- gui/ModEditDialogCommon.h | 7 - gui/ModListView.cpp | 36 -- gui/ModListView.h | 13 - gui/OneSixModEditDialog.cpp | 317 ------------ gui/OneSixModEditDialog.h | 67 --- gui/OneSixModEditDialog.ui | 319 ------------ gui/Platform.h | 32 ++ gui/Platform_Other.cpp | 27 + gui/Platform_X11.cpp | 62 +++ gui/ProgressDialog.cpp | 110 ---- gui/ProgressDialog.h | 62 --- gui/ProgressDialog.ui | 53 -- gui/aboutdialog.cpp | 24 - gui/aboutdialog.h | 22 - gui/aboutdialog.ui | 315 ------------ gui/consolewindow.cpp | 120 ----- gui/consolewindow.h | 63 --- gui/consolewindow.ui | 85 ---- gui/dialogs/AboutDialog.cpp | 37 ++ gui/dialogs/AboutDialog.h | 35 ++ gui/dialogs/AboutDialog.ui | 316 ++++++++++++ gui/dialogs/CopyInstanceDialog.cpp | 84 ++++ gui/dialogs/CopyInstanceDialog.h | 50 ++ gui/dialogs/CopyInstanceDialog.ui | 134 +++++ gui/dialogs/CustomMessageBox.cpp | 34 ++ gui/dialogs/CustomMessageBox.h | 26 + gui/dialogs/EditNotesDialog.cpp | 42 ++ gui/dialogs/EditNotesDialog.h | 38 ++ gui/dialogs/EditNotesDialog.ui | 77 +++ gui/dialogs/IconPickerDialog.cpp | 156 ++++++ gui/dialogs/IconPickerDialog.h | 48 ++ gui/dialogs/IconPickerDialog.ui | 67 +++ gui/dialogs/InstanceSettings.cpp | 180 +++++++ gui/dialogs/InstanceSettings.h | 50 ++ gui/dialogs/InstanceSettings.ui | 422 ++++++++++++++++ gui/dialogs/LegacyModEditDialog.cpp | 393 +++++++++++++++ gui/dialogs/LegacyModEditDialog.h | 78 +++ gui/dialogs/LegacyModEditDialog.ui | 321 ++++++++++++ gui/dialogs/LoginDialog.cpp | 252 ++++++++++ gui/dialogs/LoginDialog.h | 61 +++ gui/dialogs/LoginDialog.ui | 186 +++++++ gui/dialogs/LwjglSelectDialog.cpp | 72 +++ gui/dialogs/LwjglSelectDialog.h | 44 ++ gui/dialogs/LwjglSelectDialog.ui | 85 ++++ gui/dialogs/ModEditDialogCommon.cpp | 57 +++ gui/dialogs/ModEditDialogCommon.h | 22 + gui/dialogs/NewInstanceDialog.cpp | 125 +++++ gui/dialogs/NewInstanceDialog.h | 55 ++ gui/dialogs/NewInstanceDialog.ui | 179 +++++++ gui/dialogs/OneSixModEditDialog.cpp | 322 ++++++++++++ gui/dialogs/OneSixModEditDialog.h | 67 +++ gui/dialogs/OneSixModEditDialog.ui | 319 ++++++++++++ gui/dialogs/ProgressDialog.cpp | 107 ++++ gui/dialogs/ProgressDialog.h | 60 +++ gui/dialogs/ProgressDialog.ui | 53 ++ gui/dialogs/SettingsDialog.cpp | 260 ++++++++++ gui/dialogs/SettingsDialog.h | 63 +++ gui/dialogs/SettingsDialog.ui | 569 +++++++++++++++++++++ gui/dialogs/VersionSelectDialog.cpp | 111 ++++ gui/dialogs/VersionSelectDialog.h | 61 +++ gui/dialogs/VersionSelectDialog.ui | 103 ++++ gui/instancedelegate.cpp | 231 --------- gui/instancedelegate.h | 12 - gui/instancesettings.cpp | 189 ------- gui/instancesettings.h | 35 -- gui/instancesettings.ui | 422 ---------------- gui/logindialog.cpp | 248 --------- gui/logindialog.h | 57 --- gui/logindialog.ui | 185 ------- gui/lwjglselectdialog.cpp | 72 --- gui/lwjglselectdialog.h | 46 -- gui/lwjglselectdialog.ui | 85 ---- gui/mainwindow.cpp | 974 ----------------------------------- gui/mainwindow.h | 170 ------- gui/mainwindow.ui | 474 ----------------- gui/newinstancedialog.cpp | 125 ----- gui/newinstancedialog.h | 55 -- gui/newinstancedialog.ui | 179 ------- gui/newmodeditwindow.ui | 159 ------ gui/platform.h | 35 -- gui/platform_other.cpp | 27 - gui/platform_x11.cpp | 62 --- gui/settingsdialog.cpp | 256 ---------- gui/settingsdialog.h | 64 --- gui/settingsdialog.ui | 569 --------------------- gui/versionselectdialog.cpp | 110 ---- gui/versionselectdialog.h | 61 --- gui/versionselectdialog.ui | 103 ---- gui/widgets/InstanceDelegate.cpp | 246 +++++++++ gui/widgets/InstanceDelegate.h | 27 + gui/widgets/LabeledToolButton.cpp | 86 ++++ gui/widgets/LabeledToolButton.h | 37 ++ gui/widgets/MCModInfoFrame.cpp | 111 ++++ gui/widgets/MCModInfoFrame.h | 46 ++ gui/widgets/MCModInfoFrame.ui | 68 +++ gui/widgets/ModListView.cpp | 51 ++ gui/widgets/ModListView.h | 27 + 123 files changed, 8557 insertions(+), 8435 deletions(-) create mode 100644 gui/ConsoleWindow.cpp create mode 100644 gui/ConsoleWindow.h create mode 100644 gui/ConsoleWindow.ui delete mode 100644 gui/CopyInstanceDialog.cpp delete mode 100644 gui/CopyInstanceDialog.h delete mode 100644 gui/CopyInstanceDialog.ui delete mode 100644 gui/CustomMessageBox.cpp delete mode 100644 gui/CustomMessageBox.h delete mode 100644 gui/EditNotesDialog.cpp delete mode 100644 gui/EditNotesDialog.h delete mode 100644 gui/EditNotesDialog.ui delete mode 100644 gui/IconPickerDialog.cpp delete mode 100644 gui/IconPickerDialog.h delete mode 100644 gui/IconPickerDialog.ui delete mode 100644 gui/LabeledToolButton.cpp delete mode 100644 gui/LabeledToolButton.h delete mode 100644 gui/LegacyModEditDialog.cpp delete mode 100644 gui/LegacyModEditDialog.h delete mode 100644 gui/LegacyModEditDialog.ui delete mode 100644 gui/MCModInfoFrame.cpp delete mode 100644 gui/MCModInfoFrame.h delete mode 100644 gui/MCModInfoFrame.ui create mode 100644 gui/MainWindow.cpp create mode 100644 gui/MainWindow.h create mode 100644 gui/MainWindow.ui delete mode 100644 gui/ModEditDialogCommon.cpp delete mode 100644 gui/ModEditDialogCommon.h delete mode 100644 gui/ModListView.cpp delete mode 100644 gui/ModListView.h delete mode 100644 gui/OneSixModEditDialog.cpp delete mode 100644 gui/OneSixModEditDialog.h delete mode 100644 gui/OneSixModEditDialog.ui create mode 100644 gui/Platform.h create mode 100644 gui/Platform_Other.cpp create mode 100644 gui/Platform_X11.cpp delete mode 100644 gui/ProgressDialog.cpp delete mode 100644 gui/ProgressDialog.h delete mode 100644 gui/ProgressDialog.ui delete mode 100644 gui/aboutdialog.cpp delete mode 100644 gui/aboutdialog.h delete mode 100644 gui/aboutdialog.ui delete mode 100644 gui/consolewindow.cpp delete mode 100644 gui/consolewindow.h delete mode 100644 gui/consolewindow.ui create mode 100644 gui/dialogs/AboutDialog.cpp create mode 100644 gui/dialogs/AboutDialog.h create mode 100644 gui/dialogs/AboutDialog.ui create mode 100644 gui/dialogs/CopyInstanceDialog.cpp create mode 100644 gui/dialogs/CopyInstanceDialog.h create mode 100644 gui/dialogs/CopyInstanceDialog.ui create mode 100644 gui/dialogs/CustomMessageBox.cpp create mode 100644 gui/dialogs/CustomMessageBox.h create mode 100644 gui/dialogs/EditNotesDialog.cpp create mode 100644 gui/dialogs/EditNotesDialog.h create mode 100644 gui/dialogs/EditNotesDialog.ui create mode 100644 gui/dialogs/IconPickerDialog.cpp create mode 100644 gui/dialogs/IconPickerDialog.h create mode 100644 gui/dialogs/IconPickerDialog.ui create mode 100644 gui/dialogs/InstanceSettings.cpp create mode 100644 gui/dialogs/InstanceSettings.h create mode 100644 gui/dialogs/InstanceSettings.ui create mode 100644 gui/dialogs/LegacyModEditDialog.cpp create mode 100644 gui/dialogs/LegacyModEditDialog.h create mode 100644 gui/dialogs/LegacyModEditDialog.ui create mode 100644 gui/dialogs/LoginDialog.cpp create mode 100644 gui/dialogs/LoginDialog.h create mode 100644 gui/dialogs/LoginDialog.ui create mode 100644 gui/dialogs/LwjglSelectDialog.cpp create mode 100644 gui/dialogs/LwjglSelectDialog.h create mode 100644 gui/dialogs/LwjglSelectDialog.ui create mode 100644 gui/dialogs/ModEditDialogCommon.cpp create mode 100644 gui/dialogs/ModEditDialogCommon.h create mode 100644 gui/dialogs/NewInstanceDialog.cpp create mode 100644 gui/dialogs/NewInstanceDialog.h create mode 100644 gui/dialogs/NewInstanceDialog.ui create mode 100644 gui/dialogs/OneSixModEditDialog.cpp create mode 100644 gui/dialogs/OneSixModEditDialog.h create mode 100644 gui/dialogs/OneSixModEditDialog.ui create mode 100644 gui/dialogs/ProgressDialog.cpp create mode 100644 gui/dialogs/ProgressDialog.h create mode 100644 gui/dialogs/ProgressDialog.ui create mode 100644 gui/dialogs/SettingsDialog.cpp create mode 100644 gui/dialogs/SettingsDialog.h create mode 100644 gui/dialogs/SettingsDialog.ui create mode 100644 gui/dialogs/VersionSelectDialog.cpp create mode 100644 gui/dialogs/VersionSelectDialog.h create mode 100644 gui/dialogs/VersionSelectDialog.ui delete mode 100644 gui/instancedelegate.cpp delete mode 100644 gui/instancedelegate.h delete mode 100644 gui/instancesettings.cpp delete mode 100644 gui/instancesettings.h delete mode 100644 gui/instancesettings.ui delete mode 100644 gui/logindialog.cpp delete mode 100644 gui/logindialog.h delete mode 100644 gui/logindialog.ui delete mode 100644 gui/lwjglselectdialog.cpp delete mode 100644 gui/lwjglselectdialog.h delete mode 100644 gui/lwjglselectdialog.ui delete mode 100644 gui/mainwindow.cpp delete mode 100644 gui/mainwindow.h delete mode 100644 gui/mainwindow.ui delete mode 100644 gui/newinstancedialog.cpp delete mode 100644 gui/newinstancedialog.h delete mode 100644 gui/newinstancedialog.ui delete mode 100644 gui/newmodeditwindow.ui delete mode 100644 gui/platform.h delete mode 100644 gui/platform_other.cpp delete mode 100644 gui/platform_x11.cpp delete mode 100644 gui/settingsdialog.cpp delete mode 100644 gui/settingsdialog.h delete mode 100644 gui/settingsdialog.ui delete mode 100644 gui/versionselectdialog.cpp delete mode 100644 gui/versionselectdialog.h delete mode 100644 gui/versionselectdialog.ui create mode 100644 gui/widgets/InstanceDelegate.cpp create mode 100644 gui/widgets/InstanceDelegate.h create mode 100644 gui/widgets/LabeledToolButton.cpp create mode 100644 gui/widgets/LabeledToolButton.h create mode 100644 gui/widgets/MCModInfoFrame.cpp create mode 100644 gui/widgets/MCModInfoFrame.h create mode 100644 gui/widgets/MCModInfoFrame.ui create mode 100644 gui/widgets/ModListView.cpp create mode 100644 gui/widgets/ModListView.h (limited to 'gui') diff --git a/gui/ConsoleWindow.cpp b/gui/ConsoleWindow.cpp new file mode 100644 index 00000000..ec25b9cf --- /dev/null +++ b/gui/ConsoleWindow.cpp @@ -0,0 +1,135 @@ +/* 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 "ConsoleWindow.h" +#include "ui_ConsoleWindow.h" + +#include +#include + +#include +#include + +ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) : + QDialog(parent), + ui(new Ui::ConsoleWindow), + m_mayclose(true), + proc(mcproc) +{ + MultiMCPlatform::fixWM_CLASS(this); + ui->setupUi(this); + this->setWindowFlags(Qt::Window); + connect(mcproc, SIGNAL(ended(BaseInstance*)), this, SLOT(onEnded(BaseInstance*))); +} + +ConsoleWindow::~ConsoleWindow() +{ + delete ui; +} + +void ConsoleWindow::writeColor(QString text, const char *color) +{ + // append a paragraph + if (color != nullptr) + ui->text->appendHtml(QString("%2").arg(color).arg(text)); + else + ui->text->appendPlainText(text); + // scroll down + QScrollBar *bar = ui->text->verticalScrollBar(); + bar->setValue(bar->maximum()); +} + +void ConsoleWindow::write(QString data, MessageLevel::Enum mode) +{ + if (data.endsWith('\n')) + data = data.left(data.length()-1); + QStringList paragraphs = data.split('\n'); + for(QString ¶graph : paragraphs) + { + paragraph = paragraph.trimmed(); + } + + QListIterator iter(paragraphs); + if (mode == MessageLevel::MultiMC) + while(iter.hasNext()) + writeColor(iter.next(), "blue"); + else if (mode == MessageLevel::Error) + while(iter.hasNext()) + writeColor(iter.next(), "red"); + else if (mode == MessageLevel::Warning) + while(iter.hasNext()) + writeColor(iter.next(), "orange"); + else if (mode == MessageLevel::Fatal) + while(iter.hasNext()) + writeColor(iter.next(), "pink"); + else if (mode == MessageLevel::Debug) + while(iter.hasNext()) + writeColor(iter.next(), "green"); + // TODO: implement other MessageLevels + else + while(iter.hasNext()) + writeColor(iter.next()); +} + +void ConsoleWindow::clear() +{ + ui->text->clear(); +} + +void ConsoleWindow::on_closeButton_clicked() +{ + close(); +} + +void ConsoleWindow::setMayClose(bool mayclose) +{ + m_mayclose = mayclose; + if (mayclose) + ui->closeButton->setEnabled(true); + else + ui->closeButton->setEnabled(false); +} + +void ConsoleWindow::closeEvent(QCloseEvent * event) +{ + if(!m_mayclose) + event->ignore(); + else + QDialog::closeEvent(event); +} + +void ConsoleWindow::on_btnKillMinecraft_clicked() +{ + ui->btnKillMinecraft->setEnabled(false); + auto response = CustomMessageBox::selectable(this, tr("Kill Minecraft?"), + tr("This can cause the instance to get corrupted and should only be used if Minecraft is frozen for some reason"), + QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)->exec(); + if (response == QMessageBox::Yes) + proc->killMinecraft(); + else + ui->btnKillMinecraft->setEnabled(true); +} + +void ConsoleWindow::onEnded(BaseInstance *instance) +{ + ui->btnKillMinecraft->setEnabled(false); + + // TODO: Might need an option to forcefully close, even on an error + if(instance->settings().get("AutoCloseConsole").toBool()) + { + // TODO: Check why this doesn't work + if (!proc->exitCode()) this->close(); + } +} diff --git a/gui/ConsoleWindow.h b/gui/ConsoleWindow.h new file mode 100644 index 00000000..0ed35554 --- /dev/null +++ b/gui/ConsoleWindow.h @@ -0,0 +1,79 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include "logic/MinecraftProcess.h" + +namespace Ui +{ +class ConsoleWindow; +} + +class ConsoleWindow : public QDialog +{ + Q_OBJECT + +public: + explicit ConsoleWindow(MinecraftProcess *proc, QWidget *parent = 0); + ~ConsoleWindow(); + + /** + * @brief specify if the window is allowed to close + * @param mayclose + * used to keep it alive while MC runs + */ + void setMayClose(bool mayclose); + +public +slots: + /** + * @brief write a string + * @param data the string + * @param mode the WriteMode + * lines have to be put through this as a whole! + */ + void write(QString data, MessageLevel::Enum level = MessageLevel::MultiMC); + + /** + * @brief write a colored paragraph + * @param data the string + * @param color the css color name + * this will only insert a single paragraph. + * \n are ignored. a real \n is always appended. + */ + void writeColor(QString data, const char *color = nullptr); + + /** + * @brief clear the text widget + */ + void clear(); + +private +slots: + void on_closeButton_clicked(); + void on_btnKillMinecraft_clicked(); + void onEnded(BaseInstance *instance); + +protected: + void closeEvent(QCloseEvent *); + +private: + Ui::ConsoleWindow *ui; + MinecraftProcess *proc; + bool m_mayclose; +}; + diff --git a/gui/ConsoleWindow.ui b/gui/ConsoleWindow.ui new file mode 100644 index 00000000..8dc80015 --- /dev/null +++ b/gui/ConsoleWindow.ui @@ -0,0 +1,85 @@ + + + ConsoleWindow + + + + 0 + 0 + 600 + 400 + + + + MultiMC Console + + + + 0 + + + 0 + + + 0 + + + + + + 10 + + + + false + + + true + + + + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + false + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Kill Minecraft + + + + + + + Close + + + + + + + + + + diff --git a/gui/CopyInstanceDialog.cpp b/gui/CopyInstanceDialog.cpp deleted file mode 100644 index 1e0b9e6c..00000000 --- a/gui/CopyInstanceDialog.cpp +++ /dev/null @@ -1,84 +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 -#include "CopyInstanceDialog.h" -#include "ui_CopyInstanceDialog.h" - -#include "logic/InstanceFactory.h" -#include "logic/BaseVersion.h" -#include "logic/lists/IconList.h" -#include "logic/lists/MinecraftVersionList.h" -#include "logic/tasks/Task.h" -#include - -#include "gui/platform.h" -#include "versionselectdialog.h" -#include "ProgressDialog.h" -#include "IconPickerDialog.h" - -#include -#include - -CopyInstanceDialog::CopyInstanceDialog(BaseInstance *original, QWidget *parent) - : m_original(original), QDialog(parent), ui(new Ui::CopyInstanceDialog) -{ - MultiMCPlatform::fixWM_CLASS(this); - ui->setupUi(this); - resize(minimumSizeHint()); - layout()->setSizeConstraint(QLayout::SetFixedSize); - - InstIconKey = original->iconKey(); - ui->iconButton->setIcon(MMC->icons()->getIcon(InstIconKey)); - ui->instNameTextBox->setText(original->name()); - ui->instNameTextBox->setFocus(); -} - -CopyInstanceDialog::~CopyInstanceDialog() -{ - delete ui; -} - -void CopyInstanceDialog::updateDialogState() -{ - ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!instName().isEmpty()); -} - -QString CopyInstanceDialog::instName() const -{ - return ui->instNameTextBox->text(); -} - -QString CopyInstanceDialog::iconKey() const -{ - return InstIconKey; -} - -void CopyInstanceDialog::on_iconButton_clicked() -{ - IconPickerDialog dlg(this); - dlg.exec(InstIconKey); - - if (dlg.result() == QDialog::Accepted) - { - InstIconKey = dlg.selectedIconKey; - ui->iconButton->setIcon(MMC->icons()->getIcon(InstIconKey)); - } -} - -void CopyInstanceDialog::on_instNameTextBox_textChanged(const QString &arg1) -{ - updateDialogState(); -} diff --git a/gui/CopyInstanceDialog.h b/gui/CopyInstanceDialog.h deleted file mode 100644 index 7ab366e2..00000000 --- a/gui/CopyInstanceDialog.h +++ /dev/null @@ -1,50 +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. - */ - -#pragma once - -#include -#include "logic/BaseVersion.h" - -class BaseInstance; - -namespace Ui -{ -class CopyInstanceDialog; -} - -class CopyInstanceDialog : public QDialog -{ - Q_OBJECT - -public: - explicit CopyInstanceDialog(BaseInstance *original, QWidget *parent = 0); - ~CopyInstanceDialog(); - - void updateDialogState(); - - QString instName() const; - QString iconKey() const; - -private -slots: - void on_iconButton_clicked(); - void on_instNameTextBox_textChanged(const QString &arg1); - -private: - Ui::CopyInstanceDialog *ui; - QString InstIconKey; - BaseInstance *m_original; -}; diff --git a/gui/CopyInstanceDialog.ui b/gui/CopyInstanceDialog.ui deleted file mode 100644 index 1327ce0b..00000000 --- a/gui/CopyInstanceDialog.ui +++ /dev/null @@ -1,134 +0,0 @@ - - - CopyInstanceDialog - - - Qt::ApplicationModal - - - - 0 - 0 - 345 - 205 - - - - Copy Instance - - - - :/icons/toolbar/copy:/icons/toolbar/copy - - - true - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - :/icons/instances/infinity:/icons/instances/infinity - - - - 80 - 80 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Name - - - - - - - Qt::Horizontal - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - - buttonBox - accepted() - CopyInstanceDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - CopyInstanceDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/gui/CustomMessageBox.cpp b/gui/CustomMessageBox.cpp deleted file mode 100644 index e55ebbbb..00000000 --- a/gui/CustomMessageBox.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "CustomMessageBox.h" - -namespace CustomMessageBox -{ - QMessageBox *selectable(QWidget *parent, const QString &title, const QString &text, - QMessageBox::Icon icon, QMessageBox::StandardButtons buttons, - QMessageBox::StandardButton defaultButton) - { - QMessageBox *messageBox = new QMessageBox(parent); - messageBox->setWindowTitle(title); - messageBox->setText(text); - messageBox->setStandardButtons(buttons); - messageBox->setDefaultButton(defaultButton); - messageBox->setTextInteractionFlags(Qt::TextSelectableByMouse); - messageBox->setIcon(icon); - - return messageBox; - } -} diff --git a/gui/CustomMessageBox.h b/gui/CustomMessageBox.h deleted file mode 100644 index 145651ec..00000000 --- a/gui/CustomMessageBox.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include - -namespace CustomMessageBox -{ - QMessageBox *selectable(QWidget *parent, const QString &title, const QString &text, - QMessageBox::Icon icon = QMessageBox::NoIcon, - QMessageBox::StandardButtons buttons = QMessageBox::Ok, - QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); -} diff --git a/gui/EditNotesDialog.cpp b/gui/EditNotesDialog.cpp deleted file mode 100644 index 535ca804..00000000 --- a/gui/EditNotesDialog.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "EditNotesDialog.h" -#include "ui_EditNotesDialog.h" -#include "gui/platform.h" - -#include -#include - -EditNotesDialog::EditNotesDialog( QString notes, QString name, QWidget* parent ) : - m_instance_notes(notes), - m_instance_name(name), - QDialog(parent), - ui(new Ui::EditNotesDialog) -{ - 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() -{ - return ui->noteEditor->toPlainText(); -} diff --git a/gui/EditNotesDialog.h b/gui/EditNotesDialog.h deleted file mode 100644 index 582e019f..00000000 --- a/gui/EditNotesDialog.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include - -namespace Ui { -class EditNotesDialog; -} - -class EditNotesDialog : public QDialog -{ - Q_OBJECT - -public: - explicit EditNotesDialog(QString notes, QString name, QWidget *parent = 0); - ~EditNotesDialog(); - QString getText(); -private: - Ui::EditNotesDialog *ui; - QString m_instance_name; - QString m_instance_notes; -}; diff --git a/gui/EditNotesDialog.ui b/gui/EditNotesDialog.ui deleted file mode 100644 index 487dfb84..00000000 --- a/gui/EditNotesDialog.ui +++ /dev/null @@ -1,77 +0,0 @@ - - - EditNotesDialog - - - - 0 - 0 - 459 - 399 - - - - Edit Notes - - - - - - Qt::ScrollBarAlwaysOn - - - false - - - Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - EditNotesDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - EditNotesDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/gui/IconPickerDialog.cpp b/gui/IconPickerDialog.cpp deleted file mode 100644 index ebacf87c..00000000 --- a/gui/IconPickerDialog.cpp +++ /dev/null @@ -1,147 +0,0 @@ -#include -#include "IconPickerDialog.h" -#include "instancedelegate.h" -#include "ui_IconPickerDialog.h" -#include "logic/lists/IconList.h" -#include "gui/platform.h" -#include -#include -#include - -IconPickerDialog::IconPickerDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::IconPickerDialog) -{ - MultiMCPlatform::fixWM_CLASS(this); - ui->setupUi(this); - setWindowModality(Qt::WindowModal); - - auto contentsWidget = ui->iconView; - contentsWidget->setViewMode(QListView::IconMode); - contentsWidget->setFlow(QListView::LeftToRight); - contentsWidget->setIconSize(QSize(48, 48)); - contentsWidget->setMovement(QListView::Static); - contentsWidget->setResizeMode(QListView::Adjust); - contentsWidget->setSelectionMode(QAbstractItemView::SingleSelection); - contentsWidget->setSpacing(5); - contentsWidget->setWordWrap(false); - contentsWidget->setWrapping(true); - contentsWidget->setUniformItemSizes(true); - contentsWidget->setTextElideMode(Qt::ElideRight); - contentsWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); - contentsWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - contentsWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - contentsWidget->setItemDelegate(new ListViewDelegate()); - - //contentsWidget->setAcceptDrops(true); - contentsWidget->setDropIndicatorShown(true); - contentsWidget->viewport()->setAcceptDrops(true); - contentsWidget->setDragDropMode(QAbstractItemView::DropOnly); - contentsWidget->setDefaultDropAction(Qt::CopyAction); - - contentsWidget->installEventFilter(this); - - contentsWidget->setModel(MMC->icons().get()); - - auto buttonAdd = ui->buttonBox->addButton(tr("Add Icon"),QDialogButtonBox::ResetRole); - auto buttonRemove = ui->buttonBox->addButton(tr("Remove Icon"),QDialogButtonBox::ResetRole); - - - connect(buttonAdd,SIGNAL(clicked(bool)),SLOT(addNewIcon())); - connect(buttonRemove,SIGNAL(clicked(bool)),SLOT(removeSelectedIcon())); - - connect - ( - contentsWidget, - SIGNAL(doubleClicked(QModelIndex)), - SLOT(activated(QModelIndex)) - ); - - connect - ( - contentsWidget->selectionModel(), - SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - SLOT(selectionChanged(QItemSelection,QItemSelection)) - ); -} -bool IconPickerDialog::eventFilter ( QObject* obj, QEvent* evt) -{ - if(obj != ui->iconView) - return QDialog::eventFilter(obj ,evt); - if (evt->type() != QEvent::KeyPress) - { - return QDialog::eventFilter(obj ,evt); - } - QKeyEvent *keyEvent = static_cast(evt); - switch(keyEvent->key()) - { - case Qt::Key_Delete: - removeSelectedIcon(); - return true; - case Qt::Key_Plus: - addNewIcon(); - return true; - default: - break; - } - return QDialog::eventFilter(obj ,evt); -} - -void IconPickerDialog::addNewIcon() -{ - //: The title of the select icons open file dialog - QString selectIcons = tr("Select Icons"); - //: The type of icon files - QStringList fileNames = QFileDialog::getOpenFileNames(this, selectIcons, QString(), tr("Icons") + "(*.png *.jpg *.jpeg)"); - MMC->icons()->installIcons(fileNames); -} - -void IconPickerDialog::removeSelectedIcon() -{ - MMC->icons()->deleteIcon(selectedIconKey); -} - - -void IconPickerDialog::activated ( QModelIndex index ) -{ - selectedIconKey = index.data(Qt::UserRole).toString(); - accept(); -} - - -void IconPickerDialog::selectionChanged ( QItemSelection selected, QItemSelection deselected ) -{ - if(selected.empty()) - return; - - QString key = selected.first().indexes().first().data(Qt::UserRole).toString(); - if(!key.isEmpty()) - selectedIconKey = key; -} - -int IconPickerDialog::exec ( QString selection ) -{ - auto list = MMC->icons(); - auto contentsWidget = ui->iconView; - selectedIconKey = selection; - - - int index_nr = list->getIconIndex(selection); - auto model_index = list->index(index_nr); - contentsWidget->selectionModel()->select(model_index, QItemSelectionModel::Current | QItemSelectionModel::Select); - - QMetaObject::invokeMethod(this, "delayed_scroll", Qt::QueuedConnection, Q_ARG(QModelIndex,model_index)); - return QDialog::exec(); -} - -void IconPickerDialog::delayed_scroll ( QModelIndex model_index ) -{ - auto contentsWidget = ui->iconView; - contentsWidget->scrollTo(model_index); -} - - -IconPickerDialog::~IconPickerDialog() -{ - delete ui; -} diff --git a/gui/IconPickerDialog.h b/gui/IconPickerDialog.h deleted file mode 100644 index 96fc61ff..00000000 --- a/gui/IconPickerDialog.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include -#include - -namespace Ui { -class IconPickerDialog; -} - -class IconPickerDialog : public QDialog -{ - Q_OBJECT - -public: - explicit IconPickerDialog(QWidget *parent = 0); - ~IconPickerDialog(); - int exec(QString selection); - QString selectedIconKey; -protected: - virtual bool eventFilter ( QObject* , QEvent* ); -private: - Ui::IconPickerDialog *ui; - -private slots: - void selectionChanged ( QItemSelection,QItemSelection ); - void activated ( QModelIndex ); - void delayed_scroll ( QModelIndex ); - void addNewIcon(); - void removeSelectedIcon(); -}; diff --git a/gui/IconPickerDialog.ui b/gui/IconPickerDialog.ui deleted file mode 100644 index c548edfb..00000000 --- a/gui/IconPickerDialog.ui +++ /dev/null @@ -1,67 +0,0 @@ - - - IconPickerDialog - - - - 0 - 0 - 676 - 555 - - - - Pick icon - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - IconPickerDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - IconPickerDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/gui/LabeledToolButton.cpp b/gui/LabeledToolButton.cpp deleted file mode 100644 index be84d1b7..00000000 --- a/gui/LabeledToolButton.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include -#include -#include -#include "LabeledToolButton.h" -#include - - -/* - * - * Tool Button with a label on it, instead of the normal text rendering - * - */ - -LabeledToolButton::LabeledToolButton(QWidget * parent) - : QToolButton(parent) - , m_label(new QLabel(this)) -{ - //QToolButton::setText(" "); - m_label->setWordWrap(true); - m_label->setMouseTracking(false); - m_label->setAlignment(Qt::AlignCenter); - m_label->setTextInteractionFlags(Qt::NoTextInteraction); - // somehow, this makes word wrap work in the QLabel. yay. - m_label->setMinimumWidth(100); -} - -QString LabeledToolButton::text() const -{ - return m_label->text(); -} - -void LabeledToolButton::setText(const QString & text) -{ - m_label->setText(text); -} - -/*! - \reimp -*/ -QSize LabeledToolButton::sizeHint() const -{ - /* - Q_D(const QToolButton); - if (d->sizeHint.isValid()) - return d->sizeHint; - */ - ensurePolished(); - - int w = 0, h = 0; - QStyleOptionToolButton opt; - initStyleOption(&opt); - QSize sz =m_label->sizeHint(); - w = sz.width(); - h = sz.height(); - - opt.rect.setSize(QSize(w, h)); // PM_MenuButtonIndicator depends on the height - if (popupMode() == MenuButtonPopup) - w += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this); - - QSize rawSize = style()->sizeFromContents(QStyle::CT_ToolButton, &opt, QSize(w, h), this); - QSize sizeHint = rawSize.expandedTo(QApplication::globalStrut()); - return sizeHint; -} - - - -void LabeledToolButton::resizeEvent(QResizeEvent * event) -{ - m_label->setGeometry(QRect(4, 4, width()-8, height()-8)); - QWidget::resizeEvent(event); -} diff --git a/gui/LabeledToolButton.h b/gui/LabeledToolButton.h deleted file mode 100644 index 24ef798a..00000000 --- a/gui/LabeledToolButton.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include -#include - -class QLabel; - -class LabeledToolButton : public QToolButton -{ - Q_OBJECT - - QLabel * m_label; - -public: - LabeledToolButton(QWidget * parent = 0); - - QString text() const; - void setText(const QString & text); - virtual QSize sizeHint() const; -protected: - void resizeEvent(QResizeEvent * event); -}; diff --git a/gui/LegacyModEditDialog.cpp b/gui/LegacyModEditDialog.cpp deleted file mode 100644 index a7021bf9..00000000 --- a/gui/LegacyModEditDialog.cpp +++ /dev/null @@ -1,393 +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 "MultiMC.h" -#include "LegacyModEditDialog.h" -#include "ModEditDialogCommon.h" -#include "versionselectdialog.h" -#include "ProgressDialog.h" -#include "ui_LegacyModEditDialog.h" -#include "logic/ModList.h" -#include "logic/lists/ForgeVersionList.h" -#include "gui/platform.h" - -#include -#include -//#include -#include -#include -#include - -LegacyModEditDialog::LegacyModEditDialog(LegacyInstance *inst, QWidget *parent) - : m_inst(inst), QDialog(parent), ui(new Ui::LegacyModEditDialog) -{ - MultiMCPlatform::fixWM_CLASS(this); - ui->setupUi(this); - - // Jar mods - { - ensureFolderPathExists(m_inst->jarModsDir()); - m_jarmods = m_inst->jarModList(); - ui->jarModsTreeView->setModel(m_jarmods.get()); -#ifndef Q_OS_LINUX - // FIXME: internal DnD causes segfaults later - ui->jarModsTreeView->setDragDropMode(QAbstractItemView::DragDrop); - // FIXME: DnD is glitched with contiguous (we move only first item in selection) - ui->jarModsTreeView->setSelectionMode(QAbstractItemView::SingleSelection); -#endif - ui->jarModsTreeView->installEventFilter(this); - m_jarmods->startWatching(); - auto smodel = ui->jarModsTreeView->selectionModel(); - connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), - SLOT(jarCurrent(QModelIndex, QModelIndex))); - } - // Core mods - { - ensureFolderPathExists(m_inst->coreModsDir()); - m_coremods = m_inst->coreModList(); - ui->coreModsTreeView->setModel(m_coremods.get()); - ui->coreModsTreeView->installEventFilter(this); - m_coremods->startWatching(); - auto smodel = ui->coreModsTreeView->selectionModel(); - connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), - SLOT(coreCurrent(QModelIndex, QModelIndex))); - } - // Loader mods - { - ensureFolderPathExists(m_inst->loaderModsDir()); - m_mods = m_inst->loaderModList(); - ui->loaderModTreeView->setModel(m_mods.get()); - ui->loaderModTreeView->installEventFilter(this); - m_mods->startWatching(); - auto smodel = ui->loaderModTreeView->selectionModel(); - connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), - SLOT(loaderCurrent(QModelIndex, QModelIndex))); - } - // texture packs - { - ensureFolderPathExists(m_inst->texturePacksDir()); - m_texturepacks = m_inst->texturePackList(); - ui->texPackTreeView->setModel(m_texturepacks.get()); - ui->texPackTreeView->installEventFilter(this); - m_texturepacks->startWatching(); - } -} - -LegacyModEditDialog::~LegacyModEditDialog() -{ - m_mods->stopWatching(); - m_coremods->stopWatching(); - m_jarmods->stopWatching(); - m_texturepacks->stopWatching(); - delete ui; -} - -bool LegacyModEditDialog::coreListFilter(QKeyEvent *keyEvent) -{ - switch (keyEvent->key()) - { - case Qt::Key_Delete: - on_rmCoreBtn_clicked(); - return true; - case Qt::Key_Plus: - on_addCoreBtn_clicked(); - return true; - default: - break; - } - return QDialog::eventFilter(ui->coreModsTreeView, keyEvent); -} - -bool LegacyModEditDialog::jarListFilter(QKeyEvent *keyEvent) -{ - 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 QDialog::eventFilter(ui->jarModsTreeView, keyEvent); -} - -bool LegacyModEditDialog::loaderListFilter(QKeyEvent *keyEvent) -{ - switch (keyEvent->key()) - { - case Qt::Key_Delete: - on_rmModBtn_clicked(); - return true; - case Qt::Key_Plus: - on_addModBtn_clicked(); - return true; - default: - break; - } - return QDialog::eventFilter(ui->loaderModTreeView, keyEvent); -} - -bool LegacyModEditDialog::texturePackListFilter(QKeyEvent *keyEvent) -{ - switch (keyEvent->key()) - { - case Qt::Key_Delete: - on_rmTexPackBtn_clicked(); - return true; - case Qt::Key_Plus: - on_addTexPackBtn_clicked(); - return true; - default: - break; - } - return QDialog::eventFilter(ui->texPackTreeView, keyEvent); -} - -bool LegacyModEditDialog::eventFilter(QObject *obj, QEvent *ev) -{ - if (ev->type() != QEvent::KeyPress) - { - return QDialog::eventFilter(obj, ev); - } - QKeyEvent *keyEvent = static_cast(ev); - if (obj == ui->jarModsTreeView) - return jarListFilter(keyEvent); - if (obj == ui->coreModsTreeView) - return coreListFilter(keyEvent); - if (obj == ui->loaderModTreeView) - return loaderListFilter(keyEvent); - if (obj == ui->texPackTreeView) - return texturePackListFilter(keyEvent); - return QDialog::eventFilter(obj, ev); -} - -void LegacyModEditDialog::on_addCoreBtn_clicked() -{ - //: Title of core mod selection dialog - QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Core Mods")); - for (auto filename : fileNames) - { - m_coremods->stopWatching(); - m_coremods->installMod(QFileInfo(filename)); - m_coremods->startWatching(); - } -} -void LegacyModEditDialog::on_addForgeBtn_clicked() -{ - VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this); - vselect.setFilter(1, m_inst->intendedVersionId()); - if (vselect.exec() && vselect.selectedVersion()) - { - ForgeVersionPtr forge = - std::dynamic_pointer_cast(vselect.selectedVersion()); - if (!forge) - return; - auto entry = MMC->metacache()->resolveEntry("minecraftforge", forge->filename); - if (entry->stale) - { - NetJob *fjob = new NetJob("Forge download"); - fjob->addNetAction(CacheDownload::make(forge->universal_url, entry)); - ProgressDialog dlg(this); - dlg.exec(fjob); - if (dlg.result() == QDialog::Accepted) - { - m_jarmods->stopWatching(); - m_jarmods->installMod(QFileInfo(entry->getFullPath())); - m_jarmods->startWatching(); - } - else - { - // failed to download forge :/ - } - } - else - { - m_jarmods->stopWatching(); - m_jarmods->installMod(QFileInfo(entry->getFullPath())); - m_jarmods->startWatching(); - } - } -} -void LegacyModEditDialog::on_addJarBtn_clicked() -{ - //: Title of jar mod selection dialog - QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Jar Mods")); - for (auto filename : fileNames) - { - m_jarmods->stopWatching(); - m_jarmods->installMod(QFileInfo(filename)); - m_jarmods->startWatching(); - } -} -void LegacyModEditDialog::on_addModBtn_clicked() -{ - //: Title of regular mod selection dialog - QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Loader Mods")); - for (auto filename : fileNames) - { - m_mods->stopWatching(); - m_mods->installMod(QFileInfo(filename)); - m_mods->startWatching(); - } -} -void LegacyModEditDialog::on_addTexPackBtn_clicked() -{ - //: Title of texture pack selection dialog - QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Texture Packs")); - for (auto filename : fileNames) - { - m_texturepacks->stopWatching(); - m_texturepacks->installMod(QFileInfo(filename)); - m_texturepacks->startWatching(); - } -} - -void LegacyModEditDialog::on_moveJarDownBtn_clicked() -{ - int first, last; - auto list = ui->jarModsTreeView->selectionModel()->selectedRows(); - - if (!lastfirst(list, first, last)) - return; - - m_jarmods->moveModsDown(first, last); -} -void LegacyModEditDialog::on_moveJarUpBtn_clicked() -{ - int first, last; - auto list = ui->jarModsTreeView->selectionModel()->selectedRows(); - - if (!lastfirst(list, first, last)) - return; - m_jarmods->moveModsUp(first, last); -} -void LegacyModEditDialog::on_rmCoreBtn_clicked() -{ - int first, last; - auto list = ui->coreModsTreeView->selectionModel()->selectedRows(); - - if (!lastfirst(list, first, last)) - return; - m_coremods->stopWatching(); - m_coremods->deleteMods(first, last); - m_coremods->startWatching(); -} -void LegacyModEditDialog::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 LegacyModEditDialog::on_rmModBtn_clicked() -{ - int first, last; - auto list = ui->loaderModTreeView->selectionModel()->selectedRows(); - - if (!lastfirst(list, first, last)) - return; - m_mods->stopWatching(); - m_mods->deleteMods(first, last); - m_mods->startWatching(); -} -void LegacyModEditDialog::on_rmTexPackBtn_clicked() -{ - int first, last; - auto list = ui->texPackTreeView->selectionModel()->selectedRows(); - - if (!lastfirst(list, first, last)) - return; - m_texturepacks->stopWatching(); - m_texturepacks->deleteMods(first, last); - m_texturepacks->startWatching(); -} -void LegacyModEditDialog::on_viewCoreBtn_clicked() -{ - openDirInDefaultProgram(m_inst->coreModsDir(), true); -} -void LegacyModEditDialog::on_viewModBtn_clicked() -{ - openDirInDefaultProgram(m_inst->loaderModsDir(), true); -} -void LegacyModEditDialog::on_viewTexPackBtn_clicked() -{ - openDirInDefaultProgram(m_inst->texturePacksDir(), true); -} - -void LegacyModEditDialog::on_buttonBox_rejected() -{ - close(); -} - -void LegacyModEditDialog::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); -} - -void LegacyModEditDialog::coreCurrent(QModelIndex current, QModelIndex previous) -{ - if(!current.isValid()) - { - ui->coreMIFrame->clear(); - return; - } - int row = current.row(); - Mod &m = m_coremods->operator[](row); - ui->coreMIFrame->updateWithMod(m); -} - -void LegacyModEditDialog::loaderCurrent(QModelIndex current, QModelIndex previous) -{ - if(!current.isValid()) - { - ui->loaderMIFrame->clear(); - return; - } - int row = current.row(); - Mod &m = m_mods->operator[](row); - ui->loaderMIFrame->updateWithMod(m); -} diff --git a/gui/LegacyModEditDialog.h b/gui/LegacyModEditDialog.h deleted file mode 100644 index d5582aef..00000000 --- a/gui/LegacyModEditDialog.h +++ /dev/null @@ -1,78 +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. - */ - -#pragma once - -#include -#include "logic/LegacyInstance.h" -#include - -namespace Ui -{ -class LegacyModEditDialog; -} - -class LegacyModEditDialog : public QDialog -{ - Q_OBJECT - -public: - explicit LegacyModEditDialog(LegacyInstance *inst, QWidget *parent = 0); - ~LegacyModEditDialog(); - -private -slots: - - void on_addJarBtn_clicked(); - void on_rmJarBtn_clicked(); - void on_addForgeBtn_clicked(); - void on_moveJarUpBtn_clicked(); - void on_moveJarDownBtn_clicked(); - - void on_addCoreBtn_clicked(); - void on_rmCoreBtn_clicked(); - void on_viewCoreBtn_clicked(); - - void on_addModBtn_clicked(); - void on_rmModBtn_clicked(); - void on_viewModBtn_clicked(); - - void on_addTexPackBtn_clicked(); - void on_rmTexPackBtn_clicked(); - void on_viewTexPackBtn_clicked(); - - // Questionable: SettingsDialog doesn't need this for some reason? - void on_buttonBox_rejected(); - - void jarCurrent(QModelIndex current, QModelIndex previous); - void coreCurrent(QModelIndex current, QModelIndex previous); - void loaderCurrent(QModelIndex current, QModelIndex previous); - -protected: - bool eventFilter(QObject *obj, QEvent *ev); - bool jarListFilter(QKeyEvent *ev); - bool coreListFilter(QKeyEvent *ev); - bool loaderListFilter(QKeyEvent *ev); - bool texturePackListFilter(QKeyEvent *ev); - -private: - Ui::LegacyModEditDialog *ui; - std::shared_ptr m_mods; - std::shared_ptr m_coremods; - std::shared_ptr m_jarmods; - std::shared_ptr m_texturepacks; - LegacyInstance *m_inst; - NetJobPtr forgeJob; -}; diff --git a/gui/LegacyModEditDialog.ui b/gui/LegacyModEditDialog.ui deleted file mode 100644 index bb0d9ef2..00000000 --- a/gui/LegacyModEditDialog.ui +++ /dev/null @@ -1,321 +0,0 @@ - - - LegacyModEditDialog - - - - 0 - 0 - 540 - 420 - - - - Dialog - - - - - - 0 - - - - Jar Mods - - - - - - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOff - - - - - - - - - &Add - - - - - - - &Remove - - - - - - - MCForge - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Move &Up - - - - - - - Move &Down - - - - - - - - - - - QFrame::Plain - - - - - - - - Core Mods - - - - - - - - QAbstractItemView::DropOnly - - - - - - - - - &Add - - - - - - - &Remove - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - &View Folder - - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - Loader Mods - - - - - - - - true - - - QAbstractItemView::DropOnly - - - - - - - - - &Add - - - - - - - &Remove - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - &View Folder - - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - false - - - Texture Packs - - - - - - true - - - QAbstractItemView::DropOnly - - - - - - - - - &Add - - - - - - - &Remove - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - &View Folder - - - - -