From db877ba121ff87a4e029daf8555d85dfef45993a Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Mon, 9 Feb 2015 01:51:14 +0100 Subject: NOISSUE move everything. --- gui/pages/BasePage.h | 38 --- gui/pages/BasePageProvider.h | 69 ----- gui/pages/InstanceSettingsPage.cpp | 216 ------------- gui/pages/InstanceSettingsPage.h | 74 ----- gui/pages/InstanceSettingsPage.ui | 453 ---------------------------- gui/pages/LogPage.cpp | 222 -------------- gui/pages/LogPage.h | 86 ------ gui/pages/LogPage.ui | 140 --------- gui/pages/ModFolderPage.cpp | 160 ---------- gui/pages/ModFolderPage.h | 94 ------ gui/pages/ModFolderPage.ui | 124 -------- gui/pages/NotesPage.cpp | 21 -- gui/pages/NotesPage.h | 61 ---- gui/pages/NotesPage.ui | 60 ---- gui/pages/OtherLogsPage.cpp | 150 ---------- gui/pages/OtherLogsPage.h | 72 ----- gui/pages/OtherLogsPage.ui | 117 -------- gui/pages/ResourcePackPage.h | 19 -- gui/pages/ScreenshotsPage.cpp | 362 ---------------------- gui/pages/ScreenshotsPage.h | 79 ----- gui/pages/ScreenshotsPage.ui | 109 ------- gui/pages/TexturePackPage.h | 17 -- gui/pages/VersionPage.cpp | 321 -------------------- gui/pages/VersionPage.h | 80 ----- gui/pages/VersionPage.ui | 204 ------------- gui/pages/global/AccountListPage.cpp | 142 --------- gui/pages/global/AccountListPage.h | 86 ------ gui/pages/global/AccountListPage.ui | 115 ------- gui/pages/global/ExternalToolsPage.cpp | 238 --------------- gui/pages/global/ExternalToolsPage.h | 74 ----- gui/pages/global/ExternalToolsPage.ui | 197 ------------ gui/pages/global/JavaPage.cpp | 146 --------- gui/pages/global/JavaPage.h | 73 ----- gui/pages/global/JavaPage.ui | 303 ------------------- gui/pages/global/MinecraftPage.cpp | 92 ------ gui/pages/global/MinecraftPage.h | 70 ----- gui/pages/global/MinecraftPage.ui | 148 --------- gui/pages/global/MultiMCPage.cpp | 459 ---------------------------- gui/pages/global/MultiMCPage.h | 100 ------- gui/pages/global/MultiMCPage.ui | 532 --------------------------------- gui/pages/global/ProxyPage.cpp | 95 ------ gui/pages/global/ProxyPage.h | 67 ----- gui/pages/global/ProxyPage.ui | 197 ------------ 43 files changed, 6482 deletions(-) delete mode 100644 gui/pages/BasePage.h delete mode 100644 gui/pages/BasePageProvider.h delete mode 100644 gui/pages/InstanceSettingsPage.cpp delete mode 100644 gui/pages/InstanceSettingsPage.h delete mode 100644 gui/pages/InstanceSettingsPage.ui delete mode 100644 gui/pages/LogPage.cpp delete mode 100644 gui/pages/LogPage.h delete mode 100644 gui/pages/LogPage.ui delete mode 100644 gui/pages/ModFolderPage.cpp delete mode 100644 gui/pages/ModFolderPage.h delete mode 100644 gui/pages/ModFolderPage.ui delete mode 100644 gui/pages/NotesPage.cpp delete mode 100644 gui/pages/NotesPage.h delete mode 100644 gui/pages/NotesPage.ui delete mode 100644 gui/pages/OtherLogsPage.cpp delete mode 100644 gui/pages/OtherLogsPage.h delete mode 100644 gui/pages/OtherLogsPage.ui delete mode 100644 gui/pages/ResourcePackPage.h delete mode 100644 gui/pages/ScreenshotsPage.cpp delete mode 100644 gui/pages/ScreenshotsPage.h delete mode 100644 gui/pages/ScreenshotsPage.ui delete mode 100644 gui/pages/TexturePackPage.h delete mode 100644 gui/pages/VersionPage.cpp delete mode 100644 gui/pages/VersionPage.h delete mode 100644 gui/pages/VersionPage.ui delete mode 100644 gui/pages/global/AccountListPage.cpp delete mode 100644 gui/pages/global/AccountListPage.h delete mode 100644 gui/pages/global/AccountListPage.ui delete mode 100644 gui/pages/global/ExternalToolsPage.cpp delete mode 100644 gui/pages/global/ExternalToolsPage.h delete mode 100644 gui/pages/global/ExternalToolsPage.ui delete mode 100644 gui/pages/global/JavaPage.cpp delete mode 100644 gui/pages/global/JavaPage.h delete mode 100644 gui/pages/global/JavaPage.ui delete mode 100644 gui/pages/global/MinecraftPage.cpp delete mode 100644 gui/pages/global/MinecraftPage.h delete mode 100644 gui/pages/global/MinecraftPage.ui delete mode 100644 gui/pages/global/MultiMCPage.cpp delete mode 100644 gui/pages/global/MultiMCPage.h delete mode 100644 gui/pages/global/MultiMCPage.ui delete mode 100644 gui/pages/global/ProxyPage.cpp delete mode 100644 gui/pages/global/ProxyPage.h delete mode 100644 gui/pages/global/ProxyPage.ui (limited to 'gui/pages') diff --git a/gui/pages/BasePage.h b/gui/pages/BasePage.h deleted file mode 100644 index ecf0692c..00000000 --- a/gui/pages/BasePage.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2013-2015 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 -#include - -class BasePage -{ -public: - virtual ~BasePage() {} - virtual QString id() const = 0; - virtual QString displayName() const = 0; - virtual QIcon icon() const = 0; - virtual bool apply() { return true; } - virtual bool shouldDisplay() const { return true; } - virtual QString helpPage() const { return QString(); } - virtual void opened() {} - virtual void closed() {} - int stackIndex = -1; - int listIndex = -1; -}; - -typedef std::shared_ptr BasePagePtr; diff --git a/gui/pages/BasePageProvider.h b/gui/pages/BasePageProvider.h deleted file mode 100644 index c55683e0..00000000 --- a/gui/pages/BasePageProvider.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright 2013-2015 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 "BasePage.h" -#include -#include - -class BasePageProvider -{ -public: - virtual QList getPages() = 0; - virtual QString dialogTitle() = 0; -}; - -class GenericPageProvider : public BasePageProvider -{ - typedef std::function PageCreator; -public: - explicit GenericPageProvider(const QString &dialogTitle) - : m_dialogTitle(dialogTitle) - { - } - - QList getPages() override - { - QList pages; - for (PageCreator creator : m_creators) - { - pages.append(creator()); - } - return pages; - } - QString dialogTitle() override { return m_dialogTitle; } - - void setDialogTitle(const QString &title) - { - m_dialogTitle = title; - } - void addPageCreator(PageCreator page) - { - m_creators.append(page); - } - - template - void addPage() - { - addPageCreator([](){return new PageClass();}); - } - -private: - QList m_creators; - QString m_dialogTitle; -}; - -typedef std::shared_ptr BasePageProviderPtr; diff --git a/gui/pages/InstanceSettingsPage.cpp b/gui/pages/InstanceSettingsPage.cpp deleted file mode 100644 index e1a9c666..00000000 --- a/gui/pages/InstanceSettingsPage.cpp +++ /dev/null @@ -1,216 +0,0 @@ -#include "InstanceSettingsPage.h" -#include "ui_InstanceSettingsPage.h" - -#include -#include -#include - -#include "gui/dialogs/VersionSelectDialog.h" -#include "gui/NagUtils.h" -#include "logic/java/JavaVersionList.h" -#include "MultiMC.h" - -InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent) - : QWidget(parent), ui(new Ui::InstanceSettingsPage), m_instance(inst) -{ - m_settings = &(inst->settings()); - ui->setupUi(this); - loadSettings(); -} - -bool InstanceSettingsPage::shouldDisplay() const -{ - return !m_instance->isRunning(); -} - -InstanceSettingsPage::~InstanceSettingsPage() -{ - delete ui; -} - -bool InstanceSettingsPage::apply() -{ - applySettings(); - return true; -} - -void InstanceSettingsPage::applySettings() -{ - // Console - bool console = ui->consoleSettingsBox->isChecked(); - m_settings->set("OverrideConsole", console); - if (console) - { - m_settings->set("ShowConsole", ui->showConsoleCheck->isChecked()); - m_settings->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked()); - } - else - { - m_settings->reset("ShowConsole"); - m_settings->reset("AutoCloseConsole"); - } - - // Window Size - bool window = ui->windowSizeGroupBox->isChecked(); - m_settings->set("OverrideWindow", window); - if (window) - { - m_settings->set("LaunchMaximized", ui->maximizedCheckBox->isChecked()); - m_settings->set("MinecraftWinWidth", ui->windowWidthSpinBox->value()); - m_settings->set("MinecraftWinHeight", ui->windowHeightSpinBox->value()); - } - else - { - m_settings->reset("LaunchMaximized"); - m_settings->reset("MinecraftWinWidth"); - m_settings->reset("MinecraftWinHeight"); - } - - // Memory - bool memory = ui->memoryGroupBox->isChecked(); - m_settings->set("OverrideMemory", memory); - if (memory) - { - m_settings->set("MinMemAlloc", ui->minMemSpinBox->value()); - m_settings->set("MaxMemAlloc", ui->maxMemSpinBox->value()); - m_settings->set("PermGen", ui->permGenSpinBox->value()); - } - else - { - m_settings->reset("MinMemAlloc"); - m_settings->reset("MaxMemAlloc"); - m_settings->reset("PermGen"); - } - - // Java Install Settings - bool javaInstall = ui->javaSettingsGroupBox->isChecked(); - m_settings->set("OverrideJavaLocation", javaInstall); - if (javaInstall) - { - m_settings->set("JavaPath", ui->javaPathTextBox->text()); - } - else - { - m_settings->reset("JavaPath"); - } - - // Java arguments - bool javaArgs = ui->javaArgumentsGroupBox->isChecked(); - m_settings->set("OverrideJavaArgs", javaArgs); - if(javaArgs) - { - m_settings->set("JvmArgs", ui->jvmArgsTextBox->toPlainText().replace("\n", " ")); - NagUtils::checkJVMArgs(m_settings->get("JvmArgs").toString(), this->parentWidget()); - } - else - { - m_settings->reset("JvmArgs"); - } - - // old generic 'override both' is removed. - m_settings->reset("OverrideJava"); - - // Custom Commands - bool custcmd = ui->customCommandsGroupBox->isChecked(); - m_settings->set("OverrideCommands", custcmd); - if (custcmd) - { - m_settings->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text()); - m_settings->set("PostExitCommand", ui->postExitCmdTextBox->text()); - } - else - { - m_settings->reset("PreLaunchCommand"); - m_settings->reset("PostExitCommand"); - } -} - -void InstanceSettingsPage::loadSettings() -{ - // Console - ui->consoleSettingsBox->setChecked(m_settings->get("OverrideConsole").toBool()); - ui->showConsoleCheck->setChecked(m_settings->get("ShowConsole").toBool()); - ui->autoCloseConsoleCheck->setChecked(m_settings->get("AutoCloseConsole").toBool()); - - // Window Size - ui->windowSizeGroupBox->setChecked(m_settings->get("OverrideWindow").toBool()); - ui->maximizedCheckBox->setChecked(m_settings->get("LaunchMaximized").toBool()); - ui->windowWidthSpinBox->setValue(m_settings->get("MinecraftWinWidth").toInt()); - ui->windowHeightSpinBox->setValue(m_settings->get("MinecraftWinHeight").toInt()); - - // 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()); - ui->permGenSpinBox->setValue(m_settings->get("PermGen").toInt()); - - // Java Settings - bool overrideJava = m_settings->get("OverrideJava").toBool(); - bool overrideLocation = m_settings->get("OverrideJavaLocation").toBool() || overrideJava; - bool overrideArgs = m_settings->get("OverrideJavaArgs").toBool() || overrideJava; - - ui->javaSettingsGroupBox->setChecked(overrideLocation); - ui->javaPathTextBox->setText(m_settings->get("JavaPath").toString()); - - 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->postExitCmdTextBox->setText(m_settings->get("PostExitCommand").toString()); -} - -void InstanceSettingsPage::on_javaDetectBtn_clicked() -{ - JavaVersionPtr java; - - VersionSelectDialog vselect(MMC->javalist().get(), tr("Select a Java version"), this, true); - vselect.setResizeOn(2); - vselect.exec(); - - if (vselect.result() == QDialog::Accepted && vselect.selectedVersion()) - { - java = std::dynamic_pointer_cast(vselect.selectedVersion()); - ui->javaPathTextBox->setText(java->path); - } -} - -void InstanceSettingsPage::on_javaBrowseBtn_clicked() -{ - QString dir = QFileDialog::getOpenFileName(this, tr("Find Java executable")); - if (!dir.isNull()) - { - ui->javaPathTextBox->setText(dir); - } -} - -void InstanceSettingsPage::on_javaTestBtn_clicked() -{ - checker.reset(new JavaChecker()); - connect(checker.get(), SIGNAL(checkFinished(JavaCheckResult)), this, - SLOT(checkFinished(JavaCheckResult))); - checker->path = ui->javaPathTextBox->text(); - checker->performCheck(); -} - -void InstanceSettingsPage::checkFinished(JavaCheckResult result) -{ - if (result.valid) - { - QString text; - text += "Java test succeeded!\n"; - if (result.is_64bit) - text += "Using 64bit java.\n"; - text += "\n"; - text += "Platform reported: " + result.realPlatform; - QMessageBox::information(this, tr("Java test success"), text); - } - else - { - QMessageBox::warning( - this, tr("Java test failure"), - tr("The specified java binary didn't work. You should use the auto-detect feature, " - "or set the path to the java executable.")); - } -} diff --git a/gui/pages/InstanceSettingsPage.h b/gui/pages/InstanceSettingsPage.h deleted file mode 100644 index 8835d02e..00000000 --- a/gui/pages/InstanceSettingsPage.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright 2013-2015 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/net/NetJob.h" -#include "logic/java/JavaChecker.h" -#include "logic/BaseInstance.h" -#include "BasePage.h" -#include "MultiMC.h" - -class JavaChecker; -namespace Ui -{ -class InstanceSettingsPage; -} - -class InstanceSettingsPage : public QWidget, public BasePage -{ - Q_OBJECT - -public: - explicit InstanceSettingsPage(BaseInstance *inst, QWidget *parent = 0); - virtual ~InstanceSettingsPage(); - virtual QString displayName() const override - { - return tr("Settings"); - } - virtual QIcon icon() const override - { - return MMC->getThemedIcon("instance-settings"); - } - virtual QString id() const override - { - return "settings"; - } - virtual bool apply(); - virtual QString helpPage() const override - { - return "Instance-settings"; - } - virtual bool shouldDisplay() const; -private slots: - void on_javaDetectBtn_clicked(); - - void on_javaTestBtn_clicked(); - - void on_javaBrowseBtn_clicked(); - - void checkFinished(JavaCheckResult result); - - void applySettings(); - void loadSettings(); - -private: - Ui::InstanceSettingsPage *ui; - BaseInstance *m_instance; - SettingsObject *m_settings; - std::shared_ptr checker; -}; diff --git a/gui/pages/InstanceSettingsPage.ui b/gui/pages/InstanceSettingsPage.ui deleted file mode 100644 index 64109378..00000000 --- a/gui/pages/InstanceSettingsPage.ui +++ /dev/null @@ -1,453 +0,0 @@ - - - InstanceSettingsPage - - - - 0 - 0 - 458 - 426 - - - - Form - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QTabWidget::Rounded - - - 0 - - - - Java - - - - - - true - - - Java installation - - - true - - - false - - - - - - - - - Auto-detect... - - - - - - - Browse... - - - - - - - Test - - - - - - - - - - true - - - Memory - - - true - - - false - - - - - - The maximum amount of memory Minecraft is allowed to use. - - - MB - - - 512 - - - 65536 - - - 128 - - - 1024 - - - - - - - Minimum memory allocation: - - - - - - - Maximum memory allocation: - - - - - - - The amount of memory Minecraft is started with. - - - MB - - - 256 - - - 65536 - - - 128 - - - 256 - - - - - - - The amount of memory available to store loaded Java classes. - - - MB - - - 64 - - - 999999999 - - - 8 - - - 64 - - - - - - - PermGen: - - - - - - - - - - true - - - Java arguments - - - true - - - false - - - - - - - - - - - - Qt::Vertical - - - - 0 - 0 - - - - - - - - - Game windows - - - - - - true - - - Game Window - - - true - - - false - - - - - - Start Minecraft maximized? - - - - - - - - - Window height: - - - - - - - Window width: - - - - - - - 1 - - - 65536 - - - 1 - - - 854 - - - - - - - 1 - - - 65536 - - - 480 - - - - - - - - - - - - true - - - Console Settings - - - true - - - false - - - - - - Show console while the game is running? - - - - - - - Automatically close console when the game quits? - - - - - - - - - - Qt::Vertical - - - - 88 - 125 - - - - - - - - - Custom commands - - - - - - true - - - Custom Commands - - - true - - - false - - - - - - - - - Post-exit command: - - - - - - - Pre-launch command: - - - - - - - - - - - - - <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 directory 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> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - Qt::Vertical - - - - 88 - 186 - - - - - - - - - - - - settingsTabs - javaSettingsGroupBox - javaPathTextBox - javaDetectBtn - javaBrowseBtn - javaTestBtn - memoryGroupBox - minMemSpinBox - maxMemSpinBox - permGenSpinBox - javaArgumentsGroupBox - jvmArgsTextBox - windowSizeGroupBox - maximizedCheckBox - windowWidthSpinBox - windowHeightSpinBox - consoleSettingsBox - showConsoleCheck - autoCloseConsoleCheck - customCommandsGroupBox - preLaunchCmdTextBox - postExitCmdTextBox - - - - diff --git a/gui/pages/LogPage.cpp b/gui/pages/LogPage.cpp deleted file mode 100644 index 4e9e4f52..00000000 --- a/gui/pages/LogPage.cpp +++ /dev/null @@ -1,222 +0,0 @@ -#include "LogPage.h" -#include "ui_LogPage.h" - -#include "MultiMC.h" - -#include -#include -#include - -#include "logic/BaseProcess.h" -#include "gui/GuiUtil.h" - -LogPage::LogPage(BaseProcess *proc, QWidget *parent) - : QWidget(parent), ui(new Ui::LogPage), m_process(proc) -{ - ui->setupUi(this); - ui->tabWidget->tabBar()->hide(); - connect(m_process, SIGNAL(log(QString, MessageLevel::Enum)), this, - SLOT(write(QString, MessageLevel::Enum))); - - // create the format and set its font - defaultFormat = new QTextCharFormat(ui->text->currentCharFormat()); - QString fontFamily = MMC->settings()->get("ConsoleFont").toString(); - bool conversionOk = false; - int fontSize = MMC->settings()->get("ConsoleFontSize").toInt(&conversionOk); - if(!conversionOk) - { - fontSize = 11; - } - defaultFormat->setFont(QFont(fontFamily, fontSize)); - - auto findShortcut = new QShortcut(QKeySequence(QKeySequence::Find), this); - connect(findShortcut, SIGNAL(activated()), SLOT(findActivated())); - auto findNextShortcut = new QShortcut(QKeySequence(QKeySequence::FindNext), this); - connect(findNextShortcut, SIGNAL(activated()), SLOT(findNextActivated())); - connect(ui->searchBar, SIGNAL(returnPressed()), SLOT(on_findButton_clicked())); - auto findPreviousShortcut = new QShortcut(QKeySequence(QKeySequence::FindPrevious), this); - connect(findPreviousShortcut, SIGNAL(activated()), SLOT(findPreviousActivated())); -} - -LogPage::~LogPage() -{ - delete ui; - delete defaultFormat; -} - -bool LogPage::apply() -{ - return true; -} - -bool LogPage::shouldDisplay() const -{ - return m_process->instance()->isRunning(); -} - -void LogPage::on_btnPaste_clicked() -{ - GuiUtil::uploadPaste(ui->text->toPlainText(), this); -} - -void LogPage::on_btnCopy_clicked() -{ - GuiUtil::setClipboardText(ui->text->toPlainText()); -} - -void LogPage::on_btnClear_clicked() -{ - ui->text->clear(); -} - -void LogPage::on_trackLogCheckbox_clicked(bool checked) -{ - m_write_active = checked; -} - -void LogPage::on_findButton_clicked() -{ - auto modifiers = QApplication::keyboardModifiers(); - if (modifiers & Qt::ShiftModifier) - { - findPreviousActivated(); - } - else - { - findNextActivated(); - } -} - -void LogPage::findActivated() -{ - // focus the search bar if it doesn't have focus - if (!ui->searchBar->hasFocus()) - { - auto searchForCursor = ui->text->textCursor(); - auto searchForString = searchForCursor.selectedText(); - if (searchForString.size()) - { - ui->searchBar->setText(searchForString); - } - ui->searchBar->setFocus(); - ui->searchBar->selectAll(); - } -} - -void LogPage::findNextActivated() -{ - auto toSearch = ui->searchBar->text(); - if (toSearch.size()) - { - ui->text->find(toSearch); - } -} - -void LogPage::findPreviousActivated() -{ - auto toSearch = ui->searchBar->text(); - if (toSearch.size()) - { - ui->text->find(toSearch, QTextDocument::FindBackward); - } -} - -void LogPage::write(QString data, MessageLevel::Enum mode) -{ - if (!m_write_active) - { - if (mode != MessageLevel::PrePost && mode != MessageLevel::MultiMC) - { - return; - } - } - - // save the cursor so it can be restored. - auto savedCursor = ui->text->cursor(); - - QScrollBar *bar = ui->text->verticalScrollBar(); - int max_bar = bar->maximum(); - int val_bar = bar->value(); - if (isVisible()) - { - if (m_scroll_active) - { - m_scroll_active = (max_bar - val_bar) <= 1; - } - else - { - m_scroll_active = val_bar == max_bar; - } - } - if (data.endsWith('\n')) - data = data.left(data.length() - 1); - QStringList paragraphs = data.split('\n'); - QStringList filtered; - for (QString ¶graph : paragraphs) - { - //TODO: implement filtering here. - filtered.append(paragraph); - } - QListIterator iter(filtered); - QTextCharFormat format(*defaultFormat); - - switch(mode) - { - case MessageLevel::MultiMC: - { - format.setForeground(QColor("blue")); - break; - } - case MessageLevel::Debug: - { - format.setForeground(QColor("green")); - break; - } - case MessageLevel::Warning: - { - format.setForeground(QColor("orange")); - break; - } - case MessageLevel::Error: - { - format.setForeground(QColor("red")); - break; - } - case MessageLevel::Fatal: - { - format.setForeground(QColor("red")); - format.setBackground(QColor("black")); - break; - } - case MessageLevel::PrePost: - { - format.setForeground(QColor("grey")); - break; - } - case MessageLevel::Info: - case MessageLevel::Message: - default: - { - // do nothing, keep original - } - } - - while (iter.hasNext()) - { - // append a paragraph/line - auto workCursor = ui->text->textCursor(); - workCursor.movePosition(QTextCursor::End); - workCursor.insertText(iter.next(), format); - workCursor.insertBlock(); - } - - if (isVisible()) - { - if (m_scroll_active) - { - bar->setValue(bar->maximum()); - } - m_last_scroll_value = bar->value(); - } - ui->text->setCursor(savedCursor); -} diff --git a/gui/pages/LogPage.h b/gui/pages/LogPage.h deleted file mode 100644 index fea438c0..00000000 --- a/gui/pages/LogPage.h +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright 2013-2015 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/BaseInstance.h" -#include "logic/net/NetJob.h" -#include "logic/BaseProcess.h" -#include "BasePage.h" -#include - -namespace Ui -{ -class LogPage; -} -class QTextCharFormat; - -class LogPage : public QWidget, public BasePage -{ - Q_OBJECT - -public: - explicit LogPage(BaseProcess *proc, QWidget *parent = 0); - virtual ~LogPage(); - virtual QString displayName() const override - { - return tr("Minecraft Log"); - } - virtual QIcon icon() const override - { - return MMC->getThemedIcon("log"); - } - virtual QString id() const override - { - return "console"; - } - virtual bool apply(); - virtual QString helpPage() const override - { - return "Minecraft-Logs"; - } - virtual bool shouldDisplay() const; - -private 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); - void on_btnPaste_clicked(); - void on_btnCopy_clicked(); - void on_btnClear_clicked(); - - void on_trackLogCheckbox_clicked(bool checked); - - void on_findButton_clicked(); - void findActivated(); - void findNextActivated(); - void findPreviousActivated(); - -private: - Ui::LogPage *ui; - BaseProcess *m_process; - int m_last_scroll_value = 0; - bool m_scroll_active = true; - int m_saved_offset = 0; - bool m_write_active = true; - - QTextCharFormat * defaultFormat; -}; diff --git a/gui/pages/LogPage.ui b/gui/pages/LogPage.ui deleted file mode 100644 index 089bc906..00000000 --- a/gui/pages/LogPage.ui +++ /dev/null @@ -1,140 +0,0 @@ - - - LogPage - - - - 0 - 0 - 825 - 782 - - - - Log - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - - Tab 1 - - - - - - Search: - - - - - - - Find - - - - - - - false - - - true - - - - - - Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - false - - - - - - - - - Keep updating - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Copy the whole log into the clipboard - - - &Copy - - - - - - - Upload the log to paste.ee - it will stay online for a month - - - Upload - - - - - - - Clear the log - - - Clear - - - - - - - - - - - - - - - - - diff --git a/gui/pages/ModFolderPage.cpp b/gui/pages/ModFolderPage.cpp deleted file mode 100644 index 167ba471..00000000 --- a/gui/pages/ModFolderPage.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* Copyright 2013-2015 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 "ModFolderPage.h" -#include "ui_ModFolderPage.h" - -#include -#include -#include -#include -#include -#include - -#include - -#include "MultiMC.h" -#include "gui/dialogs/CustomMessageBox.h" -#include "gui/dialogs/ModEditDialogCommon.h" -#include "logic/minecraft/ModList.h" -#include "logic/minecraft/Mod.h" -#include "logic/minecraft/VersionFilterData.h" - -ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr mods, QString id, - QString iconName, QString displayName, QString helpPage, - QWidget *parent) - : QWidget(parent), ui(new Ui::ModFolderPage) -{ - ui->setupUi(this); - ui->tabWidget->tabBar()->hide(); - m_inst = inst; - m_mods = mods; - m_id = id; - m_displayName = displayName; - m_iconName = iconName; - m_helpName = helpPage; - ui->modTreeView->setModel(m_mods.get()); - ui->modTreeView->installEventFilter(this); - m_mods->startWatching(); - auto smodel = ui->modTreeView->selectionModel(); - connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), - SLOT(modCurrent(QModelIndex, QModelIndex))); -} - -CoreModFolderPage::CoreModFolderPage(BaseInstance *inst, std::shared_ptr mods, - QString id, QString iconName, QString displayName, - QString helpPage, QWidget *parent) - : ModFolderPage(inst, mods, id, iconName, displayName, helpPage, parent) -{ -} - -ModFolderPage::~ModFolderPage() -{ - m_mods->stopWatching(); - delete ui; -} - -bool ModFolderPage::shouldDisplay() const -{ - if (m_inst) - return !m_inst->isRunning(); - return true; -} - -bool CoreModFolderPage::shouldDisplay() const -{ - if (ModFolderPage::shouldDisplay()) - { - auto inst = dynamic_cast(m_inst); - if (!inst) - return true; - auto version = inst->getMinecraftProfile(); - if (!version) - return true; - if (version->m_releaseTime < g_VersionFilterData.legacyCutoffDate) - { - return true; - } - } - return false; -} - -bool ModFolderPage::modListFilter(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 QWidget::eventFilter(ui->modTreeView, keyEvent); -} - -bool ModFolderPage::eventFilter(QObject *obj, QEvent *ev) -{ - if (ev->type() != QEvent::KeyPress) - { - return QWidget::eventFilter(obj, ev); - } - QKeyEvent *keyEvent = static_cast(ev); - if (obj == ui->modTreeView) - return modListFilter(keyEvent); - return QWidget::eventFilter(obj, ev); -} - -void ModFolderPage::on_addModBtn_clicked() -{ - QStringList fileNames = QFileDialog::getOpenFileNames( - this, QApplication::translate("ModFolderPage", "Select Loader Mods")); - for (auto filename : fileNames) - { - m_mods->stopWatching(); - m_mods->installMod(QFileInfo(filename)); - m_mods->startWatching(); - } -} -void ModFolderPage::on_rmModBtn_clicked() -{ - int first, last; - auto list = ui->modTreeView->selectionModel()->selectedRows(); - - if (!lastfirst(list, first, last)) - return; - m_mods->stopWatching(); - m_mods->deleteMods(first, last); - m_mods->startWatching(); -} - -void ModFolderPage::on_viewModBtn_clicked() -{ - openDirInDefaultProgram(m_mods->dir().absolutePath(), true); -} - -void ModFolderPage::modCurrent(const QModelIndex ¤t, const QModelIndex &previous) -{ - if (!current.isValid()) - { - ui->frame->clear(); - return; - } - int row = current.row(); - Mod &m = m_mods->operator[](row); - ui->frame->updateWithMod(m); -} diff --git a/gui/pages/ModFolderPage.h b/gui/pages/ModFolderPage.h deleted file mode 100644 index bd5156d4..00000000 --- a/gui/pages/ModFolderPage.h +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright 2013-2015 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/minecraft/OneSixInstance.h" -#include "logic/net/NetJob.h" -#include "BasePage.h" -#include - -class ModList; -namespace Ui -{ -class ModFolderPage; -} - -class ModFolderPage : public QWidget, public BasePage -{ - Q_OBJECT - -public: - explicit ModFolderPage(BaseInstance *inst, std::shared_ptr mods, QString id, - QString iconName, QString displayName, QString helpPage = "", - QWidget *parent = 0); - virtual ~ModFolderPage(); - virtual QString displayName() const override - { - return m_displayName; - } - virtual QIcon icon() const override - { - return MMC->getThemedIcon(m_iconName); - } - virtual QString id() const override - { - return m_id; - } - virtual QString helpPage() const override - { - return m_helpName; - } - virtual bool shouldDisplay() const; - -protected: - bool eventFilter(QObject *obj, QEvent *ev); - bool modListFilter(QKeyEvent *ev); - -protected: - BaseInstance *m_inst; - -private: - Ui::ModFolderPage *ui; - std::shared_ptr m_mods; - QString m_iconName; - QString m_id; - QString m_displayName; - QString m_helpName; - -public -slots: - void modCurrent(const QModelIndex ¤t, const QModelIndex &previous); - -private -slots: - void on_addModBtn_clicked(); - void on_rmModBtn_clicked(); - void on_viewModBtn_clicked(); -}; - -class CoreModFolderPage : public ModFolderPage -{ -public: - explicit CoreModFolderPage(BaseInstance *inst, std::shared_ptr mods, QString id, - QString iconName, QString displayName, QString helpPage = "", - QWidget *parent = 0); - virtual ~CoreModFolderPage() - { - } - virtual bool shouldDisplay() const; -}; diff --git a/gui/pages/ModFolderPage.ui b/gui/pages/ModFolderPage.ui deleted file mode 100644 index 019b8faf..00000000 --- a/gui/pages/ModFolderPage.ui +++ /dev/null @@ -1,124 +0,0 @@ - - - ModFolderPage - - - - 0 - 0 - 723 - 532 - - - - Mods - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - - Tab 1 - - - - - - - 0 - 0 - - - - true - - - QAbstractItemView::DropOnly - - - - - - - - - &Add - - - - - - - &Remove - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - &View Folder - - - - - - - - - - 0 - 0 - - - - - - - - - - - - - ModListView - QTreeView -
gui/widgets/ModListView.h
-
- - MCModInfoFrame - QFrame -
gui/widgets/MCModInfoFrame.h
- 1 -
-
- - -
diff --git a/gui/pages/NotesPage.cpp b/gui/pages/NotesPage.cpp deleted file mode 100644 index 48bb468c..00000000 --- a/gui/pages/NotesPage.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "NotesPage.h" -#include "ui_NotesPage.h" - -NotesPage::NotesPage(BaseInstance *inst, QWidget *parent) - : QWidget(parent), ui(new Ui::NotesPage), m_inst(inst) -{ - ui->setupUi(this); - ui->tabWidget->tabBar()->hide(); - ui->noteEditor->setText(m_inst->notes()); -} - -NotesPage::~NotesPage() -{ - delete ui; -} - -bool NotesPage::apply() -{ - m_inst->setNotes(ui->noteEditor->toPlainText()); - return true; -} diff --git a/gui/pages/NotesPage.h b/gui/pages/NotesPage.h deleted file mode 100644 index 6dcdce32..00000000 --- a/gui/pages/NotesPage.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright 2013-2015 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/BaseInstance.h" -#include "logic/net/NetJob.h" -#include "BasePage.h" -#include - -namespace Ui -{ -class NotesPage; -} - -class NotesPage : public QWidget, public BasePage -{ - Q_OBJECT - -public: - explicit NotesPage(BaseInstance *inst, QWidget *parent = 0); - virtual ~NotesPage(); - virtual QString displayName() const override - { - return tr("Notes"); - } - virtual QIcon icon() const override - { - auto icon = MMC->getThemedIcon("notes"); - if(icon.isNull()) - icon = MMC->getThemedIcon("news"); - return icon; - } - virtual QString id() const override - { - return "notes"; - } - virtual bool apply(); - virtual QString helpPage() const override - { - return "Notes"; - } - -private: - Ui::NotesPage *ui; - BaseInstance *m_inst; -}; diff --git a/gui/pages/NotesPage.ui b/gui/pages/NotesPage.ui deleted file mode 100644 index 8da01c8b..00000000 --- a/gui/pages/NotesPage.ui +++ /dev/null @@ -1,60 +0,0 @@ - - - NotesPage - - - - 0 - 0 - 731 - 538 - - - - Form - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - - Tab 1 - - - - - - Qt::ScrollBarAlwaysOn - - - false - - - Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - - - - - diff --git a/gui/pages/OtherLogsPage.cpp b/gui/pages/OtherLogsPage.cpp deleted file mode 100644 index c9b0aa51..00000000 --- a/gui/pages/OtherLogsPage.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* Copyright 2013-2015 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 "OtherLogsPage.h" -#include "ui_OtherLogsPage.h" - -#include -#include - -#include "gui/GuiUtil.h" -#include "logic/RecursiveFileSystemWatcher.h" -#include - -OtherLogsPage::OtherLogsPage(QString path, QWidget *parent) - : QWidget(parent), ui(new Ui::OtherLogsPage), m_path(path), - m_watcher(new RecursiveFileSystemWatcher(this)) -{ - ui->setupUi(this); - ui->tabWidget->tabBar()->hide(); - - m_watcher->setFileExpression("(.*\\.log(\\.[0-9]*)?$)|(crash-.*\\.txt)"); - m_watcher->setRootDir(QDir::current().absoluteFilePath(m_path)); - - connect(m_watcher, &RecursiveFileSystemWatcher::filesChanged, this, - &OtherLogsPage::populateSelectLogBox); - populateSelectLogBox(); -} - -OtherLogsPage::~OtherLogsPage() -{ - delete ui; -} - -void OtherLogsPage::opened() -{ - m_watcher->enable(); -} -void OtherLogsPage::closed() -{ - m_watcher->disable(); -} - -void OtherLogsPage::populateSelectLogBox() -{ - ui->selectLogBox->clear(); - ui->selectLogBox->addItems(m_watcher->files()); - if (m_currentFile.isNull()) - { - ui->selectLogBox->setCurrentIndex(-1); - } - else - { - const int index = ui->selectLogBox->findText(m_currentFile); - if (index != -1) - ui->selectLogBox->setCurrentIndex(index); - } -} - -void OtherLogsPage::on_selectLogBox_currentIndexChanged(const int index) -{ - QString file; - if (index != -1) - { - file = ui->selectLogBox->itemText(index); - } - - if (file.isEmpty() || !QFile::exists(PathCombine(m_path, file))) - { - m_currentFile = QString(); - ui->text->clear(); - setControlsEnabled(false); - } - else - { - m_currentFile = file; - on_btnReload_clicked(); - setControlsEnabled(true); - } -} - -void OtherLogsPage::on_btnReload_clicked() -{ - QFile file(PathCombine(m_path, m_currentFile)); - if (!file.open(QFile::ReadOnly)) - { - setControlsEnabled(false); - ui->btnReload->setEnabled(true); // allow reload - m_currentFile = QString(); - QMessageBox::critical(this, tr("Error"), tr("Unable to open %1 for reading: %2") - .arg(m_currentFile, file.errorString())); - } - else - { - if (file.size() < 10000000ll) - { - ui->text->setPlainText(QString::fromUtf8(file.readAll())); - } - else - { - ui->text->setPlainText( - tr("The file (%1) is too big. You may want to open it in a viewer optimized " - "for large files.").arg(file.fileName())); - } - } -} - -void OtherLogsPage::on_btnPaste_clicked() -{ - GuiUtil::uploadPaste(ui->text->toPlainText(), this); -} -void OtherLogsPage::on_btnCopy_clicked() -{ - GuiUtil::setClipboardText(ui->text->toPlainText()); -} -void OtherLogsPage::on_btnDelete_clicked() -{ - if (QMessageBox::question(this, tr("Delete"), - tr("Do you really want to delete %1?").arg(m_currentFile), - QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) - { - return; - } - QFile file(PathCombine(m_path, m_currentFile)); - if (!file.remove()) - { - QMessageBox::critical(this, tr("Error"), tr("Unable to delete %1: %2") - .arg(m_currentFile, file.errorString())); - } -} - -void OtherLogsPage::setControlsEnabled(const bool enabled) -{ - ui->btnReload->setEnabled(enabled); - ui->btnDelete->setEnabled(enabled); - ui->btnCopy->setEnabled(enabled); - ui->btnPaste->setEnabled(enabled); - ui->text->setEnabled(enabled); -} diff --git a/gui/pages/OtherLogsPage.h b/gui/pages/OtherLogsPage.h deleted file mode 100644 index d6e4ec9f..00000000 --- a/gui/pages/OtherLogsPage.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright 2013-2015 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 "BasePage.h" -#include - -namespace Ui -{ -class OtherLogsPage; -} - -class RecursiveFileSystemWatcher; - -class OtherLogsPage : public