2022-06-12 17:20:58 +05:30
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
/*
|
|
|
|
* PolyMC - Minecraft Launcher
|
|
|
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
2013-01-09 23:52:22 +05:30
|
|
|
*
|
2022-06-12 17:20:58 +05:30
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, version 3.
|
2013-10-06 06:37:57 +05:30
|
|
|
*
|
2022-06-12 17:20:58 +05:30
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2013-01-09 23:52:22 +05:30
|
|
|
*
|
2022-06-12 17:20:58 +05:30
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following copyright and
|
|
|
|
* permission notice:
|
|
|
|
*
|
|
|
|
* Copyright 2013-2021 MultiMC Contributors
|
|
|
|
*
|
|
|
|
* Authors: Andrew Okin
|
|
|
|
* Peterix
|
|
|
|
* Orochimarufan <orochimarufan.x3@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2013-01-09 23:52:22 +05:30
|
|
|
*/
|
|
|
|
|
2013-11-04 07:23:05 +05:30
|
|
|
#pragma once
|
2013-01-09 23:52:22 +05:30
|
|
|
|
2015-10-20 20:48:53 +05:30
|
|
|
#include <memory>
|
|
|
|
|
2013-01-09 23:52:22 +05:30
|
|
|
#include <QMainWindow>
|
2013-11-12 13:53:39 +05:30
|
|
|
#include <QProcess>
|
2014-01-12 23:58:42 +05:30
|
|
|
#include <QTimer>
|
2013-01-09 23:52:22 +05:30
|
|
|
|
2015-02-09 06:21:14 +05:30
|
|
|
#include "BaseInstance.h"
|
2021-07-27 01:14:11 +05:30
|
|
|
#include "minecraft/auth/MinecraftAccount.h"
|
2015-02-09 06:21:14 +05:30
|
|
|
#include "net/NetJob.h"
|
|
|
|
#include "updater/GoUpdate.h"
|
2013-11-21 06:01:15 +05:30
|
|
|
|
2015-07-05 05:24:30 +05:30
|
|
|
class LaunchController;
|
2022-02-10 17:25:07 +05:30
|
|
|
class NewsChecker;
|
2013-11-04 01:58:04 +05:30
|
|
|
class QToolButton;
|
2015-02-01 16:14:47 +05:30
|
|
|
class InstanceProxyModel;
|
2013-08-26 02:18:41 +05:30
|
|
|
class LabeledToolButton;
|
2013-08-25 05:02:42 +05:30
|
|
|
class QLabel;
|
2015-05-12 01:51:37 +05:30
|
|
|
class MinecraftLauncher;
|
2014-02-16 02:56:44 +05:30
|
|
|
class BaseProfilerFactory;
|
2021-10-26 03:21:42 +05:30
|
|
|
class InstanceView;
|
2018-03-15 13:57:45 +05:30
|
|
|
class KonamiCode;
|
2018-03-19 07:06:12 +05:30
|
|
|
class InstanceTask;
|
2013-01-09 23:52:22 +05:30
|
|
|
|
|
|
|
class MainWindow : public QMainWindow
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
Q_OBJECT
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
class Ui;
|
2015-10-20 20:48:53 +05:30
|
|
|
|
2013-01-09 23:52:22 +05:30
|
|
|
public:
|
2018-07-15 18:21:05 +05:30
|
|
|
explicit MainWindow(QWidget *parent = 0);
|
|
|
|
~MainWindow();
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
bool eventFilter(QObject *obj, QEvent *ev) override;
|
|
|
|
void closeEvent(QCloseEvent *event) override;
|
|
|
|
void changeEvent(QEvent * event) override;
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void checkInstancePathForProblems();
|
2013-10-14 07:29:21 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void updatesAllowedChanged(bool allowed);
|
2020-02-05 04:59:23 +05:30
|
|
|
|
|
|
|
void droppedURLs(QList<QUrl> urls);
|
2017-05-01 04:57:10 +05:30
|
|
|
signals:
|
2018-07-15 18:21:05 +05:30
|
|
|
void isClosing();
|
2017-05-01 04:57:10 +05:30
|
|
|
|
2019-07-16 05:00:09 +05:30
|
|
|
protected:
|
|
|
|
QMenu * createPopupMenu() override;
|
|
|
|
|
2015-10-20 20:48:53 +05:30
|
|
|
private slots:
|
2018-07-15 18:21:05 +05:30
|
|
|
void onCatToggled(bool);
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionAbout_triggered();
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionAddInstance_triggered();
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionREDDIT_triggered();
|
2015-09-16 02:32:21 +05:30
|
|
|
|
2022-03-08 23:11:23 +05:30
|
|
|
void on_actionMATRIX_triggered();
|
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionDISCORD_triggered();
|
2016-01-09 06:09:51 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionCopyInstance_triggered();
|
2013-11-04 01:58:04 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionChangeInstGroup_triggered();
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionChangeInstIcon_triggered();
|
|
|
|
void on_changeIconButton_clicked(bool)
|
|
|
|
{
|
|
|
|
on_actionChangeInstIcon_triggered();
|
|
|
|
}
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionViewInstanceFolder_triggered();
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionViewSelectedInstFolder_triggered();
|
2018-07-28 03:27:09 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void refreshInstances();
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionViewCentralModsFolder_triggered();
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void checkForUpdates();
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionSettings_triggered();
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionManageAccounts_triggered();
|
2013-11-20 23:50:35 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionReportBug_triggered();
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2022-10-10 16:15:44 +05:30
|
|
|
void on_actionClearMetadata_triggered();
|
|
|
|
|
2022-04-09 01:07:18 +05:30
|
|
|
void on_actionOpenWiki_triggered();
|
|
|
|
|
2022-02-10 17:25:07 +05:30
|
|
|
void on_actionMoreNews_triggered();
|
|
|
|
|
|
|
|
void newsButtonClicked();
|
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionLaunchInstance_triggered();
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionLaunchInstanceOffline_triggered();
|
2014-01-27 07:30:49 +05:30
|
|
|
|
2022-07-12 00:16:11 +05:30
|
|
|
void on_actionLaunchInstanceDemo_triggered();
|
|
|
|
|
2022-06-20 00:03:34 +05:30
|
|
|
void on_actionKillInstance_triggered();
|
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionDeleteInstance_triggered();
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void deleteGroup();
|
2022-07-30 23:12:33 +05:30
|
|
|
void undoTrashInstance();
|
2016-04-11 05:00:50 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionExportInstance_triggered();
|
2015-02-13 02:31:20 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionRenameInstance_triggered();
|
|
|
|
void on_renameButton_clicked(bool)
|
|
|
|
{
|
|
|
|
on_actionRenameInstance_triggered();
|
|
|
|
}
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void on_actionEditInstance_triggered();
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2022-10-22 18:09:53 +05:30
|
|
|
void on_actionCreateInstanceShortcut_triggered();
|
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void taskEnd();
|
2013-03-12 02:49:17 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
/**
|
|
|
|
* called when an icon is changed in the icon model.
|
|
|
|
*/
|
|
|
|
void iconUpdated(QString);
|
2013-12-31 05:54:28 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void showInstanceContextMenu(const QPoint &);
|
2014-02-24 02:44:24 +05:30
|
|
|
|
2022-04-16 03:55:37 +05:30
|
|
|
void updateMainToolBar();
|
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void updateToolsMenu();
|
2014-02-16 16:19:55 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void instanceActivated(QModelIndex);
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void instanceChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
2013-07-15 01:31:30 +05:30
|
|
|
|
2019-06-23 18:24:17 +05:30
|
|
|
void instanceSelectRequest(QString id);
|
2019-06-17 19:43:52 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void instanceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
|
2015-04-07 04:51:03 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void selectionBad();
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void startTask(Task *task);
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void updateAvailable(GoUpdate::Status status);
|
2013-12-02 05:25:24 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void updateNotAvailable();
|
2014-07-14 04:27:54 +05:30
|
|
|
|
2021-11-20 20:52:22 +05:30
|
|
|
void defaultAccountChanged();
|
2013-11-27 22:26:15 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void changeActiveAccount();
|
2013-11-28 04:09:49 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void repopulateAccountsMenu();
|
2014-01-03 00:55:38 +05:30
|
|
|
|
2022-02-10 17:25:07 +05:30
|
|
|
void updateNewsLabel();
|
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
/*!
|
|
|
|
* Runs the DownloadTask and installs updates.
|
|
|
|
*/
|
|
|
|
void downloadUpdates(GoUpdate::Status status);
|
2013-11-28 04:09:49 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void konamiTriggered();
|
2018-03-15 13:57:45 +05:30
|
|
|
|
2019-06-01 15:58:53 +05:30
|
|
|
void globalSettingsClosed();
|
|
|
|
|
2022-10-26 03:52:11 +05:30
|
|
|
void lockToolbars(bool);
|
|
|
|
|
2022-04-09 02:30:42 +05:30
|
|
|
#ifndef Q_OS_MAC
|
2022-04-09 01:51:52 +05:30
|
|
|
void keyReleaseEvent(QKeyEvent *event) override;
|
2022-04-09 02:30:42 +05:30
|
|
|
#endif
|
2022-04-09 01:51:52 +05:30
|
|
|
|
2022-06-10 13:18:18 +05:30
|
|
|
void refreshCurrentInstance(bool running);
|
2022-06-10 07:55:13 +05:30
|
|
|
|
2015-10-20 20:48:53 +05:30
|
|
|
private:
|
2021-06-19 04:42:54 +05:30
|
|
|
void retranslateUi();
|
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void addInstance(QString url = QString());
|
|
|
|
void activateInstance(InstancePtr instance);
|
|
|
|
void setCatBackground(bool enabled);
|
|
|
|
void updateInstanceToolIcon(QString new_icon);
|
|
|
|
void setSelectedInstanceById(const QString &id);
|
2019-07-10 07:53:24 +05:30
|
|
|
void updateStatusCenter();
|
2013-10-06 06:37:57 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void runModalTask(Task *task);
|
|
|
|
void instanceFromInstanceTask(InstanceTask *task);
|
|
|
|
void finalizeInstance(InstancePtr inst);
|
2015-01-28 03:01:07 +05:30
|
|
|
|
2013-01-09 23:52:22 +05:30
|
|
|
private:
|
2018-07-15 18:21:05 +05:30
|
|
|
std::unique_ptr<Ui> ui;
|
|
|
|
|
|
|
|
// these are managed by Qt's memory management model!
|
2021-10-26 03:21:42 +05:30
|
|
|
InstanceView *view = nullptr;
|
2018-07-15 18:21:05 +05:30
|
|
|
InstanceProxyModel *proxymodel = nullptr;
|
2022-02-10 17:25:07 +05:30
|
|
|
QToolButton *newsLabel = nullptr;
|
2018-07-15 18:21:05 +05:30
|
|
|
QLabel *m_statusLeft = nullptr;
|
2019-07-10 07:53:24 +05:30
|
|
|
QLabel *m_statusCenter = nullptr;
|
2018-07-15 18:21:05 +05:30
|
|
|
QMenu *accountMenu = nullptr;
|
|
|
|
QToolButton *accountMenuButton = nullptr;
|
|
|
|
KonamiCode * secretEventFilter = nullptr;
|
|
|
|
|
2022-02-10 17:25:07 +05:30
|
|
|
unique_qobject_ptr<NewsChecker> m_newsChecker;
|
2018-07-15 18:21:05 +05:30
|
|
|
|
|
|
|
InstancePtr m_selectedInstance;
|
|
|
|
QString m_currentInstIcon;
|
|
|
|
|
|
|
|
// managed by the application object
|
|
|
|
Task *m_versionLoadTask = nullptr;
|
2013-01-09 23:52:22 +05:30
|
|
|
};
|
2022-01-10 00:21:46 +05:30
|
|
|
|