Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into catpacks
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
commit
6d758795af
@ -45,98 +45,95 @@
|
|||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "ui_MainWindow.h"
|
#include "ui_MainWindow.h"
|
||||||
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QUrl>
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
#include <QKeyEvent>
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
|
#include <QFileDialog>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QLabel>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QStatusBar>
|
|
||||||
#include <QToolBar>
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QInputDialog>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QToolButton>
|
|
||||||
#include <QWidgetAction>
|
|
||||||
#include <QProgressDialog>
|
#include <QProgressDialog>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
#include <QStatusBar>
|
||||||
|
#include <QToolBar>
|
||||||
|
#include <QToolButton>
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QWidgetAction>
|
||||||
|
|
||||||
#include <BaseInstance.h>
|
#include <BaseInstance.h>
|
||||||
#include <InstanceList.h>
|
|
||||||
#include <minecraft/MinecraftInstance.h>
|
|
||||||
#include <MMCZip.h>
|
|
||||||
#include <icons/IconList.h>
|
|
||||||
#include <java/JavaUtils.h>
|
|
||||||
#include <java/JavaInstallList.h>
|
|
||||||
#include <launch/LaunchTask.h>
|
|
||||||
#include <minecraft/auth/AccountList.h>
|
|
||||||
#include <SkinUtils.h>
|
|
||||||
#include <BuildConfig.h>
|
#include <BuildConfig.h>
|
||||||
#include <net/NetJob.h>
|
#include <DesktopServices.h>
|
||||||
|
#include <InstanceList.h>
|
||||||
|
#include <MMCZip.h>
|
||||||
|
#include <SkinUtils.h>
|
||||||
|
#include <icons/IconList.h>
|
||||||
|
#include <java/JavaInstallList.h>
|
||||||
|
#include <java/JavaUtils.h>
|
||||||
|
#include <launch/LaunchTask.h>
|
||||||
|
#include <minecraft/MinecraftInstance.h>
|
||||||
|
#include <minecraft/auth/AccountList.h>
|
||||||
#include <net/Download.h>
|
#include <net/Download.h>
|
||||||
|
#include <net/NetJob.h>
|
||||||
#include <news/NewsChecker.h>
|
#include <news/NewsChecker.h>
|
||||||
#include <tools/BaseProfiler.h>
|
#include <tools/BaseProfiler.h>
|
||||||
#include <updater/ExternalUpdater.h>
|
#include <updater/ExternalUpdater.h>
|
||||||
#include <DesktopServices.h>
|
|
||||||
#include "InstanceWindow.h"
|
|
||||||
#include "InstancePageProvider.h"
|
#include "InstancePageProvider.h"
|
||||||
|
#include "InstanceWindow.h"
|
||||||
#include "JavaCommon.h"
|
#include "JavaCommon.h"
|
||||||
#include "LaunchController.h"
|
#include "LaunchController.h"
|
||||||
|
|
||||||
#include "ui/instanceview/InstanceProxyModel.h"
|
|
||||||
#include "ui/instanceview/InstanceView.h"
|
|
||||||
#include "ui/instanceview/InstanceDelegate.h"
|
|
||||||
#include "ui/widgets/LabeledToolButton.h"
|
|
||||||
#include "ui/dialogs/NewInstanceDialog.h"
|
|
||||||
#include "ui/dialogs/NewsDialog.h"
|
|
||||||
#include "ui/dialogs/ProgressDialog.h"
|
|
||||||
#include "ui/dialogs/AboutDialog.h"
|
#include "ui/dialogs/AboutDialog.h"
|
||||||
#include "ui/dialogs/CustomMessageBox.h"
|
|
||||||
#include "ui/dialogs/IconPickerDialog.h"
|
|
||||||
#include "ui/dialogs/CopyInstanceDialog.h"
|
#include "ui/dialogs/CopyInstanceDialog.h"
|
||||||
|
#include "ui/dialogs/CustomMessageBox.h"
|
||||||
#include "ui/dialogs/EditAccountDialog.h"
|
#include "ui/dialogs/EditAccountDialog.h"
|
||||||
#include "ui/dialogs/ExportInstanceDialog.h"
|
#include "ui/dialogs/ExportInstanceDialog.h"
|
||||||
#include "ui/dialogs/ExportMrPackDialog.h"
|
#include "ui/dialogs/ExportMrPackDialog.h"
|
||||||
|
#include "ui/dialogs/IconPickerDialog.h"
|
||||||
#include "ui/dialogs/ImportResourceDialog.h"
|
#include "ui/dialogs/ImportResourceDialog.h"
|
||||||
|
#include "ui/dialogs/NewInstanceDialog.h"
|
||||||
|
#include "ui/dialogs/NewsDialog.h"
|
||||||
|
#include "ui/dialogs/ProgressDialog.h"
|
||||||
|
#include "ui/instanceview/InstanceDelegate.h"
|
||||||
|
#include "ui/instanceview/InstanceProxyModel.h"
|
||||||
|
#include "ui/instanceview/InstanceView.h"
|
||||||
#include "ui/themes/ITheme.h"
|
#include "ui/themes/ITheme.h"
|
||||||
#include "ui/themes/ThemeManager.h"
|
#include "ui/themes/ThemeManager.h"
|
||||||
|
#include "ui/widgets/LabeledToolButton.h"
|
||||||
|
|
||||||
#include "minecraft/mod/tasks/LocalResourceParse.h"
|
#include "minecraft/WorldList.h"
|
||||||
#include "minecraft/mod/ModFolderModel.h"
|
#include "minecraft/mod/ModFolderModel.h"
|
||||||
#include "minecraft/mod/ShaderPackFolderModel.h"
|
#include "minecraft/mod/ShaderPackFolderModel.h"
|
||||||
#include "minecraft/WorldList.h"
|
#include "minecraft/mod/tasks/LocalResourceParse.h"
|
||||||
|
|
||||||
#include "KonamiCode.h"
|
#include "KonamiCode.h"
|
||||||
|
|
||||||
#include "InstanceImportTask.h"
|
|
||||||
#include "InstanceCopyTask.h"
|
#include "InstanceCopyTask.h"
|
||||||
|
#include "InstanceImportTask.h"
|
||||||
|
|
||||||
#include "MMCTime.h"
|
#include "MMCTime.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
QString profileInUseFilter(const QString& profile, bool used)
|
QString profileInUseFilter(const QString& profile, bool used)
|
||||||
{
|
{
|
||||||
if(used)
|
if (used) {
|
||||||
{
|
|
||||||
return QObject::tr("%1 (in use)").arg(profile);
|
return QObject::tr("%1 (in use)").arg(profile);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow)
|
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
@ -184,7 +181,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
ui->instanceToolBar->addContextMenuAction(ui->newsToolBar->toggleViewAction());
|
ui->instanceToolBar->addContextMenuAction(ui->newsToolBar->toggleViewAction());
|
||||||
ui->instanceToolBar->addContextMenuAction(ui->instanceToolBar->toggleViewAction());
|
ui->instanceToolBar->addContextMenuAction(ui->instanceToolBar->toggleViewAction());
|
||||||
ui->instanceToolBar->addContextMenuAction(ui->actionLockToolbars);
|
ui->instanceToolBar->addContextMenuAction(ui->actionLockToolbars);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the menu for the folders help, accounts, and export tool buttons
|
// set the menu for the folders help, accounts, and export tool buttons
|
||||||
@ -230,7 +226,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
if (qgetenv("XDG_CURRENT_DESKTOP") == "gamescope") {
|
if (qgetenv("XDG_CURRENT_DESKTOP") == "gamescope") {
|
||||||
ui->mainToolBar->addAction(ui->actionCloseWindow);
|
ui->mainToolBar->addAction(ui->actionCloseWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the toolbar toggles to the view menu
|
// add the toolbar toggles to the view menu
|
||||||
@ -300,9 +295,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
connect(proxymodel, &InstanceProxyModel::dataChanged, this, &MainWindow::instanceDataChanged);
|
connect(proxymodel, &InstanceProxyModel::dataChanged, this, &MainWindow::instanceDataChanged);
|
||||||
|
|
||||||
view->setModel(proxymodel);
|
view->setModel(proxymodel);
|
||||||
view->setSourceOfGroupCollapseStatus([](const QString & groupName)->bool {
|
view->setSourceOfGroupCollapseStatus(
|
||||||
return APPLICATION->instances()->isGroupCollapsed(groupName);
|
[](const QString& groupName) -> bool { return APPLICATION->instances()->isGroupCollapsed(groupName); });
|
||||||
});
|
|
||||||
connect(view, &InstanceView::groupStateChanged, APPLICATION->instances().get(), &InstanceList::on_GroupStateChanged);
|
connect(view, &InstanceView::groupStateChanged, APPLICATION->instances().get(), &InstanceList::on_GroupStateChanged);
|
||||||
ui->horizontalLayout->addWidget(view);
|
ui->horizontalLayout->addWidget(view);
|
||||||
}
|
}
|
||||||
@ -360,21 +354,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
// Update the menu when the active account changes.
|
// 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.
|
// Shouldn't have to use lambdas here like this, but if I don't, the compiler throws a fit.
|
||||||
// Template hell sucks...
|
// Template hell sucks...
|
||||||
connect(
|
connect(APPLICATION->accounts().get(), &AccountList::defaultAccountChanged, [this] { defaultAccountChanged(); });
|
||||||
APPLICATION->accounts().get(),
|
connect(APPLICATION->accounts().get(), &AccountList::listChanged, [this] { repopulateAccountsMenu(); });
|
||||||
&AccountList::defaultAccountChanged,
|
|
||||||
[this] {
|
|
||||||
defaultAccountChanged();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
connect(
|
|
||||||
APPLICATION->accounts().get(),
|
|
||||||
&AccountList::listChanged,
|
|
||||||
[this]
|
|
||||||
{
|
|
||||||
repopulateAccountsMenu();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Show initial account
|
// Show initial account
|
||||||
defaultAccountChanged();
|
defaultAccountChanged();
|
||||||
@ -426,7 +407,6 @@ void MainWindow::keyReleaseEvent(QKeyEvent *event)
|
|||||||
|
|
||||||
void MainWindow::retranslateUi()
|
void MainWindow::retranslateUi()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (m_selectedInstance) {
|
if (m_selectedInstance) {
|
||||||
m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
|
m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
|
||||||
} else {
|
} else {
|
||||||
@ -456,9 +436,7 @@ void MainWindow::retranslateUi()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QMenu* MainWindow::createPopupMenu()
|
QMenu* MainWindow::createPopupMenu()
|
||||||
{
|
{
|
||||||
@ -477,10 +455,11 @@ void MainWindow::lockToolbars(bool state)
|
|||||||
APPLICATION->settings()->set("ToolbarsLocked", state);
|
APPLICATION->settings()->set("ToolbarsLocked", state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::konamiTriggered()
|
void MainWindow::konamiTriggered()
|
||||||
{
|
{
|
||||||
QString gradient = " stop:0 rgba(125, 0, 0, 255), stop:0.166 rgba(125, 125, 0, 255), stop:0.333 rgba(0, 125, 0, 255), stop:0.5 rgba(0, 125, 125, 255), stop:0.666 rgba(0, 0, 125, 255), stop:0.833 rgba(125, 0, 125, 255), stop:1 rgba(125, 0, 0, 255));";
|
QString gradient =
|
||||||
|
" stop:0 rgba(125, 0, 0, 255), stop:0.166 rgba(125, 125, 0, 255), stop:0.333 rgba(0, 125, 0, 255), stop:0.5 rgba(0, 125, 125, "
|
||||||
|
"255), stop:0.666 rgba(0, 0, 125, 255), stop:0.833 rgba(125, 0, 125, 255), stop:1 rgba(125, 0, 0, 255));";
|
||||||
QString stylesheet = "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0," + gradient;
|
QString stylesheet = "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0," + gradient;
|
||||||
if (ui->mainToolBar->styleSheet() == stylesheet) {
|
if (ui->mainToolBar->styleSheet() == stylesheet) {
|
||||||
ui->mainToolBar->setStyleSheet("");
|
ui->mainToolBar->setStyleSheet("");
|
||||||
@ -507,8 +486,7 @@ void MainWindow::showInstanceContextMenu(const QPoint &pos)
|
|||||||
actionSep->setSeparator(true);
|
actionSep->setSeparator(true);
|
||||||
|
|
||||||
bool onInstance = view->indexAt(pos).isValid();
|
bool onInstance = view->indexAt(pos).isValid();
|
||||||
if (onInstance)
|
if (onInstance) {
|
||||||
{
|
|
||||||
// reuse the file menu actions
|
// reuse the file menu actions
|
||||||
actions = ui->fileMenu->actions();
|
actions = ui->fileMenu->actions();
|
||||||
|
|
||||||
@ -525,9 +503,7 @@ void MainWindow::showInstanceContextMenu(const QPoint &pos)
|
|||||||
QAction* actionVoid = new QAction(m_selectedInstance->name(), this);
|
QAction* actionVoid = new QAction(m_selectedInstance->name(), this);
|
||||||
actionVoid->setEnabled(false);
|
actionVoid->setEnabled(false);
|
||||||
actions.prepend(actionVoid);
|
actions.prepend(actionVoid);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
auto group = view->groupNameAt(pos);
|
auto group = view->groupNameAt(pos);
|
||||||
|
|
||||||
QAction* actionVoid = new QAction(BuildConfig.LAUNCHER_DISPLAYNAME, this);
|
QAction* actionVoid = new QAction(BuildConfig.LAUNCHER_DISPLAYNAME, this);
|
||||||
@ -535,8 +511,7 @@ void MainWindow::showInstanceContextMenu(const QPoint &pos)
|
|||||||
|
|
||||||
QAction* actionCreateInstance = new QAction(tr("Create instance"), this);
|
QAction* actionCreateInstance = new QAction(tr("Create instance"), this);
|
||||||
actionCreateInstance->setToolTip(ui->actionAddInstance->toolTip());
|
actionCreateInstance->setToolTip(ui->actionAddInstance->toolTip());
|
||||||
if(!group.isNull())
|
if (!group.isNull()) {
|
||||||
{
|
|
||||||
QVariantMap data;
|
QVariantMap data;
|
||||||
data["group"] = group;
|
data["group"] = group;
|
||||||
actionCreateInstance->setData(data);
|
actionCreateInstance->setData(data);
|
||||||
@ -547,8 +522,7 @@ void MainWindow::showInstanceContextMenu(const QPoint &pos)
|
|||||||
actions.prepend(actionSep);
|
actions.prepend(actionSep);
|
||||||
actions.prepend(actionVoid);
|
actions.prepend(actionVoid);
|
||||||
actions.append(actionCreateInstance);
|
actions.append(actionCreateInstance);
|
||||||
if(!group.isNull())
|
if (!group.isNull()) {
|
||||||
{
|
|
||||||
QAction* actionDeleteGroup = new QAction(tr("Delete group '%1'").arg(group), this);
|
QAction* actionDeleteGroup = new QAction(tr("Delete group '%1'").arg(group), this);
|
||||||
QVariantMap data;
|
QVariantMap data;
|
||||||
data["group"] = group;
|
data["group"] = group;
|
||||||
@ -581,12 +555,9 @@ void MainWindow::updateToolsMenu()
|
|||||||
ui->actionLaunchInstanceDemo->setDisabled(!m_selectedInstance || currentInstanceRunning);
|
ui->actionLaunchInstanceDemo->setDisabled(!m_selectedInstance || currentInstanceRunning);
|
||||||
|
|
||||||
QMenu* launchMenu = ui->actionLaunchInstance->menu();
|
QMenu* launchMenu = ui->actionLaunchInstance->menu();
|
||||||
if (launchMenu)
|
if (launchMenu) {
|
||||||
{
|
|
||||||
launchMenu->clear();
|
launchMenu->clear();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
launchMenu = new QMenu(this);
|
launchMenu = new QMenu(this);
|
||||||
}
|
}
|
||||||
QAction* normalLaunch = launchMenu->addAction(tr("Launch"));
|
QAction* normalLaunch = launchMenu->addAction(tr("Launch"));
|
||||||
@ -595,24 +566,15 @@ void MainWindow::updateToolsMenu()
|
|||||||
normalLaunchOffline->setShortcut(QKeySequence(tr("Ctrl+Shift+O")));
|
normalLaunchOffline->setShortcut(QKeySequence(tr("Ctrl+Shift+O")));
|
||||||
QAction* normalLaunchDemo = launchMenu->addAction(tr("Launch Demo"));
|
QAction* normalLaunchDemo = launchMenu->addAction(tr("Launch Demo"));
|
||||||
normalLaunchDemo->setShortcut(QKeySequence(tr("Ctrl+Alt+O")));
|
normalLaunchDemo->setShortcut(QKeySequence(tr("Ctrl+Alt+O")));
|
||||||
if (m_selectedInstance)
|
if (m_selectedInstance) {
|
||||||
{
|
|
||||||
normalLaunch->setEnabled(m_selectedInstance->canLaunch());
|
normalLaunch->setEnabled(m_selectedInstance->canLaunch());
|
||||||
normalLaunchOffline->setEnabled(m_selectedInstance->canLaunch());
|
normalLaunchOffline->setEnabled(m_selectedInstance->canLaunch());
|
||||||
normalLaunchDemo->setEnabled(m_selectedInstance->canLaunch());
|
normalLaunchDemo->setEnabled(m_selectedInstance->canLaunch());
|
||||||
|
|
||||||
connect(normalLaunch, &QAction::triggered, [this]() {
|
connect(normalLaunch, &QAction::triggered, [this]() { APPLICATION->launch(m_selectedInstance, true, false); });
|
||||||
APPLICATION->launch(m_selectedInstance, true, false);
|
connect(normalLaunchOffline, &QAction::triggered, [this]() { APPLICATION->launch(m_selectedInstance, false, false); });
|
||||||
});
|
connect(normalLaunchDemo, &QAction::triggered, [this]() { APPLICATION->launch(m_selectedInstance, false, true); });
|
||||||
connect(normalLaunchOffline, &QAction::triggered, [this]() {
|
} else {
|
||||||
APPLICATION->launch(m_selectedInstance, false, false);
|
|
||||||
});
|
|
||||||
connect(normalLaunchDemo, &QAction::triggered, [this]() {
|
|
||||||
APPLICATION->launch(m_selectedInstance, false, true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
normalLaunch->setDisabled(true);
|
normalLaunch->setDisabled(true);
|
||||||
normalLaunchOffline->setDisabled(true);
|
normalLaunchOffline->setDisabled(true);
|
||||||
normalLaunchDemo->setDisabled(true);
|
normalLaunchDemo->setDisabled(true);
|
||||||
@ -626,35 +588,25 @@ void MainWindow::updateToolsMenu()
|
|||||||
|
|
||||||
QString profilersTitle = tr("Profilers");
|
QString profilersTitle = tr("Profilers");
|
||||||
launchMenu->addSeparator()->setText(profilersTitle);
|
launchMenu->addSeparator()->setText(profilersTitle);
|
||||||
for (auto profiler : APPLICATION->profilers().values())
|
for (auto profiler : APPLICATION->profilers().values()) {
|
||||||
{
|
|
||||||
QAction* profilerAction = launchMenu->addAction(profiler->name());
|
QAction* profilerAction = launchMenu->addAction(profiler->name());
|
||||||
QAction* profilerOfflineAction = launchMenu->addAction(tr("%1 Offline").arg(profiler->name()));
|
QAction* profilerOfflineAction = launchMenu->addAction(tr("%1 Offline").arg(profiler->name()));
|
||||||
QString error;
|
QString error;
|
||||||
if (!profiler->check(&error))
|
if (!profiler->check(&error)) {
|
||||||
{
|
|
||||||
profilerAction->setDisabled(true);
|
profilerAction->setDisabled(true);
|
||||||
profilerOfflineAction->setDisabled(true);
|
profilerOfflineAction->setDisabled(true);
|
||||||
QString profilerToolTip = tr("Profiler not setup correctly. Go into settings, \"External Tools\".");
|
QString profilerToolTip = tr("Profiler not setup correctly. Go into settings, \"External Tools\".");
|
||||||
profilerAction->setToolTip(profilerToolTip);
|
profilerAction->setToolTip(profilerToolTip);
|
||||||
profilerOfflineAction->setToolTip(profilerToolTip);
|
profilerOfflineAction->setToolTip(profilerToolTip);
|
||||||
}
|
} else if (m_selectedInstance) {
|
||||||
else if (m_selectedInstance)
|
|
||||||
{
|
|
||||||
profilerAction->setEnabled(m_selectedInstance->canLaunch());
|
profilerAction->setEnabled(m_selectedInstance->canLaunch());
|
||||||
profilerOfflineAction->setEnabled(m_selectedInstance->canLaunch());
|
profilerOfflineAction->setEnabled(m_selectedInstance->canLaunch());
|
||||||
|
|
||||||
connect(profilerAction, &QAction::triggered, [this, profiler]()
|
connect(profilerAction, &QAction::triggered,
|
||||||
{
|
[this, profiler]() { APPLICATION->launch(m_selectedInstance, true, false, profiler.get()); });
|
||||||
APPLICATION->launch(m_selectedInstance, true, false, profiler.get());
|
connect(profilerOfflineAction, &QAction::triggered,
|
||||||
});
|
[this, profiler]() { APPLICATION->launch(m_selectedInstance, false, false, profiler.get()); });
|
||||||
connect(profilerOfflineAction, &QAction::triggered, [this, profiler]()
|
} else {
|
||||||
{
|
|
||||||
APPLICATION->launch(m_selectedInstance, false, false, profiler.get());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
profilerAction->setDisabled(true);
|
profilerAction->setDisabled(true);
|
||||||
profilerOfflineAction->setDisabled(true);
|
profilerOfflineAction->setDisabled(true);
|
||||||
}
|
}
|
||||||
@ -711,11 +663,9 @@ void MainWindow::repopulateAccountsMenu()
|
|||||||
MinecraftAccountPtr defaultAccount = accounts->defaultAccount();
|
MinecraftAccountPtr defaultAccount = accounts->defaultAccount();
|
||||||
|
|
||||||
QString active_profileId = "";
|
QString active_profileId = "";
|
||||||
if (defaultAccount)
|
if (defaultAccount) {
|
||||||
{
|
|
||||||
// this can be called before accountMenuButton exists
|
// this can be called before accountMenuButton exists
|
||||||
if (ui->actionAccountsButton)
|
if (ui->actionAccountsButton) {
|
||||||
{
|
|
||||||
auto profileLabel = profileInUseFilter(defaultAccount->profileName(), defaultAccount->isInUse());
|
auto profileLabel = profileInUseFilter(defaultAccount->profileName(), defaultAccount->isInUse());
|
||||||
ui->actionAccountsButton->setText(profileLabel);
|
ui->actionAccountsButton->setText(profileLabel);
|
||||||
}
|
}
|
||||||
@ -723,38 +673,31 @@ void MainWindow::repopulateAccountsMenu()
|
|||||||
|
|
||||||
QActionGroup* accountsGroup = new QActionGroup(this);
|
QActionGroup* accountsGroup = new QActionGroup(this);
|
||||||
|
|
||||||
if (accounts->count() <= 0)
|
if (accounts->count() <= 0) {
|
||||||
{
|
|
||||||
ui->actionNoAccountsAdded->setEnabled(false);
|
ui->actionNoAccountsAdded->setEnabled(false);
|
||||||
ui->accountsMenu->addAction(ui->actionNoAccountsAdded);
|
ui->accountsMenu->addAction(ui->actionNoAccountsAdded);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO: Nicer way to iterate?
|
// TODO: Nicer way to iterate?
|
||||||
for (int i = 0; i < accounts->count(); i++)
|
for (int i = 0; i < accounts->count(); i++) {
|
||||||
{
|
|
||||||
MinecraftAccountPtr account = accounts->at(i);
|
MinecraftAccountPtr account = accounts->at(i);
|
||||||
auto profileLabel = profileInUseFilter(account->profileName(), account->isInUse());
|
auto profileLabel = profileInUseFilter(account->profileName(), account->isInUse());
|
||||||
QAction* action = new QAction(profileLabel, this);
|
QAction* action = new QAction(profileLabel, this);
|
||||||
action->setData(i);
|
action->setData(i);
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
action->setActionGroup(accountsGroup);
|
action->setActionGroup(accountsGroup);
|
||||||
if (defaultAccount == account)
|
if (defaultAccount == account) {
|
||||||
{
|
|
||||||
action->setChecked(true);
|
action->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto face = account->getFace();
|
auto face = account->getFace();
|
||||||
if (!face.isNull()) {
|
if (!face.isNull()) {
|
||||||
action->setIcon(face);
|
action->setIcon(face);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
action->setIcon(APPLICATION->getThemedIcon("noaccount"));
|
action->setIcon(APPLICATION->getThemedIcon("noaccount"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const int highestNumberKey = 9;
|
const int highestNumberKey = 9;
|
||||||
if(i<highestNumberKey)
|
if (i < highestNumberKey) {
|
||||||
{
|
|
||||||
action->setShortcut(QKeySequence(tr("Ctrl+%1").arg(i + 1)));
|
action->setShortcut(QKeySequence(tr("Ctrl+%1").arg(i + 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -781,8 +724,7 @@ void MainWindow::repopulateAccountsMenu()
|
|||||||
|
|
||||||
void MainWindow::updatesAllowedChanged(bool allowed)
|
void MainWindow::updatesAllowedChanged(bool allowed)
|
||||||
{
|
{
|
||||||
if(!BuildConfig.UPDATER_ENABLED)
|
if (!BuildConfig.UPDATER_ENABLED) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ui->actionCheckUpdate->setEnabled(allowed);
|
ui->actionCheckUpdate->setEnabled(allowed);
|
||||||
@ -817,15 +759,13 @@ void MainWindow::defaultAccountChanged()
|
|||||||
MinecraftAccountPtr account = APPLICATION->accounts()->defaultAccount();
|
MinecraftAccountPtr account = APPLICATION->accounts()->defaultAccount();
|
||||||
|
|
||||||
// FIXME: this needs adjustment for MSA
|
// FIXME: this needs adjustment for MSA
|
||||||
if (account && account->profileName() != "")
|
if (account && account->profileName() != "") {
|
||||||
{
|
|
||||||
auto profileLabel = profileInUseFilter(account->profileName(), account->isInUse());
|
auto profileLabel = profileInUseFilter(account->profileName(), account->isInUse());
|
||||||
ui->actionAccountsButton->setText(profileLabel);
|
ui->actionAccountsButton->setText(profileLabel);
|
||||||
auto face = account->getFace();
|
auto face = account->getFace();
|
||||||
if (face.isNull()) {
|
if (face.isNull()) {
|
||||||
ui->actionAccountsButton->setIcon(APPLICATION->getThemedIcon("noaccount"));
|
ui->actionAccountsButton->setIcon(APPLICATION->getThemedIcon("noaccount"));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ui->actionAccountsButton->setIcon(face);
|
ui->actionAccountsButton->setIcon(face);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -838,14 +778,11 @@ void MainWindow::defaultAccountChanged()
|
|||||||
|
|
||||||
bool MainWindow::eventFilter(QObject* obj, QEvent* ev)
|
bool MainWindow::eventFilter(QObject* obj, QEvent* ev)
|
||||||
{
|
{
|
||||||
if (obj == view)
|
if (obj == view) {
|
||||||
{
|
if (ev->type() == QEvent::KeyPress) {
|
||||||
if (ev->type() == QEvent::KeyPress)
|
|
||||||
{
|
|
||||||
secretEventFilter->input(ev);
|
secretEventFilter->input(ev);
|
||||||
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(ev);
|
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(ev);
|
||||||
switch (keyEvent->key())
|
switch (keyEvent->key()) {
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
case Qt::Key_Enter:
|
case Qt::Key_Enter:
|
||||||
case Qt::Key_Return:
|
case Qt::Key_Return:
|
||||||
@ -871,23 +808,17 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *ev)
|
|||||||
|
|
||||||
void MainWindow::updateNewsLabel()
|
void MainWindow::updateNewsLabel()
|
||||||
{
|
{
|
||||||
if (m_newsChecker->isLoadingNews())
|
if (m_newsChecker->isLoadingNews()) {
|
||||||
{
|
|
||||||
newsLabel->setText(tr("Loading news..."));
|
newsLabel->setText(tr("Loading news..."));
|
||||||
newsLabel->setEnabled(false);
|
newsLabel->setEnabled(false);
|
||||||
ui->actionMoreNews->setVisible(false);
|
ui->actionMoreNews->setVisible(false);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
QList<NewsEntryPtr> entries = m_newsChecker->getNewsEntries();
|
QList<NewsEntryPtr> entries = m_newsChecker->getNewsEntries();
|
||||||
if (entries.length() > 0)
|
if (entries.length() > 0) {
|
||||||
{
|
|
||||||
newsLabel->setText(entries[0]->title);
|
newsLabel->setText(entries[0]->title);
|
||||||
newsLabel->setEnabled(true);
|
newsLabel->setEnabled(true);
|
||||||
ui->actionMoreNews->setVisible(true);
|
ui->actionMoreNews->setVisible(true);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
newsLabel->setText(tr("No news available."));
|
newsLabel->setText(tr("No news available."));
|
||||||
newsLabel->setEnabled(false);
|
newsLabel->setEnabled(false);
|
||||||
ui->actionMoreNews->setVisible(false);
|
ui->actionMoreNews->setVisible(false);
|
||||||
@ -903,8 +834,7 @@ QList<int> stringToIntList(const QString &string)
|
|||||||
QStringList split = string.split(',', QString::SkipEmptyParts);
|
QStringList split = string.split(',', QString::SkipEmptyParts);
|
||||||
#endif
|
#endif
|
||||||
QList<int> out;
|
QList<int> out;
|
||||||
for (int i = 0; i < split.size(); ++i)
|
for (int i = 0; i < split.size(); ++i) {
|
||||||
{
|
|
||||||
out.append(split.at(i).toInt());
|
out.append(split.at(i).toInt());
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
@ -912,8 +842,7 @@ QList<int> stringToIntList(const QString &string)
|
|||||||
QString intListToString(const QList<int>& list)
|
QString intListToString(const QList<int>& list)
|
||||||
{
|
{
|
||||||
QStringList slist;
|
QStringList slist;
|
||||||
for (int i = 0; i < list.size(); ++i)
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
{
|
|
||||||
slist.append(QString::number(list.at(i)));
|
slist.append(QString::number(list.at(i)));
|
||||||
}
|
}
|
||||||
return slist.join(',');
|
return slist.join(',');
|
||||||
@ -927,40 +856,23 @@ void MainWindow::onCatToggled(bool state)
|
|||||||
|
|
||||||
void MainWindow::setCatBackground(bool enabled)
|
void MainWindow::setCatBackground(bool enabled)
|
||||||
{
|
{
|
||||||
if (enabled) {
|
view->setPaintCat(enabled);
|
||||||
view->setStyleSheet(QString(R"(
|
view->viewport()->repaint();
|
||||||
InstanceView
|
|
||||||
{
|
|
||||||
background-image: url(%1);
|
|
||||||
background-attachment: fixed;
|
|
||||||
background-clip: padding;
|
|
||||||
background-position: bottom right;
|
|
||||||
background-repeat: none;
|
|
||||||
background-color:palette(base);
|
|
||||||
})")
|
|
||||||
.arg(APPLICATION->getCatPack()));
|
|
||||||
} else {
|
|
||||||
view->setStyleSheet(QString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::runModalTask(Task* task)
|
void MainWindow::runModalTask(Task* task)
|
||||||
{
|
{
|
||||||
connect(task, &Task::failed, [this](QString reason)
|
connect(task, &Task::failed,
|
||||||
{
|
[this](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); });
|
||||||
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
connect(task, &Task::succeeded, [this, task]() {
|
||||||
});
|
|
||||||
connect(task, &Task::succeeded, [this, task]()
|
|
||||||
{
|
|
||||||
QStringList warnings = task->warnings();
|
QStringList warnings = task->warnings();
|
||||||
if(warnings.count())
|
if (warnings.count()) {
|
||||||
{
|
|
||||||
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
|
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(task, &Task::aborted, [this]
|
connect(task, &Task::aborted, [this] {
|
||||||
{
|
CustomMessageBox::selectable(this, tr("Task aborted"), tr("The task has been aborted by the user."), QMessageBox::Information)
|
||||||
CustomMessageBox::selectable(this, tr("Task aborted"), tr("The task has been aborted by the user."), QMessageBox::Information)->show();
|
->show();
|
||||||
});
|
});
|
||||||
ProgressDialog loadDialog(this);
|
ProgressDialog loadDialog(this);
|
||||||
loadDialog.setSkipButton(true, tr("Abort"));
|
loadDialog.setSkipButton(true, tr("Abort"));
|
||||||
@ -994,38 +906,30 @@ void MainWindow::finalizeInstance(InstancePtr inst)
|
|||||||
{
|
{
|
||||||
view->updateGeometries();
|
view->updateGeometries();
|
||||||
setSelectedInstanceById(inst->id());
|
setSelectedInstanceById(inst->id());
|
||||||
if (APPLICATION->accounts()->anyAccountIsValid())
|
if (APPLICATION->accounts()->anyAccountIsValid()) {
|
||||||
{
|
|
||||||
ProgressDialog loadDialog(this);
|
ProgressDialog loadDialog(this);
|
||||||
auto update = inst->createUpdateTask(Net::Mode::Online);
|
auto update = inst->createUpdateTask(Net::Mode::Online);
|
||||||
connect(update.get(), &Task::failed, [this](QString reason)
|
connect(update.get(), &Task::failed, [this](QString reason) {
|
||||||
{
|
|
||||||
QString error = QString("Instance load failed: %1").arg(reason);
|
QString error = QString("Instance load failed: %1").arg(reason);
|
||||||
CustomMessageBox::selectable(this, tr("Error"), error, QMessageBox::Warning)->show();
|
CustomMessageBox::selectable(this, tr("Error"), error, QMessageBox::Warning)->show();
|
||||||
});
|
});
|
||||||
if(update)
|
if (update) {
|
||||||
{
|
|
||||||
loadDialog.setSkipButton(true, tr("Abort"));
|
loadDialog.setSkipButton(true, tr("Abort"));
|
||||||
loadDialog.execWithTask(update.get());
|
loadDialog.execWithTask(update.get());
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
CustomMessageBox::selectable(this, tr("Error"),
|
||||||
{
|
|
||||||
CustomMessageBox::selectable(
|
|
||||||
this,
|
|
||||||
tr("Error"),
|
|
||||||
tr("The launcher cannot download Minecraft or update instances unless you have at least "
|
tr("The launcher cannot download Minecraft or update instances unless you have at least "
|
||||||
"one account added.\nPlease add your Mojang or Minecraft account."),
|
"one account added.\nPlease add your Mojang or Minecraft account."),
|
||||||
QMessageBox::Warning
|
QMessageBox::Warning)
|
||||||
)->show();
|
->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::addInstance(QString url)
|
void MainWindow::addInstance(QString url)
|
||||||
{
|
{
|
||||||
QString groupName;
|
QString groupName;
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
QObject* obj = sender();
|
QObject* obj = sender();
|
||||||
if (!obj)
|
if (!obj)
|
||||||
break;
|
break;
|
||||||
@ -1038,8 +942,7 @@ void MainWindow::addInstance(QString url)
|
|||||||
groupName = map["group"].toString();
|
groupName = map["group"].toString();
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
if(groupName.isEmpty())
|
if (groupName.isEmpty()) {
|
||||||
{
|
|
||||||
groupName = APPLICATION->settings()->get("LastUsedGroupForNewInstance").toString();
|
groupName = APPLICATION->settings()->get("LastUsedGroupForNewInstance").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1050,8 +953,7 @@ void MainWindow::addInstance(QString url)
|
|||||||
APPLICATION->settings()->set("LastUsedGroupForNewInstance", newInstDlg.instGroup());
|
APPLICATION->settings()->set("LastUsedGroupForNewInstance", newInstDlg.instGroup());
|
||||||
|
|
||||||
InstanceTask* creationTask = newInstDlg.extractTask();
|
InstanceTask* creationTask = newInstDlg.extractTask();
|
||||||
if(creationTask)
|
if (creationTask) {
|
||||||
{
|
|
||||||
instanceFromInstanceTask(creationTask);
|
instanceFromInstanceTask(creationTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1145,8 +1047,7 @@ void MainWindow::on_actionChangeInstIcon_triggered()
|
|||||||
|
|
||||||
IconPickerDialog dlg(this);
|
IconPickerDialog dlg(this);
|
||||||
dlg.execWithSelection(m_selectedInstance->iconKey());
|
dlg.execWithSelection(m_selectedInstance->iconKey());
|
||||||
if (dlg.result() == QDialog::Accepted)
|
if (dlg.result() == QDialog::Accepted) {
|
||||||
{
|
|
||||||
m_selectedInstance->setIconKey(dlg.selectedIconKey);
|
m_selectedInstance->setIconKey(dlg.selectedIconKey);
|
||||||
auto icon = APPLICATION->icons()->getIcon(dlg.selectedIconKey);
|
auto icon = APPLICATION->icons()->getIcon(dlg.selectedIconKey);
|
||||||
ui->actionChangeInstIcon->setIcon(icon);
|
ui->actionChangeInstIcon->setIcon(icon);
|
||||||
@ -1156,8 +1057,7 @@ void MainWindow::on_actionChangeInstIcon_triggered()
|
|||||||
|
|
||||||
void MainWindow::iconUpdated(QString icon)
|
void MainWindow::iconUpdated(QString icon)
|
||||||
{
|
{
|
||||||
if (icon == m_currentInstIcon)
|
if (icon == m_currentInstIcon) {
|
||||||
{
|
|
||||||
auto icon = APPLICATION->icons()->getIcon(m_currentInstIcon);
|
auto icon = APPLICATION->icons()->getIcon(m_currentInstIcon);
|
||||||
ui->actionChangeInstIcon->setIcon(icon);
|
ui->actionChangeInstIcon->setIcon(icon);
|
||||||
changeIconButton->setIcon(icon);
|
changeIconButton->setIcon(icon);
|
||||||
@ -1177,8 +1077,7 @@ void MainWindow::setSelectedInstanceById(const QString &id)
|
|||||||
if (id.isNull())
|
if (id.isNull())
|
||||||
return;
|
return;
|
||||||
const QModelIndex index = APPLICATION->instances()->getInstanceIndexById(id);
|
const QModelIndex index = APPLICATION->instances()->getInstanceIndexById(id);
|
||||||
if (index.isValid())
|
if (index.isValid()) {
|
||||||
{
|
|
||||||
QModelIndex selectionIndex = proxymodel->mapFromSource(index);
|
QModelIndex selectionIndex = proxymodel->mapFromSource(index);
|
||||||
view->selectionModel()->setCurrentIndex(selectionIndex, QItemSelectionModel::ClearAndSelect);
|
view->selectionModel()->setCurrentIndex(selectionIndex, QItemSelectionModel::ClearAndSelect);
|
||||||
updateStatusCenter();
|
updateStatusCenter();
|
||||||
@ -1200,8 +1099,7 @@ void MainWindow::on_actionChangeInstGroup_triggered()
|
|||||||
|
|
||||||
name = QInputDialog::getItem(this, tr("Group name"), tr("Enter a new group name."), groups, foo, true, &ok);
|
name = QInputDialog::getItem(this, tr("Group name"), tr("Enter a new group name."), groups, foo, true, &ok);
|
||||||
name = name.simplified();
|
name = name.simplified();
|
||||||
if (ok)
|
if (ok) {
|
||||||
{
|
|
||||||
APPLICATION->instances()->setInstanceGroup(instId, name);
|
APPLICATION->instances()->setInstanceGroup(instId, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1218,12 +1116,10 @@ void MainWindow::deleteGroup()
|
|||||||
if (!map.contains("group"))
|
if (!map.contains("group"))
|
||||||
return;
|
return;
|
||||||
QString groupName = map["group"].toString();
|
QString groupName = map["group"].toString();
|
||||||
if(!groupName.isEmpty())
|
if (!groupName.isEmpty()) {
|
||||||
{
|
auto reply = QMessageBox::question(this, tr("Delete group"), tr("Are you sure you want to delete the group %1?").arg(groupName),
|
||||||
auto reply = QMessageBox::question(this, tr("Delete group"), tr("Are you sure you want to delete the group %1?")
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
.arg(groupName), QMessageBox::Yes | QMessageBox::No);
|
if (reply == QMessageBox::Yes) {
|
||||||
if(reply == QMessageBox::Yes)
|
|
||||||
{
|
|
||||||
APPLICATION->instances()->deleteGroup(groupName);
|
APPLICATION->instances()->deleteGroup(groupName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1259,12 +1155,9 @@ void MainWindow::on_actionViewCentralModsFolder_triggered()
|
|||||||
|
|
||||||
void MainWindow::checkForUpdates()
|
void MainWindow::checkForUpdates()
|
||||||
{
|
{
|
||||||
if(BuildConfig.UPDATER_ENABLED)
|
if (BuildConfig.UPDATER_ENABLED) {
|
||||||
{
|
|
||||||
APPLICATION->triggerUpdateCheck();
|
APPLICATION->triggerUpdateCheck();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
qWarning() << "Updater not set up. Cannot check for updates.";
|
qWarning() << "Updater not set up. Cannot check for updates.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1354,7 +1247,8 @@ void MainWindow::newsButtonClicked()
|
|||||||
news_dialog.exec();
|
news_dialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onCatChanged(int) {
|
void MainWindow::onCatChanged(int)
|
||||||
|
{
|
||||||
setCatBackground(APPLICATION->settings()->get("TheCat").toBool());
|
setCatBackground(APPLICATION->settings()->get("TheCat").toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1385,14 +1279,15 @@ void MainWindow::on_actionDeleteInstance_triggered()
|
|||||||
|
|
||||||
auto linkedInstances = APPLICATION->instances()->getLinkedInstancesById(id);
|
auto linkedInstances = APPLICATION->instances()->getLinkedInstancesById(id);
|
||||||
if (!linkedInstances.empty()) {
|
if (!linkedInstances.empty()) {
|
||||||
response = CustomMessageBox::selectable(
|
response = CustomMessageBox::selectable(this, tr("There are linked instances"),
|
||||||
this, tr("There are linked instances"),
|
|
||||||
tr("The following instance(s) might reference files in this instance:\n\n"
|
tr("The following instance(s) might reference files in this instance:\n\n"
|
||||||
"%1\n\n"
|
"%1\n\n"
|
||||||
"Deleting it could break the other instance(s), \n\n"
|
"Deleting it could break the other instance(s), \n\n"
|
||||||
"Do you wish to proceed?", nullptr, linkedInstances.count()).arg(linkedInstances.join("\n")),
|
"Do you wish to proceed?",
|
||||||
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No
|
nullptr, linkedInstances.count())
|
||||||
)->exec();
|
.arg(linkedInstances.join("\n")),
|
||||||
|
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
||||||
|
->exec();
|
||||||
if (response != QMessageBox::Yes)
|
if (response != QMessageBox::Yes)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1407,8 +1302,7 @@ void MainWindow::on_actionDeleteInstance_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionExportInstanceZip_triggered()
|
void MainWindow::on_actionExportInstanceZip_triggered()
|
||||||
{
|
{
|
||||||
if (m_selectedInstance)
|
if (m_selectedInstance) {
|
||||||
{
|
|
||||||
ExportInstanceDialog dlg(m_selectedInstance, this);
|
ExportInstanceDialog dlg(m_selectedInstance, this);
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
}
|
}
|
||||||
@ -1416,8 +1310,7 @@ void MainWindow::on_actionExportInstanceZip_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionExportInstanceMrPack_triggered()
|
void MainWindow::on_actionExportInstanceMrPack_triggered()
|
||||||
{
|
{
|
||||||
if (m_selectedInstance)
|
if (m_selectedInstance) {
|
||||||
{
|
|
||||||
ExportMrPackDialog dlg(m_selectedInstance, this);
|
ExportMrPackDialog dlg(m_selectedInstance, this);
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
}
|
}
|
||||||
@ -1425,16 +1318,14 @@ void MainWindow::on_actionExportInstanceMrPack_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionRenameInstance_triggered()
|
void MainWindow::on_actionRenameInstance_triggered()
|
||||||
{
|
{
|
||||||
if (m_selectedInstance)
|
if (m_selectedInstance) {
|
||||||
{
|
|
||||||
view->edit(view->currentIndex());
|
view->edit(view->currentIndex());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionViewSelectedInstFolder_triggered()
|
void MainWindow::on_actionViewSelectedInstFolder_triggered()
|
||||||
{
|
{
|
||||||
if (m_selectedInstance)
|
if (m_selectedInstance) {
|
||||||
{
|
|
||||||
QString str = m_selectedInstance->instanceRoot();
|
QString str = m_selectedInstance->instanceRoot();
|
||||||
DesktopServices::openDirectory(QDir(str).absolutePath());
|
DesktopServices::openDirectory(QDir(str).absolutePath());
|
||||||
}
|
}
|
||||||
@ -1452,8 +1343,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||||||
|
|
||||||
void MainWindow::changeEvent(QEvent* event)
|
void MainWindow::changeEvent(QEvent* event)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::LanguageChange)
|
if (event->type() == QEvent::LanguageChange) {
|
||||||
{
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
}
|
}
|
||||||
QMainWindow::changeEvent(event);
|
QMainWindow::changeEvent(event);
|
||||||
@ -1473,8 +1363,7 @@ void MainWindow::instanceActivated(QModelIndex index)
|
|||||||
|
|
||||||
void MainWindow::on_actionLaunchInstance_triggered()
|
void MainWindow::on_actionLaunchInstance_triggered()
|
||||||
{
|
{
|
||||||
if(m_selectedInstance && !m_selectedInstance->isRunning())
|
if (m_selectedInstance && !m_selectedInstance->isRunning()) {
|
||||||
{
|
|
||||||
APPLICATION->launch(m_selectedInstance);
|
APPLICATION->launch(m_selectedInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1486,24 +1375,21 @@ void MainWindow::activateInstance(InstancePtr instance)
|
|||||||
|
|
||||||
void MainWindow::on_actionLaunchInstanceOffline_triggered()
|
void MainWindow::on_actionLaunchInstanceOffline_triggered()
|
||||||
{
|
{
|
||||||
if (m_selectedInstance)
|
if (m_selectedInstance) {
|
||||||
{
|
|
||||||
APPLICATION->launch(m_selectedInstance, false);
|
APPLICATION->launch(m_selectedInstance, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionLaunchInstanceDemo_triggered()
|
void MainWindow::on_actionLaunchInstanceDemo_triggered()
|
||||||
{
|
{
|
||||||
if (m_selectedInstance)
|
if (m_selectedInstance) {
|
||||||
{
|
|
||||||
APPLICATION->launch(m_selectedInstance, false, true);
|
APPLICATION->launch(m_selectedInstance, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionKillInstance_triggered()
|
void MainWindow::on_actionKillInstance_triggered()
|
||||||
{
|
{
|
||||||
if(m_selectedInstance && m_selectedInstance->isRunning())
|
if (m_selectedInstance && m_selectedInstance->isRunning()) {
|
||||||
{
|
|
||||||
APPLICATION->kill(m_selectedInstance);
|
APPLICATION->kill(m_selectedInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1638,8 +1524,7 @@ void MainWindow::startTask(Task *task)
|
|||||||
|
|
||||||
void MainWindow::instanceChanged(const QModelIndex& current, const QModelIndex& previous)
|
void MainWindow::instanceChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||||
{
|
{
|
||||||
if (!current.isValid())
|
if (!current.isValid()) {
|
||||||
{
|
|
||||||
APPLICATION->settings()->set("SelectedInstance", QString());
|
APPLICATION->settings()->set("SelectedInstance", QString());
|
||||||
selectionBad();
|
selectionBad();
|
||||||
return;
|
return;
|
||||||
@ -1649,8 +1534,7 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &
|
|||||||
}
|
}
|
||||||
QString id = current.data(InstanceList::InstanceIDRole).toString();
|
QString id = current.data(InstanceList::InstanceIDRole).toString();
|
||||||
m_selectedInstance = APPLICATION->instances()->getInstanceById(id);
|
m_selectedInstance = APPLICATION->instances()->getInstanceById(id);
|
||||||
if (m_selectedInstance)
|
if (m_selectedInstance) {
|
||||||
{
|
|
||||||
ui->instanceToolBar->setEnabled(true);
|
ui->instanceToolBar->setEnabled(true);
|
||||||
setInstanceActionsEnabled(true);
|
setInstanceActionsEnabled(true);
|
||||||
ui->actionLaunchInstance->setEnabled(m_selectedInstance->canLaunch());
|
ui->actionLaunchInstance->setEnabled(m_selectedInstance->canLaunch());
|
||||||
@ -1675,9 +1559,7 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &
|
|||||||
APPLICATION->settings()->set("SelectedInstance", m_selectedInstance->id());
|
APPLICATION->settings()->set("SelectedInstance", m_selectedInstance->id());
|
||||||
|
|
||||||
connect(m_selectedInstance.get(), &BaseInstance::runningStatusChanged, this, &MainWindow::refreshCurrentInstance);
|
connect(m_selectedInstance.get(), &BaseInstance::runningStatusChanged, this, &MainWindow::refreshCurrentInstance);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->instanceToolBar->setEnabled(false);
|
ui->instanceToolBar->setEnabled(false);
|
||||||
setInstanceActionsEnabled(false);
|
setInstanceActionsEnabled(false);
|
||||||
ui->actionLaunchInstance->setEnabled(false);
|
ui->actionLaunchInstance->setEnabled(false);
|
||||||
@ -1699,8 +1581,7 @@ void MainWindow::instanceDataChanged(const QModelIndex &topLeft, const QModelInd
|
|||||||
{
|
{
|
||||||
auto current = view->selectionModel()->currentIndex();
|
auto current = view->selectionModel()->currentIndex();
|
||||||
QItemSelection test(topLeft, bottomRight);
|
QItemSelection test(topLeft, bottomRight);
|
||||||
if (test.contains(current))
|
if (test.contains(current)) {
|
||||||
{
|
|
||||||
instanceChanged(current, current);
|
instanceChanged(current, current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1724,34 +1605,28 @@ void MainWindow::selectionBad()
|
|||||||
void MainWindow::checkInstancePathForProblems()
|
void MainWindow::checkInstancePathForProblems()
|
||||||
{
|
{
|
||||||
QString instanceFolder = APPLICATION->settings()->get("InstanceDir").toString();
|
QString instanceFolder = APPLICATION->settings()->get("InstanceDir").toString();
|
||||||
if (FS::checkProblemticPathJava(QDir(instanceFolder)))
|
if (FS::checkProblemticPathJava(QDir(instanceFolder))) {
|
||||||
{
|
|
||||||
QMessageBox warning(this);
|
QMessageBox warning(this);
|
||||||
warning.setText(tr("Your instance folder contains \'!\' and this is known to cause Java problems!"));
|
warning.setText(tr("Your instance folder contains \'!\' and this is known to cause Java problems!"));
|
||||||
warning.setInformativeText(
|
warning.setInformativeText(tr("You have now two options: <br/>"
|
||||||
tr(
|
|
||||||
"You have now two options: <br/>"
|
|
||||||
" - change the instance folder in the settings <br/>"
|
" - change the instance folder in the settings <br/>"
|
||||||
" - move this installation of %1 to a different folder"
|
" - move this installation of %1 to a different folder")
|
||||||
).arg(BuildConfig.LAUNCHER_DISPLAYNAME)
|
.arg(BuildConfig.LAUNCHER_DISPLAYNAME));
|
||||||
);
|
|
||||||
warning.setDefaultButton(QMessageBox::Ok);
|
warning.setDefaultButton(QMessageBox::Ok);
|
||||||
warning.exec();
|
warning.exec();
|
||||||
}
|
}
|
||||||
auto tempFolderText = tr("This is a problem: <br/>"
|
auto tempFolderText =
|
||||||
|
tr("This is a problem: <br/>"
|
||||||
" - The launcher will likely be deleted without warning by the operating system <br/>"
|
" - The launcher will likely be deleted without warning by the operating system <br/>"
|
||||||
" - close the launcher now and extract it to a real location, not a temporary folder");
|
" - close the launcher now and extract it to a real location, not a temporary folder");
|
||||||
QString pathfoldername = QDir(instanceFolder).absolutePath();
|
QString pathfoldername = QDir(instanceFolder).absolutePath();
|
||||||
if (pathfoldername.contains("Rar$", Qt::CaseInsensitive))
|
if (pathfoldername.contains("Rar$", Qt::CaseInsensitive)) {
|
||||||
{
|
|
||||||
QMessageBox warning(this);
|
QMessageBox warning(this);
|
||||||
warning.setText(tr("Your instance folder contains \'Rar$\' - that means you haven't extracted the launcher archive!"));
|
warning.setText(tr("Your instance folder contains \'Rar$\' - that means you haven't extracted the launcher archive!"));
|
||||||
warning.setInformativeText(tempFolderText);
|
warning.setInformativeText(tempFolderText);
|
||||||
warning.setDefaultButton(QMessageBox::Ok);
|
warning.setDefaultButton(QMessageBox::Ok);
|
||||||
warning.exec();
|
warning.exec();
|
||||||
}
|
} else if (pathfoldername.startsWith(QDir::tempPath()) || pathfoldername.contains("/TempState/")) {
|
||||||
else if (pathfoldername.startsWith(QDir::tempPath()) || pathfoldername.contains("/TempState/"))
|
|
||||||
{
|
|
||||||
QMessageBox warning(this);
|
QMessageBox warning(this);
|
||||||
warning.setText(tr("Your instance folder is in a temporary folder: \'%1\'!").arg(QDir::tempPath()));
|
warning.setText(tr("Your instance folder is in a temporary folder: \'%1\'!").arg(QDir::tempPath()));
|
||||||
warning.setInformativeText(tempFolderText);
|
warning.setInformativeText(tempFolderText);
|
||||||
|
@ -73,6 +73,7 @@ InstanceView::InstanceView(QWidget *parent)
|
|||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
setAutoScroll(true);
|
setAutoScroll(true);
|
||||||
|
setPaintCat(APPLICATION->settings()->get("TheCat").toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
InstanceView::~InstanceView()
|
InstanceView::~InstanceView()
|
||||||
@ -498,12 +499,34 @@ void InstanceView::mouseDoubleClickEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstanceView::setPaintCat(bool visible)
|
||||||
|
{
|
||||||
|
m_catVisible = visible;
|
||||||
|
if (visible)
|
||||||
|
m_catPixmap.load(APPLICATION->getCatPack());
|
||||||
|
else
|
||||||
|
m_catPixmap = QPixmap();
|
||||||
|
}
|
||||||
|
|
||||||
void InstanceView::paintEvent(QPaintEvent* event)
|
void InstanceView::paintEvent(QPaintEvent* event)
|
||||||
{
|
{
|
||||||
executeDelayedItemsLayout();
|
executeDelayedItemsLayout();
|
||||||
|
|
||||||
QPainter painter(this->viewport());
|
QPainter painter(this->viewport());
|
||||||
|
|
||||||
|
if (m_catVisible) {
|
||||||
|
int widWidth = this->viewport()->width();
|
||||||
|
int widHeight = this->viewport()->height();
|
||||||
|
if (m_catPixmap.width() < widWidth)
|
||||||
|
widWidth = m_catPixmap.width();
|
||||||
|
if (m_catPixmap.height() < widHeight)
|
||||||
|
widHeight = m_catPixmap.height();
|
||||||
|
auto pixmap = m_catPixmap.scaled(widWidth, widHeight, Qt::KeepAspectRatio);
|
||||||
|
QRect rectOfPixmap = pixmap.rect();
|
||||||
|
rectOfPixmap.moveBottomRight(this->viewport()->rect().bottomRight());
|
||||||
|
painter.drawPixmap(rectOfPixmap.topLeft(), pixmap);
|
||||||
|
}
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
QStyleOptionViewItem option;
|
QStyleOptionViewItem option;
|
||||||
initViewItemOption(&option);
|
initViewItemOption(&option);
|
||||||
|
@ -85,10 +85,8 @@ public:
|
|||||||
|
|
||||||
virtual QRegion visualRegionForSelection(const QItemSelection &selection) const override;
|
virtual QRegion visualRegionForSelection(const QItemSelection &selection) const override;
|
||||||
|
|
||||||
int spacing() const
|
int spacing() const { return m_spacing; };
|
||||||
{
|
void setPaintCat(bool visible);
|
||||||
return m_spacing;
|
|
||||||
};
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void updateGeometries() override;
|
virtual void updateGeometries() override;
|
||||||
@ -139,6 +137,8 @@ private:
|
|||||||
int m_currentItemsPerRow = -1;
|
int m_currentItemsPerRow = -1;
|
||||||
int m_currentCursorColumn= -1;
|
int m_currentCursorColumn= -1;
|
||||||
mutable QCache<int, QRect> geometryCache;
|
mutable QCache<int, QRect> geometryCache;
|
||||||
|
bool m_catVisible = false;
|
||||||
|
QPixmap m_catPixmap;
|
||||||
|
|
||||||
// point where the currently active mouse action started in geometry coordinates
|
// point where the currently active mouse action started in geometry coordinates
|
||||||
QPoint m_pressedPosition;
|
QPoint m_pressedPosition;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user