mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-13 13:47:46 +02:00
Implement account override
Signed-off-by: Yihe Li <winmikedows@hotmail.com>
This commit is contained in:
@ -50,9 +50,11 @@
|
|||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "InstanceList.h"
|
#include "InstanceList.h"
|
||||||
#include "icons/IconList.h"
|
#include "icons/IconList.h"
|
||||||
|
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
#include "minecraft/ShortcutUtils.h"
|
#include "minecraft/ShortcutUtils.h"
|
||||||
#include "minecraft/WorldList.h"
|
#include "minecraft/WorldList.h"
|
||||||
|
#include "minecraft/auth/AccountList.h"
|
||||||
|
|
||||||
CreateShortcutDialog::CreateShortcutDialog(InstancePtr instance, QWidget* parent)
|
CreateShortcutDialog::CreateShortcutDialog(InstancePtr instance, QWidget* parent)
|
||||||
: QDialog(parent), ui(new Ui::CreateShortcutDialog), m_instance(instance)
|
: QDialog(parent), ui(new Ui::CreateShortcutDialog), m_instance(instance)
|
||||||
@ -95,6 +97,25 @@ CreateShortcutDialog::CreateShortcutDialog(InstancePtr instance, QWidget* parent
|
|||||||
ui->worldSelectionBox->addItem(entry_name, world.name());
|
ui->worldSelectionBox->addItem(entry_name, world.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Populate accounts
|
||||||
|
auto accounts = APPLICATION->accounts();
|
||||||
|
MinecraftAccountPtr defaultAccount = accounts->defaultAccount();
|
||||||
|
if (accounts->count() <= 0) {
|
||||||
|
ui->overrideAccountCheckbox->setEnabled(false);
|
||||||
|
} else
|
||||||
|
for (int i = 0; i < accounts->count(); i++) {
|
||||||
|
MinecraftAccountPtr account = accounts->at(i);
|
||||||
|
auto profileLabel = account->profileName();
|
||||||
|
if (account->isInUse())
|
||||||
|
profileLabel = tr("%1 (in use)").arg(profileLabel);
|
||||||
|
auto face = account->getFace();
|
||||||
|
QIcon icon = face.isNull() ? APPLICATION->getThemedIcon("noaccount") : face;
|
||||||
|
ui->accountSelectionBox->addItem(profileLabel, account->profileName());
|
||||||
|
ui->accountSelectionBox->setItemIcon(i, icon);
|
||||||
|
if (defaultAccount == account)
|
||||||
|
ui->accountSelectionBox->setCurrentIndex(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateShortcutDialog::~CreateShortcutDialog()
|
CreateShortcutDialog::~CreateShortcutDialog()
|
||||||
@ -118,8 +139,6 @@ void CreateShortcutDialog::on_overrideAccountCheckbox_stateChanged(int state)
|
|||||||
ui->accountOptionsGroup->setEnabled(state == Qt::Checked);
|
ui->accountOptionsGroup->setEnabled(state == Qt::Checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateShortcutDialog::on_accountSelectionBox_currentIndexChanged(int index) {}
|
|
||||||
|
|
||||||
void CreateShortcutDialog::on_targetCheckbox_stateChanged(int state)
|
void CreateShortcutDialog::on_targetCheckbox_stateChanged(int state)
|
||||||
{
|
{
|
||||||
ui->targetOptionsGroup->setEnabled(state == Qt::Checked);
|
ui->targetOptionsGroup->setEnabled(state == Qt::Checked);
|
||||||
@ -186,10 +205,14 @@ void CreateShortcutDialog::createShortcut()
|
|||||||
auto name = ui->instNameTextBox->text();
|
auto name = ui->instNameTextBox->text();
|
||||||
if (name.isEmpty())
|
if (name.isEmpty())
|
||||||
name = ui->instNameTextBox->placeholderText();
|
name = ui->instNameTextBox->placeholderText();
|
||||||
|
if (ui->overrideAccountCheckbox->isChecked())
|
||||||
|
extraArgs.append({ "--profile", ui->accountSelectionBox->currentData().toString() });
|
||||||
|
|
||||||
|
ShortcutUtils::Shortcut args{ m_instance.get(), name, targetString, this, extraArgs, InstIconKey };
|
||||||
if (target == SaveTarget::Desktop)
|
if (target == SaveTarget::Desktop)
|
||||||
ShortcutUtils::createInstanceShortcutOnDesktop({ m_instance.get(), name, targetString, this, extraArgs, InstIconKey });
|
ShortcutUtils::createInstanceShortcutOnDesktop(args);
|
||||||
else if (target == SaveTarget::Applications)
|
else if (target == SaveTarget::Applications)
|
||||||
ShortcutUtils::createInstanceShortcutInApplications({ m_instance.get(), name, targetString, this, extraArgs, InstIconKey });
|
ShortcutUtils::createInstanceShortcutInApplications(args);
|
||||||
else
|
else
|
||||||
ShortcutUtils::createInstanceShortcutInOther({ m_instance.get(), name, targetString, this, extraArgs, InstIconKey });
|
ShortcutUtils::createInstanceShortcutInOther(args);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,6 @@ class CreateShortcutDialog : public QDialog {
|
|||||||
|
|
||||||
// Override account
|
// Override account
|
||||||
void on_overrideAccountCheckbox_stateChanged(int state);
|
void on_overrideAccountCheckbox_stateChanged(int state);
|
||||||
void on_accountSelectionBox_currentIndexChanged(int index);
|
|
||||||
|
|
||||||
// Override target (world, server)
|
// Override target (world, server)
|
||||||
void on_targetCheckbox_stateChanged(int state);
|
void on_targetCheckbox_stateChanged(int state);
|
||||||
|
Reference in New Issue
Block a user