aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/MainWindow.cpp
diff options
context:
space:
mode:
authorRachel Powers <508861+Ryex@users.noreply.github.com>2023-07-30 15:33:46 -0700
committerGitHub <noreply@github.com>2023-07-30 15:33:46 -0700
commitb9fe37aec14b7cc61cbef09d5d2256f68a48d220 (patch)
treed2f5422ffe3a2c4732068bdee3b6fede3404fb8e /launcher/ui/MainWindow.cpp
parent520594e5296b09205e55bc018b1f759df5725e96 (diff)
parent9137721e8e5b44f2338a36874a393435cbc6daa3 (diff)
downloadPrismLauncher-b9fe37aec14b7cc61cbef09d5d2256f68a48d220.tar.gz
PrismLauncher-b9fe37aec14b7cc61cbef09d5d2256f68a48d220.tar.bz2
PrismLauncher-b9fe37aec14b7cc61cbef09d5d2256f68a48d220.zip
Merge branch 'develop' into chore/add-compiler-warnings
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Diffstat (limited to 'launcher/ui/MainWindow.cpp')
-rw-r--r--launcher/ui/MainWindow.cpp616
1 files changed, 257 insertions, 359 deletions
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index ac2e73e4..1069ab25 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -43,102 +43,100 @@
#include "FileSystem.h"
#include "MainWindow.h"
+#include "ui/dialogs/ExportToModListDialog.h"
#include "ui_MainWindow.h"
-#include <QVariant>
-#include <QUrl>
#include <QDir>
#include <QFileInfo>
+#include <QUrl>
+#include <QVariant>
-#include <QKeyEvent>
#include <QAction>
#include <QActionGroup>
#include <QApplication>
#include <QButtonGroup>
+#include <QFileDialog>
#include <QHBoxLayout>
#include <QHeaderView>
+#include <QInputDialog>
+#include <QKeyEvent>
+#include <QLabel>
#include <QMainWindow>
-#include <QStatusBar>
-#include <QToolBar>
-#include <QWidget>
#include <QMenu>
#include <QMenuBar>
#include <QMessageBox>
-#include <QFileDialog>
-#include <QInputDialog>
-#include <QLabel>
-#include <QToolButton>
-#include <QWidgetAction>
#include <QProgressDialog>
#include <QShortcut>
+#include <QStatusBar>
+#include <QToolBar>
+#include <QToolButton>
+#include <QWidget>
+#include <QWidgetAction>
#include <BaseInstance.h>
+#include <BuildConfig.h>
+#include <DesktopServices.h>
#include <InstanceList.h>
-#include <minecraft/MinecraftInstance.h>
#include <MMCZip.h>
+#include <SkinUtils.h>
#include <icons/IconList.h>
-#include <java/JavaUtils.h>
#include <java/JavaInstallList.h>
+#include <java/JavaUtils.h>
#include <launch/LaunchTask.h>
+#include <minecraft/MinecraftInstance.h>
#include <minecraft/auth/AccountList.h>
-#include <SkinUtils.h>
-#include <BuildConfig.h>
-#include <net/NetJob.h>
#include <net/Download.h>
+#include <net/NetJob.h>
#include <news/NewsChecker.h>
#include <tools/BaseProfiler.h>
#include <updater/ExternalUpdater.h>
-#include <DesktopServices.h>
-#include "InstanceWindow.h"
#include "InstancePageProvider.h"
+#include "InstanceWindow.h"
#include "JavaCommon.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/CustomMessageBox.h"
-#include "ui/dialogs/IconPickerDialog.h"
#include "ui/dialogs/CopyInstanceDialog.h"
+#include "ui/dialogs/CustomMessageBox.h"
#include "ui/dialogs/EditAccountDialog.h"
#include "ui/dialogs/ExportInstanceDialog.h"
#include "ui/dialogs/ExportPackDialog.h"
+#include "ui/dialogs/IconPickerDialog.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/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/ShaderPackFolderModel.h"
-#include "minecraft/WorldList.h"
+#include "minecraft/mod/tasks/LocalResourceParse.h"
#include "KonamiCode.h"
-#include "InstanceImportTask.h"
#include "InstanceCopyTask.h"
+#include "InstanceImportTask.h"
#include "MMCTime.h"
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);
- }
- else
- {
+ } else {
return profile;
}
}
-}
+} // namespace
-MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
+MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
@@ -184,7 +182,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
ui->instanceToolBar->addContextMenuAction(ui->newsToolBar->toggleViewAction());
ui->instanceToolBar->addContextMenuAction(ui->instanceToolBar->toggleViewAction());
ui->instanceToolBar->addContextMenuAction(ui->actionLockToolbars);
-
}
// set the menu for the folders help, accounts, and export tool buttons
@@ -206,6 +203,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
exportInstanceMenu->addAction(ui->actionExportInstanceZip);
exportInstanceMenu->addAction(ui->actionExportInstanceMrPack);
exportInstanceMenu->addAction(ui->actionExportInstanceFlamePack);
+ exportInstanceMenu->addAction(ui->actionExportInstanceToModList);
ui->actionExportInstance->setMenu(exportInstanceMenu);
}
@@ -231,7 +229,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
if (qgetenv("XDG_CURRENT_DESKTOP") == "gamescope") {
ui->mainToolBar->addAction(ui->actionCloseWindow);
}
-
}
// add the toolbar toggles to the view menu
@@ -301,9 +298,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
connect(proxymodel, &InstanceProxyModel::dataChanged, this, &MainWindow::instanceDataChanged);
view->setModel(proxymodel);
- view->setSourceOfGroupCollapseStatus([](const QString & groupName)->bool {
- return APPLICATION->instances()->isGroupCollapsed(groupName);
- });
+ view->setSourceOfGroupCollapseStatus(
+ [](const QString& groupName) -> bool { return APPLICATION->instances()->isGroupCollapsed(groupName); });
connect(view, &InstanceView::groupStateChanged, APPLICATION->instances().get(), &InstanceList::on_GroupStateChanged);
ui->horizontalLayout->addWidget(view);
}
@@ -349,7 +345,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
statusBar()->addPermanentWidget(m_statusCenter, 0);
// Add "manage accounts" button, right align
- QWidget *spacer = new QWidget();
+ QWidget* spacer = new QWidget();
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
ui->mainToolBar->insertWidget(ui->actionAccountsButton, spacer);
@@ -361,21 +357,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
// 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(
- APPLICATION->accounts().get(),
- &AccountList::defaultAccountChanged,
- [this] {
- defaultAccountChanged();
- }
- );
- connect(
- APPLICATION->accounts().get(),
- &AccountList::listChanged,
- [this]
- {
- repopulateAccountsMenu();
- }
- );
+ connect(APPLICATION->accounts().get(), &AccountList::defaultAccountChanged, [this] { defaultAccountChanged(); });
+ connect(APPLICATION->accounts().get(), &AccountList::listChanged, [this] { repopulateAccountsMenu(); });
// Show initial account
defaultAccountChanged();
@@ -416,9 +399,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
// macOS always has a native menu bar, so these fixes are not applicable
// Other systems may or may not have a native menu bar (most do not - it seems like only Ubuntu Unity does)
#ifndef Q_OS_MAC
-void MainWindow::keyReleaseEvent(QKeyEvent *event)
+void MainWindow::keyReleaseEvent(QKeyEvent* event)
{
- if(event->key()==Qt::Key_Alt && !APPLICATION->settings()->get("MenuBarInsteadOfToolBar").toBool())
+ if (event->key() == Qt::Key_Alt && !APPLICATION->settings()->get("MenuBarInsteadOfToolBar").toBool())
ui->menuBar->setVisible(!ui->menuBar->isVisible());
else
QMainWindow::keyReleaseEvent(event);
@@ -427,7 +410,6 @@ void MainWindow::keyReleaseEvent(QKeyEvent *event)
void MainWindow::retranslateUi()
{
-
if (m_selectedInstance) {
m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
} else {
@@ -437,7 +419,7 @@ void MainWindow::retranslateUi()
ui->retranslateUi(this);
MinecraftAccountPtr defaultAccount = APPLICATION->accounts()->defaultAccount();
- if(defaultAccount) {
+ if (defaultAccount) {
auto profileLabel = profileInUseFilter(defaultAccount->profileName(), defaultAccount->isInUse());
ui->actionAccountsButton->setText(profileLabel);
}
@@ -457,14 +439,12 @@ void MainWindow::retranslateUi()
}
}
-MainWindow::~MainWindow()
-{
-}
+MainWindow::~MainWindow() {}
-QMenu * MainWindow::createPopupMenu()
+QMenu* MainWindow::createPopupMenu()
{
QMenu* filteredMenu = QMainWindow::createPopupMenu();
- filteredMenu->removeAction( ui->mainToolBar->toggleViewAction() );
+ filteredMenu->removeAction(ui->mainToolBar->toggleViewAction());
filteredMenu->addAction(ui->actionLockToolbars);
@@ -478,10 +458,11 @@ void MainWindow::lockToolbars(bool state)
APPLICATION->settings()->set("ToolbarsLocked", state);
}
-
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;
if (ui->mainToolBar->styleSheet() == stylesheet) {
ui->mainToolBar->setStyleSheet("");
@@ -500,16 +481,15 @@ void MainWindow::konamiTriggered()
}
}
-void MainWindow::showInstanceContextMenu(const QPoint &pos)
+void MainWindow::showInstanceContextMenu(const QPoint& pos)
{
- QList<QAction *> actions;
+ QList<QAction*> actions;
- QAction *actionSep = new QAction("", this);
+ QAction* actionSep = new QAction("", this);
actionSep->setSeparator(true);
bool onInstance = view->indexAt(pos).isValid();
- if (onInstance)
- {
+ if (onInstance) {
// reuse the file menu actions
actions = ui->fileMenu->actions();
@@ -523,18 +503,16 @@ void MainWindow::showInstanceContextMenu(const QPoint &pos)
// add header
actions.prepend(actionSep);
- QAction *actionVoid = new QAction(m_selectedInstance->name(), this);
+ QAction* actionVoid = new QAction(m_selectedInstance->name(), this);
actionVoid->setEnabled(false);
actions.prepend(actionVoid);
- }
- else
- {
+ } else {
auto group = view->groupNameAt(pos);
- QAction *actionVoid = new QAction(BuildConfig.LAUNCHER_DISPLAYNAME, this);
+ QAction* actionVoid = new QAction(BuildConfig.LAUNCHER_DISPLAYNAME, this);
actionVoid->setEnabled(false);
- QAction *actionCreateInstance = new QAction(tr("Create instance"), this);
+ QAction* actionCreateInstance = new QAction(tr("Create instance"), this);
actionCreateInstance->setToolTip(ui->actionAddInstance->toolTip());
if(!group.isNull())
{
@@ -581,39 +559,27 @@ void MainWindow::updateToolsMenu()
ui->actionLaunchInstanceOffline->setDisabled(!m_selectedInstance || currentInstanceRunning);
ui->actionLaunchInstanceDemo->setDisabled(!m_selectedInstance || currentInstanceRunning);
- QMenu *launchMenu = ui->actionLaunchInstance->menu();
- if (launchMenu)
- {
+ QMenu* launchMenu = ui->actionLaunchInstance->menu();
+ if (launchMenu) {
launchMenu->clear();
- }
- else
- {
+ } else {
launchMenu = new QMenu(this);
}
- QAction *normalLaunch = launchMenu->addAction(tr("Launch"));
+ QAction* normalLaunch = launchMenu->addAction(tr("Launch"));
normalLaunch->setShortcut(QKeySequence::Open);
- QAction *normalLaunchOffline = launchMenu->addAction(tr("Launch Offline"));
+ QAction* normalLaunchOffline = launchMenu->addAction(tr("Launch Offline"));
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")));
- if (m_selectedInstance)
- {
+ if (m_selectedInstance) {
normalLaunch->setEnabled(m_selectedInstance->canLaunch());
normalLaunchOffline->setEnabled(m_selectedInstance->canLaunch());
normalLaunchDemo->setEnabled(m_selectedInstance->canLaunch());
- connect(normalLaunch, &QAction::triggered, [this]() {
- 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);
- });
- }
- else
- {
+ connect(normalLaunch, &QAction::triggered, [this]() { 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); });
+ } else {
normalLaunch->setDisabled(true);
normalLaunchOffline->setDisabled(true);
normalLaunchDemo->setDisabled(true);
@@ -627,35 +593,25 @@ void MainWindow::updateToolsMenu()
QString profilersTitle = tr("Profilers");
launchMenu->addSeparator()->setText(profilersTitle);
- for (auto profiler : APPLICATION->profilers().values())
- {
- QAction *profilerAction = launchMenu->addAction(profiler->name());
- QAction *profilerOfflineAction = launchMenu->addAction(tr("%1 Offline").arg(profiler->name()));
+ for (auto profiler : APPLICATION->profilers().values()) {
+ QAction* profilerAction = launchMenu->addAction(profiler->name());
+ QAction* profilerOfflineAction = launchMenu->addAction(tr("%1 Offline").arg(profiler->name()));
QString error;
- if (!profiler->check(&error))
- {
+ if (!profiler->check(&error)) {
profilerAction->setDisabled(true);
profilerOfflineAction->setDisabled(true);
QString profilerToolTip = tr("Profiler not setup correctly. Go into settings, \"External Tools\".");
profilerAction->setToolTip(profilerToolTip);
profilerOfflineAction->setToolTip(profilerToolTip);
- }
- else if (m_selectedInstance)
- {
+ } else if (m_selectedInstance) {
profilerAction->setEnabled(m_selectedInstance->canLaunch());
profilerOfflineAction->setEnabled(m_selectedInstance->canLaunch());
- connect(profilerAction, &QAction::triggered, [this, profiler]()
- {
- APPLICATION->launch(m_selectedInstance, true, false, profiler.get());
- });
- connect(profilerOfflineAction, &QAction::triggered, [this, profiler]()
- {
- APPLICATION->launch(m_selectedInstance, false, false, profiler.get());
- });
- }
- else
- {
+ connect(profilerAction, &QAction::triggered,
+ [this, profiler]() { APPLICATION->launch(m_selectedInstance, true, false, profiler.get()); });
+ connect(profilerOfflineAction, &QAction::triggered,
+ [this, profiler]() { APPLICATION->launch(m_selectedInstance, false, false, profiler.get()); });
+ } else {
profilerAction->setDisabled(true);
profilerOfflineAction->setDisabled(true);
}
@@ -665,7 +621,7 @@ void MainWindow::updateToolsMenu()
void MainWindow::updateThemeMenu()
{
- QMenu *themeMenu = ui->actionChangeTheme->menu();
+ QMenu* themeMenu = ui->actionChangeTheme->menu();
if (themeMenu) {
themeMenu->clear();
@@ -675,10 +631,10 @@ void MainWindow::updateThemeMenu()
auto themes = APPLICATION->getValidApplicationThemes();
- QActionGroup* themesGroup = new QActionGroup( this );
+ QActionGroup* themesGroup = new QActionGroup(this);
for (auto* theme : themes) {
- QAction * themeAction = themeMenu->addAction(theme->name());
+ QAction* themeAction = themeMenu->addAction(theme->name());
themeAction->setCheckable(true);
if (APPLICATION->settings()->get("ApplicationTheme").toString() == theme->id()) {
@@ -700,7 +656,7 @@ void MainWindow::repopulateAccountsMenu()
ui->accountsMenu->clear();
// NOTE: this is done so the accounts button text is not set to the accounts menu title
- QMenu *accountsButtonMenu = ui->actionAccountsButton->menu();
+ QMenu* accountsButtonMenu = ui->actionAccountsButton->menu();
if (accountsButtonMenu) {
accountsButtonMenu->clear();
} else {
@@ -712,11 +668,9 @@ void MainWindow::repopulateAccountsMenu()
MinecraftAccountPtr defaultAccount = accounts->defaultAccount();
QString active_profileId = "";
- if (defaultAccount)
- {
+ if (defaultAccount) {
// this can be called before accountMenuButton exists
- if (ui->actionAccountsButton)
- {
+ if (ui->actionAccountsButton) {
auto profileLabel = profileInUseFilter(defaultAccount->profileName(), defaultAccount->isInUse());
ui->actionAccountsButton->setText(profileLabel);
}
@@ -724,38 +678,31 @@ void MainWindow::repopulateAccountsMenu()
QActionGroup* accountsGroup = new QActionGroup(this);
- if (accounts->count() <= 0)
- {
+ if (accounts->count() <= 0) {
ui->actionNoAccountsAdded->setEnabled(false);
ui->accountsMenu->addAction(ui->actionNoAccountsAdded);
- }
- else
- {
+ } else {
// 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);
auto profileLabel = profileInUseFilter(account->profileName(), account->isInUse());
- QAction *action = new QAction(profileLabel, this);
+ QAction* action = new QAction(profileLabel, this);
action->setData(i);
action->setCheckable(true);
action->setActionGroup(accountsGroup);
- if (defaultAccount == account)
- {
+ if (defaultAccount == account) {
action->setChecked(true);
}
auto face = account->getFace();
- if(!face.isNull()) {
+ if (!face.isNull()) {
action->setIcon(face);
- }
- else {
+ } else {
action->setIcon(APPLICATION->getThemedIcon("noaccount"));
}
const int highestNumberKey = 9;
- if(i<highestNumberKey)
- {
+ if (i < highestNumberKey) {
action->setShortcut(QKeySequence(tr("Ctrl+%1").arg(i + 1)));
}
@@ -782,8 +729,7 @@ void MainWindow::repopulateAccountsMenu()
void MainWindow::updatesAllowedChanged(bool allowed)
{
- if(!BuildConfig.UPDATER_ENABLED)
- {
+ if (!BuildConfig.UPDATER_ENABLED) {
return;
}
ui->actionCheckUpdate->setEnabled(allowed);
@@ -794,7 +740,7 @@ void MainWindow::updatesAllowedChanged(bool allowed)
*/
void MainWindow::changeActiveAccount()
{
- QAction *sAction = (QAction *)sender();
+ QAction* sAction = (QAction*)sender();
// Profile's associated Mojang username
if (sAction->data().type() != QVariant::Type::Int)
@@ -818,15 +764,13 @@ void MainWindow::defaultAccountChanged()
MinecraftAccountPtr account = APPLICATION->accounts()->defaultAccount();
// FIXME: this needs adjustment for MSA
- if (account && account->profileName() != "")
- {
+ if (account && account->profileName() != "") {
auto profileLabel = profileInUseFilter(account->profileName(), account->isInUse());
ui->actionAccountsButton->setText(profileLabel);
auto face = account->getFace();
- if(face.isNull()) {
+ if (face.isNull()) {
ui->actionAccountsButton->setIcon(APPLICATION->getThemedIcon("noaccount"));
- }
- else {
+ } else {
ui->actionAccountsButton->setIcon(face);
}
return;
@@ -837,33 +781,30 @@ void MainWindow::defaultAccountChanged()
ui->actionAccountsButton->setText(tr("Accounts"));
}
-bool MainWindow::eventFilter(QObject *obj, QEvent *ev)
+bool MainWindow::eventFilter(QObject* obj, QEvent* ev)
{
- if (obj == view)
- {
- if (ev->type() == QEvent::KeyPress)
- {
+ if (obj == view) {
+ if (ev->type() == QEvent::KeyPress) {
secretEventFilter->input(ev);
- QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev);
- switch (keyEvent->key())
- {
- /*
- case Qt::Key_Enter:
- case Qt::Key_Return:
- activateInstance(m_selectedInstance);
- return true;
- */
- case Qt::Key_Delete:
- on_actionDeleteInstance_triggered();
- return true;
- case Qt::Key_F5:
- refreshInstances();
- return true;
- case Qt::Key_F2:
- on_actionRenameInstance_triggered();
- return true;
- default:
- break;
+ QKeyEvent* keyEvent = static_cast<QKeyEvent*>(ev);
+ switch (keyEvent->key()) {
+ /*
+ case Qt::Key_Enter:
+ case Qt::Key_Return:
+ activateInstance(m_selectedInstance);
+ return true;
+ */
+ case Qt::Key_Delete:
+ on_actionDeleteInstance_triggered();
+ return true;
+ case Qt::Key_F5:
+ refreshInstances();
+ return true;
+ case Qt::Key_F2:
+ on_actionRenameInstance_triggered();
+ return true;
+ default:
+ break;
}
}
}
@@ -872,23 +813,17 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *ev)
void MainWindow::updateNewsLabel()
{
- if (m_newsChecker->isLoadingNews())
- {
+ if (m_newsChecker->isLoadingNews()) {
newsLabel->setText(tr("Loading news..."));
newsLabel->setEnabled(false);
ui->actionMoreNews->setVisible(false);
- }
- else
- {
+ } else {
QList<NewsEntryPtr> entries = m_newsChecker->getNewsEntries();
- if (entries.length() > 0)
- {
+ if (entries.length() > 0) {
newsLabel->setText(entries[0]->title);
newsLabel->setEnabled(true);
ui->actionMoreNews->setVisible(true);
- }
- else
- {
+ } else {
newsLabel->setText(tr("No news available."));
newsLabel->setEnabled(false);
ui->actionMoreNews->setVisible(false);
@@ -896,7 +831,7 @@ void MainWindow::updateNewsLabel()
}
}
-QList<int> stringToIntList(const QString &string)
+QList<int> stringToIntList(const QString& string)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QStringList split = string.split(',', Qt::SkipEmptyParts);
@@ -904,17 +839,15 @@ QList<int> stringToIntList(const QString &string)
QStringList split = string.split(',', QString::SkipEmptyParts);
#endif
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());
}
return out;
}
-QString intListToString(const QList<int> &list)
+QString intListToString(const QList<int>& list)
{
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)));
}
return slist.join(',');
@@ -932,30 +865,26 @@ void MainWindow::setCatBackground(bool enabled)
view->viewport()->repaint();
}
-void MainWindow::runModalTask(Task *task)
+void MainWindow::runModalTask(Task* task)
{
- connect(task, &Task::failed, [this](QString reason)
- {
- CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
- });
- connect(task, &Task::succeeded, [this, task]()
- {
- QStringList warnings = task->warnings();
- if(warnings.count())
- {
- CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
- }
- });
- connect(task, &Task::aborted, [this]
- {
- CustomMessageBox::selectable(this, tr("Task aborted"), tr("The task has been aborted by the user."), QMessageBox::Information)->show();
- });
+ connect(task, &Task::failed,
+ [this](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); });
+ connect(task, &Task::succeeded, [this, task]() {
+ QStringList warnings = task->warnings();
+ if (warnings.count()) {
+ CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
+ }
+ });
+ connect(task, &Task::aborted, [this] {
+ CustomMessageBox::selectable(this, tr("Task aborted"), tr("The task has been aborted by the user."), QMessageBox::Information)
+ ->show();
+ });
ProgressDialog loadDialog(this);
loadDialog.setSkipButton(true, tr("Abort"));
loadDialog.execWithTask(task);
}
-void MainWindow::instanceFromInstanceTask(InstanceTask *rawTask)
+void MainWindow::instanceFromInstanceTask(InstanceTask* rawTask)
{
unique_qobject_ptr<Task> task(APPLICATION->instances()->wrapInstanceTask(rawTask));
runModalTask(task.get());
@@ -982,52 +911,43 @@ void MainWindow::finalizeInstance(InstancePtr inst)
{
view->updateGeometries();
setSelectedInstanceById(inst->id());
- if (APPLICATION->accounts()->anyAccountIsValid())
- {
+ if (APPLICATION->accounts()->anyAccountIsValid()) {
ProgressDialog loadDialog(this);
auto update = inst->createUpdateTask(Net::Mode::Online);
- connect(update.get(), &Task::failed, [this](QString reason)
- {
- QString error = QString("Instance load failed: %1").arg(reason);
- CustomMessageBox::selectable(this, tr("Error"), error, QMessageBox::Warning)->show();
- });
- if(update)
- {
+ connect(update.get(), &Task::failed, [this](QString reason) {
+ QString error = QString("Instance load failed: %1").arg(reason);
+ CustomMessageBox::selectable(this, tr("Error"), error, QMessageBox::Warning)->show();
+ });
+ if (update) {
loadDialog.setSkipButton(true, tr("Abort"));
loadDialog.execWithTask(update.get());
}
- }
- else
- {
- CustomMessageBox::selectable(
- this,
- tr("Error"),
- tr("The launcher cannot download Minecraft or update instances unless you have at least "
- "one account added.\nPlease add your Mojang or Minecraft account."),
- QMessageBox::Warning
- )->show();
+ } else {
+ CustomMessageBox::selectable(this, tr("Error"),
+ tr("The launcher cannot download Minecraft or update instances unless you have at least "
+ "one account added.\nPlease add your Mojang or Minecraft account."),
+ QMessageBox::Warning)
+ ->show();
}
}
void MainWindow::addInstance(QString url)
{
QString groupName;
- do
- {
+ do {
QObject* obj = sender();
- if(!obj)
+ if (!obj)
break;
- QAction *action = qobject_cast<QAction *>(obj);
- if(!action)
+ QAction* action = qobject_cast<QAction*>(obj);
+ if (!action)
break;
auto map = action->data().toMap();
- if(!map.contains("group"))
+ if (!map.contains("group"))
break;
groupName = map["group"].toString();
- } while(0);
+ } while (0);
- if(groupName.isEmpty())
- {
+ if (groupName.isEmpty()) {
groupName = APPLICATION->settings()->get("LastUsedGroupForNewInstance").toString();
}
@@ -1037,9 +957,8 @@ void MainWindow::addInstance(QString url)
APPLICATION->settings()->set("LastUsedGroupForNewInstance", newInstDlg.instGroup());
- InstanceTask * creationTask = newInstDlg.extractTask();
- if(creationTask)
- {
+ InstanceTask* creationTask = newInstDlg.extractTask();
+ if (creationTask) {
instanceFromInstanceTask(creationTask);
}
}
@@ -1064,7 +983,7 @@ void MainWindow::processURLs(QList<QUrl> urls)
break;
}
- auto localFileName = QDir::toNativeSeparators(url.toLocalFile()) ;
+ auto localFileName = QDir::toNativeSeparators(url.toLocalFile());
QFileInfo localFileInfo(localFileName);
auto type = ResourceUtils::identify(localFileInfo);
@@ -1133,8 +1052,7 @@ void MainWindow::on_actionChangeInstIcon_triggered()
IconPickerDialog dlg(this);
dlg.execWithSelection(m_selectedInstance->iconKey());
- if (dlg.result() == QDialog::Accepted)
- {
+ if (dlg.result() == QDialog::Accepted) {
m_selectedInstance->setIconKey(dlg.selectedIconKey);
auto icon = APPLICATION->icons()->getIcon(dlg.selectedIconKey);
ui->actionChangeInstIcon->setIcon(icon);
@@ -1160,13 +1078,12 @@ void MainWindow::updateInstanceToolIcon(QString new_icon)
changeIconButton->setIcon(icon);
}
-void MainWindow::setSelectedInstanceById(const QString &id)
+void MainWindow::setSelectedInstanceById(const QString& id)
{
if (id.isNull())
return;
const QModelIndex index = APPLICATION->instances()->getInstanceIndexById(id);
- if (index.isValid())
- {
+ if (index.isValid()) {
QModelIndex selectionIndex = proxymodel->mapFromSource(index);
view->selectionModel()->setCurrentIndex(selectionIndex, QItemSelectionModel::ClearAndSelect);
updateStatusCenter();
@@ -1188,8 +1105,7 @@ void MainWindow::on_actionChangeInstGroup_triggered()
name = QInputDialog::getItem(this, tr("Group name"), tr("Enter a new group name."), groups, foo, true, &ok);
name = name.simplified();
- if (ok)
- {
+ if (ok) {
APPLICATION->instances()->setInstanceGroup(instId, name);
}
}
@@ -1197,21 +1113,19 @@ void MainWindow::on_actionChangeInstGroup_triggered()
void MainWindow::deleteGroup()
{
QObject* obj = sender();
- if(!obj)
+ if (!obj)
return;
- QAction *action = qobject_cast<QAction *>(obj);
- if(!action)
+ QAction* action = qobject_cast<QAction*>(obj);
+ if (!action)
return;
auto map = action->data().toMap();
- if(!map.contains("group"))
+ if (!map.contains("group"))
return;
QString groupName = map["group"].toString();
- if(!groupName.isEmpty())
- {
- auto reply = QMessageBox::question(this, tr("Delete group"), tr("Are you sure you want to delete the group %1?")
- .arg(groupName), QMessageBox::Yes | QMessageBox::No);
- if(reply == QMessageBox::Yes)
- {
+ if (!groupName.isEmpty()) {
+ auto reply = QMessageBox::question(this, tr("Delete group"), tr("Are you sure you want to delete the group %1?").arg(groupName),
+ QMessageBox::Yes | QMessageBox::No);
+ if (reply == QMessageBox::Yes) {
APPLICATION->instances()->deleteGroup(groupName);
}
}
@@ -1247,12 +1161,9 @@ void MainWindow::on_actionViewCentralModsFolder_triggered()
void MainWindow::checkForUpdates()
{
- if(BuildConfig.UPDATER_ENABLED)
- {
+ if (BuildConfig.UPDATER_ENABLED) {
APPLICATION->triggerUpdateCheck();
- }
- else
- {
+ } else {
qWarning() << "Updater not set up. Cannot check for updates.";
}
}
@@ -1280,16 +1191,16 @@ void MainWindow::globalSettingsClosed()
void MainWindow::on_actionEditInstance_triggered()
{
-
if (!m_selectedInstance)
return;
if (m_selectedInstance->canEdit()) {
APPLICATION->showInstanceWindow(m_selectedInstance);
- } else {
- CustomMessageBox::selectable(this, tr("Instance not editable"),
+ } else {
+ CustomMessageBox::selectable(this, tr("Instance not editable"),
tr("This instance is not editable. It may be broken, invalid, or too old. Check logs for details."),
- QMessageBox::Critical)->show();
+ QMessageBox::Critical)
+ ->show();
}
}
@@ -1352,7 +1263,8 @@ void MainWindow::newsButtonClicked()
news_dialog.exec();
}
-void MainWindow::onCatChanged(int) {
+void MainWindow::onCatChanged(int)
+{
setCatBackground(APPLICATION->settings()->get("TheCat").toBool());
}
@@ -1383,14 +1295,15 @@ void MainWindow::on_actionDeleteInstance_triggered()
auto linkedInstances = APPLICATION->instances()->getLinkedInstancesById(id);
if (!linkedInstances.empty()) {
- response = CustomMessageBox::selectable(
- this, tr("There are linked instances"),
- tr("The following instance(s) might reference files in this instance:\n\n"
- "%1\n\n"
- "Deleting it could break the other instance(s), \n\n"
- "Do you wish to proceed?", nullptr, linkedInstances.count()).arg(linkedInstances.join("\n")),
- QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No
- )->exec();
+ response = CustomMessageBox::selectable(this, tr("There are linked instances"),
+ tr("The following instance(s) might reference files in this instance:\n\n"
+ "%1\n\n"
+ "Deleting it could break the other instance(s), \n\n"
+ "Do you wish to proceed?",
+ nullptr, linkedInstances.count())
+ .arg(linkedInstances.join("\n")),
+ QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
+ ->exec();
if (response != QMessageBox::Yes)
return;
}
@@ -1405,8 +1318,7 @@ void MainWindow::on_actionDeleteInstance_triggered()
void MainWindow::on_actionExportInstanceZip_triggered()
{
- if (m_selectedInstance)
- {
+ if (m_selectedInstance) {
ExportInstanceDialog dlg(m_selectedInstance, this);
dlg.exec();
}
@@ -1414,13 +1326,20 @@ void MainWindow::on_actionExportInstanceZip_triggered()
void MainWindow::on_actionExportInstanceMrPack_triggered()
{
- if (m_selectedInstance)
- {
+ if (m_selectedInstance) {
ExportPackDialog dlg(m_selectedInstance, this);
dlg.exec();
}
}
+void MainWindow::on_actionExportInstanceToModList_triggered()
+{
+ if (m_selectedInstance) {
+ ExportToModListDialog dlg(m_selectedInstance, this);
+ dlg.exec();
+ }
+}
+
void MainWindow::on_actionExportInstanceFlamePack_triggered()
{
if (m_selectedInstance) {
@@ -1447,22 +1366,20 @@ void MainWindow::on_actionExportInstanceFlamePack_triggered()
void MainWindow::on_actionRenameInstance_triggered()
{
- if (m_selectedInstance)
- {
+ if (m_selectedInstance) {
view->edit(view->currentIndex());
}
}
void MainWindow::on_actionViewSelectedInstFolder_triggered()
{
- if (m_selectedInstance)
- {
+ if (m_selectedInstance) {
QString str = m_selectedInstance->instanceRoot();
DesktopServices::openDirectory(QDir(str).absolutePath());
}
}
-void MainWindow::closeEvent(QCloseEvent *event)
+void MainWindow::closeEvent(QCloseEvent* event)
{
// Save the window state and geometry.
APPLICATION->settings()->set("MainWindowState", saveState().toBase64());
@@ -1474,8 +1391,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
void MainWindow::changeEvent(QEvent* event)
{
- if (event->type() == QEvent::LanguageChange)
- {
+ if (event->type() == QEvent::LanguageChange) {
retranslateUi();
}
QMainWindow::changeEvent(event);
@@ -1495,8 +1411,7 @@ void MainWindow::instanceActivated(QModelIndex index)
void MainWindow::on_actionLaunchInstance_triggered()
{
- if(m_selectedInstance && !m_selectedInstance->isRunning())
- {
+ if (m_selectedInstance && !m_selectedInstance->isRunning()) {
APPLICATION->launch(m_selectedInstance);
}
}
@@ -1508,24 +1423,21 @@ void MainWindow::activateInstance(InstancePtr instance)
void MainWindow::on_actionLaunchInstanceOffline_triggered()
{
- if (m_selectedInstance)
- {
+ if (m_selectedInstance) {
APPLICATION->launch(m_selectedInstance, false);
}
}
void MainWindow::on_actionLaunchInstanceDemo_triggered()
{
- if (m_selectedInstance)
- {
+ if (m_selectedInstance) {
APPLICATION->launch(m_selectedInstance, false, true);
}
}
void MainWindow::on_actionKillInstance_triggered()
{
- if(m_selectedInstance && m_selectedInstance->isRunning())
- {
+ if (m_selectedInstance && m_selectedInstance->isRunning()) {
APPLICATION->kill(m_selectedInstance);
}
}
@@ -1546,39 +1458,36 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered()
QString iconPath;
QStringList args;
#if defined(Q_OS_MACOS)
- appPath = QApplication::applicationFilePath();
- if (appPath.startsWith("/private/var/")) {
- QMessageBox::critical(this, tr("Create instance shortcut"),
- tr("The launcher is in the folder it was extracted from, therefore it cannot create shortcuts."));
- return;
- }
+ appPath = QApplication::applicationFilePath();
+ if (appPath.startsWith("/private/var/")) {
+ QMessageBox::critical(this, tr("Create instance shortcut"),
+ tr("The launcher is in the folder it was extracted from, therefore it cannot create shortcuts."));
+ return;
+ }
- auto pIcon = APPLICATION->icons()->icon(m_selectedInstance->iconKey());
- if (pIcon == nullptr)
- {
- pIcon = APPLICATION->icons()->icon("grass");
- }
+ auto pIcon = APPLICATION->icons()->icon(m_selectedInstance->iconKey());
+ if (pIcon == nullptr) {
+ pIcon = APPLICATION->icons()->icon("grass");
+ }
- iconPath = FS::PathCombine(m_selectedInstance->instanceRoot(), "Icon.icns");
+ iconPath = FS::PathCombine(m_selectedInstance->instanceRoot(), "Icon.icns");
- QFile iconFile(iconPath);
- if (!iconFile.open(QFile::WriteOnly))
- {
- QMessageBox::critical(this, tr("Create instance Application"), tr("Failed to create icon for Application."));
- return;
- }
+ QFile iconFile(iconPath);
+ if (!iconFile.open(QFile::WriteOnly)) {
+ QMessageBox::critical(this, tr("Create instance Application"), tr("Failed to create icon for Application."));
+ return;
+ }
- QIcon icon = pIcon->icon();
+ QIcon icon = pIcon->icon();
- bool success = icon.pixmap(1024, 1024).save(iconPath, "ICNS");
- iconFile.close();
+ bool success = icon.pixmap(1024, 1024).save(iconPath, "ICNS");
+ iconFile.close();
- if (!success)
- {
- iconFile.remove();
- QMessageBox::critical(this, tr("Create instance Application"), tr("Failed to create icon for Application."));
- return;
- }
+ if (!success) {
+ iconFile.remove();
+ QMessageBox::critical(this, tr("Create instance Application"), tr("Failed to create icon for Application."));
+ return;
+ }
#elif defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
if (appPath.startsWith("/tmp/.mount_")) {
// AppImage!
@@ -1662,7 +1571,7 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered()
args.append({ "--launch", m_selectedInstance->id() });
if (FS::createShortcut(desktopFilePath, appPath, args, m_selectedInstance->name(), iconPath)) {
#if not defined(Q_OS_MACOS)
- QMessageBox::information(this, tr("Create instance shortcut"), tr("Created a shortcut to this instance on your desktop!"));
+ QMessageBox::information(this, tr("Create instance shortcut"), tr("Created a shortcut to this instance on your desktop!"));
#else
QMessageBox::information(this, tr("Create instance shortcut"), tr("Created a shortcut to this instance!"));
#endif
@@ -1676,24 +1585,23 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered()
void MainWindow::taskEnd()
{
- QObject *sender = QObject::sender();
+ QObject* sender = QObject::sender();
if (sender == m_versionLoadTask)
m_versionLoadTask = NULL;
sender->deleteLater();
}
-void MainWindow::startTask(Task *task)
+void MainWindow::startTask(Task* task)
{
connect(task, SIGNAL(succeeded()), SLOT(taskEnd()));
connect(task, SIGNAL(failed(QString)), SLOT(taskEnd()));
task->start();
}
-void MainWindow::instanceChanged(const QModelIndex &current, [[maybe_unused]] const QModelIndex &previous)
+void MainWindow::instanceChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
{
- if (!current.isValid())
- {
+ if (!current.isValid()) {
APPLICATION->settings()->set("SelectedInstance", QString());
selectionBad();
return;
@@ -1703,8 +1611,7 @@ void MainWindow::instanceChanged(const QModelIndex &current, [[maybe_unused]] co
}
QString id = current.data(InstanceList::InstanceIDRole).toString();
m_selectedInstance = APPLICATION->instances()->getInstanceById(id);
- if (m_selectedInstance)
- {
+ if (m_selectedInstance) {
ui->instanceToolBar->setEnabled(true);
setInstanceActionsEnabled(true);
ui->actionLaunchInstance->setEnabled(m_selectedInstance->canLaunch());
@@ -1714,7 +1621,7 @@ void MainWindow::instanceChanged(const QModelIndex &current, [[maybe_unused]] co
// Disable demo-mode if not available.
auto instance = dynamic_cast<MinecraftInstance*>(m_selectedInstance.get());
if (instance) {
- ui->actionLaunchInstanceDemo->setEnabled(instance->supportsDemo());
+ ui->actionLaunchInstanceDemo->setEnabled(instance->supportsDemo());
}
ui->actionKillInstance->setEnabled(m_selectedInstance->isRunning());
@@ -1729,9 +1636,7 @@ void MainWindow::instanceChanged(const QModelIndex &current, [[maybe_unused]] co
APPLICATION->settings()->set("SelectedInstance", m_selectedInstance->id());
connect(m_selectedInstance.get(), &BaseInstance::runningStatusChanged, this, &MainWindow::refreshCurrentInstance);
- }
- else
- {
+ } else {
ui->instanceToolBar->setEnabled(false);
setInstanceActionsEnabled(false);
ui->actionLaunchInstance->setEnabled(false);
@@ -1749,12 +1654,11 @@ void MainWindow::instanceSelectRequest(QString id)
setSelectedInstanceById(id);
}
-void MainWindow::instanceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
+void MainWindow::instanceDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
{
auto current = view->selectionModel()->currentIndex();
QItemSelection test(topLeft, bottomRight);
- if (test.contains(current))
- {
+ if (test.contains(current)) {
instanceChanged(current, current);
}
}
@@ -1778,34 +1682,28 @@ void MainWindow::selectionBad()
void MainWindow::checkInstancePathForProblems()
{
QString instanceFolder = APPLICATION->settings()->get("InstanceDir").toString();
- if (FS::checkProblemticPathJava(QDir(instanceFolder)))
- {
+ if (FS::checkProblemticPathJava(QDir(instanceFolder))) {
QMessageBox warning(this);
warning.setText(tr("Your instance folder contains \'!\' and this is known to cause Java problems!"));
- warning.setInformativeText(
- tr(
- "You have now two options: <br/>"
- " - change the instance folder in the settings <br/>"
- " - move this installation of %1 to a different folder"
- ).arg(BuildConfig.LAUNCHER_DISPLAYNAME)
- );
+ warning.setInformativeText(tr("You have now two options: <br/>"
+ " - change the instance folder in the settings <br/>"
+ " - move this installation of %1 to a different folder")
+ .arg(BuildConfig.LAUNCHER_DISPLAYNAME));
warning.setDefaultButton(QMessageBox::Ok);
warning.exec();
}
- auto tempFolderText = tr("This is a problem: <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");
+ auto tempFolderText =
+ tr("This is a problem: <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");
QString pathfoldername = QDir(instanceFolder).absolutePath();
- if (pathfoldername.contains("Rar$", Qt::CaseInsensitive))
- {
+ if (pathfoldername.contains("Rar$", Qt::CaseInsensitive)) {
QMessageBox warning(this);
warning.setText(tr("Your instance folder contains \'Rar$\' - that means you haven't extracted the launcher archive!"));
warning.setInformativeText(tempFolderText);
warning.setDefaultButton(QMessageBox::Ok);
warning.exec();
- }
- else if (pathfoldername.startsWith(QDir::tempPath()) || pathfoldername.contains("/TempState/"))
- {
+ } else if (pathfoldername.startsWith(QDir::tempPath()) || pathfoldername.contains("/TempState/")) {
QMessageBox warning(this);
warning.setText(tr("Your instance folder is in a temporary folder: \'%1\'!").arg(QDir::tempPath()));
warning.setInformativeText(tempFolderText);