summaryrefslogtreecommitdiffstats
path: root/src/yuzu/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r--src/yuzu/main.cpp185
1 files changed, 161 insertions, 24 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index fbf96be03..5f6cdc0c6 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -101,6 +101,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
#include "core/perf_stats.h"
#include "core/telemetry_session.h"
#include "input_common/main.h"
+#include "util/overlay_dialog.h"
#include "video_core/gpu.h"
#include "video_core/shader_notify.h"
#include "yuzu/about_dialog.h"
@@ -227,6 +228,8 @@ GMainWindow::GMainWindow()
SetDiscordEnabled(UISettings::values.enable_discord_presence);
discord_rpc->Update();
+ RegisterMetaTypes();
+
InitializeWidgets();
InitializeDebugWidgets();
InitializeRecentFileMenuActions();
@@ -375,6 +378,55 @@ GMainWindow::~GMainWindow() {
delete render_window;
}
+void GMainWindow::RegisterMetaTypes() {
+ // Register integral and floating point types
+ qRegisterMetaType<u8>("u8");
+ qRegisterMetaType<u16>("u16");
+ qRegisterMetaType<u32>("u32");
+ qRegisterMetaType<u64>("u64");
+ qRegisterMetaType<u128>("u128");
+ qRegisterMetaType<s8>("s8");
+ qRegisterMetaType<s16>("s16");
+ qRegisterMetaType<s32>("s32");
+ qRegisterMetaType<s64>("s64");
+ qRegisterMetaType<f32>("f32");
+ qRegisterMetaType<f64>("f64");
+
+ // Register string types
+ qRegisterMetaType<std::string>("std::string");
+ qRegisterMetaType<std::wstring>("std::wstring");
+ qRegisterMetaType<std::u8string>("std::u8string");
+ qRegisterMetaType<std::u16string>("std::u16string");
+ qRegisterMetaType<std::u32string>("std::u32string");
+ qRegisterMetaType<std::string_view>("std::string_view");
+ qRegisterMetaType<std::wstring_view>("std::wstring_view");
+ qRegisterMetaType<std::u8string_view>("std::u8string_view");
+ qRegisterMetaType<std::u16string_view>("std::u16string_view");
+ qRegisterMetaType<std::u32string_view>("std::u32string_view");
+
+ // Register applet types
+
+ // Controller Applet
+ qRegisterMetaType<Core::Frontend::ControllerParameters>("Core::Frontend::ControllerParameters");
+
+ // Software Keyboard Applet
+ qRegisterMetaType<Core::Frontend::KeyboardInitializeParameters>(
+ "Core::Frontend::KeyboardInitializeParameters");
+ qRegisterMetaType<Core::Frontend::InlineAppearParameters>(
+ "Core::Frontend::InlineAppearParameters");
+ qRegisterMetaType<Core::Frontend::InlineTextParameters>("Core::Frontend::InlineTextParameters");
+ qRegisterMetaType<Service::AM::Applets::SwkbdResult>("Service::AM::Applets::SwkbdResult");
+ qRegisterMetaType<Service::AM::Applets::SwkbdTextCheckResult>(
+ "Service::AM::Applets::SwkbdTextCheckResult");
+ qRegisterMetaType<Service::AM::Applets::SwkbdReplyType>("Service::AM::Applets::SwkbdReplyType");
+
+ // Web Browser Applet
+ qRegisterMetaType<Service::AM::Applets::WebExitReason>("Service::AM::Applets::WebExitReason");
+
+ // Register loader types
+ qRegisterMetaType<Core::System::ResultStatus>("Core::System::ResultStatus");
+}
+
void GMainWindow::ControllerSelectorReconfigureControllers(
const Core::Frontend::ControllerParameters& parameters) {
QtControllerSelectorDialog dialog(this, parameters, input_subsystem.get());
@@ -414,25 +466,112 @@ void GMainWindow::ProfileSelectorSelectProfile() {
emit ProfileSelectorFinishedSelection(uuid);
}
-void GMainWindow::SoftwareKeyboardGetText(
- const Core::Frontend::SoftwareKeyboardParameters& parameters) {
- QtSoftwareKeyboardDialog dialog(this, parameters);
- dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint |
- Qt::WindowTitleHint | Qt::WindowSystemMenuHint |
- Qt::WindowCloseButtonHint);
- dialog.setWindowModality(Qt::WindowModal);
+void GMainWindow::SoftwareKeyboardInitialize(
+ bool is_inline, Core::Frontend::KeyboardInitializeParameters initialize_parameters) {
+ if (software_keyboard) {
+ LOG_ERROR(Frontend, "The software keyboard is already initialized!");
+ return;
+ }
- if (dialog.exec() == QDialog::Rejected) {
- emit SoftwareKeyboardFinishedText(std::nullopt);
+ software_keyboard = new QtSoftwareKeyboardDialog(render_window, Core::System::GetInstance(),
+ is_inline, std::move(initialize_parameters));
+
+ if (is_inline) {
+ connect(
+ software_keyboard, &QtSoftwareKeyboardDialog::SubmitInlineText, this,
+ [this](Service::AM::Applets::SwkbdReplyType reply_type, std::u16string submitted_text,
+ s32 cursor_position) {
+ emit SoftwareKeyboardSubmitInlineText(reply_type, submitted_text, cursor_position);
+ },
+ Qt::QueuedConnection);
+ } else {
+ connect(
+ software_keyboard, &QtSoftwareKeyboardDialog::SubmitNormalText, this,
+ [this](Service::AM::Applets::SwkbdResult result, std::u16string submitted_text) {
+ emit SoftwareKeyboardSubmitNormalText(result, submitted_text);
+ },
+ Qt::QueuedConnection);
+ }
+}
+
+void GMainWindow::SoftwareKeyboardShowNormal() {
+ if (!software_keyboard) {
+ LOG_ERROR(Frontend, "The software keyboard is not initialized!");
return;
}
- emit SoftwareKeyboardFinishedText(dialog.GetText());
+ const auto& layout = render_window->GetFramebufferLayout();
+
+ const auto x = layout.screen.left;
+ const auto y = layout.screen.top;
+ const auto w = layout.screen.GetWidth();
+ const auto h = layout.screen.GetHeight();
+
+ software_keyboard->ShowNormalKeyboard(render_window->mapToGlobal(QPoint(x, y)), QSize(w, h));
}
-void GMainWindow::SoftwareKeyboardInvokeCheckDialog(std::u16string error_message) {
- QMessageBox::warning(this, tr("Text Check Failed"), QString::fromStdU16String(error_message));
- emit SoftwareKeyboardFinishedCheckDialog();
+void GMainWindow::SoftwareKeyboardShowTextCheck(
+ Service::AM::Applets::SwkbdTextCheckResult text_check_result,
+ std::u16string text_check_message) {
+ if (!software_keyboard) {
+ LOG_ERROR(Frontend, "The software keyboard is not initialized!");
+ return;
+ }
+
+ software_keyboard->ShowTextCheckDialog(text_check_result, text_check_message);
+}
+
+void GMainWindow::SoftwareKeyboardShowInline(
+ Core::Frontend::InlineAppearParameters appear_parameters) {
+ if (!software_keyboard) {
+ LOG_ERROR(Frontend, "The software keyboard is not initialized!");
+ return;
+ }
+
+ const auto& layout = render_window->GetFramebufferLayout();
+
+ const auto x =
+ static_cast<int>(layout.screen.left + (0.5f * layout.screen.GetWidth() *
+ ((2.0f * appear_parameters.key_top_translate_x) +
+ (1.0f - appear_parameters.key_top_scale_x))));
+ const auto y =
+ static_cast<int>(layout.screen.top + (layout.screen.GetHeight() *
+ ((2.0f * appear_parameters.key_top_translate_y) +
+ (1.0f - appear_parameters.key_top_scale_y))));
+ const auto w = static_cast<int>(layout.screen.GetWidth() * appear_parameters.key_top_scale_x);
+ const auto h = static_cast<int>(layout.screen.GetHeight() * appear_parameters.key_top_scale_y);
+
+ software_keyboard->ShowInlineKeyboard(std::move(appear_parameters),
+ render_window->mapToGlobal(QPoint(x, y)), QSize(w, h));
+}
+
+void GMainWindow::SoftwareKeyboardHideInline() {
+ if (!software_keyboard) {
+ LOG_ERROR(Frontend, "The software keyboard is not initialized!");
+ return;
+ }
+
+ software_keyboard->HideInlineKeyboard();
+}
+
+void GMainWindow::SoftwareKeyboardInlineTextChanged(
+ Core::Frontend::InlineTextParameters text_parameters) {
+ if (!software_keyboard) {
+ LOG_ERROR(Frontend, "The software keyboard is not initialized!");
+ return;
+ }
+
+ software_keyboard->InlineTextChanged(std::move(text_parameters));
+}
+
+void GMainWindow::SoftwareKeyboardExit() {
+ if (!software_keyboard) {
+ return;
+ }
+
+ software_keyboard->ExitKeyboard();
+
+ software_keyboard = nullptr;
}
void GMainWindow::WebBrowserOpenWebPage(std::string_view main_url, std::string_view additional_args,
@@ -978,6 +1117,10 @@ void GMainWindow::ConnectWidgetEvents() {
connect(this, &GMainWindow::EmulationStopping, render_window,
&GRenderWindow::OnEmulationStopping);
+ // Software Keyboard Applet
+ connect(this, &GMainWindow::EmulationStarting, this, &GMainWindow::SoftwareKeyboardExit);
+ connect(this, &GMainWindow::EmulationStopping, this, &GMainWindow::SoftwareKeyboardExit);
+
connect(&status_bar_update_timer, &QTimer::timeout, this, &GMainWindow::UpdateStatusBar);
}
@@ -2187,15 +2330,6 @@ void GMainWindow::OnStartGame() {
emu_thread->SetRunning(true);
- qRegisterMetaType<Core::Frontend::ControllerParameters>("Core::Frontend::ControllerParameters");
- qRegisterMetaType<Core::Frontend::SoftwareKeyboardParameters>(
- "Core::Frontend::SoftwareKeyboardParameters");
- qRegisterMetaType<Core::System::ResultStatus>("Core::System::ResultStatus");
- qRegisterMetaType<std::string>("std::string");
- qRegisterMetaType<std::optional<std::u16string>>("std::optional<std::u16string>");
- qRegisterMetaType<std::string_view>("std::string_view");
- qRegisterMetaType<Service::AM::Applets::WebExitReason>("Service::AM::Applets::WebExitReason");
-
connect(emu_thread.get(), &EmuThread::ErrorThrown, this, &GMainWindow::OnCoreError);
ui.action_Start->setEnabled(false);
@@ -2244,8 +2378,11 @@ void GMainWindow::OnExecuteProgram(std::size_t program_index) {
BootGame(last_filename_booted, program_index);
}
-void GMainWindow::ErrorDisplayDisplayError(QString body) {
- QMessageBox::critical(this, tr("Error Display"), body);
+void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_text) {
+ OverlayDialog dialog(render_window, Core::System::GetInstance(), error_code, error_text,
+ QString{}, tr("OK"), Qt::AlignLeft | Qt::AlignVCenter);
+ dialog.exec();
+
emit ErrorDisplayFinished();
}