From 7e0596558a3dd4dd21484f2c205dd7054577a25e Mon Sep 17 00:00:00 2001 From: ts-korhonen Date: Sat, 12 Feb 2022 17:31:28 +0200 Subject: [PATCH 1/2] qt: Unify VM manager requested shutdown behavior with Win32. Add implementation for -N commandline switch. Save nvr on close. --- src/qt/qt_main.cpp | 6 +++++- src/qt/qt_mainwindow.cpp | 5 ++++- src/qt/qt_winmanagerfilter.cpp | 19 ++++--------------- src/qt/qt_winmanagerfilter.hpp | 17 ++--------------- 4 files changed, 15 insertions(+), 32 deletions(-) diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index c05ee3980..a3074bc2d 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -199,7 +199,11 @@ int main(int argc, char* argv[]) { QObject::connect(wmfilter.get(), &WindowsManagerFilter::showsettings, main_window, &MainWindow::showSettings); QObject::connect(wmfilter.get(), &WindowsManagerFilter::pause, main_window, &MainWindow::togglePause); QObject::connect(wmfilter.get(), &WindowsManagerFilter::reset, main_window, &MainWindow::hardReset); - QObject::connect(wmfilter.get(), &WindowsManagerFilter::shutdown, [](){ plat_power_off(); }); + QObject::connect(wmfilter.get(), &WindowsManagerFilter::request_shutdown, main_window, &MainWindow::close); + QObject::connect(wmfilter.get(), &WindowsManagerFilter::force_shutdown, [](){ + do_stop(); + emit main_window->close(); + }); QObject::connect(wmfilter.get(), &WindowsManagerFilter::ctrlaltdel, [](){ pc_send_cad(); }); QObject::connect(wmfilter.get(), &WindowsManagerFilter::dialogstatus, [main_hwnd](bool open){ PostMessage((HWND)(uintptr_t)source_hwnd, WM_SENDDLGSTATUS, (WPARAM)(open ? 1 : 0), (LPARAM)main_hwnd); diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 1b4dfe08d..dbcc48e96 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -40,6 +40,8 @@ extern "C" { #include <86box/vid_ega.h> #include <86box/version.h> + extern int qt_nvr_save(void); + #ifdef MTR_ENABLED #include #endif @@ -419,7 +421,7 @@ MainWindow::MainWindow(QWidget *parent) : } void MainWindow::closeEvent(QCloseEvent *event) { - if (confirm_exit && cpu_thread_run) + if (confirm_exit && confirm_exit_cmdl && cpu_thread_run) { QMessageBox questionbox(QMessageBox::Icon::Question, "86Box", tr("Are you sure you want to exit 86Box?"), QMessageBox::Yes | QMessageBox::No, this); QCheckBox *chkbox = new QCheckBox(tr("Don't show this message again")); @@ -444,6 +446,7 @@ void MainWindow::closeEvent(QCloseEvent *event) { window_y = this->geometry().y(); } } + qt_nvr_save(); config_save(); event->accept(); } diff --git a/src/qt/qt_winmanagerfilter.cpp b/src/qt/qt_winmanagerfilter.cpp index cdaa6734e..6eb6d9cd5 100644 --- a/src/qt/qt_winmanagerfilter.cpp +++ b/src/qt/qt_winmanagerfilter.cpp @@ -12,20 +12,6 @@ * Teemu Korhonen * * Copyright 2022 Teemu Korhonen - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "qt_winmanagerfilter.hpp" @@ -51,7 +37,10 @@ bool WindowsManagerFilter::nativeEventFilter(const QByteArray &eventType, void * emit reset(); return true; case WM_SHUTDOWN: - emit shutdown(); + if (msg->wParam == 1) + emit force_shutdown(); + else + emit request_shutdown(); return true; case WM_CTRLALTDEL: emit ctrlaltdel(); diff --git a/src/qt/qt_winmanagerfilter.hpp b/src/qt/qt_winmanagerfilter.hpp index 405d84aed..924011e30 100644 --- a/src/qt/qt_winmanagerfilter.hpp +++ b/src/qt/qt_winmanagerfilter.hpp @@ -12,20 +12,6 @@ * Teemu Korhonen * * Copyright 2022 Teemu Korhonen - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef QT_WINDOWSMANAGERFILTER_HPP @@ -58,7 +44,8 @@ signals: void ctrlaltdel(); void showsettings(); void reset(); - void shutdown(); + void request_shutdown(); + void force_shutdown(); void dialogstatus(bool open); protected: From 764422f2c0f2ed58f28b9c52ffe5fd8389b532e2 Mon Sep 17 00:00:00 2001 From: ts-korhonen Date: Sat, 12 Feb 2022 17:54:39 +0200 Subject: [PATCH 2/2] qt: Set AppUserModelID so 86Box groups with 86BoxManager in task bar --- src/qt/qt_mainwindow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index dbcc48e96..d7c25ebfa 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -67,6 +67,10 @@ extern "C" { #include #include +#ifdef Q_OS_WINDOWS +#include +#endif + #include "qt_settings.hpp" #include "qt_machinestatus.hpp" #include "qt_mediamenu.hpp" @@ -90,6 +94,8 @@ MainWindow::MainWindow(QWidget *parent) : ui(new Ui::MainWindow) { #ifdef Q_OS_WINDOWS + SetCurrentProcessExplicitAppUserModelID(L"86Box.86Box"); + auto font_name = tr("FONT_NAME"); auto font_size = tr("FONT_SIZE"); QApplication::setFont(QFont(font_name, font_size.toInt()));