mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-24 21:15:39 +01:00
Merge pull request #1587 from lioncash/private
configure_system: Minor cleanup-related changes
This commit is contained in:
commit
476b9f8fc5
@ -21,12 +21,8 @@
|
|||||||
#include "yuzu/configuration/configure_system.h"
|
#include "yuzu/configuration/configure_system.h"
|
||||||
#include "yuzu/main.h"
|
#include "yuzu/main.h"
|
||||||
|
|
||||||
static std::string GetImagePath(Service::Account::UUID uuid) {
|
namespace {
|
||||||
return FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) +
|
constexpr std::array<int, 12> days_in_month = {{
|
||||||
"/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg";
|
|
||||||
}
|
|
||||||
|
|
||||||
static const std::array<int, 12> days_in_month = {{
|
|
||||||
31,
|
31,
|
||||||
29,
|
29,
|
||||||
31,
|
31,
|
||||||
@ -42,7 +38,7 @@ static const std::array<int, 12> days_in_month = {{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
// Same backup JPEG used by acc IProfile::GetImage if no jpeg found
|
// Same backup JPEG used by acc IProfile::GetImage if no jpeg found
|
||||||
static constexpr std::array<u8, 107> backup_jpeg{
|
constexpr std::array<u8, 107> backup_jpeg{
|
||||||
0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02,
|
0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02,
|
||||||
0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x06, 0x06, 0x05,
|
0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x06, 0x06, 0x05,
|
||||||
0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e,
|
0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e,
|
||||||
@ -52,15 +48,32 @@ static constexpr std::array<u8, 107> backup_jpeg{
|
|||||||
0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9,
|
0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::string GetImagePath(Service::Account::UUID uuid) {
|
||||||
|
return FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) +
|
||||||
|
"/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetAccountUsername(const Service::Account::ProfileManager& manager,
|
||||||
|
Service::Account::UUID uuid) {
|
||||||
|
Service::Account::ProfileBase profile;
|
||||||
|
if (!manager.GetProfileBase(uuid, profile)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return Common::StringFromFixedZeroTerminatedBuffer(
|
||||||
|
reinterpret_cast<const char*>(profile.username.data()), profile.username.size());
|
||||||
|
}
|
||||||
|
} // Anonymous namespace
|
||||||
|
|
||||||
ConfigureSystem::ConfigureSystem(QWidget* parent)
|
ConfigureSystem::ConfigureSystem(QWidget* parent)
|
||||||
: QWidget(parent), ui(new Ui::ConfigureSystem),
|
: QWidget(parent), ui(new Ui::ConfigureSystem),
|
||||||
profile_manager(std::make_unique<Service::Account::ProfileManager>()) {
|
profile_manager(std::make_unique<Service::Account::ProfileManager>()) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
connect(ui->combo_birthmonth,
|
connect(ui->combo_birthmonth,
|
||||||
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||||
&ConfigureSystem::updateBirthdayComboBox);
|
&ConfigureSystem::UpdateBirthdayComboBox);
|
||||||
connect(ui->button_regenerate_console_id, &QPushButton::clicked, this,
|
connect(ui->button_regenerate_console_id, &QPushButton::clicked, this,
|
||||||
&ConfigureSystem::refreshConsoleID);
|
&ConfigureSystem::RefreshConsoleID);
|
||||||
|
|
||||||
layout = new QVBoxLayout;
|
layout = new QVBoxLayout;
|
||||||
tree_view = new QTreeView;
|
tree_view = new QTreeView;
|
||||||
@ -154,7 +167,7 @@ void ConfigureSystem::UpdateCurrentUser() {
|
|||||||
|
|
||||||
const auto& current_user = profile_manager->GetUser(Settings::values.current_user);
|
const auto& current_user = profile_manager->GetUser(Settings::values.current_user);
|
||||||
ASSERT(current_user != std::nullopt);
|
ASSERT(current_user != std::nullopt);
|
||||||
const auto username = GetAccountUsername(*current_user);
|
const auto username = GetAccountUsername(*profile_manager, *current_user);
|
||||||
|
|
||||||
scene->clear();
|
scene->clear();
|
||||||
scene->addPixmap(
|
scene->addPixmap(
|
||||||
@ -164,14 +177,6 @@ void ConfigureSystem::UpdateCurrentUser() {
|
|||||||
|
|
||||||
void ConfigureSystem::ReadSystemSettings() {}
|
void ConfigureSystem::ReadSystemSettings() {}
|
||||||
|
|
||||||
std::string ConfigureSystem::GetAccountUsername(Service::Account::UUID uuid) const {
|
|
||||||
Service::Account::ProfileBase profile;
|
|
||||||
if (!profile_manager->GetProfileBase(uuid, profile))
|
|
||||||
return "";
|
|
||||||
return Common::StringFromFixedZeroTerminatedBuffer(
|
|
||||||
reinterpret_cast<const char*>(profile.username.data()), profile.username.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigureSystem::applyConfiguration() {
|
void ConfigureSystem::applyConfiguration() {
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
return;
|
return;
|
||||||
@ -180,7 +185,7 @@ void ConfigureSystem::applyConfiguration() {
|
|||||||
Settings::Apply();
|
Settings::Apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureSystem::updateBirthdayComboBox(int birthmonth_index) {
|
void ConfigureSystem::UpdateBirthdayComboBox(int birthmonth_index) {
|
||||||
if (birthmonth_index < 0 || birthmonth_index >= 12)
|
if (birthmonth_index < 0 || birthmonth_index >= 12)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -205,7 +210,7 @@ void ConfigureSystem::updateBirthdayComboBox(int birthmonth_index) {
|
|||||||
ui->combo_birthday->setCurrentIndex(birthday_index);
|
ui->combo_birthday->setCurrentIndex(birthday_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureSystem::refreshConsoleID() {
|
void ConfigureSystem::RefreshConsoleID() {
|
||||||
QMessageBox::StandardButton reply;
|
QMessageBox::StandardButton reply;
|
||||||
QString warning_text = tr("This will replace your current virtual Switch with a new one. "
|
QString warning_text = tr("This will replace your current virtual Switch with a new one. "
|
||||||
"Your current virtual Switch will not be recoverable. "
|
"Your current virtual Switch will not be recoverable. "
|
||||||
@ -232,8 +237,7 @@ void ConfigureSystem::SelectUser(const QModelIndex& index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureSystem::AddUser() {
|
void ConfigureSystem::AddUser() {
|
||||||
Service::Account::UUID uuid;
|
const auto uuid = Service::Account::UUID::Generate();
|
||||||
uuid.Generate();
|
|
||||||
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
const auto username =
|
const auto username =
|
||||||
@ -253,7 +257,7 @@ void ConfigureSystem::RenameUser() {
|
|||||||
const auto user = tree_view->currentIndex().row();
|
const auto user = tree_view->currentIndex().row();
|
||||||
const auto uuid = profile_manager->GetUser(user);
|
const auto uuid = profile_manager->GetUser(user);
|
||||||
ASSERT(uuid != std::nullopt);
|
ASSERT(uuid != std::nullopt);
|
||||||
const auto username = GetAccountUsername(*uuid);
|
const auto username = GetAccountUsername(*profile_manager, *uuid);
|
||||||
|
|
||||||
Service::Account::ProfileBase profile;
|
Service::Account::ProfileBase profile;
|
||||||
if (!profile_manager->GetProfileBase(*uuid, profile))
|
if (!profile_manager->GetProfileBase(*uuid, profile))
|
||||||
@ -293,7 +297,7 @@ void ConfigureSystem::DeleteUser() {
|
|||||||
const auto index = tree_view->currentIndex().row();
|
const auto index = tree_view->currentIndex().row();
|
||||||
const auto uuid = profile_manager->GetUser(index);
|
const auto uuid = profile_manager->GetUser(index);
|
||||||
ASSERT(uuid != std::nullopt);
|
ASSERT(uuid != std::nullopt);
|
||||||
const auto username = GetAccountUsername(*uuid);
|
const auto username = GetAccountUsername(*profile_manager, *uuid);
|
||||||
|
|
||||||
const auto confirm =
|
const auto confirm =
|
||||||
QMessageBox::question(this, tr("Confirm Delete"),
|
QMessageBox::question(this, tr("Confirm Delete"),
|
||||||
@ -321,10 +325,10 @@ void ConfigureSystem::SetUserImage() {
|
|||||||
const auto index = tree_view->currentIndex().row();
|
const auto index = tree_view->currentIndex().row();
|
||||||
const auto uuid = profile_manager->GetUser(index);
|
const auto uuid = profile_manager->GetUser(index);
|
||||||
ASSERT(uuid != std::nullopt);
|
ASSERT(uuid != std::nullopt);
|
||||||
const auto username = GetAccountUsername(*uuid);
|
const auto username = GetAccountUsername(*profile_manager, *uuid);
|
||||||
|
|
||||||
const auto file = QFileDialog::getOpenFileName(this, tr("Select User Image"), QString(),
|
const auto file = QFileDialog::getOpenFileName(this, tr("Select User Image"), QString(),
|
||||||
"JPEG Images (*.jpg *.jpeg)");
|
tr("JPEG Images (*.jpg *.jpeg)"));
|
||||||
|
|
||||||
if (file.isEmpty())
|
if (file.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -9,17 +9,16 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
namespace Service::Account {
|
|
||||||
class ProfileManager;
|
|
||||||
struct UUID;
|
|
||||||
} // namespace Service::Account
|
|
||||||
|
|
||||||
class QGraphicsScene;
|
class QGraphicsScene;
|
||||||
class QStandardItem;
|
class QStandardItem;
|
||||||
class QStandardItemModel;
|
class QStandardItemModel;
|
||||||
class QTreeView;
|
class QTreeView;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
|
|
||||||
|
namespace Service::Account {
|
||||||
|
class ProfileManager;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ConfigureSystem;
|
class ConfigureSystem;
|
||||||
}
|
}
|
||||||
@ -29,28 +28,25 @@ class ConfigureSystem : public QWidget {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ConfigureSystem(QWidget* parent = nullptr);
|
explicit ConfigureSystem(QWidget* parent = nullptr);
|
||||||
~ConfigureSystem();
|
~ConfigureSystem() override;
|
||||||
|
|
||||||
void applyConfiguration();
|
void applyConfiguration();
|
||||||
void setConfiguration();
|
void setConfiguration();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void ReadSystemSettings();
|
||||||
|
|
||||||
|
void UpdateBirthdayComboBox(int birthmonth_index);
|
||||||
|
void RefreshConsoleID();
|
||||||
|
|
||||||
void PopulateUserList();
|
void PopulateUserList();
|
||||||
void UpdateCurrentUser();
|
void UpdateCurrentUser();
|
||||||
|
|
||||||
public slots:
|
|
||||||
void updateBirthdayComboBox(int birthmonth_index);
|
|
||||||
void refreshConsoleID();
|
|
||||||
|
|
||||||
void SelectUser(const QModelIndex& index);
|
void SelectUser(const QModelIndex& index);
|
||||||
void AddUser();
|
void AddUser();
|
||||||
void RenameUser();
|
void RenameUser();
|
||||||
void DeleteUser();
|
void DeleteUser();
|
||||||
void SetUserImage();
|
void SetUserImage();
|
||||||
|
|
||||||
private:
|
|
||||||
void ReadSystemSettings();
|
|
||||||
std::string GetAccountUsername(Service::Account::UUID uuid) const;
|
|
||||||
|
|
||||||
QVBoxLayout* layout;
|
QVBoxLayout* layout;
|
||||||
QTreeView* tree_view;
|
QTreeView* tree_view;
|
||||||
QStandardItemModel* item_model;
|
QStandardItemModel* item_model;
|
||||||
@ -59,11 +55,12 @@ private:
|
|||||||
std::vector<QList<QStandardItem*>> list_items;
|
std::vector<QList<QStandardItem*>> list_items;
|
||||||
|
|
||||||
std::unique_ptr<Ui::ConfigureSystem> ui;
|
std::unique_ptr<Ui::ConfigureSystem> ui;
|
||||||
bool enabled;
|
bool enabled = false;
|
||||||
|
|
||||||
int birthmonth, birthday;
|
int birthmonth = 0;
|
||||||
int language_index;
|
int birthday = 0;
|
||||||
int sound_index;
|
int language_index = 0;
|
||||||
|
int sound_index = 0;
|
||||||
|
|
||||||
std::unique_ptr<Service::Account::ProfileManager> profile_manager;
|
std::unique_ptr<Service::Account::ProfileManager> profile_manager;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user