early-access version 1770

This commit is contained in:
pineappleEA 2021-06-09 21:52:48 +02:00
parent 56a92bdb02
commit 104bc82566
5 changed files with 50 additions and 7 deletions

View file

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 1769. This is the source code for early-access 1770.
## Legal Notice ## Legal Notice

View file

@ -42,7 +42,7 @@ class ServiceManager;
static const int kMaxPortSize = 8; ///< Maximum size of a port name (8 characters) static const int kMaxPortSize = 8; ///< Maximum size of a port name (8 characters)
/// Arbitrary default number of maximum connections to an HLE service. /// Arbitrary default number of maximum connections to an HLE service.
static const u32 DefaultMaxSessions = 64; static const u32 DefaultMaxSessions = 0x10000;
/** /**
* This is an non-templated base of ServiceFramework to reduce code bloat and compilation times, it * This is an non-templated base of ServiceFramework to reduce code bloat and compilation times, it

View file

@ -1395,7 +1395,8 @@ void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) {
void ConfigureInputPlayer::CreateProfile() { void ConfigureInputPlayer::CreateProfile() {
const auto profile_name = const auto profile_name =
LimitableInputDialog::GetText(this, tr("New Profile"), tr("Enter a profile name:"), 1, 20); LimitableInputDialog::GetText(this, tr("New Profile"), tr("Enter a profile name:"), 1, 20,
LimitableInputDialog::InputLimiter::Filesystem);
if (profile_name.isEmpty()) { if (profile_name.isEmpty()) {
return; return;

View file

@ -21,11 +21,13 @@ void LimitableInputDialog::CreateUI() {
text_label = new QLabel(this); text_label = new QLabel(this);
text_entry = new QLineEdit(this); text_entry = new QLineEdit(this);
text_label_invalid = new QLabel(this);
buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
auto* const layout = new QVBoxLayout; auto* const layout = new QVBoxLayout;
layout->addWidget(text_label); layout->addWidget(text_label);
layout->addWidget(text_entry); layout->addWidget(text_entry);
layout->addWidget(text_label_invalid);
layout->addWidget(buttons); layout->addWidget(buttons);
setLayout(layout); setLayout(layout);
@ -37,18 +39,36 @@ void LimitableInputDialog::ConnectEvents() {
} }
QString LimitableInputDialog::GetText(QWidget* parent, const QString& title, const QString& text, QString LimitableInputDialog::GetText(QWidget* parent, const QString& title, const QString& text,
int min_character_limit, int max_character_limit) { int min_character_limit, int max_character_limit,
InputLimiter limit_type) {
Q_ASSERT(min_character_limit <= max_character_limit); Q_ASSERT(min_character_limit <= max_character_limit);
LimitableInputDialog dialog{parent}; LimitableInputDialog dialog{parent};
dialog.setWindowTitle(title); dialog.setWindowTitle(title);
dialog.text_label->setText(text); dialog.text_label->setText(text);
dialog.text_entry->setMaxLength(max_character_limit); dialog.text_entry->setMaxLength(max_character_limit);
dialog.text_label_invalid->show();
switch (limit_type) {
case InputLimiter::Filesystem:
dialog.invalid_characters = QStringLiteral("<>:;\"/\\|,.!?*");
break;
default:
dialog.invalid_characters.clear();
dialog.text_label_invalid->hide();
break;
}
dialog.text_label_invalid->setText(
tr("The text can't contain any of the following characters:\n%1")
.arg(dialog.invalid_characters));
auto* const ok_button = dialog.buttons->button(QDialogButtonBox::Ok); auto* const ok_button = dialog.buttons->button(QDialogButtonBox::Ok);
ok_button->setEnabled(false); ok_button->setEnabled(false);
connect(dialog.text_entry, &QLineEdit::textEdited, [&](const QString& new_text) { connect(dialog.text_entry, &QLineEdit::textEdited, [&] {
ok_button->setEnabled(new_text.length() >= min_character_limit); if (!dialog.invalid_characters.isEmpty()) {
dialog.RemoveInvalidCharacters();
}
ok_button->setEnabled(dialog.text_entry->text().length() >= min_character_limit);
}); });
if (dialog.exec() != QDialog::Accepted) { if (dialog.exec() != QDialog::Accepted) {
@ -57,3 +77,15 @@ QString LimitableInputDialog::GetText(QWidget* parent, const QString& title, con
return dialog.text_entry->text(); return dialog.text_entry->text();
} }
void LimitableInputDialog::RemoveInvalidCharacters() {
auto cpos = text_entry->cursorPosition();
for (int i = 0; i < text_entry->text().length(); i++) {
if (invalid_characters.contains(text_entry->text().at(i))) {
text_entry->setText(text_entry->text().remove(i, 1));
i--;
cpos--;
}
}
text_entry->setCursorPosition(cpos);
}

View file

@ -18,14 +18,24 @@ public:
explicit LimitableInputDialog(QWidget* parent = nullptr); explicit LimitableInputDialog(QWidget* parent = nullptr);
~LimitableInputDialog() override; ~LimitableInputDialog() override;
enum class InputLimiter {
None,
Filesystem,
};
static QString GetText(QWidget* parent, const QString& title, const QString& text, static QString GetText(QWidget* parent, const QString& title, const QString& text,
int min_character_limit, int max_character_limit); int min_character_limit, int max_character_limit,
InputLimiter limit_type = InputLimiter::None);
private: private:
void CreateUI(); void CreateUI();
void ConnectEvents(); void ConnectEvents();
void RemoveInvalidCharacters();
QString invalid_characters;
QLabel* text_label; QLabel* text_label;
QLineEdit* text_entry; QLineEdit* text_entry;
QLabel* text_label_invalid;
QDialogButtonBox* buttons; QDialogButtonBox* buttons;
}; };