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/ColumnResizer.cpp | 202 ---- gui/ColumnResizer.h | 38 - gui/ConsoleWindow.cpp | 260 ---- gui/ConsoleWindow.h | 65 - gui/GuiUtil.cpp | 48 - gui/GuiUtil.h | 9 - gui/InstancePageProvider.cpp | 0 gui/InstancePageProvider.h | 52 - gui/InstanceProxyModel.cpp | 23 - gui/InstanceProxyModel.h | 13 - gui/MainWindow.cpp | 2069 -------------------------------- gui/MainWindow.h | 218 ---- gui/NagUtils.cpp | 38 - gui/NagUtils.h | 23 - gui/Platform.h | 32 - gui/Platform_Other.cpp | 27 - gui/Platform_X11.cpp | 62 - gui/dialogs/AboutDialog.cpp | 127 -- gui/dialogs/AboutDialog.h | 47 - gui/dialogs/AboutDialog.ui | 544 --------- gui/dialogs/AccountSelectDialog.cpp | 85 -- gui/dialogs/AccountSelectDialog.h | 90 -- gui/dialogs/AccountSelectDialog.ui | 56 - gui/dialogs/CopyInstanceDialog.cpp | 101 -- gui/dialogs/CopyInstanceDialog.h | 52 - gui/dialogs/CopyInstanceDialog.ui | 161 --- gui/dialogs/CustomMessageBox.cpp | 35 - gui/dialogs/CustomMessageBox.h | 26 - gui/dialogs/EditAccountDialog.cpp | 51 - gui/dialogs/EditAccountDialog.h | 60 - gui/dialogs/EditAccountDialog.ui | 94 -- gui/dialogs/IconPickerDialog.cpp | 156 --- gui/dialogs/IconPickerDialog.h | 48 - gui/dialogs/IconPickerDialog.ui | 67 -- gui/dialogs/LoginDialog.cpp | 110 -- gui/dialogs/LoginDialog.h | 58 - gui/dialogs/LoginDialog.ui | 77 -- gui/dialogs/ModEditDialogCommon.cpp | 40 - gui/dialogs/ModEditDialogCommon.h | 9 - gui/dialogs/NewInstanceDialog.cpp | 207 ---- gui/dialogs/NewInstanceDialog.h | 59 - gui/dialogs/NewInstanceDialog.ui | 309 ----- gui/dialogs/NotificationDialog.cpp | 84 -- gui/dialogs/NotificationDialog.h | 44 - gui/dialogs/NotificationDialog.ui | 85 -- gui/dialogs/ProgressDialog.cpp | 125 -- gui/dialogs/ProgressDialog.h | 65 - gui/dialogs/ProgressDialog.ui | 66 - gui/dialogs/UpdateDialog.cpp | 186 --- gui/dialogs/UpdateDialog.h | 61 - gui/dialogs/UpdateDialog.ui | 106 -- gui/dialogs/VersionSelectDialog.cpp | 177 --- gui/dialogs/VersionSelectDialog.h | 66 - gui/dialogs/VersionSelectDialog.ui | 110 -- gui/groupview/GroupView.cpp | 1003 ---------------- gui/groupview/GroupView.h | 125 -- gui/groupview/GroupedProxyModel.cpp | 42 - gui/groupview/GroupedProxyModel.h | 15 - gui/groupview/InstanceDelegate.cpp | 362 ------ gui/groupview/InstanceDelegate.h | 35 - gui/groupview/VisualGroup.cpp | 301 ----- gui/groupview/VisualGroup.h | 91 -- gui/pagedialog/PageDialog.cpp | 62 - gui/pagedialog/PageDialog.h | 36 - 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 --- gui/widgets/Common.cpp | 27 - gui/widgets/Common.h | 6 - gui/widgets/IconLabel.cpp | 43 - gui/widgets/IconLabel.h | 26 - gui/widgets/LabeledToolButton.cpp | 86 -- gui/widgets/LabeledToolButton.h | 37 - gui/widgets/LineSeparator.cpp | 37 - gui/widgets/LineSeparator.h | 18 - gui/widgets/MCModInfoFrame.cpp | 111 -- gui/widgets/MCModInfoFrame.h | 46 - gui/widgets/MCModInfoFrame.ui | 68 -- gui/widgets/ModListView.cpp | 62 - gui/widgets/ModListView.h | 27 - gui/widgets/PageContainer.cpp | 210 ---- gui/widgets/PageContainer.h | 63 - gui/widgets/PageContainer_p.h | 123 -- gui/widgets/ServerStatus.cpp | 129 -- gui/widgets/ServerStatus.h | 37 - gui/widgets/VersionListView.cpp | 147 --- gui/widgets/VersionListView.h | 43 - 127 files changed, 16923 deletions(-) delete mode 100644 gui/ColumnResizer.cpp delete mode 100644 gui/ColumnResizer.h delete mode 100644 gui/ConsoleWindow.cpp delete mode 100644 gui/ConsoleWindow.h delete mode 100644 gui/GuiUtil.cpp delete mode 100644 gui/GuiUtil.h delete mode 100644 gui/InstancePageProvider.cpp delete mode 100644 gui/InstancePageProvider.h delete mode 100644 gui/InstanceProxyModel.cpp delete mode 100644 gui/InstanceProxyModel.h delete mode 100644 gui/MainWindow.cpp delete mode 100644 gui/MainWindow.h delete mode 100644 gui/NagUtils.cpp delete mode 100644 gui/NagUtils.h delete mode 100644 gui/Platform.h delete mode 100644 gui/Platform_Other.cpp delete mode 100644 gui/Platform_X11.cpp delete mode 100644 gui/dialogs/AboutDialog.cpp delete mode 100644 gui/dialogs/AboutDialog.h delete mode 100644 gui/dialogs/AboutDialog.ui delete mode 100644 gui/dialogs/AccountSelectDialog.cpp delete mode 100644 gui/dialogs/AccountSelectDialog.h delete mode 100644 gui/dialogs/AccountSelectDialog.ui delete mode 100644 gui/dialogs/CopyInstanceDialog.cpp delete mode 100644 gui/dialogs/CopyInstanceDialog.h delete mode 100644 gui/dialogs/CopyInstanceDialog.ui delete mode 100644 gui/dialogs/CustomMessageBox.cpp delete mode 100644 gui/dialogs/CustomMessageBox.h delete mode 100644 gui/dialogs/EditAccountDialog.cpp delete mode 100644 gui/dialogs/EditAccountDialog.h delete mode 100644 gui/dialogs/EditAccountDialog.ui delete mode 100644 gui/dialogs/IconPickerDialog.cpp delete mode 100644 gui/dialogs/IconPickerDialog.h delete mode 100644 gui/dialogs/IconPickerDialog.ui delete mode 100644 gui/dialogs/LoginDialog.cpp delete mode 100644 gui/dialogs/LoginDialog.h delete mode 100644 gui/dialogs/LoginDialog.ui delete mode 100644 gui/dialogs/ModEditDialogCommon.cpp delete mode 100644 gui/dialogs/ModEditDialogCommon.h delete mode 100644 gui/dialogs/NewInstanceDialog.cpp delete mode 100644 gui/dialogs/NewInstanceDialog.h delete mode 100644 gui/dialogs/NewInstanceDialog.ui delete mode 100644 gui/dialogs/NotificationDialog.cpp delete mode 100644 gui/dialogs/NotificationDialog.h delete mode 100644 gui/dialogs/NotificationDialog.ui delete mode 100644 gui/dialogs/ProgressDialog.cpp delete mode 100644 gui/dialogs/ProgressDialog.h delete mode 100644 gui/dialogs/ProgressDialog.ui delete mode 100644 gui/dialogs/UpdateDialog.cpp delete mode 100644 gui/dialogs/UpdateDialog.h delete mode 100644 gui/dialogs/UpdateDialog.ui delete mode 100644 gui/dialogs/VersionSelectDialog.cpp delete mode 100644 gui/dialogs/VersionSelectDialog.h delete mode 100644 gui/dialogs/VersionSelectDialog.ui delete mode 100644 gui/groupview/GroupView.cpp delete mode 100644 gui/groupview/GroupView.h delete mode 100644 gui/groupview/GroupedProxyModel.cpp delete mode 100644 gui/groupview/GroupedProxyModel.h delete mode 100644 gui/groupview/InstanceDelegate.cpp delete mode 100644 gui/groupview/InstanceDelegate.h delete mode 100644 gui/groupview/VisualGroup.cpp delete mode 100644 gui/groupview/VisualGroup.h delete mode 100644 gui/pagedialog/PageDialog.cpp delete mode 100644 gui/pagedialog/PageDialog.h 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 delete mode 100644 gui/widgets/Common.cpp delete mode 100644 gui/widgets/Common.h delete mode 100644 gui/widgets/IconLabel.cpp delete mode 100644 gui/widgets/IconLabel.h delete mode 100644 gui/widgets/LabeledToolButton.cpp delete mode 100644 gui/widgets/LabeledToolButton.h delete mode 100644 gui/widgets/LineSeparator.cpp delete mode 100644 gui/widgets/LineSeparator.h delete mode 100644 gui/widgets/MCModInfoFrame.cpp delete mode 100644 gui/widgets/MCModInfoFrame.h delete mode 100644 gui/widgets/MCModInfoFrame.ui delete mode 100644 gui/widgets/ModListView.cpp delete mode 100644 gui/widgets/ModListView.h delete mode 100644 gui/widgets/PageContainer.cpp delete mode 100644 gui/widgets/PageContainer.h delete mode 100644 gui/widgets/PageContainer_p.h delete mode 100644 gui/widgets/ServerStatus.cpp delete mode 100644 gui/widgets/ServerStatus.h delete mode 100644 gui/widgets/VersionListView.cpp delete mode 100644 gui/widgets/VersionListView.h (limited to 'gui') diff --git a/gui/ColumnResizer.cpp b/gui/ColumnResizer.cpp deleted file mode 100644 index 1c5597aa..00000000 --- a/gui/ColumnResizer.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright 2011 Aurélien Gâteau - * License: LGPL v2.1 or later (see COPYING) - */ -#include "ColumnResizer.h" - -#include -#include -#include -#include -#include -#include - -class FormLayoutWidgetItem : public QWidgetItem -{ -public: - FormLayoutWidgetItem(QWidget* widget, QFormLayout* formLayout, QFormLayout::ItemRole itemRole) - : QWidgetItem(widget) - , m_width(-1) - , m_formLayout(formLayout) - , m_itemRole(itemRole) - {} - - QSize sizeHint() const - { - QSize size = QWidgetItem::sizeHint(); - if (m_width != -1) { - size.setWidth(m_width); - } - return size; - } - - QSize minimumSize() const - { - QSize size = QWidgetItem::minimumSize(); - if (m_width != -1) { - size.setWidth(m_width); - } - return size; - } - - QSize maximumSize() const - { - QSize size = QWidgetItem::maximumSize(); - if (m_width != -1) { - size.setWidth(m_width); - } - return size; - } - - void setWidth(int width) - { - if (width != m_width) { - m_width = width; - invalidate(); - } - } - - void setGeometry(const QRect& _rect) - { - QRect rect = _rect; - int width = widget()->sizeHint().width(); - if (m_itemRole == QFormLayout::LabelRole && m_formLayout->labelAlignment() & Qt::AlignRight) { - rect.setLeft(rect.right() - width); - } - QWidgetItem::setGeometry(rect); - } - - QFormLayout* formLayout() const - { - return m_formLayout; - } - -private: - int m_width; - QFormLayout* m_formLayout; - QFormLayout::ItemRole m_itemRole; -}; - -typedef QPair GridColumnInfo; - -class ColumnResizerPrivate -{ -public: - ColumnResizerPrivate(ColumnResizer* q_ptr) - : q(q_ptr) - , m_updateTimer(new QTimer(q)) - { - m_updateTimer->setSingleShot(true); - m_updateTimer->setInterval(0); - QObject::connect(m_updateTimer, SIGNAL(timeout()), q, SLOT(updateWidth())); - } - - void scheduleWidthUpdate() - { - m_updateTimer->start(); - } - - ColumnResizer* q; - QTimer* m_updateTimer; - QList m_widgets; - QList m_wrWidgetItemList; - QList m_gridColumnInfoList; -}; - -ColumnResizer::ColumnResizer(QObject* parent) -: QObject(parent) -, d(new ColumnResizerPrivate(this)) -{} - -ColumnResizer::~ColumnResizer() -{ - delete d; -} - -void ColumnResizer::addWidget(QWidget* widget) -{ - d->m_widgets.append(widget); - widget->installEventFilter(this); - d->scheduleWidthUpdate(); -} - -void ColumnResizer::updateWidth() -{ - int width = 0; - Q_FOREACH(QWidget* widget, d->m_widgets) { - width = qMax(widget->sizeHint().width(), width); - } - Q_FOREACH(FormLayoutWidgetItem* item, d->m_wrWidgetItemList) { - item->setWidth(width); - item->formLayout()->update(); - } - Q_FOREACH(GridColumnInfo info, d->m_gridColumnInfoList) { - info.first->setColumnMinimumWidth(info.second, width); - } -} - -bool ColumnResizer::eventFilter(QObject*, QEvent* event) -{ - if (event->type() == QEvent::Resize) { - d->scheduleWidthUpdate(); - } - return false; -} - -void ColumnResizer::addWidgetsFromLayout(QLayout* layout, int column) -{ - Q_ASSERT(column >= 0); - QGridLayout* gridLayout = qobject_cast(layout); - QFormLayout* formLayout = qobject_cast(layout); - if (gridLayout) { - addWidgetsFromGridLayout(gridLayout, column); - } else if (formLayout) { - if (column > QFormLayout::SpanningRole) { - qCritical() << "column should not be more than" << QFormLayout::SpanningRole << "for QFormLayout"; - return; - } - QFormLayout::ItemRole role = static_cast(column); - addWidgetsFromFormLayout(formLayout, role); - } else { - qCritical() << "Don't know how to handle layout" << layout; - } -} - -void ColumnResizer::addWidgetsFromGridLayout(QGridLayout* layout, int column) -{ - for (int row = 0; row < layout->rowCount(); ++row) { - QLayoutItem* item = layout->itemAtPosition(row, column); - if (!item) { - continue; - } - QWidget* widget = item->widget(); - if (!widget) { - continue; - } - addWidget(widget); - } - d->m_gridColumnInfoList << GridColumnInfo(layout, column); -} - -void ColumnResizer::addWidgetsFromFormLayout(QFormLayout* layout, QFormLayout::ItemRole role) -{ - for (int row = 0; row < layout->rowCount(); ++row) { - QLayoutItem* item = layout->itemAt(row, role); - if (!item) { - continue; - } - QWidget* widget = item->widget(); - if (!widget) { - continue; - } - layout->removeItem(item); - delete item; - FormLayoutWidgetItem* newItem = new FormLayoutWidgetItem(widget, layout, role); - layout->setItem(row, role, newItem); - addWidget(widget); - d->m_wrWidgetItemList << newItem; - } -} - -#include -// vi: ts=4 sw=4 et diff --git a/gui/ColumnResizer.h b/gui/ColumnResizer.h deleted file mode 100644 index 4bbac383..00000000 --- a/gui/ColumnResizer.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2011 Aurélien Gâteau - * License: LGPL v2.1 or later (see COPYING) - */ -#pragma once - -#include - -#include -#include - -class QEvent; -class QGridLayout; -class QLayout; -class QWidget; - -class ColumnResizerPrivate; -class ColumnResizer : public QObject -{ - Q_OBJECT -public: - ColumnResizer(QObject* parent = 0); - ~ColumnResizer(); - - void addWidget(QWidget* widget); - void addWidgetsFromLayout(QLayout*, int column); - void addWidgetsFromGridLayout(QGridLayout*, int column); - void addWidgetsFromFormLayout(QFormLayout*, QFormLayout::ItemRole role); - -private Q_SLOTS: - void updateWidth(); - -protected: - bool eventFilter(QObject*, QEvent* event); - -private: - ColumnResizerPrivate* const d; -}; diff --git a/gui/ConsoleWindow.cpp b/gui/ConsoleWindow.cpp deleted file mode 100644 index a9c1f455..00000000 --- a/gui/ConsoleWindow.cpp +++ /dev/null @@ -1,260 +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 "ConsoleWindow.h" -#include "MultiMC.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "widgets/PageContainer.h" -#include "pages/LogPage.h" -#include "InstancePageProvider.h" - -#include "logic/icons/IconList.h" - -class LogPageProvider : public BasePageProvider -{ -public: - LogPageProvider(BasePageProviderPtr parent, BasePage * log_page) - { - m_parent = parent; - m_log_page = log_page; - } - virtual QString dialogTitle() {return "Fake";}; - virtual QList getPages() - { - auto pages = m_parent->getPages(); - pages.prepend(m_log_page); - return pages; - } -private: - BasePageProviderPtr m_parent; - BasePage * m_log_page; -}; - -ConsoleWindow::ConsoleWindow(BaseProcess *process, QWidget *parent) - : QMainWindow(parent), m_proc(process) -{ - MultiMCPlatform::fixWM_CLASS(this); - setAttribute(Qt::WA_DeleteOnClose); - - auto instance = m_proc->instance(); - auto icon = ENV.icons()->getIcon(instance->iconKey()); - QString windowTitle = tr("Console window for ") + instance->name(); - - // Set window properties - { - setWindowIcon(icon); - setWindowTitle(windowTitle); - } - - // Add page container - { - auto mainLayout = new QVBoxLayout; - auto provider = std::make_shared(m_proc->instance()); - auto baseprovider = std::dynamic_pointer_cast(provider); - auto proxy_provider = std::make_shared(baseprovider, new LogPage(m_proc)); - m_container = new PageContainer(proxy_provider, "console", this); - mainLayout->addWidget(m_container); - mainLayout->setSpacing(0); - mainLayout->setContentsMargins(0,0,0,0); - setLayout(mainLayout); - setCentralWidget(m_container); - } - - // Add custom buttons to the page container layout. - { - auto horizontalLayout = new QHBoxLayout(); - horizontalLayout->setObjectName(QStringLiteral("horizontalLayout")); - horizontalLayout->setContentsMargins(6, -1, 6, -1); - - auto btnHelp = new QPushButton(); - btnHelp->setText(tr("Help")); - horizontalLayout->addWidget(btnHelp); - connect(btnHelp, SIGNAL(clicked(bool)), m_container, SLOT(help())); - - auto spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - horizontalLayout->addSpacerItem(spacer); - - m_killButton = new QPushButton(); - m_killButton->setText(tr("Kill Minecraft")); - horizontalLayout->addWidget(m_killButton); - connect(m_killButton, SIGNAL(clicked(bool)), SLOT(on_btnKillMinecraft_clicked())); - - m_closeButton = new QPushButton(); - m_closeButton->setText(tr("Close")); - horizontalLayout->addWidget(m_closeButton); - connect(m_closeButton, SIGNAL(clicked(bool)), SLOT(on_closeButton_clicked())); - - m_container->addButtons(horizontalLayout); - } - - // restore window state - { - auto base64State = MMC->settings()->get("ConsoleWindowState").toByteArray(); - restoreState(QByteArray::fromBase64(base64State)); - auto base64Geometry = MMC->settings()->get("ConsoleWindowGeometry").toByteArray(); - restoreGeometry(QByteArray::fromBase64(base64Geometry)); - } - - // Set up tray icon - { - m_trayIcon = new QSystemTrayIcon(icon, this); - m_trayIcon->setToolTip(windowTitle); - - connect(m_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), - SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); - m_trayIcon->show(); - } - - // Set up signal connections - connect(m_proc, SIGNAL(ended(InstancePtr, int, QProcess::ExitStatus)), this, - SLOT(onEnded(InstancePtr, int, QProcess::ExitStatus))); - connect(m_proc, SIGNAL(prelaunch_failed(InstancePtr, int, QProcess::ExitStatus)), this, - SLOT(onEnded(InstancePtr, int, QProcess::ExitStatus))); - connect(m_proc, SIGNAL(launch_failed(InstancePtr)), this, - SLOT(onLaunchFailed(InstancePtr))); - - setMayClose(false); - - if (m_proc->instance()->settings().get("ShowConsole").toBool()) - { - show(); - } -} - -void ConsoleWindow::iconActivated(QSystemTrayIcon::ActivationReason reason) -{ - switch (reason) - { - case QSystemTrayIcon::Trigger: - { - toggleConsole(); - } - default: - return; - } -} - -void ConsoleWindow::on_closeButton_clicked() -{ - close(); -} - -void ConsoleWindow::setMayClose(bool mayclose) -{ - if(mayclose) - m_closeButton->setText(tr("Close")); - else - m_closeButton->setText(tr("Hide")); - m_mayclose = mayclose; -} - -void ConsoleWindow::toggleConsole() -{ - if (isVisible()) - { - if(!isActiveWindow()) - { - activateWindow(); - return; - } - hide(); - } - else - { - show(); - } -} - -void ConsoleWindow::closeEvent(QCloseEvent *event) -{ - if (!m_mayclose) - { - toggleConsole(); - event->ignore(); - } - else if(m_container->requestClose(event)) - { - MMC->settings()->set("ConsoleWindowState", saveState().toBase64()); - MMC->settings()->set("ConsoleWindowGeometry", saveGeometry().toBase64()); - - emit isClosing(); - m_trayIcon->hide(); - event->accept(); - } -} - -void ConsoleWindow::on_btnKillMinecraft_clicked() -{ - m_killButton->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) - m_proc->killProcess(); - else - m_killButton->setEnabled(true); -} - -void ConsoleWindow::onEnded(InstancePtr instance, int code, QProcess::ExitStatus status) -{ - bool peacefulExit = code == 0 && status != QProcess::CrashExit; - m_killButton->setEnabled(false); - setMayClose(true); - if (instance->settings().get("AutoCloseConsole").toBool()) - { - if (peacefulExit) - { - this->close(); - return; - } - } - if (!isVisible()) - { - show(); - } - // Raise Window - if (MMC->settings()->get("RaiseConsole").toBool()) - { - raise(); - activateWindow(); - } -} - -void ConsoleWindow::onLaunchFailed(InstancePtr instance) -{ - m_killButton->setEnabled(false); - - setMayClose(true); - - if (!isVisible()) - show(); -} -ConsoleWindow::~ConsoleWindow() -{ - -} diff --git a/gui/ConsoleWindow.h b/gui/ConsoleWindow.h deleted file mode 100644 index a14cd2fc..00000000 --- a/gui/ConsoleWindow.h +++ /dev/null @@ -1,65 +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 "logic/BaseProcess.h" - -class QPushButton; -class PageContainer; -class ConsoleWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit ConsoleWindow(BaseProcess *proc, QWidget *parent = 0); - virtual ~ConsoleWindow(); - - /** - * @brief specify if the window is allowed to close - * @param mayclose - * used to keep it alive while MC runs - */ - void setMayClose(bool mayclose); - -signals: - void isClosing(); - -private -slots: - void on_closeButton_clicked(); - void on_btnKillMinecraft_clicked(); - - void onEnded(InstancePtr instance, int code, QProcess::ExitStatus status); - void onLaunchFailed(InstancePtr instance); - - // FIXME: add handlers for the other MinecraftProcess signals (pre/post launch command - // failures) - - void iconActivated(QSystemTrayIcon::ActivationReason); - void toggleConsole(); -protected: - void closeEvent(QCloseEvent *); - -private: - BaseProcess *m_proc = nullptr; - bool m_mayclose = true; - QSystemTrayIcon *m_trayIcon = nullptr; - PageContainer *m_container = nullptr; - QPushButton *m_closeButton = nullptr; - QPushButton *m_killButton = nullptr; -}; diff --git a/gui/GuiUtil.cpp b/gui/GuiUtil.cpp deleted file mode 100644 index fcbc8acd..00000000 --- a/gui/GuiUtil.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "GuiUtil.h" - -#include -#include -#include - -#include "dialogs/ProgressDialog.h" -#include "logic/net/PasteUpload.h" -#include "dialogs/CustomMessageBox.h" - -void GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget) -{ - ProgressDialog dialog(parentWidget); - std::unique_ptr paste(new PasteUpload(parentWidget, text)); - - if (!paste->validateText()) - { - CustomMessageBox::selectable( - parentWidget, QObject::tr("Upload failed"), - QObject::tr("The log file is too big. You'll have to upload it manually."), - QMessageBox::Warning)->exec(); - return; - } - - dialog.exec(paste.get()); - if (!paste->successful()) - { - CustomMessageBox::selectable(parentWidget, QObject::tr("Upload failed"), - paste->failReason(), QMessageBox::Critical)->exec(); - } - else - { - const QString link = paste->pasteLink(); - setClipboardText(link); - QDesktopServices::openUrl(link); - CustomMessageBox::selectable( - parentWidget, QObject::tr("Upload finished"), - QObject::tr("The link to the uploaded log has been opened in " - "the default " - "browser and placed in your clipboard.").arg(link), - QMessageBox::Information)->exec(); - } -} - -void GuiUtil::setClipboardText(const QString &text) -{ - QApplication::clipboard()->setText(text); -} diff --git a/gui/GuiUtil.h b/gui/GuiUtil.h deleted file mode 100644 index 9f872f75..00000000 --- a/gui/GuiUtil.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include - -namespace GuiUtil -{ -void uploadPaste(const QString &text, QWidget *parentWidget); -void setClipboardText(const QString &text); -} diff --git a/gui/InstancePageProvider.cpp b/gui/InstancePageProvider.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/gui/InstancePageProvider.h b/gui/InstancePageProvider.h deleted file mode 100644 index d4f7cb91..00000000 --- a/gui/InstancePageProvider.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once -#include "logic/minecraft/OneSixInstance.h" -#include "pages/BasePage.h" -#include "pages/VersionPage.h" -#include "pages/ModFolderPage.h" -#include "pages/ResourcePackPage.h" -#include "pages/TexturePackPage.h" -#include "pages/NotesPage.h" -#include "pages/ScreenshotsPage.h" -#include "pages/InstanceSettingsPage.h" -#include "pages/OtherLogsPage.h" -#include "pages/BasePageProvider.h" -#include - -class InstancePageProvider : public QObject, public BasePageProvider -{ - Q_OBJECT -public: - explicit InstancePageProvider(InstancePtr parent) - { - inst = parent; - } - - virtual ~InstancePageProvider() {}; - virtual QList getPages() override - { - QList values; - std::shared_ptr onesix = std::dynamic_pointer_cast(inst); - if(onesix) - { - values.append(new VersionPage(onesix.get())); - values.append(new ModFolderPage(onesix.get(), onesix->loaderModList(), "mods", "loadermods", - tr("Loader mods"), "Loader-mods")); - values.append(new CoreModFolderPage(onesix.get(), onesix->coreModList(), "coremods", "coremods", - tr("Core mods"), "Core-mods")); - values.append(new ResourcePackPage(onesix.get())); - values.append(new TexturePackPage(onesix.get())); - values.append(new NotesPage(onesix.get())); - values.append(new ScreenshotsPage(PathCombine(onesix->minecraftRoot(), "screenshots"))); - values.append(new InstanceSettingsPage(onesix.get())); - values.append(new OtherLogsPage(onesix->minecraftRoot())); - } - return values; - } - - virtual QString dialogTitle() override - { - return tr("Edit Instance (%1)").arg(inst->name()); - } -protected: - InstancePtr inst; -}; diff --git a/gui/InstanceProxyModel.cpp b/gui/InstanceProxyModel.cpp deleted file mode 100644 index 09d6fd85..00000000 --- a/gui/InstanceProxyModel.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "InstanceProxyModel.h" -#include "MultiMC.h" -#include - -InstanceProxyModel::InstanceProxyModel(QObject *parent) : GroupedProxyModel(parent) -{ -} - -bool InstanceProxyModel::subSortLessThan(const QModelIndex &left, - const QModelIndex &right) const -{ - BaseInstance *pdataLeft = static_cast(left.internalPointer()); - BaseInstance *pdataRight = static_cast(right.internalPointer()); - QString sortMode = MMC->settings()->get("InstSortMode").toString(); - if (sortMode == "LastLaunch") - { - return pdataLeft->lastLaunch() > pdataRight->lastLaunch(); - } - else - { - return QString::localeAwareCompare(pdataLeft->name(), pdataRight->name()) < 0; - } -} diff --git a/gui/InstanceProxyModel.h b/gui/InstanceProxyModel.h deleted file mode 100644 index e558efc4..00000000 --- a/gui/InstanceProxyModel.h +++ /dev/null @@ -1,13 +0,0 @@ -#include "groupview/GroupedProxyModel.h" - -/** - * A proxy model that is responsible for sorting instances into groups - */ -class InstanceProxyModel : public GroupedProxyModel -{ -public: - explicit InstanceProxyModel(QObject *parent = 0); - -protected: - virtual bool subSortLessThan(const QModelIndex &left, const QModelIndex &right) const; -}; diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp deleted file mode 100644 index 0b0af7f4..00000000 --- a/gui/MainWindow.cpp +++ /dev/null @@ -1,2069 +0,0 @@ -/* Copyright 2013-2015 MultiMC Contributors - * - * Authors: Andrew Okin - * Peterix - * Orochimarufan - * - * 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 "BuildConfig.h" - -#include "MainWindow.h" - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class Ui_MainWindow -{ -public: - QAction *actionAddInstance; - QAction *actionViewInstanceFolder; - QAction *actionRefresh; - QAction *actionViewCentralModsFolder; - QAction *actionCheckUpdate; - QAction *actionSettings; - QAction *actionReportBug; - QAction *actionPatreon; - QAction *actionMoreNews; - QAction *actionAbout; - QAction *actionLaunchInstance; - QAction *actionRenameInstance; - QAction *actionChangeInstGroup; - QAction *actionChangeInstIcon; - QAction *actionEditInstNotes; - QAction *actionEditInstance; - QAction *actionViewSelectedInstFolder; - QAction *actionDeleteInstance; - QAction *actionConfig_Folder; - QAction *actionCAT; - QAction *actionCopyInstance; - QAction *actionManageAccounts; - QAction *actionLaunchInstanceOffline; - QAction *actionScreenshots; - QAction *actionInstanceSettings; - QAction *actionExportInstance; - QWidget *centralWidget; - QHBoxLayout *horizontalLayout; - QToolBar *mainToolBar; - QStatusBar *statusBar; - QToolBar *instanceToolBar; - QToolBar *newsToolBar; - - void setupUi(QMainWindow *MainWindow) - { - if (MainWindow->objectName().isEmpty()) - { - MainWindow->setObjectName(QStringLiteral("MainWindow")); - } - MainWindow->resize(694, 563); - MainWindow->setWindowIcon(MMC->getThemedIcon("multimc")); - actionAddInstance = new QAction(MainWindow); - actionAddInstance->setObjectName(QStringLiteral("actionAddInstance")); - actionAddInstance->setIcon(MMC->getThemedIcon("new")); - actionViewInstanceFolder = new QAction(MainWindow); - actionViewInstanceFolder->setObjectName(QStringLiteral("actionViewInstanceFolder")); - actionViewInstanceFolder->setIcon(MMC->getThemedIcon("viewfolder")); - actionRefresh = new QAction(MainWindow); - actionRefresh->setObjectName(QStringLiteral("actionRefresh")); - actionRefresh->setIcon(MMC->getThemedIcon("refresh")); - actionViewCentralModsFolder = new QAction(MainWindow); - actionViewCentralModsFolder->setObjectName(QStringLiteral("actionViewCentralModsFolder")); - actionViewCentralModsFolder->setIcon(MMC->getThemedIcon("centralmods")); - actionCheckUpdate = new QAction(MainWindow); - actionCheckUpdate->setObjectName(QStringLiteral("actionCheckUpdate")); - actionCheckUpdate->setIcon(MMC->getThemedIcon("checkupdate")); - actionSettings = new QAction(MainWindow); - actionSettings->setObjectName(QStringLiteral("actionSettings")); - actionSettings->setIcon(MMC->getThemedIcon("settings")); - actionSettings->setMenuRole(QAction::PreferencesRole); - actionReportBug = new QAction(MainWindow); - actionReportBug->setObjectName(QStringLiteral("actionReportBug")); - actionReportBug->setIcon(MMC->getThemedIcon("bug")); - actionPatreon = new QAction(MainWindow); - actionPatreon->setObjectName(QStringLiteral("actionPatreon")); - actionPatreon->setIcon(MMC->getThemedIcon("patreon")); - actionMoreNews = new QAction(MainWindow); - actionMoreNews->setObjectName(QStringLiteral("actionMoreNews")); - actionMoreNews->setIcon(MMC->getThemedIcon("news")); - actionAbout = new QAction(MainWindow); - actionAbout->setObjectName(QStringLiteral("actionAbout")); - actionAbout->setIcon(MMC->getThemedIcon("about")); - actionAbout->setMenuRole(QAction::AboutRole); - actionLaunchInstance = new QAction(MainWindow); - actionLaunchInstance->setObjectName(QStringLiteral("actionLaunchInstance")); - actionRenameInstance = new QAction(MainWindow); - actionRenameInstance->setObjectName(QStringLiteral("actionRenameInstance")); - actionChangeInstGroup = new QAction(MainWindow); - actionChangeInstGroup->setObjectName(QStringLiteral("actionChangeInstGroup")); - actionChangeInstIcon = new QAction(MainWindow); - actionChangeInstIcon->setObjectName(QStringLiteral("actionChangeInstIcon")); - actionChangeInstIcon->setEnabled(true); - actionChangeInstIcon->setIcon(QIcon(":/icons/instances/infinity")); - actionChangeInstIcon->setIconVisibleInMenu(true); - actionEditInstNotes = new QAction(MainWindow); - actionEditInstNotes->setObjectName(QStringLiteral("actionEditInstNotes")); - actionEditInstance = new QAction(MainWindow); - actionEditInstance->setObjectName(QStringLiteral("actionEditInstance")); - actionViewSelectedInstFolder = new QAction(MainWindow); - actionViewSelectedInstFolder->setObjectName(QStringLiteral("actionViewSelectedInstFolder")); - actionDeleteInstance = new QAction(MainWindow); - actionDeleteInstance->setObjectName(QStringLiteral("actionDeleteInstance")); - actionConfig_Folder = new QAction(MainWindow); - actionConfig_Folder->setObjectName(QStringLiteral("actionConfig_Folder")); - actionCAT = new QAction(MainWindow); - actionCAT->setObjectName(QStringLiteral("actionCAT")); - actionCAT->setCheckable(true); - actionCAT->setIcon(MMC->getThemedIcon("cat")); - actionCopyInstance = new QAction(MainWindow); - actionCopyInstance->setObjectName(QStringLiteral("actionCopyInstance")); - actionCopyInstance->setIcon(MMC->getThemedIcon("copy")); - actionManageAccounts = new QAction(MainWindow); - actionManageAccounts->setObjectName(QStringLiteral("actionManageAccounts")); - actionLaunchInstanceOffline = new QAction(MainWindow); - actionLaunchInstanceOffline->setObjectName(QStringLiteral("actionLaunchInstanceOffline")); - actionScreenshots = new QAction(MainWindow); - actionScreenshots->setObjectName(QStringLiteral("actionScreenshots")); - actionInstanceSettings = new QAction(MainWindow); - actionInstanceSettings->setObjectName(QStringLiteral("actionInstanceSettings")); - actionExportInstance = new QAction(MainWindow); - actionExportInstance->setObjectName(QStringLiteral("actionExportInstance")); - centralWidget = new QWidget(MainWindow); - centralWidget->setObjectName(QStringLiteral("centralWidget")); - horizontalLayout = new QHBoxLayout(centralWidget); - horizontalLayout->setSpacing(0); - horizontalLayout->setContentsMargins(11, 11, 11, 11); - horizontalLayout->setObjectName(QStringLiteral("horizontalLayout")); - horizontalLayout->setSizeConstraint(QLayout::SetDefaultConstraint); - horizontalLayout->setContentsMargins(0, 0, 0, 0); - MainWindow->setCentralWidget(centralWidget); - mainToolBar = new QToolBar(MainWindow); - mainToolBar->setObjectName(QStringLiteral("mainToolBar")); - mainToolBar->setMovable(false); - mainToolBar->setAllowedAreas(Qt::TopToolBarArea); - mainToolBar->setToolButtonStyle(Qt::ToolButtonIconOnly); - mainToolBar->setFloatable(false); - MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar); - statusBar = new QStatusBar(MainWindow); - statusBar->setObjectName(QStringLiteral("statusBar")); - MainWindow->setStatusBar(statusBar); - instanceToolBar = new QToolBar(MainWindow); - instanceToolBar->setObjectName(QStringLiteral("instanceToolBar")); - instanceToolBar->setEnabled(true); - instanceToolBar->setAllowedAreas(Qt::LeftToolBarArea|Qt::RightToolBarArea); - instanceToolBar->setIconSize(QSize(80, 80)); - instanceToolBar->setToolButtonStyle(Qt::ToolButtonIconOnly); - instanceToolBar->setFloatable(false); - MainWindow->addToolBar(Qt::RightToolBarArea, instanceToolBar); - newsToolBar = new QToolBar(MainWindow); - newsToolBar->setObjectName(QStringLiteral("newsToolBar")); - newsToolBar->setMovable(false); - newsToolBar->setAllowedAreas(Qt::BottomToolBarArea); - newsToolBar->setIconSize(QSize(16, 16)); - newsToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - newsToolBar->setFloatable(false); - MainWindow->addToolBar(Qt::BottomToolBarArea, newsToolBar); - - mainToolBar->addAction(actionAddInstance); - mainToolBar->addAction(actionCopyInstance); - mainToolBar->addSeparator(); - mainToolBar->addAction(actionViewInstanceFolder); - mainToolBar->addAction(actionViewCentralModsFolder); - mainToolBar->addAction(actionRefresh); - mainToolBar->addSeparator(); - mainToolBar->addAction(actionCheckUpdate); - mainToolBar->addAction(actionSettings); - mainToolBar->addSeparator(); - mainToolBar->addAction(actionReportBug); - mainToolBar->addAction(actionAbout); - mainToolBar->addSeparator(); - mainToolBar->addAction(actionPatreon); - mainToolBar->addAction(actionCAT); - instanceToolBar->addAction(actionChangeInstIcon); - instanceToolBar->addAction(actionLaunchInstance); - instanceToolBar->addAction(actionLaunchInstanceOffline); - instanceToolBar->addAction(actionChangeInstGroup); - instanceToolBar->addSeparator(); - instanceToolBar->addAction(actionEditInstance); - instanceToolBar->addAction(actionInstanceSettings); - instanceToolBar->addAction(actionEditInstNotes); - instanceToolBar->addAction(actionScreenshots); - instanceToolBar->addSeparator(); - instanceToolBar->addAction(actionViewSelectedInstFolder); - instanceToolBar->addAction(actionConfig_Folder); - instanceToolBar->addSeparator(); - instanceToolBar->addAction(actionExportInstance); - instanceToolBar->addAction(actionDeleteInstance); - newsToolBar->addAction(actionMoreNews); - - retranslateUi(MainWindow); - - QMetaObject::connectSlotsByName(MainWindow); - } // setupUi - - void retranslateUi(QMainWindow *MainWindow) - { - MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MultiMC 5", 0)); - actionAddInstance->setText(QApplication::translate("MainWindow", "Add Instance", 0)); - actionAddInstance->setToolTip(QApplication::translate("MainWindow", "Add a new instance.", 0)); - actionAddInstance->setStatusTip(QApplication::translate("MainWindow", "Add a new instance.", 0)); - actionViewInstanceFolder->setText(QApplication::translate("MainWindow", "View Instance Folder", 0)); - actionViewInstanceFolder->setToolTip(QApplication::translate("MainWindow", "Open the instance folder in a file browser.", 0)); - actionViewInstanceFolder->setStatusTip(QApplication::translate("MainWindow", "Open the instance folder in a file browser.", 0)); - actionRefresh->setText(QApplication::translate("MainWindow", "Refresh", 0)); - actionRefresh->setToolTip(QApplication::translate("MainWindow", "Reload the instance list.", 0)); - actionRefresh->setStatusTip(QApplication::translate("MainWindow", "Reload the instance list.", 0)); - actionViewCentralModsFolder->setText(QApplication::translate("MainWindow", "View Central Mods Folder", 0)); - actionViewCentralModsFolder->setToolTip(QApplication::translate("MainWindow", "Open the central mods folder in a file browser.", 0)); - actionViewCentralModsFolder->setStatusTip(QApplication::translate("MainWindow", "Open the central mods folder in a file browser.", 0)); - actionCheckUpdate->setText(QApplication::translate("MainWindow", "Check for Updates", 0)); - actionCheckUpdate->setToolTip(QApplication::translate("MainWindow", "Check for new updates for MultiMC", 0)); - actionCheckUpdate->setStatusTip(QApplication::translate("MainWindow", "Check for new updates for MultiMC", 0)); - actionSettings->setText(QApplication::translate("MainWindow", "Settings", 0)); - actionSettings->setToolTip(QApplication::translate("MainWindow", "Change settings.", 0)); - actionSettings->setStatusTip(QApplication::translate("MainWindow", "Change settings.", 0)); - actionReportBug->setText(QApplication::translate("MainWindow", "Report a Bug", 0)); - actionReportBug->setToolTip(QApplication::translate("MainWindow", "Open the bug tracker to report a bug with MultiMC.", 0)); - actionReportBug->setStatusTip(QApplication::translate("MainWindow", "Open the bug tracker to report a bug with MultiMC.", 0)); - actionPatreon->setText(QApplication::translate("MainWindow", "Support us on Patreon!", 0)); - actionPatreon->setToolTip(QApplication::translate("MainWindow", "Open the MultiMC Patreon page.", 0)); - actionPatreon->setStatusTip(QApplication::translate("MainWindow", "Open the MultiMC Patreon page.", 0)); - actionMoreNews->setText(QApplication::translate("MainWindow", "More News", 0)); - actionMoreNews->setIconText(QApplication::translate("MainWindow", "More news...", 0)); - actionMoreNews->setToolTip(QApplication::translate("MainWindow", "Open the MultiMC development blog to read more news about MultiMC.", 0)); - actionMoreNews->setStatusTip(QApplication::translate("MainWindow", "Open the MultiMC development blog to read more news about MultiMC.", 0)); - actionAbout->setText(QApplication::translate("MainWindow", "About MultiMC", 0)); - actionAbout->setToolTip(QApplication::translate("MainWindow", "View information about MultiMC.", 0)); - actionAbout->setStatusTip(QApplication::translate("MainWindow", "About MultiMC", 0)); - actionLaunchInstance->setText(QApplication::translate("MainWindow", "Play", 0)); - actionLaunchInstance->setToolTip(QApplication::translate("MainWindow", "Launch the selected instance.", 0)); - actionLaunchInstance->setStatusTip(QApplication::translate("MainWindow", "Launch the selected instance.", 0)); - actionRenameInstance->setText(QApplication::translate("MainWindow", "Instance Name", 0)); - actionRenameInstance->setToolTip(QApplication::translate("MainWindow", "Rename the selected instance.", 0)); - actionRenameInstance->setStatusTip(QApplication::translate("MainWindow", "Rename the selected instance.", 0)); - actionChangeInstGroup->setText(QApplication::translate("MainWindow", "Change Group", 0)); - actionChangeInstGroup->setToolTip(QApplication::translate("MainWindow", "Change the selected instance's group.", 0)); - actionChangeInstGroup->setStatusTip(QApplication::translate("MainWindow", "Change the selected instance's group.", 0)); - actionChangeInstIcon->setText(QApplication::translate("MainWindow", "Change Icon", 0)); - actionChangeInstIcon->setToolTip(QApplication::translate("MainWindow", "Change the selected instance's icon.", 0)); - actionChangeInstIcon->setStatusTip(QApplication::translate("MainWindow", "Change the selected instance's icon.", 0)); - actionEditInstNotes->setText(QApplication::translate("MainWindow", "Edit Notes", 0)); - actionEditInstNotes->setToolTip(QApplication::translate("MainWindow", "Edit the notes for the selected instance.", 0)); - actionEditInstNotes->setStatusTip(QApplication::translate("MainWindow", "Edit the notes for the selected instance.", 0)); - actionEditInstance->setText(QApplication::translate("MainWindow", "Edit Instance", 0)); - actionEditInstance->setIconText(QApplication::translate("MainWindow", "Edit Instance", 0)); - actionEditInstance->setToolTip(QApplication::translate("MainWindow", "Change the instance settings, mods and versions.", 0)); - actionEditInstance->setStatusTip(QApplication::translate("MainWindow", "Change the instance settings, mods and versions.", 0)); - actionViewSelectedInstFolder->setText(QApplication::translate("MainWindow", "Instance Folder", 0)); - actionViewSelectedInstFolder->setToolTip(QApplication::translate("MainWindow", "Open the selected instance's root folder in a file browser.", 0)); - actionViewSelectedInstFolder->setStatusTip(QApplication::translate("MainWindow", "Open the selected instance's root folder in a file browser.", 0)); - actionDeleteInstance->setText(QApplication::translate("MainWindow", "Delete", 0)); - actionDeleteInstance->setToolTip(QApplication::translate("MainWindow", "Delete the selected instance.", 0)); - actionDeleteInstance->setStatusTip(QApplication::translate("MainWindow", "Delete the selected instance.", 0)); - actionConfig_Folder->setText(QApplication::translate("MainWindow", "Config Folder", 0)); - actionConfig_Folder->setToolTip(QApplication::translate("MainWindow", "Open the instance's config folder", 0)); - actionCAT->setText(QApplication::translate("MainWindow", "Meow", 0)); - actionCAT->setToolTip(QApplication::translate("MainWindow", "

It's a fluffy kitty :3

", 0)); - actionCopyInstance->setText(QApplication::translate("MainWindow", "Copy Instance", 0)); - actionCopyInstance->setToolTip(QApplication::translate("MainWindow", "Copy the selected instance.", 0)); - actionCopyInstance->setStatusTip(QApplication::translate("MainWindow", "Add a new instance.", 0)); - actionManageAccounts->setText(QApplication::translate("MainWindow", "Manage Accounts", 0)); - actionManageAccounts->setToolTip(QApplication::translate("MainWindow", "Manage your Mojang or Minecraft accounts.", 0)); - actionLaunchInstanceOffline->setText(QApplication::translate("MainWindow", "Play Offline", 0)); - actionLaunchInstanceOffline->setToolTip(QApplication::translate("MainWindow", "Launch the selected instance in offline mode.", 0)); - actionLaunchInstanceOffline->setStatusTip(QApplication::translate("MainWindow", "Launch the selected instance.", 0)); - actionScreenshots->setText(QApplication::translate("MainWindow", "Manage Screenshots", 0)); - actionScreenshots->setToolTip(QApplication::translate("MainWindow", "

View and upload screenshots for this instance

", 0)); - actionInstanceSettings->setText(QApplication::translate("MainWindow", "Instance Settings", 0)); - actionInstanceSettings->setToolTip(QApplication::translate("MainWindow", "Change the settings specific to the instance", 0)); - actionExportInstance->setText(QApplication::translate("MainWindow", "Export Instance", 0)); - mainToolBar->setWindowTitle(QApplication::translate("MainWindow", "Main Toolbar", 0)); - instanceToolBar->setWindowTitle(QApplication::translate("MainWindow", "Instance Toolbar", 0)); - newsToolBar->setWindowTitle(QApplication::translate("MainWindow", "News Toolbar", 0)); - } // retranslateUi - -}; - -namespace Ui { - class MainWindow: public Ui_MainWindow {}; -} // namespace Ui - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "osutils.h" -#include "userutils.h" -#include "pathutils.h" - -#include "gui/groupview/GroupView.h" -#include "gui/groupview/InstanceDelegate.h" -#include "gui/InstanceProxyModel.h" - -#include "gui/Platform.h" - -#include "gui/widgets/LabeledToolButton.h" -#include "widgets/ServerStatus.h" - -#include "gui/dialogs/NewInstanceDialog.h" -#include "gui/dialogs/ProgressDialog.h" -#include "gui/dialogs/AboutDialog.h" -#include "gui/dialogs/VersionSelectDialog.h" -#include "gui/dialogs/CustomMessageBox.h" -#include "gui/dialogs/IconPickerDialog.h" -#include "gui/dialogs/CopyInstanceDialog.h" -#include "gui/dialogs/AccountSelectDialog.h" -#include "gui/dialogs/UpdateDialog.h" -#include "gui/dialogs/EditAccountDialog.h" -#include "gui/dialogs/NotificationDialog.h" - -#include "gui/pages/global/MultiMCPage.h" -#include "gui/pages/global/ExternalToolsPage.h" -#include "gui/pages/global/AccountListPage.h" -#include "gui/pages/global/ProxyPage.h" -#include "gui/pages/global/JavaPage.h" -#include "gui/pages/global/MinecraftPage.h" - -#include "gui/ConsoleWindow.h" -#include "pagedialog/PageDialog.h" - -#include "logic/InstanceList.h" -#include "logic/minecraft/MinecraftVersionList.h" -#include "logic/minecraft/LwjglVersionList.h" -#include "logic/icons/IconList.h" -#include "logic/java/JavaVersionList.h" - -#include "logic/auth/flows/AuthenticateTask.h" -#include "logic/auth/flows/RefreshTask.h" - -#include "logic/updater/DownloadTask.h" - -#include "logic/news/NewsChecker.h" - -#include "logic/net/URLConstants.h" -#include "logic/net/NetJob.h" -#include "logic/Env.h" - -#include "logic/BaseInstance.h" -#include "logic/BaseProcess.h" -#include "logic/java/JavaUtils.h" -#include "gui/NagUtils.h" -#include "InstancePageProvider.h" -#include "logic/minecraft/SkinUtils.h" - -//#include "logic/minecraft/LegacyInstance.h" - -#include -#include -#include -#include "logic/net/CacheDownload.h" - -#include "logic/tools/BaseProfiler.h" - -MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) -{ - MultiMCPlatform::fixWM_CLASS(this); - ui->setupUi(this); - - // initialize the news checker - m_newsChecker.reset(new NewsChecker(BuildConfig.NEWS_RSS_URL)); - - QString winTitle = - QString("MultiMC 5 - Version %1").arg(BuildConfig.printableVersionString()); - if (!BuildConfig.BUILD_PLATFORM.isEmpty()) - winTitle += " on " + BuildConfig.BUILD_PLATFORM; - setWindowTitle(winTitle); - - // OSX magic. - setUnifiedTitleAndToolBarOnMac(true); - - // Global shortcuts - { - // FIXME: This is kinda weird. and bad. We need some kind of managed shutdown. - auto q = new QShortcut(QKeySequence::Quit, this); - connect(q, SIGNAL(activated()), qApp, SLOT(quit())); - } - - // The instance action toolbar customizations - { - // disabled until we have an instance selected - ui->instanceToolBar->setEnabled(false); - - // the rename label is inside the rename tool button - renameButton = new LabeledToolButton(); - renameButton->setText("Instance Name"); - renameButton->setToolTip(ui->actionRenameInstance->toolTip()); - connect(renameButton, SIGNAL(clicked(bool)), SLOT(on_actionRenameInstance_triggered())); - ui->instanceToolBar->insertWidget(ui->actionLaunchInstance, renameButton); - ui->instanceToolBar->insertSeparator(ui->actionLaunchInstance); - renameButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - } - - // Add the news label to the news toolbar. - { - newsLabel = new QToolButton(); - newsLabel->setIcon(MMC->getThemedIcon("news")); - newsLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - newsLabel->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - ui->newsToolBar->insertWidget(ui->actionMoreNews, newsLabel); - QObject::connect(newsLabel, &QAbstractButton::clicked, this, - &MainWindow::newsButtonClicked); - QObject::connect(m_newsChecker.get(), &NewsChecker::newsLoaded, this, - &MainWindow::updateNewsLabel); - updateNewsLabel(); - } - - // Create the instance list widget - { - view = new GroupView(ui->centralWidget); - - view->setSelectionMode(QAbstractItemView::SingleSelection); - // view->setCategoryDrawer(drawer); - // view->setCollapsibleBlocks(true); - // view->setViewMode(QListView::IconMode); - // view->setFlow(QListView::LeftToRight); - // view->setWordWrap(true); - // view->setMouseTracking(true); - // view->viewport()->setAttribute(Qt::WA_Hover); - auto delegate = new ListViewDelegate(); - view->setItemDelegate(delegate); - // view->setSpacing(10); - // view->setUniformItemWidths(true); - - // do not show ugly blue border on the mac - view->setAttribute(Qt::WA_MacShowFocusRect, false); - - view->installEventFilter(this); - - proxymodel = new InstanceProxyModel(this); - // proxymodel->setSortRole(KCategorizedSortFilterProxyModel::CategorySortRole); - // proxymodel->setFilterRole(KCategorizedSortFilterProxyModel::CategorySortRole); - // proxymodel->setDynamicSortFilter ( true ); - - // FIXME: instList should be global-ish, or at least not tied to the main window... - // maybe the application itself? - proxymodel->setSourceModel(MMC->instances().get()); - proxymodel->sort(0); - view->setFrameShape(QFrame::NoFrame); - view->setModel(proxymodel); - - view->setContextMenuPolicy(Qt::CustomContextMenu); - connect(view, SIGNAL(customContextMenuRequested(const QPoint &)), this, - SLOT(showInstanceContextMenu(const QPoint &))); - - ui->horizontalLayout->addWidget(view); - } - // The cat background - { - bool cat_enable = MMC->settings()->get("TheCat").toBool(); - ui->actionCAT->setChecked(cat_enable); - connect(ui->actionCAT, SIGNAL(toggled(bool)), SLOT(onCatToggled(bool))); - setCatBackground(cat_enable); - } - // start instance when double-clicked - connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, - SLOT(instanceActivated(const QModelIndex &))); - // track the selection -- update the instance toolbar - connect(view->selectionModel(), - SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, - SLOT(instanceChanged(const QModelIndex &, const QModelIndex &))); - - // track icon changes and update the toolbar! - connect(ENV.icons().get(), SIGNAL(iconUpdated(QString)), SLOT(iconUpdated(QString))); - - // model reset -> selection is invalid. All the instance pointers are wrong. - // FIXME: stop using POINTERS everywhere - connect(MMC->instances().get(), SIGNAL(dataIsInvalid()), SLOT(selectionBad())); - - m_statusLeft = new QLabel(tr("No instance selected"), this); - m_statusRight = new ServerStatus(this); - statusBar()->addPermanentWidget(m_statusLeft, 1); - statusBar()->addPermanentWidget(m_statusRight, 0); - - // Add "manage accounts" button, right align - QWidget *spacer = new QWidget(); - spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - ui->mainToolBar->addWidget(spacer); - - accountMenu = new QMenu(this); - manageAccountsAction = new QAction(tr("Manage Accounts"), this); - manageAccountsAction->setCheckable(false); - connect(manageAccountsAction, SIGNAL(triggered(bool)), this, - SLOT(on_actionManageAccounts_triggered())); - - repopulateAccountsMenu(); - - accountMenuButton = new QToolButton(this); - accountMenuButton->setText(tr("Accounts")); - accountMenuButton->setMenu(accountMenu); - accountMenuButton->setPopupMode(QToolButton::InstantPopup); - accountMenuButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - accountMenuButton->setIcon(MMC->getThemedIcon("noaccount")); - - QWidgetAction *accountMenuButtonAction = new QWidgetAction(this); - accountMenuButtonAction->setDefaultWidget(accountMenuButton); - - ui->mainToolBar->addAction(accountMenuButtonAction); - - // set up global pages dialog - { - m_globalSettingsProvider = std::make_shared(tr("Settings")); - m_globalSettingsProvider->addPage(); - m_globalSettingsProvider->addPage(); - m_globalSettingsProvider->addPage(); - m_globalSettingsProvider->addPage(); - m_globalSettingsProvider->addPage(); - m_globalSettingsProvider->addPage(); - } - - // Update the menu when the active account changes. - // Shouldn't have to use lambdas here like this, but if I don't, the compiler throws a fit. - // Template hell sucks... - connect(MMC->accounts().get(), &MojangAccountList::activeAccountChanged, [this] - { activeAccountChanged(); }); - connect(MMC->accounts().get(), &MojangAccountList::listChanged, [this] - { repopulateAccountsMenu(); }); - - // Show initial account - activeAccountChanged(); - - auto accounts = MMC->accounts(); - - QList skin_dls; - for (int i = 0; i < accounts->count(); i++) - { - auto account = accounts->at(i); - if (account != nullptr) - { - for (auto profile : account->profiles()) - { - auto meta = Env::getInstance().metacache()->resolveEntry("skins", profile.name + ".png"); - auto action = CacheDownload::make( - QUrl("http://" + URLConstants::SKINS_BASE + profile.name + ".png"), meta); - skin_dls.append(action); - meta->stale = true; - } - } - } - if (!skin_dls.isEmpty()) - { - auto job = new NetJob("Startup player skins download"); - connect(job, SIGNAL(succeeded()), SLOT(skinJobFinished())); - connect(job, SIGNAL(failed()), SLOT(skinJobFinished())); - for (auto action : skin_dls) - { - job->addNetAction(action); - } - skin_download_job.reset(job); - job->start(); - } - - // run the things that load and download other things... FIXME: this is NOT the place - // FIXME: invisible actions in the background = NOPE. - { - if (!MMC->minecraftlist()->isLoaded()) - { - m_versionLoadTask = MMC->minecraftlist()->getLoadTask(); - startTask(m_versionLoadTask); - } - if (!MMC->lwjgllist()->isLoaded()) - { - MMC->lwjgllist()->loadList(); - } - - m_newsChecker->reloadNews(); - updateNewsLabel(); - - // set up the updater object. - auto updater = MMC->updateChecker(); - connect(updater.get(), &UpdateChecker::updateAvailable, this, - &MainWindow::updateAvailable); - connect(updater.get(), &UpdateChecker::noUpdateFound, this, - &MainWindow::updateNotAvailable); - // if automatic update checks are allowed, start one. - if (MMC->settings()->get("AutoUpdate").toBool()) - { - auto updater = MMC->updateChecker(); - updater->checkForUpdate(MMC->settings()->get("UpdateChannel").toString(), false); - } - auto checker = new NotificationChecker(); - checker->setNotificationsUrl(QUrl(BuildConfig.NOTIFICATION_URL)); - checker->setApplicationChannel(BuildConfig.VERSION_CHANNEL); - checker->setApplicationPlatform(BuildConfig.BUILD_PLATFORM); - checker->setApplicationFullVersion(BuildConfig.FULL_VERSION_STR); - m_notificationChecker.reset(checker); - connect(m_notificationChecker.get(), - &NotificationChecker::notificationCheckFinished, this, - &MainWindow::notificationsChanged); - checker->checkForNotifications(); - } - - setSelectedInstanceById(MMC->settings()->get("SelectedInstance").toString()); - - // removing this looks stupid - view->setFocus(); -} - -MainWindow::~MainWindow() -{ - delete ui; - delete proxymodel; -} - -void MainWindow::skinJobFinished() -{ - activeAccountChanged(); - skin_download_job.reset(); -} - -void MainWindow::showInstanceContextMenu(const QPoint &pos) -{ - QList actions; - - QAction *actionSep = new QAction("", this); - actionSep->setSeparator(true); - - bool onInstance = view->indexAt(pos).isValid(); - if (onInstance) - { - actions = ui->instanceToolBar->actions(); - - QAction *actionVoid = new QAction(m_selectedInstance->name(), this); - actionVoid->setEnabled(false); - - QAction *actionRename = new QAction(tr("Rename"), this); - actionRename->setToolTip(ui->actionRenameInstance->toolTip()); - - QAction *actionCopyInstance = new QAction(tr("Copy instance"), this); - actionCopyInstance->setToolTip(ui->actionCopyInstance->toolTip()); - - connect(actionRename, SIGNAL(triggered(bool)), - SLOT(on_actionRenameInstance_triggered())); - connect(actionCopyInstance, SIGNAL(triggered(bool)), - SLOT(on_actionCopyInstance_triggered())); - - actions.replace(1, actionRename); - actions.prepend(actionSep); - actions.prepend(actionVoi