Qt: Drop Qt 6.1 workaround in Host::GetTopLevelWindowInfo()

This commit is contained in:
Stenzek 2023-11-27 00:15:55 +10:00
parent c40cc4ef43
commit 5a0a6ebe06
No known key found for this signature in database
3 changed files with 11 additions and 10 deletions

View File

@ -2645,11 +2645,14 @@ void MainWindow::checkForSettingChanges()
updateWindowState(); updateWindowState();
} }
void MainWindow::getWindowInfo(WindowInfo* wi) std::optional<WindowInfo> MainWindow::getWindowInfo()
{ {
std::optional<WindowInfo> opt_wi(QtUtils::GetWindowInfoForWidget(this)); if (!m_display_widget || isRenderingToMain())
if (opt_wi.has_value()) return QtUtils::GetWindowInfoForWidget(this);
*wi = opt_wi.value(); else if (QWidget* widget = getDisplayContainer())
return QtUtils::GetWindowInfoForWidget(widget);
else
return std::nullopt;
} }
void MainWindow::onCheckForUpdatesActionTriggered() void MainWindow::onCheckForUpdatesActionTriggered()

View File

@ -104,7 +104,7 @@ public Q_SLOTS:
bool requestShutdown(bool allow_confirm = true, bool allow_save_to_state = true, bool save_state = true); bool requestShutdown(bool allow_confirm = true, bool allow_save_to_state = true, bool save_state = true);
void requestExit(bool allow_confirm = true); void requestExit(bool allow_confirm = true);
void checkForSettingChanges(); void checkForSettingChanges();
void getWindowInfo(WindowInfo* wi); std::optional<WindowInfo> getWindowInfo();
void checkForUpdates(bool display_message); void checkForUpdates(bool display_message);

View File

@ -118,6 +118,7 @@ EmuThread::~EmuThread() = default;
void QtHost::RegisterTypes() void QtHost::RegisterTypes()
{ {
// Register any standard types we need elsewhere // Register any standard types we need elsewhere
qRegisterMetaType<std::optional<WindowInfo>>("std::optional<WindowInfo>()");
qRegisterMetaType<std::optional<bool>>(); qRegisterMetaType<std::optional<bool>>();
qRegisterMetaType<std::function<void()>>("std::function<void()>"); qRegisterMetaType<std::function<void()>>("std::function<void()>");
qRegisterMetaType<std::shared_ptr<SystemBootParameters>>(); qRegisterMetaType<std::shared_ptr<SystemBootParameters>>();
@ -1632,11 +1633,8 @@ void Host::RequestExit(bool allow_confirm)
std::optional<WindowInfo> Host::GetTopLevelWindowInfo() std::optional<WindowInfo> Host::GetTopLevelWindowInfo()
{ {
// Normally we'd just feed the std::optional all the way through here. But that won't work because of some bug std::optional<WindowInfo> ret;
// in Qt 6.1, and we can't upgrade that because of raging/abusive Win7 users... to anyone still using that dead QMetaObject::invokeMethod(g_main_window, &MainWindow::getWindowInfo, Qt::BlockingQueuedConnection, &ret);
// OS, this is a passive-aggressive "screw you".
WindowInfo ret;
QMetaObject::invokeMethod(g_main_window, "getWindowInfo", Qt::BlockingQueuedConnection, Q_ARG(WindowInfo*, &ret));
return ret; return ret;
} }