Merge pull request #9505 from liamwhite/request-exit

applets: implement RequestExit
This commit is contained in:
liamwhite 2023-03-29 09:11:34 -04:00 committed by GitHub
commit 8bdc51b620
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 312 additions and 61 deletions

View file

@ -0,0 +1,14 @@
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
namespace Core::Frontend {
class Applet {
public:
virtual ~Applet() = default;
virtual void Close() const = 0;
};
} // namespace Core::Frontend

View file

@ -10,6 +10,8 @@ namespace Core::Frontend {
CabinetApplet::~CabinetApplet() = default; CabinetApplet::~CabinetApplet() = default;
void DefaultCabinetApplet::Close() const {}
void DefaultCabinetApplet::ShowCabinetApplet( void DefaultCabinetApplet::ShowCabinetApplet(
const CabinetCallback& callback, const CabinetParameters& parameters, const CabinetCallback& callback, const CabinetParameters& parameters,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const { std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const {

View file

@ -4,6 +4,7 @@
#pragma once #pragma once
#include <functional> #include <functional>
#include "core/frontend/applets/applet.h"
#include "core/hle/service/nfp/nfp_types.h" #include "core/hle/service/nfp/nfp_types.h"
namespace Service::NFP { namespace Service::NFP {
@ -20,7 +21,7 @@ struct CabinetParameters {
using CabinetCallback = std::function<void(bool, const std::string&)>; using CabinetCallback = std::function<void(bool, const std::string&)>;
class CabinetApplet { class CabinetApplet : public Applet {
public: public:
virtual ~CabinetApplet(); virtual ~CabinetApplet();
virtual void ShowCabinetApplet(const CabinetCallback& callback, virtual void ShowCabinetApplet(const CabinetCallback& callback,
@ -30,6 +31,7 @@ public:
class DefaultCabinetApplet final : public CabinetApplet { class DefaultCabinetApplet final : public CabinetApplet {
public: public:
void Close() const override;
void ShowCabinetApplet(const CabinetCallback& callback, const CabinetParameters& parameters, void ShowCabinetApplet(const CabinetCallback& callback, const CabinetParameters& parameters,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const override; std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const override;
}; };

View file

@ -16,6 +16,8 @@ DefaultControllerApplet::DefaultControllerApplet(HID::HIDCore& hid_core_) : hid_
DefaultControllerApplet::~DefaultControllerApplet() = default; DefaultControllerApplet::~DefaultControllerApplet() = default;
void DefaultControllerApplet::Close() const {}
void DefaultControllerApplet::ReconfigureControllers(ReconfigureCallback callback, void DefaultControllerApplet::ReconfigureControllers(ReconfigureCallback callback,
const ControllerParameters& parameters) const { const ControllerParameters& parameters) const {
LOG_INFO(Service_HID, "called, deducing the best configuration based on the given parameters!"); LOG_INFO(Service_HID, "called, deducing the best configuration based on the given parameters!");

View file

@ -7,6 +7,7 @@
#include <vector> #include <vector>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/frontend/applets/applet.h"
namespace Core::HID { namespace Core::HID {
class HIDCore; class HIDCore;
@ -34,7 +35,7 @@ struct ControllerParameters {
bool allow_gamecube_controller{}; bool allow_gamecube_controller{};
}; };
class ControllerApplet { class ControllerApplet : public Applet {
public: public:
using ReconfigureCallback = std::function<void()>; using ReconfigureCallback = std::function<void()>;
@ -49,6 +50,7 @@ public:
explicit DefaultControllerApplet(HID::HIDCore& hid_core_); explicit DefaultControllerApplet(HID::HIDCore& hid_core_);
~DefaultControllerApplet() override; ~DefaultControllerApplet() override;
void Close() const override;
void ReconfigureControllers(ReconfigureCallback callback, void ReconfigureControllers(ReconfigureCallback callback,
const ControllerParameters& parameters) const override; const ControllerParameters& parameters) const override;

View file

@ -8,6 +8,8 @@ namespace Core::Frontend {
ErrorApplet::~ErrorApplet() = default; ErrorApplet::~ErrorApplet() = default;
void DefaultErrorApplet::Close() const {}
void DefaultErrorApplet::ShowError(Result error, FinishedCallback finished) const { void DefaultErrorApplet::ShowError(Result error, FinishedCallback finished) const {
LOG_CRITICAL(Service_Fatal, "Application requested error display: {:04}-{:04} (raw={:08X})", LOG_CRITICAL(Service_Fatal, "Application requested error display: {:04}-{:04} (raw={:08X})",
error.module.Value(), error.description.Value(), error.raw); error.module.Value(), error.description.Value(), error.raw);

View file

@ -6,11 +6,12 @@
#include <chrono> #include <chrono>
#include <functional> #include <functional>
#include "core/frontend/applets/applet.h"
#include "core/hle/result.h" #include "core/hle/result.h"
namespace Core::Frontend { namespace Core::Frontend {
class ErrorApplet { class ErrorApplet : public Applet {
public: public:
using FinishedCallback = std::function<void()>; using FinishedCallback = std::function<void()>;
@ -28,6 +29,7 @@ public:
class DefaultErrorApplet final : public ErrorApplet { class DefaultErrorApplet final : public ErrorApplet {
public: public:
void Close() const override;
void ShowError(Result error, FinishedCallback finished) const override; void ShowError(Result error, FinishedCallback finished) const override;
void ShowErrorWithTimestamp(Result error, std::chrono::seconds time, void ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
FinishedCallback finished) const override; FinishedCallback finished) const override;

View file

@ -10,6 +10,8 @@ ParentalControlsApplet::~ParentalControlsApplet() = default;
DefaultParentalControlsApplet::~DefaultParentalControlsApplet() = default; DefaultParentalControlsApplet::~DefaultParentalControlsApplet() = default;
void DefaultParentalControlsApplet::Close() const {}
void DefaultParentalControlsApplet::VerifyPIN(std::function<void(bool)> finished, void DefaultParentalControlsApplet::VerifyPIN(std::function<void(bool)> finished,
bool suspend_future_verification_temporarily) { bool suspend_future_verification_temporarily) {
LOG_INFO(Service_AM, LOG_INFO(Service_AM,
@ -39,6 +41,8 @@ PhotoViewerApplet::~PhotoViewerApplet() = default;
DefaultPhotoViewerApplet::~DefaultPhotoViewerApplet() = default; DefaultPhotoViewerApplet::~DefaultPhotoViewerApplet() = default;
void DefaultPhotoViewerApplet::Close() const {}
void DefaultPhotoViewerApplet::ShowPhotosForApplication(u64 title_id, void DefaultPhotoViewerApplet::ShowPhotosForApplication(u64 title_id,
std::function<void()> finished) const { std::function<void()> finished) const {
LOG_INFO(Service_AM, LOG_INFO(Service_AM,

View file

@ -6,9 +6,11 @@
#include <functional> #include <functional>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/frontend/applets/applet.h"
namespace Core::Frontend { namespace Core::Frontend {
class ParentalControlsApplet { class ParentalControlsApplet : public Applet {
public: public:
virtual ~ParentalControlsApplet(); virtual ~ParentalControlsApplet();
@ -33,6 +35,7 @@ class DefaultParentalControlsApplet final : public ParentalControlsApplet {
public: public:
~DefaultParentalControlsApplet() override; ~DefaultParentalControlsApplet() override;
void Close() const override;
void VerifyPIN(std::function<void(bool)> finished, void VerifyPIN(std::function<void(bool)> finished,
bool suspend_future_verification_temporarily) override; bool suspend_future_verification_temporarily) override;
void VerifyPINForSettings(std::function<void(bool)> finished) override; void VerifyPINForSettings(std::function<void(bool)> finished) override;
@ -40,7 +43,7 @@ public:
void ChangePIN(std::function<void()> finished) override; void ChangePIN(std::function<void()> finished) override;
}; };
class PhotoViewerApplet { class PhotoViewerApplet : public Applet {
public: public:
virtual ~PhotoViewerApplet(); virtual ~PhotoViewerApplet();
@ -52,6 +55,7 @@ class DefaultPhotoViewerApplet final : public PhotoViewerApplet {
public: public:
~DefaultPhotoViewerApplet() override; ~DefaultPhotoViewerApplet() override;
void Close() const override;
void ShowPhotosForApplication(u64 title_id, std::function<void()> finished) const override; void ShowPhotosForApplication(u64 title_id, std::function<void()> finished) const override;
void ShowAllPhotos(std::function<void()> finished) const override; void ShowAllPhotos(std::function<void()> finished) const override;
}; };

View file

@ -8,6 +8,8 @@ namespace Core::Frontend {
MiiEditApplet::~MiiEditApplet() = default; MiiEditApplet::~MiiEditApplet() = default;
void DefaultMiiEditApplet::Close() const {}
void DefaultMiiEditApplet::ShowMiiEdit(const MiiEditCallback& callback) const { void DefaultMiiEditApplet::ShowMiiEdit(const MiiEditCallback& callback) const {
LOG_WARNING(Service_AM, "(STUBBED) called"); LOG_WARNING(Service_AM, "(STUBBED) called");

View file

@ -5,9 +5,11 @@
#include <functional> #include <functional>
#include "core/frontend/applets/applet.h"
namespace Core::Frontend { namespace Core::Frontend {
class MiiEditApplet { class MiiEditApplet : public Applet {
public: public:
using MiiEditCallback = std::function<void()>; using MiiEditCallback = std::function<void()>;
@ -18,6 +20,7 @@ public:
class DefaultMiiEditApplet final : public MiiEditApplet { class DefaultMiiEditApplet final : public MiiEditApplet {
public: public:
void Close() const override;
void ShowMiiEdit(const MiiEditCallback& callback) const override; void ShowMiiEdit(const MiiEditCallback& callback) const override;
}; };

View file

@ -9,6 +9,8 @@ namespace Core::Frontend {
ProfileSelectApplet::~ProfileSelectApplet() = default; ProfileSelectApplet::~ProfileSelectApplet() = default;
void DefaultProfileSelectApplet::Close() const {}
void DefaultProfileSelectApplet::SelectProfile(SelectProfileCallback callback) const { void DefaultProfileSelectApplet::SelectProfile(SelectProfileCallback callback) const {
Service::Account::ProfileManager manager; Service::Account::ProfileManager manager;
callback(manager.GetUser(Settings::values.current_user.GetValue()).value_or(Common::UUID{})); callback(manager.GetUser(Settings::values.current_user.GetValue()).value_or(Common::UUID{}));

View file

@ -7,9 +7,11 @@
#include <optional> #include <optional>
#include "common/uuid.h" #include "common/uuid.h"
#include "core/frontend/applets/applet.h"
namespace Core::Frontend { namespace Core::Frontend {
class ProfileSelectApplet { class ProfileSelectApplet : public Applet {
public: public:
using SelectProfileCallback = std::function<void(std::optional<Common::UUID>)>; using SelectProfileCallback = std::function<void(std::optional<Common::UUID>)>;
@ -20,6 +22,7 @@ public:
class DefaultProfileSelectApplet final : public ProfileSelectApplet { class DefaultProfileSelectApplet final : public ProfileSelectApplet {
public: public:
void Close() const override;
void SelectProfile(SelectProfileCallback callback) const override; void SelectProfile(SelectProfileCallback callback) const override;
}; };

View file

@ -13,6 +13,8 @@ SoftwareKeyboardApplet::~SoftwareKeyboardApplet() = default;
DefaultSoftwareKeyboardApplet::~DefaultSoftwareKeyboardApplet() = default; DefaultSoftwareKeyboardApplet::~DefaultSoftwareKeyboardApplet() = default;
void DefaultSoftwareKeyboardApplet::Close() const {}
void DefaultSoftwareKeyboardApplet::InitializeKeyboard( void DefaultSoftwareKeyboardApplet::InitializeKeyboard(
bool is_inline, KeyboardInitializeParameters initialize_parameters, bool is_inline, KeyboardInitializeParameters initialize_parameters,
SubmitNormalCallback submit_normal_callback_, SubmitInlineCallback submit_inline_callback_) { SubmitNormalCallback submit_normal_callback_, SubmitInlineCallback submit_inline_callback_) {

View file

@ -7,6 +7,7 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "core/frontend/applets/applet.h"
#include "core/hle/service/am/applets/applet_software_keyboard_types.h" #include "core/hle/service/am/applets/applet_software_keyboard_types.h"
namespace Core::Frontend { namespace Core::Frontend {
@ -52,7 +53,7 @@ struct InlineTextParameters {
s32 cursor_position; s32 cursor_position;
}; };
class SoftwareKeyboardApplet { class SoftwareKeyboardApplet : public Applet {
public: public:
using SubmitInlineCallback = using SubmitInlineCallback =
std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)>; std::function<void(Service::AM::Applets::SwkbdReplyType, std::u16string, s32)>;
@ -84,6 +85,8 @@ class DefaultSoftwareKeyboardApplet final : public SoftwareKeyboardApplet {
public: public:
~DefaultSoftwareKeyboardApplet() override; ~DefaultSoftwareKeyboardApplet() override;
void Close() const override;
void InitializeKeyboard(bool is_inline, KeyboardInitializeParameters initialize_parameters, void InitializeKeyboard(bool is_inline, KeyboardInitializeParameters initialize_parameters,
SubmitNormalCallback submit_normal_callback_, SubmitNormalCallback submit_normal_callback_,
SubmitInlineCallback submit_inline_callback_) override; SubmitInlineCallback submit_inline_callback_) override;

View file

@ -10,6 +10,8 @@ WebBrowserApplet::~WebBrowserApplet() = default;
DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default; DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default;
void DefaultWebBrowserApplet::Close() const {}
void DefaultWebBrowserApplet::OpenLocalWebPage(const std::string& local_url, void DefaultWebBrowserApplet::OpenLocalWebPage(const std::string& local_url,
ExtractROMFSCallback extract_romfs_callback, ExtractROMFSCallback extract_romfs_callback,
OpenWebPageCallback callback) const { OpenWebPageCallback callback) const {

View file

@ -5,11 +5,12 @@
#include <functional> #include <functional>
#include "core/frontend/applets/applet.h"
#include "core/hle/service/am/applets/applet_web_browser_types.h" #include "core/hle/service/am/applets/applet_web_browser_types.h"
namespace Core::Frontend { namespace Core::Frontend {
class WebBrowserApplet { class WebBrowserApplet : public Applet {
public: public:
using ExtractROMFSCallback = std::function<void()>; using ExtractROMFSCallback = std::function<void()>;
using OpenWebPageCallback = using OpenWebPageCallback =
@ -29,6 +30,8 @@ class DefaultWebBrowserApplet final : public WebBrowserApplet {
public: public:
~DefaultWebBrowserApplet() override; ~DefaultWebBrowserApplet() override;
void Close() const override;
void OpenLocalWebPage(const std::string& local_url, ExtractROMFSCallback extract_romfs_callback, void OpenLocalWebPage(const std::string& local_url, ExtractROMFSCallback extract_romfs_callback,
OpenWebPageCallback callback) const override; OpenWebPageCallback callback) const override;

View file

@ -945,7 +945,7 @@ public:
{0, &ILibraryAppletAccessor::GetAppletStateChangedEvent, "GetAppletStateChangedEvent"}, {0, &ILibraryAppletAccessor::GetAppletStateChangedEvent, "GetAppletStateChangedEvent"},
{1, &ILibraryAppletAccessor::IsCompleted, "IsCompleted"}, {1, &ILibraryAppletAccessor::IsCompleted, "IsCompleted"},
{10, &ILibraryAppletAccessor::Start, "Start"}, {10, &ILibraryAppletAccessor::Start, "Start"},
{20, nullptr, "RequestExit"}, {20, &ILibraryAppletAccessor::RequestExit, "RequestExit"},
{25, nullptr, "Terminate"}, {25, nullptr, "Terminate"},
{30, &ILibraryAppletAccessor::GetResult, "GetResult"}, {30, &ILibraryAppletAccessor::GetResult, "GetResult"},
{50, nullptr, "SetOutOfFocusApplicationSuspendingEnabled"}, {50, nullptr, "SetOutOfFocusApplicationSuspendingEnabled"},
@ -1010,6 +1010,15 @@ private:
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
} }
void RequestExit(HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called");
ASSERT(applet != nullptr);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(applet->RequestExit());
}
void PushInData(HLERequestContext& ctx) { void PushInData(HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "called"); LOG_DEBUG(Service_AM, "called");

View file

@ -174,4 +174,9 @@ void Cabinet::Cancel() {
broker.SignalStateChanged(); broker.SignalStateChanged();
} }
Result Cabinet::RequestExit() {
frontend.Close();
R_SUCCEED();
}
} // namespace Service::AM::Applets } // namespace Service::AM::Applets

View file

@ -89,6 +89,7 @@ public:
void Execute() override; void Execute() override;
void DisplayCompleted(bool apply_changes, std::string_view amiibo_name); void DisplayCompleted(bool apply_changes, std::string_view amiibo_name);
void Cancel(); void Cancel();
Result RequestExit() override;
private: private:
const Core::Frontend::CabinetApplet& frontend; const Core::Frontend::CabinetApplet& frontend;

View file

@ -262,4 +262,9 @@ void Controller::ConfigurationComplete() {
broker.SignalStateChanged(); broker.SignalStateChanged();
} }
Result Controller::RequestExit() {
frontend.Close();
R_SUCCEED();
}
} // namespace Service::AM::Applets } // namespace Service::AM::Applets

View file

@ -129,6 +129,7 @@ public:
Result GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;
Result RequestExit() override;
void ConfigurationComplete(); void ConfigurationComplete();

View file

@ -209,4 +209,9 @@ void Error::DisplayCompleted() {
broker.SignalStateChanged(); broker.SignalStateChanged();
} }
Result Error::RequestExit() {
frontend.Close();
R_SUCCEED();
}
} // namespace Service::AM::Applets } // namespace Service::AM::Applets

View file

@ -34,6 +34,7 @@ public:
Result GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;
Result RequestExit() override;
void DisplayCompleted(); void DisplayCompleted();

View file

@ -150,6 +150,11 @@ void Auth::AuthFinished(bool is_successful) {
broker.SignalStateChanged(); broker.SignalStateChanged();
} }
Result Auth::RequestExit() {
frontend.Close();
R_SUCCEED();
}
PhotoViewer::PhotoViewer(Core::System& system_, LibraryAppletMode applet_mode_, PhotoViewer::PhotoViewer(Core::System& system_, LibraryAppletMode applet_mode_,
const Core::Frontend::PhotoViewerApplet& frontend_) const Core::Frontend::PhotoViewerApplet& frontend_)
: Applet{system_, applet_mode_}, frontend{frontend_}, system{system_} {} : Applet{system_, applet_mode_}, frontend{frontend_}, system{system_} {}
@ -202,6 +207,11 @@ void PhotoViewer::ViewFinished() {
broker.SignalStateChanged(); broker.SignalStateChanged();
} }
Result PhotoViewer::RequestExit() {
frontend.Close();
R_SUCCEED();
}
StubApplet::StubApplet(Core::System& system_, AppletId id_, LibraryAppletMode applet_mode_) StubApplet::StubApplet(Core::System& system_, AppletId id_, LibraryAppletMode applet_mode_)
: Applet{system_, applet_mode_}, id{id_}, system{system_} {} : Applet{system_, applet_mode_}, id{id_}, system{system_} {}
@ -250,4 +260,9 @@ void StubApplet::Execute() {
broker.SignalStateChanged(); broker.SignalStateChanged();
} }
Result StubApplet::RequestExit() {
// Nothing to do.
R_SUCCEED();
}
} // namespace Service::AM::Applets } // namespace Service::AM::Applets

View file

@ -28,6 +28,7 @@ public:
Result GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;
Result RequestExit() override;
void AuthFinished(bool is_successful = true); void AuthFinished(bool is_successful = true);
@ -59,6 +60,7 @@ public:
Result GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;
Result RequestExit() override;
void ViewFinished(); void ViewFinished();
@ -80,6 +82,7 @@ public:
Result GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;
Result RequestExit() override;
private: private:
AppletId id; AppletId id;

View file

@ -135,4 +135,9 @@ void MiiEdit::MiiEditOutputForCharInfoEditing(MiiEditResult result,
broker.SignalStateChanged(); broker.SignalStateChanged();
} }
Result MiiEdit::RequestExit() {
frontend.Close();
R_SUCCEED();
}
} // namespace Service::AM::Applets } // namespace Service::AM::Applets

View file

@ -25,6 +25,7 @@ public:
Result GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;
Result RequestExit() override;
void MiiEditOutput(MiiEditResult result, s32 index); void MiiEditOutput(MiiEditResult result, s32 index);

View file

@ -73,4 +73,9 @@ void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) {
broker.SignalStateChanged(); broker.SignalStateChanged();
} }
Result ProfileSelect::RequestExit() {
frontend.Close();
R_SUCCEED();
}
} // namespace Service::AM::Applets } // namespace Service::AM::Applets

View file

@ -42,6 +42,7 @@ public:
Result GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;
Result RequestExit() override;
void SelectionComplete(std::optional<Common::UUID> uuid); void SelectionComplete(std::optional<Common::UUID> uuid);

View file

@ -770,6 +770,11 @@ void SoftwareKeyboard::ExitKeyboard() {
broker.SignalStateChanged(); broker.SignalStateChanged();
} }
Result SoftwareKeyboard::RequestExit() {
frontend.Close();
R_SUCCEED();
}
// Inline Software Keyboard Requests // Inline Software Keyboard Requests
void SoftwareKeyboard::RequestFinalize(const std::vector<u8>& request_data) { void SoftwareKeyboard::RequestFinalize(const std::vector<u8>& request_data) {

View file

@ -31,6 +31,7 @@ public:
Result GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;
Result RequestExit() override;
/** /**
* Submits the input text to the application. * Submits the input text to the application.

View file

@ -363,6 +363,11 @@ void WebBrowser::WebBrowserExit(WebExitReason exit_reason, std::string last_url)
broker.SignalStateChanged(); broker.SignalStateChanged();
} }
Result WebBrowser::RequestExit() {
frontend.Close();
R_SUCCEED();
}
bool WebBrowser::InputTLVExistsInMap(WebArgInputTLVType input_tlv_type) const { bool WebBrowser::InputTLVExistsInMap(WebArgInputTLVType input_tlv_type) const {
return web_arg_input_tlv_map.find(input_tlv_type) != web_arg_input_tlv_map.end(); return web_arg_input_tlv_map.find(input_tlv_type) != web_arg_input_tlv_map.end();
} }

View file

@ -35,6 +35,7 @@ public:
Result GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;
Result RequestExit() override;
void ExtractOfflineRomFS(); void ExtractOfflineRomFS();

View file

@ -142,6 +142,7 @@ public:
virtual Result GetStatus() const = 0; virtual Result GetStatus() const = 0;
virtual void ExecuteInteractive() = 0; virtual void ExecuteInteractive() = 0;
virtual void Execute() = 0; virtual void Execute() = 0;
virtual Result RequestExit() = 0;
AppletDataBroker& GetBroker() { AppletDataBroker& GetBroker() {
return broker; return broker;

View file

@ -245,12 +245,19 @@ void QtAmiiboSettingsDialog::SetSettingsDescription() {
QtAmiiboSettings::QtAmiiboSettings(GMainWindow& parent) { QtAmiiboSettings::QtAmiiboSettings(GMainWindow& parent) {
connect(this, &QtAmiiboSettings::MainWindowShowAmiiboSettings, &parent, connect(this, &QtAmiiboSettings::MainWindowShowAmiiboSettings, &parent,
&GMainWindow::AmiiboSettingsShowDialog, Qt::QueuedConnection); &GMainWindow::AmiiboSettingsShowDialog, Qt::QueuedConnection);
connect(this, &QtAmiiboSettings::MainWindowRequestExit, &parent,
&GMainWindow::AmiiboSettingsRequestExit, Qt::QueuedConnection);
connect(&parent, &GMainWindow::AmiiboSettingsFinished, this, connect(&parent, &GMainWindow::AmiiboSettingsFinished, this,
&QtAmiiboSettings::MainWindowFinished, Qt::QueuedConnection); &QtAmiiboSettings::MainWindowFinished, Qt::QueuedConnection);
} }
QtAmiiboSettings::~QtAmiiboSettings() = default; QtAmiiboSettings::~QtAmiiboSettings() = default;
void QtAmiiboSettings::Close() const {
callback = {};
emit MainWindowRequestExit();
}
void QtAmiiboSettings::ShowCabinetApplet( void QtAmiiboSettings::ShowCabinetApplet(
const Core::Frontend::CabinetCallback& callback_, const Core::Frontend::CabinetCallback& callback_,
const Core::Frontend::CabinetParameters& parameters, const Core::Frontend::CabinetParameters& parameters,
@ -260,5 +267,7 @@ void QtAmiiboSettings::ShowCabinetApplet(
} }
void QtAmiiboSettings::MainWindowFinished(bool is_success, const std::string& name) { void QtAmiiboSettings::MainWindowFinished(bool is_success, const std::string& name) {
if (callback) {
callback(is_success, name); callback(is_success, name);
}
} }

View file

@ -68,6 +68,7 @@ public:
explicit QtAmiiboSettings(GMainWindow& parent); explicit QtAmiiboSettings(GMainWindow& parent);
~QtAmiiboSettings() override; ~QtAmiiboSettings() override;
void Close() const override;
void ShowCabinetApplet(const Core::Frontend::CabinetCallback& callback_, void ShowCabinetApplet(const Core::Frontend::CabinetCallback& callback_,
const Core::Frontend::CabinetParameters& parameters, const Core::Frontend::CabinetParameters& parameters,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const override; std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const override;
@ -75,6 +76,7 @@ public:
signals: signals:
void MainWindowShowAmiiboSettings(const Core::Frontend::CabinetParameters& parameters, void MainWindowShowAmiiboSettings(const Core::Frontend::CabinetParameters& parameters,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const; std::shared_ptr<Service::NFP::NfpDevice> nfp_device) const;
void MainWindowRequestExit() const;
private: private:
void MainWindowFinished(bool is_success, const std::string& name); void MainWindowFinished(bool is_success, const std::string& name);

View file

@ -678,12 +678,19 @@ void QtControllerSelectorDialog::DisableUnsupportedPlayers() {
QtControllerSelector::QtControllerSelector(GMainWindow& parent) { QtControllerSelector::QtControllerSelector(GMainWindow& parent) {
connect(this, &QtControllerSelector::MainWindowReconfigureControllers, &parent, connect(this, &QtControllerSelector::MainWindowReconfigureControllers, &parent,
&GMainWindow::ControllerSelectorReconfigureControllers, Qt::QueuedConnection); &GMainWindow::ControllerSelectorReconfigureControllers, Qt::QueuedConnection);
connect(this, &QtControllerSelector::MainWindowRequestExit, &parent,
&GMainWindow::ControllerSelectorRequestExit, Qt::QueuedConnection);
connect(&parent, &GMainWindow::ControllerSelectorReconfigureFinished, this, connect(&parent, &GMainWindow::ControllerSelectorReconfigureFinished, this,
&QtControllerSelector::MainWindowReconfigureFinished, Qt::QueuedConnection); &QtControllerSelector::MainWindowReconfigureFinished, Qt::QueuedConnection);
} }
QtControllerSelector::~QtControllerSelector() = default; QtControllerSelector::~QtControllerSelector() = default;
void QtControllerSelector::Close() const {
callback = {};
emit MainWindowRequestExit();
}
void QtControllerSelector::ReconfigureControllers( void QtControllerSelector::ReconfigureControllers(
ReconfigureCallback callback_, const Core::Frontend::ControllerParameters& parameters) const { ReconfigureCallback callback_, const Core::Frontend::ControllerParameters& parameters) const {
callback = std::move(callback_); callback = std::move(callback_);
@ -691,5 +698,7 @@ void QtControllerSelector::ReconfigureControllers(
} }
void QtControllerSelector::MainWindowReconfigureFinished() { void QtControllerSelector::MainWindowReconfigureFinished() {
if (callback) {
callback(); callback();
}
} }

View file

@ -156,6 +156,7 @@ public:
explicit QtControllerSelector(GMainWindow& parent); explicit QtControllerSelector(GMainWindow& parent);
~QtControllerSelector() override; ~QtControllerSelector() override;
void Close() const override;
void ReconfigureControllers( void ReconfigureControllers(
ReconfigureCallback callback_, ReconfigureCallback callback_,
const Core::Frontend::ControllerParameters& parameters) const override; const Core::Frontend::ControllerParameters& parameters) const override;
@ -163,6 +164,7 @@ public:
signals: signals:
void MainWindowReconfigureControllers( void MainWindowReconfigureControllers(
const Core::Frontend::ControllerParameters& parameters) const; const Core::Frontend::ControllerParameters& parameters) const;
void MainWindowRequestExit() const;
private: private:
void MainWindowReconfigureFinished(); void MainWindowReconfigureFinished();

View file

@ -8,12 +8,19 @@
QtErrorDisplay::QtErrorDisplay(GMainWindow& parent) { QtErrorDisplay::QtErrorDisplay(GMainWindow& parent) {
connect(this, &QtErrorDisplay::MainWindowDisplayError, &parent, connect(this, &QtErrorDisplay::MainWindowDisplayError, &parent,
&GMainWindow::ErrorDisplayDisplayError, Qt::QueuedConnection); &GMainWindow::ErrorDisplayDisplayError, Qt::QueuedConnection);
connect(this, &QtErrorDisplay::MainWindowRequestExit, &parent,
&GMainWindow::ErrorDisplayRequestExit, Qt::QueuedConnection);
connect(&parent, &GMainWindow::ErrorDisplayFinished, this, connect(&parent, &GMainWindow::ErrorDisplayFinished, this,
&QtErrorDisplay::MainWindowFinishedError, Qt::DirectConnection); &QtErrorDisplay::MainWindowFinishedError, Qt::DirectConnection);
} }
QtErrorDisplay::~QtErrorDisplay() = default; QtErrorDisplay::~QtErrorDisplay() = default;
void QtErrorDisplay::Close() const {
callback = {};
emit MainWindowRequestExit();
}
void QtErrorDisplay::ShowError(Result error, FinishedCallback finished) const { void QtErrorDisplay::ShowError(Result error, FinishedCallback finished) const {
callback = std::move(finished); callback = std::move(finished);
emit MainWindowDisplayError( emit MainWindowDisplayError(
@ -55,5 +62,7 @@ void QtErrorDisplay::ShowCustomErrorText(Result error, std::string dialog_text,
} }
void QtErrorDisplay::MainWindowFinishedError() { void QtErrorDisplay::MainWindowFinishedError() {
if (callback) {
callback(); callback();
}
} }

View file

@ -16,6 +16,7 @@ public:
explicit QtErrorDisplay(GMainWindow& parent); explicit QtErrorDisplay(GMainWindow& parent);
~QtErrorDisplay() override; ~QtErrorDisplay() override;
void Close() const override;
void ShowError(Result error, FinishedCallback finished) const override; void ShowError(Result error, FinishedCallback finished) const override;
void ShowErrorWithTimestamp(Result error, std::chrono::seconds time, void ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
FinishedCallback finished) const override; FinishedCallback finished) const override;
@ -24,6 +25,7 @@ public:
signals: signals:
void MainWindowDisplayError(QString error_code, QString error_text) const; void MainWindowDisplayError(QString error_code, QString error_text) const;
void MainWindowRequestExit() const;
private: private:
void MainWindowFinishedError(); void MainWindowFinishedError();

View file

@ -157,17 +157,26 @@ void QtProfileSelectionDialog::SelectUser(const QModelIndex& index) {
QtProfileSelector::QtProfileSelector(GMainWindow& parent) { QtProfileSelector::QtProfileSelector(GMainWindow& parent) {
connect(this, &QtProfileSelector::MainWindowSelectProfile, &parent, connect(this, &QtProfileSelector::MainWindowSelectProfile, &parent,
&GMainWindow::ProfileSelectorSelectProfile, Qt::QueuedConnection); &GMainWindow::ProfileSelectorSelectProfile, Qt::QueuedConnection);
connect(this, &QtProfileSelector::MainWindowRequestExit, &parent,
&GMainWindow::ProfileSelectorRequestExit, Qt::QueuedConnection);
connect(&parent, &GMainWindow::ProfileSelectorFinishedSelection, this, connect(&parent, &GMainWindow::ProfileSelectorFinishedSelection, this,
&QtProfileSelector::MainWindowFinishedSelection, Qt::DirectConnection); &QtProfileSelector::MainWindowFinishedSelection, Qt::DirectConnection);
} }
QtProfileSelector::~QtProfileSelector() = default; QtProfileSelector::~QtProfileSelector() = default;
void QtProfileSelector::Close() const {
callback = {};
emit MainWindowRequestExit();
}
void QtProfileSelector::SelectProfile(SelectProfileCallback callback_) const { void QtProfileSelector::SelectProfile(SelectProfileCallback callback_) const {
callback = std::move(callback_); callback = std::move(callback_);
emit MainWindowSelectProfile(); emit MainWindowSelectProfile();
} }
void QtProfileSelector::MainWindowFinishedSelection(std::optional<Common::UUID> uuid) { void QtProfileSelector::MainWindowFinishedSelection(std::optional<Common::UUID> uuid) {
if (callback) {
callback(uuid); callback(uuid);
}
} }

View file

@ -65,10 +65,12 @@ public:
explicit QtProfileSelector(GMainWindow& parent); explicit QtProfileSelector(GMainWindow& parent);
~QtProfileSelector() override; ~QtProfileSelector() override;
void Close() const override;
void SelectProfile(SelectProfileCallback callback_) const override; void SelectProfile(SelectProfileCallback callback_) const override;
signals: signals:
void MainWindowSelectProfile() const; void MainWindowSelectProfile() const;
void MainWindowRequestExit() const;
private: private:
void MainWindowFinishedSelection(std::optional<Common::UUID> uuid); void MainWindowFinishedSelection(std::optional<Common::UUID> uuid);

View file

@ -233,6 +233,10 @@ public:
explicit QtSoftwareKeyboard(GMainWindow& parent); explicit QtSoftwareKeyboard(GMainWindow& parent);
~QtSoftwareKeyboard() override; ~QtSoftwareKeyboard() override;
void Close() const override {
ExitKeyboard();
}
void InitializeKeyboard(bool is_inline, void InitializeKeyboard(bool is_inline,
Core::Frontend::KeyboardInitializeParameters initialize_parameters, Core::Frontend::KeyboardInitializeParameters initialize_parameters,
SubmitNormalCallback submit_normal_callback_, SubmitNormalCallback submit_normal_callback_,

View file

@ -393,6 +393,8 @@ void QtNXWebEngineView::FocusFirstLinkElement() {
QtWebBrowser::QtWebBrowser(GMainWindow& main_window) { QtWebBrowser::QtWebBrowser(GMainWindow& main_window) {
connect(this, &QtWebBrowser::MainWindowOpenWebPage, &main_window, connect(this, &QtWebBrowser::MainWindowOpenWebPage, &main_window,
&GMainWindow::WebBrowserOpenWebPage, Qt::QueuedConnection); &GMainWindow::WebBrowserOpenWebPage, Qt::QueuedConnection);
connect(this, &QtWebBrowser::MainWindowRequestExit, &main_window,
&GMainWindow::WebBrowserRequestExit, Qt::QueuedConnection);
connect(&main_window, &GMainWindow::WebBrowserExtractOfflineRomFS, this, connect(&main_window, &GMainWindow::WebBrowserExtractOfflineRomFS, this,
&QtWebBrowser::MainWindowExtractOfflineRomFS, Qt::QueuedConnection); &QtWebBrowser::MainWindowExtractOfflineRomFS, Qt::QueuedConnection);
connect(&main_window, &GMainWindow::WebBrowserClosed, this, connect(&main_window, &GMainWindow::WebBrowserClosed, this,
@ -401,6 +403,11 @@ QtWebBrowser::QtWebBrowser(GMainWindow& main_window) {
QtWebBrowser::~QtWebBrowser() = default; QtWebBrowser::~QtWebBrowser() = default;
void QtWebBrowser::Close() const {
callback = {};
emit MainWindowRequestExit();
}
void QtWebBrowser::OpenLocalWebPage(const std::string& local_url, void QtWebBrowser::OpenLocalWebPage(const std::string& local_url,
ExtractROMFSCallback extract_romfs_callback_, ExtractROMFSCallback extract_romfs_callback_,
OpenWebPageCallback callback_) const { OpenWebPageCallback callback_) const {
@ -436,5 +443,7 @@ void QtWebBrowser::MainWindowExtractOfflineRomFS() {
void QtWebBrowser::MainWindowWebBrowserClosed(Service::AM::Applets::WebExitReason exit_reason, void QtWebBrowser::MainWindowWebBrowserClosed(Service::AM::Applets::WebExitReason exit_reason,
std::string last_url) { std::string last_url) {
if (callback) {
callback(exit_reason, last_url); callback(exit_reason, last_url);
}
} }

View file

@ -196,6 +196,7 @@ public:
explicit QtWebBrowser(GMainWindow& parent); explicit QtWebBrowser(GMainWindow& parent);
~QtWebBrowser() override; ~QtWebBrowser() override;
void Close() const override;
void OpenLocalWebPage(const std::string& local_url, void OpenLocalWebPage(const std::string& local_url,
ExtractROMFSCallback extract_romfs_callback_, ExtractROMFSCallback extract_romfs_callback_,
OpenWebPageCallback callback_) const override; OpenWebPageCallback callback_) const override;
@ -206,6 +207,7 @@ public:
signals: signals:
void MainWindowOpenWebPage(const std::string& main_url, const std::string& additional_args, void MainWindowOpenWebPage(const std::string& main_url, const std::string& additional_args,
bool is_local) const; bool is_local) const;
void MainWindowRequestExit() const;
private: private:
void MainWindowExtractOfflineRomFS(); void MainWindowExtractOfflineRomFS();

View file

@ -596,27 +596,45 @@ void GMainWindow::RegisterMetaTypes() {
void GMainWindow::AmiiboSettingsShowDialog(const Core::Frontend::CabinetParameters& parameters, void GMainWindow::AmiiboSettingsShowDialog(const Core::Frontend::CabinetParameters& parameters,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device) { std::shared_ptr<Service::NFP::NfpDevice> nfp_device) {
QtAmiiboSettingsDialog dialog(this, parameters, input_subsystem.get(), nfp_device); cabinet_applet =
new QtAmiiboSettingsDialog(this, parameters, input_subsystem.get(), nfp_device);
SCOPE_EXIT({
cabinet_applet->deleteLater();
cabinet_applet = nullptr;
});
dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | cabinet_applet->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint |
Qt::WindowTitleHint | Qt::WindowSystemMenuHint); Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
dialog.setWindowModality(Qt::WindowModal); cabinet_applet->setWindowModality(Qt::WindowModal);
if (dialog.exec() == QDialog::Rejected) {
if (cabinet_applet->exec() == QDialog::Rejected) {
emit AmiiboSettingsFinished(false, {}); emit AmiiboSettingsFinished(false, {});
return; return;
} }
emit AmiiboSettingsFinished(true, dialog.GetName()); emit AmiiboSettingsFinished(true, cabinet_applet->GetName());
}
void GMainWindow::AmiiboSettingsRequestExit() {
if (cabinet_applet) {
cabinet_applet->reject();
}
} }
void GMainWindow::ControllerSelectorReconfigureControllers( void GMainWindow::ControllerSelectorReconfigureControllers(
const Core::Frontend::ControllerParameters& parameters) { const Core::Frontend::ControllerParameters& parameters) {
QtControllerSelectorDialog dialog(this, parameters, input_subsystem.get(), *system); controller_applet =
new QtControllerSelectorDialog(this, parameters, input_subsystem.get(), *system);
SCOPE_EXIT({
controller_applet->deleteLater();
controller_applet = nullptr;
});
dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | controller_applet->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint |
Qt::WindowTitleHint | Qt::WindowSystemMenuHint); Qt::WindowStaysOnTopHint | Qt::WindowTitleHint |
dialog.setWindowModality(Qt::WindowModal); Qt::WindowSystemMenuHint);
dialog.exec(); controller_applet->setWindowModality(Qt::WindowModal);
controller_applet->exec();
emit ControllerSelectorReconfigureFinished(); emit ControllerSelectorReconfigureFinished();
@ -627,19 +645,30 @@ void GMainWindow::ControllerSelectorReconfigureControllers(
UpdateStatusButtons(); UpdateStatusButtons();
} }
void GMainWindow::ControllerSelectorRequestExit() {
if (controller_applet) {
controller_applet->reject();
}
}
void GMainWindow::ProfileSelectorSelectProfile() { void GMainWindow::ProfileSelectorSelectProfile() {
QtProfileSelectionDialog dialog(system->HIDCore(), this); profile_select_applet = new QtProfileSelectionDialog(system->HIDCore(), this);
dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | SCOPE_EXIT({
Qt::WindowTitleHint | Qt::WindowSystemMenuHint | profile_select_applet->deleteLater();
Qt::WindowCloseButtonHint); profile_select_applet = nullptr;
dialog.setWindowModality(Qt::WindowModal); });
if (dialog.exec() == QDialog::Rejected) {
profile_select_applet->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint |
Qt::WindowStaysOnTopHint | Qt::WindowTitleHint |
Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
profile_select_applet->setWindowModality(Qt::WindowModal);
if (profile_select_applet->exec() == QDialog::Rejected) {
emit ProfileSelectorFinishedSelection(std::nullopt); emit ProfileSelectorFinishedSelection(std::nullopt);
return; return;
} }
const Service::Account::ProfileManager manager; const Service::Account::ProfileManager manager;
const auto uuid = manager.GetUser(static_cast<std::size_t>(dialog.GetIndex())); const auto uuid = manager.GetUser(static_cast<std::size_t>(profile_select_applet->GetIndex()));
if (!uuid.has_value()) { if (!uuid.has_value()) {
emit ProfileSelectorFinishedSelection(std::nullopt); emit ProfileSelectorFinishedSelection(std::nullopt);
return; return;
@ -648,6 +677,12 @@ void GMainWindow::ProfileSelectorSelectProfile() {
emit ProfileSelectorFinishedSelection(uuid); emit ProfileSelectorFinishedSelection(uuid);
} }
void GMainWindow::ProfileSelectorRequestExit() {
if (profile_select_applet) {
profile_select_applet->reject();
}
}
void GMainWindow::SoftwareKeyboardInitialize( void GMainWindow::SoftwareKeyboardInitialize(
bool is_inline, Core::Frontend::KeyboardInitializeParameters initialize_parameters) { bool is_inline, Core::Frontend::KeyboardInitializeParameters initialize_parameters) {
if (software_keyboard) { if (software_keyboard) {
@ -772,7 +807,7 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
return; return;
} }
QtNXWebEngineView web_browser_view(this, *system, input_subsystem.get()); web_applet = new QtNXWebEngineView(this, *system, input_subsystem.get());
ui->action_Pause->setEnabled(false); ui->action_Pause->setEnabled(false);
ui->action_Restart->setEnabled(false); ui->action_Restart->setEnabled(false);
@ -799,9 +834,9 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
loading_progress.setValue(1); loading_progress.setValue(1);
if (is_local) { if (is_local) {
web_browser_view.LoadLocalWebPage(main_url, additional_args); web_applet->LoadLocalWebPage(main_url, additional_args);
} else { } else {
web_browser_view.LoadExternalWebPage(main_url, additional_args); web_applet->LoadExternalWebPage(main_url, additional_args);
} }
if (render_window->IsLoadingComplete()) { if (render_window->IsLoadingComplete()) {
@ -810,15 +845,15 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
const auto& layout = render_window->GetFramebufferLayout(); const auto& layout = render_window->GetFramebufferLayout();
const auto scale_ratio = devicePixelRatioF(); const auto scale_ratio = devicePixelRatioF();
web_browser_view.resize(layout.screen.GetWidth() / scale_ratio, web_applet->resize(layout.screen.GetWidth() / scale_ratio,
layout.screen.GetHeight() / scale_ratio); layout.screen.GetHeight() / scale_ratio);
web_browser_view.move(layout.screen.left / scale_ratio, web_applet->move(layout.screen.left / scale_ratio,
(layout.screen.top / scale_ratio) + menuBar()->height()); (layout.screen.top / scale_ratio) + menuBar()->height());
web_browser_view.setZoomFactor(static_cast<qreal>(layout.screen.GetWidth() / scale_ratio) / web_applet->setZoomFactor(static_cast<qreal>(layout.screen.GetWidth() / scale_ratio) /
static_cast<qreal>(Layout::ScreenUndocked::Width)); static_cast<qreal>(Layout::ScreenUndocked::Width));
web_browser_view.setFocus(); web_applet->setFocus();
web_browser_view.show(); web_applet->show();
loading_progress.setValue(2); loading_progress.setValue(2);
@ -831,7 +866,7 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
// TODO (Morph): Remove this // TODO (Morph): Remove this
QAction* exit_action = new QAction(tr("Disable Web Applet"), this); QAction* exit_action = new QAction(tr("Disable Web Applet"), this);
connect(exit_action, &QAction::triggered, this, [this, &web_browser_view] { connect(exit_action, &QAction::triggered, this, [this] {
const auto result = QMessageBox::warning( const auto result = QMessageBox::warning(
this, tr("Disable Web Applet"), this, tr("Disable Web Applet"),
tr("Disabling the web applet can lead to undefined behavior and should only be used " tr("Disabling the web applet can lead to undefined behavior and should only be used "
@ -840,21 +875,21 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
if (result == QMessageBox::Yes) { if (result == QMessageBox::Yes) {
UISettings::values.disable_web_applet = true; UISettings::values.disable_web_applet = true;
web_browser_view.SetFinished(true); web_applet->SetFinished(true);
} }
}); });
ui->menubar->addAction(exit_action); ui->menubar->addAction(exit_action);
while (!web_browser_view.IsFinished()) { while (!web_applet->IsFinished()) {
QCoreApplication::processEvents(); QCoreApplication::processEvents();
if (!exit_check) { if (!exit_check) {
web_browser_view.page()->runJavaScript( web_applet->page()->runJavaScript(
QStringLiteral("end_applet;"), [&](const QVariant& variant) { QStringLiteral("end_applet;"), [&](const QVariant& variant) {
exit_check = false; exit_check = false;
if (variant.toBool()) { if (variant.toBool()) {
web_browser_view.SetFinished(true); web_applet->SetFinished(true);
web_browser_view.SetExitReason( web_applet->SetExitReason(
Service::AM::Applets::WebExitReason::EndButtonPressed); Service::AM::Applets::WebExitReason::EndButtonPressed);
} }
}); });
@ -862,22 +897,22 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
exit_check = true; exit_check = true;
} }
if (web_browser_view.GetCurrentURL().contains(QStringLiteral("localhost"))) { if (web_applet->GetCurrentURL().contains(QStringLiteral("localhost"))) {
if (!web_browser_view.IsFinished()) { if (!web_applet->IsFinished()) {
web_browser_view.SetFinished(true); web_applet->SetFinished(true);
web_browser_view.SetExitReason(Service::AM::Applets::WebExitReason::CallbackURL); web_applet->SetExitReason(Service::AM::Applets::WebExitReason::CallbackURL);
} }
web_browser_view.SetLastURL(web_browser_view.GetCurrentURL().toStdString()); web_applet->SetLastURL(web_applet->GetCurrentURL().toStdString());
} }
std::this_thread::sleep_for(std::chrono::milliseconds(1)); std::this_thread::sleep_for(std::chrono::milliseconds(1));
} }
const auto exit_reason = web_browser_view.GetExitReason(); const auto exit_reason = web_applet->GetExitReason();
const auto last_url = web_browser_view.GetLastURL(); const auto last_url = web_applet->GetLastURL();
web_browser_view.hide(); web_applet->hide();
render_window->setFocus(); render_window->setFocus();
@ -903,6 +938,15 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
#endif #endif
} }
void GMainWindow::WebBrowserRequestExit() {
#ifdef YUZU_USE_QT_WEB_ENGINE
if (web_applet) {
web_applet->SetExitReason(Service::AM::Applets::WebExitReason::ExitRequested);
web_applet->SetFinished(true);
}
#endif
}
void GMainWindow::InitializeWidgets() { void GMainWindow::InitializeWidgets() {
#ifdef YUZU_ENABLE_COMPATIBILITY_REPORTING #ifdef YUZU_ENABLE_COMPATIBILITY_REPORTING
ui->action_Report_Compatibility->setVisible(true); ui->action_Report_Compatibility->setVisible(true);
@ -3089,13 +3133,23 @@ void GMainWindow::OnSaveConfig() {
} }
void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_text) { void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_text) {
OverlayDialog dialog(render_window, *system, error_code, error_text, QString{}, tr("OK"), error_applet = new OverlayDialog(render_window, *system, error_code, error_text, QString{},
Qt::AlignLeft | Qt::AlignVCenter); tr("OK"), Qt::AlignLeft | Qt::AlignVCenter);
dialog.exec(); SCOPE_EXIT({
error_applet->deleteLater();
error_applet = nullptr;
});
error_applet->exec();
emit ErrorDisplayFinished(); emit ErrorDisplayFinished();
} }
void GMainWindow::ErrorDisplayRequestExit() {
if (error_applet) {
error_applet->reject();
}
}
void GMainWindow::OnMenuReportCompatibility() { void GMainWindow::OnMenuReportCompatibility() {
#if defined(ARCHITECTURE_x86_64) && !defined(__APPLE__) #if defined(ARCHITECTURE_x86_64) && !defined(__APPLE__)
const auto& caps = Common::GetCPUCaps(); const auto& caps = Common::GetCPUCaps();

View file

@ -47,7 +47,11 @@ enum class DumpRomFSTarget;
enum class InstalledEntryType; enum class InstalledEntryType;
class GameListPlaceholder; class GameListPlaceholder;
class QtAmiiboSettingsDialog;
class QtControllerSelectorDialog;
class QtProfileSelectionDialog;
class QtSoftwareKeyboardDialog; class QtSoftwareKeyboardDialog;
class QtNXWebEngineView;
enum class StartGameType { enum class StartGameType {
Normal, // Can use custom configuration Normal, // Can use custom configuration
@ -184,8 +188,10 @@ public slots:
void OnSaveConfig(); void OnSaveConfig();
void AmiiboSettingsShowDialog(const Core::Frontend::CabinetParameters& parameters, void AmiiboSettingsShowDialog(const Core::Frontend::CabinetParameters& parameters,
std::shared_ptr<Service::NFP::NfpDevice> nfp_device); std::shared_ptr<Service::NFP::NfpDevice> nfp_device);
void AmiiboSettingsRequestExit();
void ControllerSelectorReconfigureControllers( void ControllerSelectorReconfigureControllers(
const Core::Frontend::ControllerParameters& parameters); const Core::Frontend::ControllerParameters& parameters);
void ControllerSelectorRequestExit();
void SoftwareKeyboardInitialize( void SoftwareKeyboardInitialize(
bool is_inline, Core::Frontend::KeyboardInitializeParameters initialize_parameters); bool is_inline, Core::Frontend::KeyboardInitializeParameters initialize_parameters);
void SoftwareKeyboardShowNormal(); void SoftwareKeyboardShowNormal();
@ -196,9 +202,12 @@ public slots:
void SoftwareKeyboardInlineTextChanged(Core::Frontend::InlineTextParameters text_parameters); void SoftwareKeyboardInlineTextChanged(Core::Frontend::InlineTextParameters text_parameters);
void SoftwareKeyboardExit(); void SoftwareKeyboardExit();
void ErrorDisplayDisplayError(QString error_code, QString error_text); void ErrorDisplayDisplayError(QString error_code, QString error_text);
void ErrorDisplayRequestExit();
void ProfileSelectorSelectProfile(); void ProfileSelectorSelectProfile();
void ProfileSelectorRequestExit();
void WebBrowserOpenWebPage(const std::string& main_url, const std::string& additional_args, void WebBrowserOpenWebPage(const std::string& main_url, const std::string& additional_args,
bool is_local); bool is_local);
void WebBrowserRequestExit();
void OnAppFocusStateChanged(Qt::ApplicationState state); void OnAppFocusStateChanged(Qt::ApplicationState state);
void OnTasStateChanged(); void OnTasStateChanged();
@ -466,7 +475,12 @@ private:
QString last_filename_booted; QString last_filename_booted;
// Applets // Applets
QtAmiiboSettingsDialog* cabinet_applet = nullptr;
QtControllerSelectorDialog* controller_applet = nullptr;
QtProfileSelectionDialog* profile_select_applet = nullptr;
QDialog* error_applet = nullptr;
QtSoftwareKeyboardDialog* software_keyboard = nullptr; QtSoftwareKeyboardDialog* software_keyboard = nullptr;
QtNXWebEngineView* web_applet = nullptr;
// True if amiibo file select is visible // True if amiibo file select is visible
bool is_amiibo_file_select_active{}; bool is_amiibo_file_select_active{};