Qt: fix user manager localusername and add textvalue to the inputdialog

This commit is contained in:
Megamouse 2018-07-27 00:12:00 +02:00
parent f84883223b
commit e29ea61f7c
2 changed files with 11 additions and 3 deletions

View File

@ -12,12 +12,18 @@ UserAccount::UserAccount(const std::string& user_id)
fs::file file;
if (file.open(m_user_dir + "localusername", fs::read))
{
file.read(m_username, 16*sizeof(char)); // max of 16 chars on real PS3
m_username = file.to_string();
file.close();
if (m_username.length() > 16) // max of 16 chars on real PS3
{
m_username = m_username.substr(0, 16);
LOG_WARNING(GENERAL, "UserAccount: localusername of userId=%s was too long, cropped to: %s", m_user_id, m_username);
}
}
else
{
LOG_WARNING(GENERAL, "UserAccount: localusername file read error (userId=%s, userDir=%s).", m_user_id, m_user_dir);
LOG_ERROR(GENERAL, "UserAccount: localusername file read error (userId=%s, userDir=%s).", m_user_id, m_user_dir);
}
}

View File

@ -270,10 +270,12 @@ void user_manager_dialog::OnUserRename()
const std::string user_id = m_user_list[key].GetUserId();
const std::string username = m_user_list[key].GetUsername();
const QString q_username = qstr(username);
QInputDialog* dialog = new QInputDialog(this);
dialog->setWindowTitle(tr("Rename User"));
dialog->setLabelText(tr("User Id: %0\nOld Username: %1\n\nNew Username: ").arg(qstr(user_id)).arg(qstr(username)));
dialog->setLabelText(tr("User Id: %0\nOld Username: %1\n\nNew Username: ").arg(qstr(user_id)).arg(q_username));
dialog->setTextValue(q_username);
dialog->resize(200, 100);
while (dialog->exec() != QDialog::Rejected)