configure_system: Clear selection after user delete
This commit is contained in:
parent
702622b8f1
commit
e408bbceed
@ -323,7 +323,7 @@ void ProfileManager::WriteUserSaveFile() {
|
|||||||
|
|
||||||
FileUtil::IOFile save(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) +
|
FileUtil::IOFile save(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) +
|
||||||
"/system/save/8000000000000010/su/avators/profiles.dat",
|
"/system/save/8000000000000010/su/avators/profiles.dat",
|
||||||
"rb");
|
"wb");
|
||||||
|
|
||||||
save.Resize(sizeof(ProfileDataRaw));
|
save.Resize(sizeof(ProfileDataRaw));
|
||||||
save.Seek(0, SEEK_SET);
|
save.Seek(0, SEEK_SET);
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include "common/common_paths.h"
|
#include "common/common_paths.h"
|
||||||
#include "common/logging/backend.h"
|
#include "common/logging/backend.h"
|
||||||
|
#include "common/string_util.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
#include "ui_configure_system.h"
|
#include "ui_configure_system.h"
|
||||||
@ -112,8 +113,6 @@ void ConfigureSystem::setConfiguration() {
|
|||||||
item_model->removeRows(0, item_model->rowCount());
|
item_model->removeRows(0, item_model->rowCount());
|
||||||
list_items.clear();
|
list_items.clear();
|
||||||
|
|
||||||
ui->pm_add->setEnabled(profile_manager->GetUserCount() < 8);
|
|
||||||
|
|
||||||
PopulateUserList();
|
PopulateUserList();
|
||||||
UpdateCurrentUser();
|
UpdateCurrentUser();
|
||||||
}
|
}
|
||||||
@ -156,6 +155,8 @@ void ConfigureSystem::PopulateUserList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureSystem::UpdateCurrentUser() {
|
void ConfigureSystem::UpdateCurrentUser() {
|
||||||
|
ui->pm_add->setEnabled(profile_manager->GetUserCount() < 8);
|
||||||
|
|
||||||
const auto& current_user = profile_manager->GetAllUsers()[Settings::values.current_user];
|
const auto& current_user = profile_manager->GetAllUsers()[Settings::values.current_user];
|
||||||
const auto username = GetAccountUsername(current_user);
|
const auto username = GetAccountUsername(current_user);
|
||||||
|
|
||||||
@ -230,10 +231,7 @@ void ConfigureSystem::SelectUser(const QModelIndex& index) {
|
|||||||
UpdateCurrentUser();
|
UpdateCurrentUser();
|
||||||
|
|
||||||
ui->pm_remove->setEnabled(profile_manager->GetUserCount() >= 2);
|
ui->pm_remove->setEnabled(profile_manager->GetUserCount() >= 2);
|
||||||
ui->pm_remove->setEnabled(false);
|
|
||||||
|
|
||||||
ui->pm_rename->setEnabled(true);
|
ui->pm_rename->setEnabled(true);
|
||||||
|
|
||||||
ui->pm_set_image->setEnabled(true);
|
ui->pm_set_image->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,9 +280,12 @@ void ConfigureSystem::RenameUser() {
|
|||||||
|
|
||||||
profile_manager->SetProfileBase(uuid, profile);
|
profile_manager->SetProfileBase(uuid, profile);
|
||||||
|
|
||||||
list_items[user][0] = new QStandardItem{
|
item_model->setItem(
|
||||||
GetIcon(uuid).scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
|
user, 0,
|
||||||
QString::fromStdString(username_std + '\n' + uuid.FormatSwitch())};
|
new QStandardItem{
|
||||||
|
GetIcon(uuid).scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
|
||||||
|
QString::fromStdString(username_std + '\n' + uuid.FormatSwitch())});
|
||||||
|
UpdateCurrentUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureSystem::DeleteUser() {
|
void ConfigureSystem::DeleteUser() {
|
||||||
@ -302,11 +303,13 @@ void ConfigureSystem::DeleteUser() {
|
|||||||
|
|
||||||
if (Settings::values.current_user == tree_view->currentIndex().row())
|
if (Settings::values.current_user == tree_view->currentIndex().row())
|
||||||
Settings::values.current_user = 0;
|
Settings::values.current_user = 0;
|
||||||
|
UpdateCurrentUser();
|
||||||
|
|
||||||
if (!profile_manager->RemoveUser(uuid))
|
if (!profile_manager->RemoveUser(uuid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
item_model->removeRows(tree_view->currentIndex().row(), 1);
|
item_model->removeRows(tree_view->currentIndex().row(), 1);
|
||||||
|
tree_view->clearSelection();
|
||||||
|
|
||||||
ui->pm_remove->setEnabled(false);
|
ui->pm_remove->setEnabled(false);
|
||||||
ui->pm_rename->setEnabled(false);
|
ui->pm_rename->setEnabled(false);
|
||||||
@ -334,7 +337,10 @@ void ConfigureSystem::SetUserImage() {
|
|||||||
FileUtil::CreateFullPath(GetImagePath(uuid));
|
FileUtil::CreateFullPath(GetImagePath(uuid));
|
||||||
FileUtil::Copy(file.toStdString(), GetImagePath(uuid));
|
FileUtil::Copy(file.toStdString(), GetImagePath(uuid));
|
||||||
|
|
||||||
list_items[index][0] = new QStandardItem{
|
item_model->setItem(
|
||||||
GetIcon(uuid).scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
|
index, 0,
|
||||||
QString::fromStdString(username + '\n' + uuid.FormatSwitch())};
|
new QStandardItem{
|
||||||
|
GetIcon(uuid).scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
|
||||||
|
QString::fromStdString(username + '\n' + uuid.FormatSwitch())});
|
||||||
|
UpdateCurrentUser();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user