mirror of
https://github.com/stenzek/duckstation.git
synced 2026-04-11 00:23:01 +00:00
Qt: Use metaobject class name for saving/restoration
Less chance for error.
This commit is contained in:
@@ -180,13 +180,13 @@ bool MiniHost::EarlyProcessStartup()
|
||||
// Thanks, and I hope you understand.
|
||||
//
|
||||
|
||||
const char* message = ICON_EMOJI_WARNING "WARNING! You are not using an official release! " ICON_EMOJI_WARNING "\n\n"
|
||||
"DuckStation is licensed under the terms of CC-BY-NC-ND-4.0,\n"
|
||||
"which does not allow modified builds to be distributed.\n\n"
|
||||
"This build is NOT OFFICIAL and may be broken and/or malicious.\n\n"
|
||||
"You should download an official build from https://www.duckstation.org/.";
|
||||
const char* title = "WARNING! You are not using an official release!";
|
||||
const char* message = "DuckStation is licensed under the terms of CC-BY-NC-ND-4.0,\n"
|
||||
"which does not allow modified builds to be distributed.\n\n"
|
||||
"This build is NOT OFFICIAL and may be broken and/or malicious.\n\n"
|
||||
"You should download an official build from https://www.duckstation.org/.";
|
||||
|
||||
Host::AddKeyedOSDWarning("OfficialReleaseWarning", message, Host::OSD_CRITICAL_ERROR_DURATION);
|
||||
Host::AddIconOSDMessage(OSDMessageType::Error, "OfficialReleaseWarning", ICON_EMOJI_WARNING, title, message);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
@@ -1483,8 +1483,17 @@ void Host::ConfirmMessageAsync(std::string_view title, std::string_view message,
|
||||
FullscreenUI::Initialize();
|
||||
|
||||
// Need to reset run idle state _again_ after displaying.
|
||||
auto final_callback = [callback = std::move(callback)](bool result) {
|
||||
auto final_callback = [callback = std::move(callback), needs_pause](bool result) {
|
||||
FullscreenUI::UpdateRunIdleState();
|
||||
|
||||
if (needs_pause)
|
||||
{
|
||||
Host::RunOnCPUThread([]() {
|
||||
if (System::IsValid())
|
||||
System::PauseSystem(false);
|
||||
});
|
||||
}
|
||||
|
||||
callback(result);
|
||||
};
|
||||
|
||||
|
||||
@@ -498,7 +498,7 @@ void ControllerSettingsWindow::createWidgets()
|
||||
void ControllerSettingsWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
if (isEditingGlobalSettings())
|
||||
QtUtils::SaveWindowGeometry("ControllerSettingsWindow", this);
|
||||
QtUtils::SaveWindowGeometry(this);
|
||||
|
||||
QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ CoverDownloadWindow::~CoverDownloadWindow()
|
||||
|
||||
void CoverDownloadWindow::closeEvent(QCloseEvent* ev)
|
||||
{
|
||||
QtUtils::SaveWindowGeometry("CoverDownloadWindow", this);
|
||||
QtUtils::SaveWindowGeometry(this);
|
||||
QWidget::closeEvent(ev);
|
||||
cancelThread();
|
||||
emit closed();
|
||||
|
||||
@@ -434,7 +434,7 @@ void DebuggerWindow::onMemorySearchStringChanged(const QString&)
|
||||
|
||||
void DebuggerWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
QtUtils::SaveWindowGeometry("DebuggerWindow", this);
|
||||
QtUtils::SaveWindowGeometry(this);
|
||||
g_emu_thread->disconnect(this);
|
||||
Host::RunOnCPUThread(&CPU::ClearBreakpoints);
|
||||
QMainWindow::closeEvent(event);
|
||||
|
||||
@@ -199,7 +199,7 @@ void MainWindow::initialize()
|
||||
|
||||
switchToGameListView();
|
||||
|
||||
QtUtils::RestoreWindowGeometry("MainWindow", this);
|
||||
QtUtils::RestoreWindowGeometry(this);
|
||||
|
||||
#ifdef _WIN32
|
||||
registerForDeviceNotifications();
|
||||
@@ -2887,7 +2887,7 @@ void MainWindow::closeEvent(QCloseEvent* event)
|
||||
// When recreating, g_main_window will be null at this point.
|
||||
if (!QtHost::IsSystemValidOrStarting() || !g_main_window)
|
||||
{
|
||||
QtUtils::SaveWindowGeometry("MainWindow", this);
|
||||
QtUtils::SaveWindowGeometry(this);
|
||||
|
||||
// surfaceless for language change
|
||||
if (s_fullscreen_ui_started && g_main_window)
|
||||
|
||||
@@ -455,7 +455,7 @@ void MemoryEditorWindow::updateUIEnabled()
|
||||
|
||||
void MemoryEditorWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
QtUtils::SaveWindowGeometry("MemoryEditorWindow", this);
|
||||
QtUtils::SaveWindowGeometry(this);
|
||||
QWidget::closeEvent(event);
|
||||
emit closed();
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ void MemoryScannerWindow::enableUi(bool enabled)
|
||||
|
||||
void MemoryScannerWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
QtUtils::SaveWindowGeometry("MemoryScannerWindow", this);
|
||||
QtUtils::SaveWindowGeometry(this);
|
||||
QWidget::closeEvent(event);
|
||||
emit closed();
|
||||
}
|
||||
|
||||
@@ -825,7 +825,7 @@ void EmuThread::exitFullscreenUI()
|
||||
{
|
||||
Host::RunOnUIThread([]() {
|
||||
// Restore the geometry of the main window, since the display window may have been moved.
|
||||
QtUtils::RestoreWindowGeometry("MainWindow", g_main_window);
|
||||
QtUtils::RestoreWindowGeometry(g_main_window);
|
||||
|
||||
// if we were in nogui mode, the game list won't have been populated yet. do it now.
|
||||
g_main_window->refreshGameList(false);
|
||||
|
||||
@@ -93,8 +93,9 @@ void QtUtils::ShowOrRaiseWindow(QWidget* window, const QWidget* parent_window, b
|
||||
{
|
||||
bool restored = false;
|
||||
if (restore_geometry)
|
||||
restored = RestoreWindowGeometry(window->metaObject()->className(), window);
|
||||
restored = RestoreWindowGeometry(window);
|
||||
|
||||
// NOTE: Must be before centering the window, otherwise the size may not be correct.
|
||||
window->show();
|
||||
|
||||
if (!restored && parent_window)
|
||||
@@ -594,6 +595,11 @@ std::optional<WindowInfo> QtUtils::GetWindowInfoForWidget(QWidget* widget, Rende
|
||||
return wi;
|
||||
}
|
||||
|
||||
void QtUtils::SaveWindowGeometry(QWidget* widget, bool auto_commit_changes /* = true */)
|
||||
{
|
||||
SaveWindowGeometry(widget->metaObject()->className(), widget, auto_commit_changes);
|
||||
}
|
||||
|
||||
void QtUtils::SaveWindowGeometry(std::string_view window_name, QWidget* widget, bool auto_commit_changes)
|
||||
{
|
||||
// don't touch minimized/fullscreen windows
|
||||
@@ -652,6 +658,11 @@ void QtUtils::SaveWindowGeometry(std::string_view window_name, QWidget* widget,
|
||||
Host::CommitBaseSettingChanges();
|
||||
}
|
||||
|
||||
bool QtUtils::RestoreWindowGeometry(QWidget* widget)
|
||||
{
|
||||
return RestoreWindowGeometry(widget->metaObject()->className(), widget);
|
||||
}
|
||||
|
||||
bool QtUtils::RestoreWindowGeometry(std::string_view window_name, QWidget* widget)
|
||||
{
|
||||
const auto lock = Host::GetSettingsLock();
|
||||
|
||||
@@ -169,9 +169,11 @@ QSize GetPixelSizeForWidget(const QWidget* widget, qreal device_pixel_ratio = -1
|
||||
std::optional<WindowInfo> GetWindowInfoForWidget(QWidget* widget, RenderAPI render_api, Error* error = nullptr);
|
||||
|
||||
/// Saves a window's geometry to configuration. Returns false if the configuration was changed.
|
||||
void SaveWindowGeometry(QWidget* widget, bool auto_commit_changes = true);
|
||||
void SaveWindowGeometry(std::string_view window_name, QWidget* widget, bool auto_commit_changes = true);
|
||||
|
||||
/// Restores a window's geometry from configuration. Returns false if it was not found in the configuration.
|
||||
bool RestoreWindowGeometry(QWidget* widget);
|
||||
bool RestoreWindowGeometry(std::string_view window_name, QWidget* widget);
|
||||
|
||||
/// Positions a window in the center of its parent or the screen.
|
||||
|
||||
@@ -80,7 +80,7 @@ SettingsWindow::~SettingsWindow()
|
||||
void SettingsWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
if (!isPerGameSettings())
|
||||
QtUtils::SaveWindowGeometry("SettingsWindow", this);
|
||||
QtUtils::SaveWindowGeometry(this);
|
||||
|
||||
QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user