mirror of
https://github.com/PrismLauncher/PrismLauncher
synced 2026-04-23 09:05:03 +00:00
feat: add Manage Skins menu item to accounts button in MainWindow (#5414)
This commit is contained in:
commit
48f240703f
|
|
@ -105,6 +105,7 @@
|
||||||
#include "ui/dialogs/NewInstanceDialog.h"
|
#include "ui/dialogs/NewInstanceDialog.h"
|
||||||
#include "ui/dialogs/NewsDialog.h"
|
#include "ui/dialogs/NewsDialog.h"
|
||||||
#include "ui/dialogs/ProgressDialog.h"
|
#include "ui/dialogs/ProgressDialog.h"
|
||||||
|
#include "ui/dialogs/skins/SkinManageDialog.h"
|
||||||
#include "ui/instanceview/InstanceDelegate.h"
|
#include "ui/instanceview/InstanceDelegate.h"
|
||||||
#include "ui/instanceview/InstanceProxyModel.h"
|
#include "ui/instanceview/InstanceProxyModel.h"
|
||||||
#include "ui/instanceview/InstanceView.h"
|
#include "ui/instanceview/InstanceView.h"
|
||||||
|
|
@ -180,7 +181,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||||
ui->instanceToolBar->insertSeparator(ui->actionLaunchInstance);
|
ui->instanceToolBar->insertSeparator(ui->actionLaunchInstance);
|
||||||
|
|
||||||
// restore the instance toolbar settings
|
// restore the instance toolbar settings
|
||||||
auto const setting_name = QString("WideBarVisibility_%1").arg(ui->instanceToolBar->objectName());
|
const auto setting_name = QString("WideBarVisibility_%1").arg(ui->instanceToolBar->objectName());
|
||||||
instanceToolbarSetting = APPLICATION->settings()->getOrRegisterSetting(setting_name);
|
instanceToolbarSetting = APPLICATION->settings()->getOrRegisterSetting(setting_name);
|
||||||
|
|
||||||
ui->instanceToolBar->setVisibilityState(QByteArray::fromBase64(instanceToolbarSetting->get().toString().toUtf8()));
|
ui->instanceToolBar->setVisibilityState(QByteArray::fromBase64(instanceToolbarSetting->get().toString().toUtf8()));
|
||||||
|
|
@ -396,6 +397,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||||
// 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(APPLICATION->accounts(), &AccountList::defaultAccountChanged, [this] { defaultAccountChanged(); });
|
connect(APPLICATION->accounts(), &AccountList::defaultAccountChanged, [this] { defaultAccountChanged(); });
|
||||||
|
connect(APPLICATION->accounts(), &AccountList::listActivityChanged, [this] { defaultAccountChanged(); });
|
||||||
connect(APPLICATION->accounts(), &AccountList::listChanged, [this] { defaultAccountChanged(); });
|
connect(APPLICATION->accounts(), &AccountList::listChanged, [this] { defaultAccountChanged(); });
|
||||||
|
|
||||||
// Show initial account
|
// Show initial account
|
||||||
|
|
@ -653,6 +655,9 @@ void MainWindow::repopulateAccountsMenu()
|
||||||
|
|
||||||
auto accounts = APPLICATION->accounts();
|
auto accounts = APPLICATION->accounts();
|
||||||
MinecraftAccountPtr defaultAccount = accounts->defaultAccount();
|
MinecraftAccountPtr defaultAccount = accounts->defaultAccount();
|
||||||
|
|
||||||
|
bool canChangeSkin = defaultAccount && (defaultAccount->accountType() == AccountType::MSA) && !defaultAccount->isActive();
|
||||||
|
ui->actionManageSkins->setEnabled(canChangeSkin);
|
||||||
|
|
||||||
QString active_profileId = "";
|
QString active_profileId = "";
|
||||||
if (defaultAccount) {
|
if (defaultAccount) {
|
||||||
|
|
@ -709,6 +714,7 @@ void MainWindow::repopulateAccountsMenu()
|
||||||
connect(ui->actionNoDefaultAccount, &QAction::triggered, this, &MainWindow::changeActiveAccount);
|
connect(ui->actionNoDefaultAccount, &QAction::triggered, this, &MainWindow::changeActiveAccount);
|
||||||
|
|
||||||
ui->accountsMenu->addSeparator();
|
ui->accountsMenu->addSeparator();
|
||||||
|
ui->accountsMenu->addAction(ui->actionManageSkins);
|
||||||
ui->accountsMenu->addAction(ui->actionManageAccounts);
|
ui->accountsMenu->addAction(ui->actionManageAccounts);
|
||||||
|
|
||||||
accountsButtonMenu->addActions(ui->accountsMenu->actions());
|
accountsButtonMenu->addActions(ui->accountsMenu->actions());
|
||||||
|
|
@ -942,9 +948,7 @@ void MainWindow::processURLs(QList<QUrl> urls)
|
||||||
QUrl local_url;
|
QUrl local_url;
|
||||||
if (!url.isLocalFile()) { // download the remote resource and identify
|
if (!url.isLocalFile()) { // download the remote resource and identify
|
||||||
|
|
||||||
const bool isExternalURLImport =
|
const bool isExternalURLImport = (url.host().toLower() == "import") || (url.path().startsWith("/import", Qt::CaseInsensitive));
|
||||||
(url.host().toLower() == "import") ||
|
|
||||||
(url.path().startsWith("/import", Qt::CaseInsensitive));
|
|
||||||
|
|
||||||
QUrl dl_url;
|
QUrl dl_url;
|
||||||
if (url.scheme() == "curseforge" || (url.scheme() == BuildConfig.LAUNCHER_APP_BINARY_NAME && url.host() == "install")) {
|
if (url.scheme() == "curseforge" || (url.scheme() == BuildConfig.LAUNCHER_APP_BINARY_NAME && url.host() == "install")) {
|
||||||
|
|
@ -952,7 +956,7 @@ void MainWindow::processURLs(QList<QUrl> urls)
|
||||||
// format of url curseforge://install?addonId=IDHERE&fileId=IDHERE
|
// format of url curseforge://install?addonId=IDHERE&fileId=IDHERE
|
||||||
// format of url binaryname://install?platform=curseforge&addonId=IDHERE&fileId=IDHERE
|
// format of url binaryname://install?platform=curseforge&addonId=IDHERE&fileId=IDHERE
|
||||||
QUrlQuery query(url);
|
QUrlQuery query(url);
|
||||||
|
|
||||||
// check if this is a binaryname:// url
|
// check if this is a binaryname:// url
|
||||||
if (url.scheme() == BuildConfig.LAUNCHER_APP_BINARY_NAME) {
|
if (url.scheme() == BuildConfig.LAUNCHER_APP_BINARY_NAME) {
|
||||||
// check this is an curseforge platform request
|
// check this is an curseforge platform request
|
||||||
|
|
@ -1015,8 +1019,7 @@ void MainWindow::processURLs(QList<QUrl> urls)
|
||||||
receivedData.insert(it->first, it->second);
|
receivedData.insert(it->first, it->second);
|
||||||
emit APPLICATION->oauthReplyRecieved(receivedData);
|
emit APPLICATION->oauthReplyRecieved(receivedData);
|
||||||
continue;
|
continue;
|
||||||
} else if ((url.scheme() == "prismlauncher" || url.scheme() == BuildConfig.LAUNCHER_APP_BINARY_NAME)
|
} else if ((url.scheme() == "prismlauncher" || url.scheme() == BuildConfig.LAUNCHER_APP_BINARY_NAME) && isExternalURLImport) {
|
||||||
&& isExternalURLImport) {
|
|
||||||
// PrismLauncher URL protocol modpack import
|
// PrismLauncher URL protocol modpack import
|
||||||
// works for any prism fork
|
// works for any prism fork
|
||||||
// preferred import format: prismlauncher://import?url=ENCODED
|
// preferred import format: prismlauncher://import?url=ENCODED
|
||||||
|
|
@ -1035,7 +1038,6 @@ void MainWindow::processURLs(QList<QUrl> urls)
|
||||||
|
|
||||||
// alternative import format: prismlauncher://import/ENCODED
|
// alternative import format: prismlauncher://import/ENCODED
|
||||||
if (encodedTarget.isEmpty()) {
|
if (encodedTarget.isEmpty()) {
|
||||||
|
|
||||||
QString p = path;
|
QString p = path;
|
||||||
|
|
||||||
if (p.startsWith("/import/", Qt::CaseInsensitive)) {
|
if (p.startsWith("/import/", Qt::CaseInsensitive)) {
|
||||||
|
|
@ -1050,12 +1052,9 @@ void MainWindow::processURLs(QList<QUrl> urls)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encodedTarget.isEmpty()) {
|
if (encodedTarget.isEmpty()) {
|
||||||
CustomMessageBox::selectable(
|
CustomMessageBox::selectable(this, tr("Error"), tr("Invalid import link: missing 'url' parameter."),
|
||||||
this,
|
QMessageBox::Critical)
|
||||||
tr("Error"),
|
->show();
|
||||||
tr("Invalid import link: missing 'url' parameter."),
|
|
||||||
QMessageBox::Critical
|
|
||||||
)->show();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1065,23 +1064,15 @@ void MainWindow::processURLs(QList<QUrl> urls)
|
||||||
|
|
||||||
// Validate: only allow http(s)
|
// Validate: only allow http(s)
|
||||||
if (!target.isValid() || (target.scheme() != "https" && target.scheme() != "http")) {
|
if (!target.isValid() || (target.scheme() != "https" && target.scheme() != "http")) {
|
||||||
CustomMessageBox::selectable(
|
CustomMessageBox::selectable(this, tr("Error"), tr("Invalid import link: URL must be http(s)."), QMessageBox::Critical)
|
||||||
this,
|
->show();
|
||||||
tr("Error"),
|
|
||||||
tr("Invalid import link: URL must be http(s)."),
|
|
||||||
QMessageBox::Critical
|
|
||||||
)->show();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto res = QMessageBox::question(
|
const auto res = QMessageBox::question(
|
||||||
this,
|
this, tr("Install modpack"),
|
||||||
tr("Install modpack"),
|
tr("Do you want to download and import a modpack from:\n%1\n\nURL:\n%2").arg(target.host(), target.toString()),
|
||||||
tr("Do you want to download and import a modpack from:\n%1\n\nURL:\n%2")
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||||
.arg(target.host(), target.toString()),
|
|
||||||
QMessageBox::Yes | QMessageBox::No,
|
|
||||||
QMessageBox::Yes
|
|
||||||
);
|
|
||||||
if (res != QMessageBox::Yes) {
|
if (res != QMessageBox::Yes) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -1396,6 +1387,16 @@ void MainWindow::on_actionEditInstance_triggered()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionManageSkins_triggered()
|
||||||
|
{
|
||||||
|
auto account = APPLICATION->accounts()->defaultAccount();
|
||||||
|
|
||||||
|
if (account && (account->accountType() == AccountType::MSA) && !account->isActive()) {
|
||||||
|
SkinManageDialog dialog(this, account);
|
||||||
|
dialog.exec();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionManageAccounts_triggered()
|
void MainWindow::on_actionManageAccounts_triggered()
|
||||||
{
|
{
|
||||||
APPLICATION->ShowGlobalSettings(this, "accounts");
|
APPLICATION->ShowGlobalSettings(this, "accounts");
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,8 @@ class MainWindow : public QMainWindow {
|
||||||
|
|
||||||
void on_actionSettings_triggered();
|
void on_actionSettings_triggered();
|
||||||
|
|
||||||
|
void on_actionManageSkins_triggered();
|
||||||
|
|
||||||
void on_actionManageAccounts_triggered();
|
void on_actionManageAccounts_triggered();
|
||||||
|
|
||||||
void on_actionReportBug_triggered();
|
void on_actionReportBug_triggered();
|
||||||
|
|
|
||||||
|
|
@ -322,6 +322,14 @@
|
||||||
<enum>QAction::PreferencesRole</enum>
|
<enum>QAction::PreferencesRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionManageSkins">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="settings"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Manage &Skins...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
<action name="actionManageAccounts">
|
<action name="actionManageAccounts">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="accounts"/>
|
<iconset theme="accounts"/>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue