Create a unified dialog to ask user for offline name

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle
2025-10-07 01:07:50 +05:00
parent 8b5e91920d
commit ea004846a9
9 changed files with 201 additions and 235 deletions

View File

@@ -61,6 +61,7 @@
#include "JavaCommon.h"
#include "launch/steps/TextPrint.h"
#include "tasks/Task.h"
#include "ui/dialogs/ChooseOfflineNameDialog.h"
LaunchController::LaunchController() : Task() {}
@@ -157,10 +158,15 @@ QString LaunchController::askOfflineName(QString playerName, bool demo, bool& ok
QString lastOfflinePlayerName = APPLICATION->settings()->get("LastOfflinePlayerName").toString();
QString usedname = lastOfflinePlayerName.isEmpty() ? playerName : lastOfflinePlayerName;
QString name = QInputDialog::getText(m_parentWidget, tr("Player name"), message, QLineEdit::Normal, usedname, &ok);
if (!ok)
ChooseOfflineNameDialog dialog(message, m_parentWidget);
dialog.setWindowTitle(tr("Player name"));
dialog.setUsername(usedname);
if (dialog.exec() != QDialog::Accepted) {
return {};
if (name.length()) {
}
if (const QString name = dialog.getUsername(); !name.isEmpty()) {
usedname = name;
APPLICATION->settings()->set("LastOfflinePlayerName", usedname);
}