diff options
Diffstat (limited to '')
| -rw-r--r-- | src/yuzu/configuration/configure_system.cpp | 43 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_system.h | 10 |
2 files changed, 28 insertions, 25 deletions
diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 3aa9ca07e..a9bd5465d 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp | |||
| @@ -21,12 +21,8 @@ | |||
| 21 | #include "yuzu/configuration/configure_system.h" | 21 | #include "yuzu/configuration/configure_system.h" |
| 22 | #include "yuzu/main.h" | 22 | #include "yuzu/main.h" |
| 23 | 23 | ||
| 24 | static std::string GetImagePath(Service::Account::UUID uuid) { | 24 | namespace { |
| 25 | return FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + | 25 | constexpr std::array<int, 12> days_in_month = {{ |
| 26 | "/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg"; | ||
| 27 | } | ||
| 28 | |||
| 29 | static const std::array<int, 12> days_in_month = {{ | ||
| 30 | 31, | 26 | 31, |
| 31 | 29, | 27 | 29, |
| 32 | 31, | 28 | 31, |
| @@ -42,7 +38,7 @@ static const std::array<int, 12> days_in_month = {{ | |||
| 42 | }}; | 38 | }}; |
| 43 | 39 | ||
| 44 | // Same backup JPEG used by acc IProfile::GetImage if no jpeg found | 40 | // Same backup JPEG used by acc IProfile::GetImage if no jpeg found |
| 45 | static constexpr std::array<u8, 107> backup_jpeg{ | 41 | constexpr std::array<u8, 107> backup_jpeg{ |
| 46 | 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, | 42 | 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, |
| 47 | 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x06, 0x06, 0x05, | 43 | 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x06, 0x06, 0x05, |
| 48 | 0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e, | 44 | 0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e, |
| @@ -52,6 +48,23 @@ static constexpr std::array<u8, 107> backup_jpeg{ | |||
| 52 | 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9, | 48 | 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9, |
| 53 | }; | 49 | }; |
| 54 | 50 | ||
| 51 | std::string GetImagePath(Service::Account::UUID uuid) { | ||
| 52 | return FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + | ||
| 53 | "/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg"; | ||
| 54 | } | ||
| 55 | |||
| 56 | std::string GetAccountUsername(const Service::Account::ProfileManager& manager, | ||
| 57 | Service::Account::UUID uuid) { | ||
| 58 | Service::Account::ProfileBase profile; | ||
| 59 | if (!manager.GetProfileBase(uuid, profile)) { | ||
| 60 | return ""; | ||
| 61 | } | ||
| 62 | |||
| 63 | return Common::StringFromFixedZeroTerminatedBuffer( | ||
| 64 | reinterpret_cast<const char*>(profile.username.data()), profile.username.size()); | ||
| 65 | } | ||
| 66 | } // Anonymous namespace | ||
| 67 | |||
| 55 | ConfigureSystem::ConfigureSystem(QWidget* parent) | 68 | ConfigureSystem::ConfigureSystem(QWidget* parent) |
| 56 | : QWidget(parent), ui(new Ui::ConfigureSystem), | 69 | : QWidget(parent), ui(new Ui::ConfigureSystem), |
| 57 | profile_manager(std::make_unique<Service::Account::ProfileManager>()) { | 70 | profile_manager(std::make_unique<Service::Account::ProfileManager>()) { |
| @@ -154,7 +167,7 @@ void ConfigureSystem::UpdateCurrentUser() { | |||
| 154 | 167 | ||
| 155 | const auto& current_user = profile_manager->GetUser(Settings::values.current_user); | 168 | const auto& current_user = profile_manager->GetUser(Settings::values.current_user); |
| 156 | ASSERT(current_user != std::nullopt); | 169 | ASSERT(current_user != std::nullopt); |
| 157 | const auto username = GetAccountUsername(*current_user); | 170 | const auto username = GetAccountUsername(*profile_manager, *current_user); |
| 158 | 171 | ||
| 159 | scene->clear(); | 172 | scene->clear(); |
| 160 | scene->addPixmap( | 173 | scene->addPixmap( |
| @@ -164,14 +177,6 @@ void ConfigureSystem::UpdateCurrentUser() { | |||
| 164 | 177 | ||
| 165 | void ConfigureSystem::ReadSystemSettings() {} | 178 | void ConfigureSystem::ReadSystemSettings() {} |
| 166 | 179 | ||
| 167 | std::string ConfigureSystem::GetAccountUsername(Service::Account::UUID uuid) const { | ||
| 168 | Service::Account::ProfileBase profile; | ||
| 169 | if (!profile_manager->GetProfileBase(uuid, profile)) | ||
| 170 | return ""; | ||
| 171 | return Common::StringFromFixedZeroTerminatedBuffer( | ||
| 172 | reinterpret_cast<const char*>(profile.username.data()), profile.username.size()); | ||
| 173 | } | ||
| 174 | |||
| 175 | void ConfigureSystem::applyConfiguration() { | 180 | void ConfigureSystem::applyConfiguration() { |
| 176 | if (!enabled) | 181 | if (!enabled) |
| 177 | return; | 182 | return; |
| @@ -252,7 +257,7 @@ void ConfigureSystem::RenameUser() { | |||
| 252 | const auto user = tree_view->currentIndex().row(); | 257 | const auto user = tree_view->currentIndex().row(); |
| 253 | const auto uuid = profile_manager->GetUser(user); | 258 | const auto uuid = profile_manager->GetUser(user); |
| 254 | ASSERT(uuid != std::nullopt); | 259 | ASSERT(uuid != std::nullopt); |
| 255 | const auto username = GetAccountUsername(*uuid); | 260 | const auto username = GetAccountUsername(*profile_manager, *uuid); |
| 256 | 261 | ||
| 257 | Service::Account::ProfileBase profile; | 262 | Service::Account::ProfileBase profile; |
| 258 | if (!profile_manager->GetProfileBase(*uuid, profile)) | 263 | if (!profile_manager->GetProfileBase(*uuid, profile)) |
| @@ -292,7 +297,7 @@ void ConfigureSystem::DeleteUser() { | |||
| 292 | const auto index = tree_view->currentIndex().row(); | 297 | const auto index = tree_view->currentIndex().row(); |
| 293 | const auto uuid = profile_manager->GetUser(index); | 298 | const auto uuid = profile_manager->GetUser(index); |
| 294 | ASSERT(uuid != std::nullopt); | 299 | ASSERT(uuid != std::nullopt); |
| 295 | const auto username = GetAccountUsername(*uuid); | 300 | const auto username = GetAccountUsername(*profile_manager, *uuid); |
| 296 | 301 | ||
| 297 | const auto confirm = | 302 | const auto confirm = |
| 298 | QMessageBox::question(this, tr("Confirm Delete"), | 303 | QMessageBox::question(this, tr("Confirm Delete"), |
| @@ -320,7 +325,7 @@ void ConfigureSystem::SetUserImage() { | |||
| 320 | const auto index = tree_view->currentIndex().row(); | 325 | const auto index = tree_view->currentIndex().row(); |
| 321 | const auto uuid = profile_manager->GetUser(index); | 326 | const auto uuid = profile_manager->GetUser(index); |
| 322 | ASSERT(uuid != std::nullopt); | 327 | ASSERT(uuid != std::nullopt); |
| 323 | const auto username = GetAccountUsername(*uuid); | 328 | const auto username = GetAccountUsername(*profile_manager, *uuid); |
| 324 | 329 | ||
| 325 | const auto file = QFileDialog::getOpenFileName(this, tr("Select User Image"), QString(), | 330 | const auto file = QFileDialog::getOpenFileName(this, tr("Select User Image"), QString(), |
| 326 | "JPEG Images (*.jpg *.jpeg)"); | 331 | "JPEG Images (*.jpg *.jpeg)"); |
diff --git a/src/yuzu/configuration/configure_system.h b/src/yuzu/configuration/configure_system.h index 0d15d9ac4..07764e1f7 100644 --- a/src/yuzu/configuration/configure_system.h +++ b/src/yuzu/configuration/configure_system.h | |||
| @@ -9,17 +9,16 @@ | |||
| 9 | #include <QList> | 9 | #include <QList> |
| 10 | #include <QWidget> | 10 | #include <QWidget> |
| 11 | 11 | ||
| 12 | namespace Service::Account { | ||
| 13 | class ProfileManager; | ||
| 14 | struct UUID; | ||
| 15 | } // namespace Service::Account | ||
| 16 | |||
| 17 | class QGraphicsScene; | 12 | class QGraphicsScene; |
| 18 | class QStandardItem; | 13 | class QStandardItem; |
| 19 | class QStandardItemModel; | 14 | class QStandardItemModel; |
| 20 | class QTreeView; | 15 | class QTreeView; |
| 21 | class QVBoxLayout; | 16 | class QVBoxLayout; |
| 22 | 17 | ||
| 18 | namespace Service::Account { | ||
| 19 | class ProfileManager; | ||
| 20 | } | ||
| 21 | |||
| 23 | namespace Ui { | 22 | namespace Ui { |
| 24 | class ConfigureSystem; | 23 | class ConfigureSystem; |
| 25 | } | 24 | } |
| @@ -36,7 +35,6 @@ public: | |||
| 36 | 35 | ||
| 37 | private: | 36 | private: |
| 38 | void ReadSystemSettings(); | 37 | void ReadSystemSettings(); |
| 39 | std::string GetAccountUsername(Service::Account::UUID uuid) const; | ||
| 40 | 38 | ||
| 41 | void UpdateBirthdayComboBox(int birthmonth_index); | 39 | void UpdateBirthdayComboBox(int birthmonth_index); |
| 42 | void RefreshConsoleID(); | 40 | void RefreshConsoleID(); |