2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

main: Add the ability to disable the web applet

This should only be used for Super Mario 3D All-Stars. This is a temporary solution until it can be implemented properly.
This commit is contained in:
Morph 2020-11-30 10:34:18 -05:00
parent 8b95bf041d
commit 2ddd83cdfe
2 changed files with 27 additions and 0 deletions

View file

@ -370,6 +370,12 @@ void GMainWindow::WebBrowserOpenLocalWebPage(std::string_view main_url,
std::string_view additional_args) {
#ifdef YUZU_USE_QT_WEB_ENGINE
if (disable_web_applet) {
emit WebBrowserClosed(Service::AM::Applets::WebExitReason::WindowClosed,
"http://localhost");
return;
}
QtNXWebEngineView web_browser_view(this, Core::System::GetInstance());
ui.action_Pause->setEnabled(false);
@ -418,6 +424,22 @@ void GMainWindow::WebBrowserOpenLocalWebPage(std::string_view main_url,
bool exit_check = false;
// TODO (Morph): Remove this
QAction* exit_action = new QAction(tr("Disable Web Applet"), this);
connect(exit_action, &QAction::triggered, this, [this, &web_browser_view] {
const auto result = QMessageBox::warning(
this, tr("Disable Web Applet"),
tr("Disabling the web applet will cause it to not be shown again for the rest of the "
"emulated session. This can lead to undefined behavior and should only be used with "
"Super Mario 3D All-Stars. Are you sure you want to disable the web applet?"),
QMessageBox::Yes | QMessageBox::No);
if (result == QMessageBox::Yes) {
disable_web_applet = true;
web_browser_view.SetFinished(true);
}
});
ui.menubar->addAction(exit_action);
while (!web_browser_view.IsFinished()) {
QCoreApplication::processEvents();
@ -462,6 +484,8 @@ void GMainWindow::WebBrowserOpenLocalWebPage(std::string_view main_url,
ui.action_Restart->setEnabled(true);
ui.action_Stop->setEnabled(true);
ui.menubar->removeAction(exit_action);
QCoreApplication::processEvents();
emit WebBrowserClosed(exit_reason, last_url);

View file

@ -325,6 +325,9 @@ private:
// Last game booted, used for multi-process apps
QString last_filename_booted;
// Disables the web applet for the rest of the emulated session
bool disable_web_applet{};
protected:
void dropEvent(QDropEvent* event) override;
void dragEnterEvent(QDragEnterEvent* event) override;