1
0
Fork 0
forked from suyu/suyu

qt_software_keyboard: Use Common::U16StringFromBuffer

See ffd3afcf2
This commit is contained in:
lat9nq 2022-05-15 18:08:08 -04:00
parent ffd3afcf2f
commit f7908eebb9

View file

@ -411,11 +411,11 @@ void QtSoftwareKeyboardDialog::ShowTextCheckDialog(
break; break;
} }
auto text = ui->topOSK->currentIndex() == 1 const auto& text = ui->topOSK->currentIndex() == 1 ? ui->text_edit_osk->toPlainText()
? ui->text_edit_osk->toPlainText().toStdU16String() : ui->line_edit_osk->text();
: ui->line_edit_osk->text().toStdU16String(); std::u16string text_s = Common::U16StringFromBuffer(text.utf16(), text.size());
emit SubmitNormalText(SwkbdResult::Ok, std::move(text), true); emit SubmitNormalText(SwkbdResult::Ok, std::move(text_s), true);
break; break;
} }
} }
@ -562,7 +562,7 @@ void QtSoftwareKeyboardDialog::keyPressEvent(QKeyEvent* event) {
return; return;
} }
InlineTextInsertString(entered_text.toStdU16String()); InlineTextInsertString(Common::U16StringFromBuffer(entered_text.utf16(), entered_text.size()));
} }
void QtSoftwareKeyboardDialog::MoveAndResizeWindow(QPoint pos, QSize size) { void QtSoftwareKeyboardDialog::MoveAndResizeWindow(QPoint pos, QSize size) {
@ -1119,11 +1119,11 @@ void QtSoftwareKeyboardDialog::NormalKeyboardButtonClicked(QPushButton* button)
} }
if (button == ui->button_ok || button == ui->button_ok_shift || button == ui->button_ok_num) { if (button == ui->button_ok || button == ui->button_ok_shift || button == ui->button_ok_num) {
auto text = ui->topOSK->currentIndex() == 1 const auto& text = ui->topOSK->currentIndex() == 1 ? ui->text_edit_osk->toPlainText()
? ui->text_edit_osk->toPlainText().toStdU16String() : ui->line_edit_osk->text();
: ui->line_edit_osk->text().toStdU16String(); std::u16string text_s = Common::U16StringFromBuffer(text.utf16(), text.size());
emit SubmitNormalText(SwkbdResult::Ok, std::move(text)); emit SubmitNormalText(SwkbdResult::Ok, std::move(text_s));
return; return;
} }
@ -1189,7 +1189,8 @@ void QtSoftwareKeyboardDialog::InlineKeyboardButtonClicked(QPushButton* button)
return; return;
} }
InlineTextInsertString(button->text().toStdU16String()); InlineTextInsertString(
Common::U16StringFromBuffer(button->text().utf16(), button->text().size()));
// Revert the keyboard to lowercase if the shift key is active. // Revert the keyboard to lowercase if the shift key is active.
if (bottom_osk_index == BottomOSKIndex::UpperCase && !caps_lock_enabled) { if (bottom_osk_index == BottomOSKIndex::UpperCase && !caps_lock_enabled) {
@ -1282,11 +1283,11 @@ void QtSoftwareKeyboardDialog::TranslateButtonPress(Core::HID::NpadButton button
if (is_inline) { if (is_inline) {
emit SubmitInlineText(SwkbdReplyType::DecidedCancel, current_text, cursor_position); emit SubmitInlineText(SwkbdReplyType::DecidedCancel, current_text, cursor_position);
} else { } else {
auto text = ui->topOSK->currentIndex() == 1 const auto& text = ui->topOSK->currentIndex() == 1 ? ui->text_edit_osk->toPlainText()
? ui->text_edit_osk->toPlainText().toStdU16String() : ui->line_edit_osk->text();
: ui->line_edit_osk->text().toStdU16String(); std::u16string text_s = Common::U16StringFromBuffer(text.utf16(), text.size());
emit SubmitNormalText(SwkbdResult::Cancel, std::move(text)); emit SubmitNormalText(SwkbdResult::Cancel, std::move(text_s));
} }
break; break;
case Core::HID::NpadButton::Y: case Core::HID::NpadButton::Y: