aboutsummaryrefslogtreecommitdiff
path: root/launcher/dialogs
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2021-11-20 16:22:22 +0100
committerPetr Mrázek <peterix@gmail.com>2021-11-20 16:22:22 +0100
commit0c861db7a201c813530e703257f286257f39872f (patch)
tree5ba0e10632ecef461f50bcc6e32512062932a193 /launcher/dialogs
parenteafeb64decf9fa3b4ae9617abc777698e51b24d0 (diff)
downloadPrismLauncher-0c861db7a201c813530e703257f286257f39872f.tar.gz
PrismLauncher-0c861db7a201c813530e703257f286257f39872f.tar.bz2
PrismLauncher-0c861db7a201c813530e703257f286257f39872f.zip
NOISSUE Some happy little refactors
Diffstat (limited to 'launcher/dialogs')
-rw-r--r--launcher/dialogs/AboutDialog.cpp4
-rw-r--r--launcher/dialogs/CopyInstanceDialog.cpp10
-rw-r--r--launcher/dialogs/ExportInstanceDialog.cpp4
-rw-r--r--launcher/dialogs/IconPickerDialog.cpp12
-rw-r--r--launcher/dialogs/LoginDialog.h2
-rw-r--r--launcher/dialogs/MSALoginDialog.h2
-rw-r--r--launcher/dialogs/NewComponentDialog.cpp4
-rw-r--r--launcher/dialogs/NewInstanceDialog.cpp24
-rw-r--r--launcher/dialogs/ProfileSelectDialog.cpp4
-rw-r--r--launcher/dialogs/ProfileSelectDialog.h2
-rw-r--r--launcher/dialogs/ProfileSetupDialog.cpp10
-rw-r--r--launcher/dialogs/SkinUploadDialog.cpp9
-rw-r--r--launcher/dialogs/UpdateDialog.cpp12
-rw-r--r--launcher/dialogs/VersionSelectDialog.cpp2
14 files changed, 52 insertions, 49 deletions
diff --git a/launcher/dialogs/AboutDialog.cpp b/launcher/dialogs/AboutDialog.cpp
index 0c3f07db..6921bf63 100644
--- a/launcher/dialogs/AboutDialog.cpp
+++ b/launcher/dialogs/AboutDialog.cpp
@@ -16,7 +16,7 @@
#include "AboutDialog.h"
#include "ui_AboutDialog.h"
#include <QIcon>
-#include "Launcher.h"
+#include "Application.h"
#include "BuildConfig.h"
#include <net/NetJob.h>
@@ -88,7 +88,7 @@ AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDia
ui->urlLabel->setOpenExternalLinks(true);
- ui->icon->setPixmap(LAUNCHER->getThemedIcon("logo").pixmap(64));
+ ui->icon->setPixmap(APPLICATION->getThemedIcon("logo").pixmap(64));
ui->title->setText(launcherName);
ui->versionLabel->setText(tr("Version") +": " + BuildConfig.printableVersionString());
diff --git a/launcher/dialogs/CopyInstanceDialog.cpp b/launcher/dialogs/CopyInstanceDialog.cpp
index 802016d9..1c8d6711 100644
--- a/launcher/dialogs/CopyInstanceDialog.cpp
+++ b/launcher/dialogs/CopyInstanceDialog.cpp
@@ -16,7 +16,7 @@
#include <QLayout>
#include <QPushButton>
-#include "Launcher.h"
+#include "Application.h"
#include "CopyInstanceDialog.h"
#include "ui_CopyInstanceDialog.h"
@@ -36,16 +36,16 @@ CopyInstanceDialog::CopyInstanceDialog(InstancePtr original, QWidget *parent)
layout()->setSizeConstraint(QLayout::SetFixedSize);
InstIconKey = original->iconKey();
- ui->iconButton->setIcon(LAUNCHER->icons()->getIcon(InstIconKey));
+ ui->iconButton->setIcon(APPLICATION->icons()->getIcon(InstIconKey));
ui->instNameTextBox->setText(original->name());
ui->instNameTextBox->setFocus();
- auto groups = LAUNCHER->instances()->getGroups().toSet();
+ auto groups = APPLICATION->instances()->getGroups().toSet();
auto groupList = QStringList(groups.toList());
groupList.sort(Qt::CaseInsensitive);
groupList.removeOne("");
groupList.push_front("");
ui->groupBox->addItems(groupList);
- int index = groupList.indexOf(LAUNCHER->instances()->getInstanceGroup(m_original->id()));
+ int index = groupList.indexOf(APPLICATION->instances()->getInstanceGroup(m_original->id()));
if(index == -1)
{
index = 0;
@@ -99,7 +99,7 @@ void CopyInstanceDialog::on_iconButton_clicked()
if (dlg.result() == QDialog::Accepted)
{
InstIconKey = dlg.selectedIconKey;
- ui->iconButton->setIcon(LAUNCHER->icons()->getIcon(InstIconKey));
+ ui->iconButton->setIcon(APPLICATION->icons()->getIcon(InstIconKey));
}
}
diff --git a/launcher/dialogs/ExportInstanceDialog.cpp b/launcher/dialogs/ExportInstanceDialog.cpp
index 639b7043..1a164875 100644
--- a/launcher/dialogs/ExportInstanceDialog.cpp
+++ b/launcher/dialogs/ExportInstanceDialog.cpp
@@ -27,7 +27,7 @@
#include <QSaveFile>
#include "MMCStrings.h"
#include "SeparatorPrefixTree.h"
-#include "Launcher.h"
+#include "Application.h"
#include <icons/IconList.h>
#include <FileSystem.h>
@@ -341,7 +341,7 @@ ExportInstanceDialog::~ExportInstanceDialog()
void SaveIcon(InstancePtr m_instance)
{
auto iconKey = m_instance->iconKey();
- auto iconList = LAUNCHER->icons();
+ auto iconList = APPLICATION->icons();
auto mmcIcon = iconList->icon(iconKey);
if(!mmcIcon || mmcIcon->isBuiltIn()) {
return;
diff --git a/launcher/dialogs/IconPickerDialog.cpp b/launcher/dialogs/IconPickerDialog.cpp
index a1c432a8..af9d0683 100644
--- a/launcher/dialogs/IconPickerDialog.cpp
+++ b/launcher/dialogs/IconPickerDialog.cpp
@@ -17,7 +17,7 @@
#include <QPushButton>
#include <QFileDialog>
-#include "Launcher.h"
+#include "Application.h"
#include "IconPickerDialog.h"
#include "ui_IconPickerDialog.h"
@@ -59,7 +59,7 @@ IconPickerDialog::IconPickerDialog(QWidget *parent)
contentsWidget->installEventFilter(this);
- contentsWidget->setModel(LAUNCHER->icons().get());
+ contentsWidget->setModel(APPLICATION->icons().get());
// NOTE: ResetRole forces the button to be on the left, while the OK/Cancel ones are on the right. We win.
auto buttonAdd = ui->buttonBox->addButton(tr("Add Icon"), QDialogButtonBox::ResetRole);
@@ -106,12 +106,12 @@ void IconPickerDialog::addNewIcon()
//: The type of icon files
auto filter = IconUtils::getIconFilter();
QStringList fileNames = QFileDialog::getOpenFileNames(this, selectIcons, QString(), tr("Icons %1").arg(filter));
- LAUNCHER->icons()->installIcons(fileNames);
+ APPLICATION->icons()->installIcons(fileNames);
}
void IconPickerDialog::removeSelectedIcon()
{
- LAUNCHER->icons()->deleteIcon(selectedIconKey);
+ APPLICATION->icons()->deleteIcon(selectedIconKey);
}
void IconPickerDialog::activated(QModelIndex index)
@@ -133,7 +133,7 @@ void IconPickerDialog::selectionChanged(QItemSelection selected, QItemSelection
int IconPickerDialog::execWithSelection(QString selection)
{
- auto list = LAUNCHER->icons();
+ auto list = APPLICATION->icons();
auto contentsWidget = ui->iconView;
selectedIconKey = selection;
@@ -159,5 +159,5 @@ IconPickerDialog::~IconPickerDialog()
void IconPickerDialog::openFolder()
{
- DesktopServices::openDirectory(LAUNCHER->icons()->getDirectory(), true);
+ DesktopServices::openDirectory(APPLICATION->icons()->getDirectory(), true);
}
diff --git a/launcher/dialogs/LoginDialog.h b/launcher/dialogs/LoginDialog.h
index 13463640..833cb570 100644
--- a/launcher/dialogs/LoginDialog.h
+++ b/launcher/dialogs/LoginDialog.h
@@ -54,5 +54,5 @@ slots:
private:
Ui::LoginDialog *ui;
MinecraftAccountPtr m_account;
- std::shared_ptr<Task> m_loginTask;
+ shared_qobject_ptr<Task> m_loginTask;
};
diff --git a/launcher/dialogs/MSALoginDialog.h b/launcher/dialogs/MSALoginDialog.h
index 3d26a0dd..4cf146ab 100644
--- a/launcher/dialogs/MSALoginDialog.h
+++ b/launcher/dialogs/MSALoginDialog.h
@@ -55,7 +55,7 @@ slots:
private:
Ui::MSALoginDialog *ui;
MinecraftAccountPtr m_account;
- std::shared_ptr<AccountTask> m_loginTask;
+ shared_qobject_ptr<AccountTask> m_loginTask;
QTimer m_externalLoginTimer;
int m_externalLoginElapsed = 0;
int m_externalLoginTimeout = 0;
diff --git a/launcher/dialogs/NewComponentDialog.cpp b/launcher/dialogs/NewComponentDialog.cpp
index 1cea54f4..1bbafb0c 100644
--- a/launcher/dialogs/NewComponentDialog.cpp
+++ b/launcher/dialogs/NewComponentDialog.cpp
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-#include "Launcher.h"
+#include "Application.h"
#include "NewComponentDialog.h"
#include "ui_NewComponentDialog.h"
@@ -46,7 +46,7 @@ NewComponentDialog::NewComponentDialog(const QString & initialName, const QStrin
connect(ui->nameTextBox, &QLineEdit::textChanged, this, &NewComponentDialog::updateDialogState);
connect(ui->uidTextBox, &QLineEdit::textChanged, this, &NewComponentDialog::updateDialogState);
- auto groups = LAUNCHER->instances()->getGroups().toSet();
+ auto groups = APPLICATION->instances()->getGroups().toSet();
ui->nameTextBox->setFocus();
originalPlaceholderText = ui->uidTextBox->placeholderText();
diff --git a/launcher/dialogs/NewInstanceDialog.cpp b/launcher/dialogs/NewInstanceDialog.cpp
index d18eb3d5..a19f91b7 100644
--- a/launcher/dialogs/NewInstanceDialog.cpp
+++ b/launcher/dialogs/NewInstanceDialog.cpp
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-#include "Launcher.h"
+#include "Application.h"
#include "NewInstanceDialog.h"
#include "ui_NewInstanceDialog.h"
@@ -48,12 +48,12 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString
{
ui->setupUi(this);
- setWindowIcon(LAUNCHER->getThemedIcon("new"));
+ setWindowIcon(APPLICATION->getThemedIcon("new"));
InstIconKey = "default";
- ui->iconButton->setIcon(LAUNCHER->icons()->getIcon(InstIconKey));
+ ui->iconButton->setIcon(APPLICATION->icons()->getIcon(InstIconKey));
- auto groups = LAUNCHER->instances()->getGroups().toSet();
+ auto groups = APPLICATION->instances()->getGroups().toSet();
auto groupList = QStringList(groups.toList());
groupList.sort(Qt::CaseInsensitive);
groupList.removeOne("");
@@ -105,18 +105,18 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString
updateDialogState();
- restoreGeometry(QByteArray::fromBase64(LAUNCHER->settings()->get("NewInstanceGeometry").toByteArray()));
+ restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get("NewInstanceGeometry").toByteArray()));
}
void NewInstanceDialog::reject()
{
- LAUNCHER->settings()->set("NewInstanceGeometry", saveGeometry().toBase64());
+ APPLICATION->settings()->set("NewInstanceGeometry", saveGeometry().toBase64());
QDialog::reject();
}
void NewInstanceDialog::accept()
{
- LAUNCHER->settings()->set("NewInstanceGeometry", saveGeometry().toBase64());
+ APPLICATION->settings()->set("NewInstanceGeometry", saveGeometry().toBase64());
importIconNow();
QDialog::accept();
}
@@ -155,7 +155,7 @@ void NewInstanceDialog::setSuggestedPack(const QString& name, InstanceTask* task
if(!task)
{
- ui->iconButton->setIcon(LAUNCHER->icons()->getIcon("default"));
+ ui->iconButton->setIcon(APPLICATION->icons()->getIcon("default"));
importIcon = false;
}
@@ -175,7 +175,7 @@ void NewInstanceDialog::setSuggestedIconFromFile(const QString &path, const QStr
void NewInstanceDialog::setSuggestedIcon(const QString &key)
{
- auto icon = LAUNCHER->icons()->getIcon(key);
+ auto icon = APPLICATION->icons()->getIcon(key);
importIcon = false;
ui->iconButton->setIcon(icon);
@@ -234,7 +234,7 @@ void NewInstanceDialog::on_iconButton_clicked()
if (dlg.result() == QDialog::Accepted)
{
InstIconKey = dlg.selectedIconKey;
- ui->iconButton->setIcon(LAUNCHER->icons()->getIcon(InstIconKey));
+ ui->iconButton->setIcon(APPLICATION->icons()->getIcon(InstIconKey));
importIcon = false;
}
}
@@ -247,9 +247,9 @@ void NewInstanceDialog::on_instNameTextBox_textChanged(const QString &arg1)
void NewInstanceDialog::importIconNow()
{
if(importIcon) {
- LAUNCHER->icons()->installIcon(importIconPath, importIconName);
+ APPLICATION->icons()->installIcon(importIconPath, importIconName);
InstIconKey = importIconName;
importIcon = false;
}
- LAUNCHER->settings()->set("NewInstanceGeometry", saveGeometry().toBase64());
+ APPLICATION->settings()->set("NewInstanceGeometry", saveGeometry().toBase64());
}
diff --git a/launcher/dialogs/ProfileSelectDialog.cpp b/launcher/dialogs/ProfileSelectDialog.cpp
index 1082748f..0e3e493c 100644
--- a/launcher/dialogs/ProfileSelectDialog.cpp
+++ b/launcher/dialogs/ProfileSelectDialog.cpp
@@ -23,14 +23,14 @@
#include <dialogs/ProgressDialog.h>
-#include <Launcher.h>
+#include <Application.h>
ProfileSelectDialog::ProfileSelectDialog(const QString &message, int flags, QWidget *parent)
: QDialog(parent), ui(new Ui::ProfileSelectDialog)
{
ui->setupUi(this);
- m_accounts = LAUNCHER->accounts();
+ m_accounts = APPLICATION->accounts();
auto view = ui->listView;
//view->setModel(m_accounts.get());
//view->hideColumn(AccountList::ActiveColumn);
diff --git a/launcher/dialogs/ProfileSelectDialog.h b/launcher/dialogs/ProfileSelectDialog.h
index a4acd9a1..38aa4249 100644
--- a/launcher/dialogs/ProfileSelectDialog.h
+++ b/launcher/dialogs/ProfileSelectDialog.h
@@ -80,7 +80,7 @@ slots:
void on_buttonBox_rejected();
protected:
- std::shared_ptr<AccountList> m_accounts;
+ shared_qobject_ptr<AccountList> m_accounts;
//! The account that was selected when the user clicked OK.
MinecraftAccountPtr m_selected;
diff --git a/launcher/dialogs/ProfileSetupDialog.cpp b/launcher/dialogs/ProfileSetupDialog.cpp
index e3d7aec2..51c20202 100644
--- a/launcher/dialogs/ProfileSetupDialog.cpp
+++ b/launcher/dialogs/ProfileSetupDialog.cpp
@@ -23,19 +23,21 @@
#include <dialogs/ProgressDialog.h>
-#include <Launcher.h>
+#include <Application.h>
#include <minecraft/auth/flows/AuthRequest.h>
#include <minecraft/auth/flows/Parsers.h>
+#include <QJsonDocument>
+
ProfileSetupDialog::ProfileSetupDialog(MinecraftAccountPtr accountToSetup, QWidget *parent)
: QDialog(parent), m_accountToSetup(accountToSetup), ui(new Ui::ProfileSetupDialog)
{
ui->setupUi(this);
ui->errorLabel->setVisible(false);
- goodIcon = LAUNCHER->getThemedIcon("status-good");
- yellowIcon = LAUNCHER->getThemedIcon("status-yellow");
- badIcon = LAUNCHER->getThemedIcon("status-bad");
+ goodIcon = APPLICATION->getThemedIcon("status-good");
+ yellowIcon = APPLICATION->getThemedIcon("status-yellow");
+ badIcon = APPLICATION->getThemedIcon("status-bad");
QRegExp permittedNames("[a-zA-Z0-9_]{3,16}");
auto nameEdit = ui->nameEdit;
diff --git a/launcher/dialogs/SkinUploadDialog.cpp b/launcher/dialogs/SkinUploadDialog.cpp
index 97478f4b..4e6142fa 100644
--- a/launcher/dialogs/SkinUploadDialog.cpp
+++ b/launcher/dialogs/SkinUploadDialog.cpp
@@ -3,14 +3,15 @@
#include <QPainter>
#include <FileSystem.h>
+
#include <minecraft/services/SkinUpload.h>
+#include <minecraft/services/CapeChange.h>
#include <tasks/SequentialTask.h>
#include "SkinUploadDialog.h"
#include "ui_SkinUploadDialog.h"
#include "ProgressDialog.h"
#include "CustomMessageBox.h"
-#include <minecraft/services/CapeChange.h>
void SkinUploadDialog::on_buttonBox_rejected()
{
@@ -91,10 +92,10 @@ void SkinUploadDialog::on_buttonBox_accepted()
model = SkinUpload::ALEX;
}
SequentialTask skinUpload;
- skinUpload.addTask(std::make_shared<SkinUpload>(this, session, FS::read(fileName), model));
+ skinUpload.addTask(shared_qobject_ptr<SkinUpload>(new SkinUpload(this, session, FS::read(fileName), model)));
auto selectedCape = ui->capeCombo->currentData().toString();
- if(selectedCape != session->m_accountPtr->accountData()->minecraftProfile.currentCape) {
- skinUpload.addTask(std::make_shared<CapeChange>(this, session, selectedCape));
+ if(selectedCape != m_acct->accountData()->minecraftProfile.currentCape) {
+ skinUpload.addTask(shared_qobject_ptr<CapeChange>(new CapeChange(this, session, selectedCape)));
}
if (prog.execWithTask(&skinUpload) != QDialog::Accepted)
{
diff --git a/launcher/dialogs/UpdateDialog.cpp b/launcher/dialogs/UpdateDialog.cpp
index ca3bd915..f3701546 100644
--- a/launcher/dialogs/UpdateDialog.cpp
+++ b/launcher/dialogs/UpdateDialog.cpp
@@ -1,7 +1,7 @@
#include "UpdateDialog.h"
#include "ui_UpdateDialog.h"
#include <QDebug>
-#include "Launcher.h"
+#include "Application.h"
#include <settings/SettingsObject.h>
#include <Json.h>
@@ -11,7 +11,7 @@
UpdateDialog::UpdateDialog(bool hasUpdate, QWidget *parent) : QDialog(parent), ui(new Ui::UpdateDialog)
{
ui->setupUi(this);
- auto channel = LAUNCHER->settings()->get("UpdateChannel").toString();
+ auto channel = APPLICATION->settings()->get("UpdateChannel").toString();
if(hasUpdate)
{
ui->label->setText(tr("A new %1 update is available!").arg(channel));
@@ -24,7 +24,7 @@ UpdateDialog::UpdateDialog(bool hasUpdate, QWidget *parent) : QDialog(parent), u
}
ui->changelogBrowser->setHtml(tr("<center><h1>Loading changelog...</h1></center>"));
loadChangelog();
- restoreGeometry(QByteArray::fromBase64(LAUNCHER->settings()->get("UpdateDialogGeometry").toByteArray()));
+ restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get("UpdateDialogGeometry").toByteArray()));
}
UpdateDialog::~UpdateDialog()
@@ -33,7 +33,7 @@ UpdateDialog::~UpdateDialog()
void UpdateDialog::loadChangelog()
{
- auto channel = LAUNCHER->settings()->get("UpdateChannel").toString();
+ auto channel = APPLICATION->settings()->get("UpdateChannel").toString();
dljob.reset(new NetJob("Changelog"));
QString url;
if(channel == "stable")
@@ -65,7 +65,7 @@ QString reprocessMarkdown(QByteArray markdown)
QString reprocessCommits(QByteArray json)
{
- auto channel = LAUNCHER->settings()->get("UpdateChannel").toString();
+ auto channel = APPLICATION->settings()->get("UpdateChannel").toString();
try
{
QString result;
@@ -177,6 +177,6 @@ void UpdateDialog::on_btnUpdateNow_clicked()
void UpdateDialog::closeEvent(QCloseEvent* evt)
{
- LAUNCHER->settings()->set("UpdateDialogGeometry", saveGeometry().toBase64());
+ APPLICATION->settings()->set("UpdateDialogGeometry", saveGeometry().toBase64());
QDialog::closeEvent(evt);
}
diff --git a/launcher/dialogs/VersionSelectDialog.cpp b/launcher/dialogs/VersionSelectDialog.cpp
index 82eb70f4..a920f6b7 100644
--- a/launcher/dialogs/VersionSelectDialog.cpp
+++ b/launcher/dialogs/VersionSelectDialog.cpp
@@ -28,7 +28,7 @@
#include <BaseVersionList.h>
#include <tasks/Task.h>
#include <QDebug>
-#include "Launcher.h"
+#include "Application.h"
#include <VersionProxyModel.h>
#include <widgets/VersionSelectWidget.h>