PrismLauncher/launcher/ui/MainWindow.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

257 lines
6.6 KiB
C
Raw Normal View History

2022-06-12 12:50:58 +01:00
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
2022-06-12 12:50:58 +01:00
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
2013-01-09 18:22:22 +00:00
*
2022-06-12 12:50:58 +01:00
* 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.
*
2022-06-12 12:50:58 +01:00
* 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 18:22:22 +00:00
*
2022-06-12 12:50:58 +01:00
* 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 18:22:22 +00:00
*/
#pragma once
2013-01-09 18:22:22 +00:00
#include <memory>
2013-01-09 18:22:22 +00:00
#include <QMainWindow>
#include <QProcess>
#include <QTimer>
2013-01-09 18:22:22 +00:00
2015-02-09 00:51:14 +00:00
#include "BaseInstance.h"
#include "minecraft/auth/MinecraftAccount.h"
2015-02-09 00:51:14 +00:00
#include "net/NetJob.h"
class LaunchController;
class NewsChecker;
class QToolButton;
class InstanceProxyModel;
class LabeledToolButton;
class QLabel;
class MinecraftLauncher;
class BaseProfilerFactory;
class InstanceView;
class KonamiCode;
2018-03-19 01:36:12 +00:00
class InstanceTask;
class LabeledToolButton;
2013-01-09 18:22:22 +00:00
namespace Ui
{
class MainWindow;
}
2013-01-09 18:22:22 +00:00
class MainWindow : public QMainWindow
{
Q_OBJECT
2013-01-09 18:22:22 +00:00
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
bool eventFilter(QObject *obj, QEvent *ev) override;
void closeEvent(QCloseEvent *event) override;
void changeEvent(QEvent * event) override;
void checkInstancePathForProblems();
void updatesAllowedChanged(bool allowed);
void processURLs(QList<QUrl> urls);
signals:
void isClosing();
protected:
QMenu * createPopupMenu() override;
private slots:
void onCatToggled(bool);
void onCatChanged(int);
2013-01-09 18:22:22 +00:00
void on_actionAbout_triggered();
2013-01-09 18:22:22 +00:00
void on_actionAddInstance_triggered();
2015-09-15 22:02:21 +01:00
void on_actionREDDIT_triggered();
2022-03-08 17:41:23 +00:00
void on_actionMATRIX_triggered();
void on_actionDISCORD_triggered();
void on_actionCopyInstance_triggered();
void on_actionChangeInstGroup_triggered();
void on_actionChangeInstIcon_triggered();
void on_actionViewLauncherRootFolder_triggered();
void on_actionViewInstanceFolder_triggered();
void on_actionViewCentralModsFolder_triggered();
void on_actionViewIconThemeFolder_triggered();
void on_actionViewWidgetThemeFolder_triggered();
void on_actionViewSelectedInstFolder_triggered();
void refreshInstances();
void checkForUpdates();
2013-01-09 18:22:22 +00:00
void on_actionSettings_triggered();
void on_actionManageAccounts_triggered();
2013-01-09 18:22:22 +00:00
void on_actionReportBug_triggered();
void on_actionClearMetadata_triggered();
#ifdef Q_OS_MAC
void on_actionAddToPATH_triggered();
#endif
void on_actionOpenWiki_triggered();
void on_actionMoreNews_triggered();
void newsButtonClicked();
void on_actionLaunchInstance_triggered();
void on_actionLaunchInstanceOffline_triggered();
void on_actionLaunchInstanceDemo_triggered();
void on_actionKillInstance_triggered();
void on_actionDeleteInstance_triggered();
void deleteGroup();
void undoTrashInstance();
inline void on_actionExportInstance_triggered() { on_actionExportInstanceZip_triggered(); }
void on_actionExportInstanceZip_triggered();
void on_actionExportInstanceMrPack_triggered();
void on_actionExportInstanceFlamePack_triggered();
void on_actionExportInstanceToModList_triggered();
void on_actionRenameInstance_triggered();
void on_actionEditInstance_triggered();
void on_actionCreateInstanceShortcut_triggered();
void taskEnd();
2013-03-11 21:19:17 +00:00
/**
* called when an icon is changed in the icon model.
*/
void iconUpdated(QString);
2014-02-23 21:14:24 +00:00
void showInstanceContextMenu(const QPoint &);
void updateMainToolBar();
void updateToolsMenu();
void updateThemeMenu();
void instanceActivated(QModelIndex);
void instanceChanged(const QModelIndex &current, const QModelIndex &previous);
void instanceSelectRequest(QString id);
void instanceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
void selectionBad();
void startTask(Task *task);
2021-11-20 15:22:22 +00:00
void defaultAccountChanged();
2013-11-27 22:39:49 +00:00
void changeActiveAccount();
void repopulateAccountsMenu();
void updateNewsLabel();
2013-11-27 22:39:49 +00:00
void konamiTriggered();
void globalSettingsClosed();
void lockToolbars(bool);
#ifndef Q_OS_MAC
void keyReleaseEvent(QKeyEvent *event) override;
#endif
2022-06-10 08:48:18 +01:00
void refreshCurrentInstance(bool running);
private:
void retranslateUi();
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 03:23:24 +01:00
void updateStatusCenter();
void setInstanceActionsEnabled(bool enabled);
2016-10-02 23:55:54 +01:00
void runModalTask(Task *task);
2018-03-19 01:36:12 +00:00
void instanceFromInstanceTask(InstanceTask *task);
2015-01-27 21:31:07 +00:00
void finalizeInstance(InstancePtr inst);
2013-01-09 18:22:22 +00:00
private:
Ui::MainWindow *ui;
// these are managed by Qt's memory management model!
InstanceView *view = nullptr;
InstanceProxyModel *proxymodel = nullptr;
QToolButton *newsLabel = nullptr;
QLabel *m_statusLeft = nullptr;
2019-07-10 03:23:24 +01:00
QLabel *m_statusCenter = nullptr;
LabeledToolButton *changeIconButton = nullptr;
LabeledToolButton *renameButton = nullptr;
QToolButton *helpMenuButton = nullptr;
KonamiCode * secretEventFilter = nullptr;
2018-07-15 13:51:05 +01:00
std::shared_ptr<Setting> instanceToolbarSetting = nullptr;
unique_qobject_ptr<NewsChecker> m_newsChecker;
2018-07-15 13:51:05 +01:00
2014-03-30 19:11:05 +01:00
InstancePtr m_selectedInstance;
QString m_currentInstIcon;
2018-07-15 13:51:05 +01:00
// managed by the application object
Task *m_versionLoadTask = nullptr;
2013-01-09 18:22:22 +00:00
};