mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-25 04:02:42 +01:00
Qt: Remember last game window position and visibility
- Remembers the last game window geometry and tries to apply it on boot - Remembers the last minimized/maximized/windowed/fullscreen state and tries to apply it on boot - All existing game window settings keep priority - Should work with multi-monitor setups as well - Ignored if the user forced a different screen with cli commands
This commit is contained in:
parent
8bd05871d0
commit
982e09a486
@ -579,6 +579,12 @@ bool gs_frame::get_mouse_lock_state()
|
||||
|
||||
void gs_frame::hide_on_close()
|
||||
{
|
||||
// Make sure not to save the hidden state, which is useless to us.
|
||||
const Visibility current_visibility = visibility();
|
||||
m_gui_settings->SetValue(gui::gs_visibility, current_visibility == Visibility::Hidden ? Visibility::AutomaticVisibility : current_visibility);
|
||||
m_gui_settings->SetValue(gui::gs_geometry, geometry());
|
||||
m_gui_settings->sync();
|
||||
|
||||
if (!g_progr.load())
|
||||
{
|
||||
// Hide the dialog before stopping if no progress bar is being shown.
|
||||
@ -630,10 +636,19 @@ void gs_frame::show()
|
||||
Emu.CallFromMainThread([this]()
|
||||
{
|
||||
QWindow::show();
|
||||
|
||||
if (g_cfg.misc.start_fullscreen || m_start_games_fullscreen)
|
||||
{
|
||||
setVisibility(FullScreen);
|
||||
}
|
||||
else if (const QVariant var = m_gui_settings->GetValue(gui::gs_visibility); var.canConvert<Visibility>())
|
||||
{
|
||||
// Restore saved visibility from last time. Make sure not to hide the window, or the user can't access it anymore.
|
||||
if (const Visibility visibility = var.value<Visibility>(); visibility != Visibility::Hidden)
|
||||
{
|
||||
setVisibility(visibility);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// if we do this before show, the QWinTaskbarProgress won't show
|
||||
|
@ -323,7 +323,9 @@ std::unique_ptr<gs_frame> gui_application::get_gs_frame()
|
||||
|
||||
auto [w, h] = ::at32(g_video_out_resolution_map, g_cfg.video.resolution);
|
||||
|
||||
if (m_gui_settings->GetValue(gui::gs_resize).toBool())
|
||||
const bool resize_game_window = m_gui_settings->GetValue(gui::gs_resize).toBool();
|
||||
|
||||
if (resize_game_window)
|
||||
{
|
||||
if (m_gui_settings->GetValue(gui::gs_resize_manual).toBool())
|
||||
{
|
||||
@ -343,11 +345,12 @@ std::unique_ptr<gs_frame> gui_application::get_gs_frame()
|
||||
|
||||
// Use screen index set by CLI argument
|
||||
int screen_index = m_game_screen_index;
|
||||
const int last_screen_index = m_gui_settings->GetValue(gui::gs_screen).toInt();
|
||||
|
||||
// In no-gui mode: use last used screen if no CLI index was set
|
||||
if (screen_index < 0 && !m_main_window)
|
||||
// Use last used screen if no CLI index was set
|
||||
if (screen_index < 0)
|
||||
{
|
||||
screen_index = m_gui_settings->GetValue(gui::gs_screen).toInt();
|
||||
screen_index = last_screen_index;
|
||||
}
|
||||
|
||||
// Try to find the specified screen
|
||||
@ -378,7 +381,21 @@ std::unique_ptr<gs_frame> gui_application::get_gs_frame()
|
||||
base_geometry = m_main_window ? m_main_window->frameGeometry() : primaryScreen()->geometry();
|
||||
}
|
||||
|
||||
const QRect frame_geometry = gui::utils::create_centered_window_geometry(screen, base_geometry, w, h);
|
||||
// Use saved geometry if possible. Ignore this if the last used screen is different than the requested screen.
|
||||
QRect frame_geometry = screen_index != last_screen_index ? QRect{} : m_gui_settings->GetValue(gui::gs_geometry).value<QRect>();
|
||||
|
||||
if (frame_geometry.isNull() || frame_geometry.isEmpty())
|
||||
{
|
||||
// Center above main window or inside screen if the saved geometry is invalid
|
||||
frame_geometry = gui::utils::create_centered_window_geometry(screen, base_geometry, w, h);
|
||||
}
|
||||
else if (resize_game_window)
|
||||
{
|
||||
// Apply size override to our saved geometry if needed
|
||||
frame_geometry.setSize(QSize(w, h));
|
||||
}
|
||||
|
||||
// Load AppIcon
|
||||
const QIcon app_icon = m_main_window ? m_main_window->GetAppIcon() : gui::utils::get_app_icon_from_path(Emu.GetBoot(), Emu.GetTitleID());
|
||||
|
||||
gs_frame* frame = nullptr;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <QSize>
|
||||
#include <QColor>
|
||||
#include <QMessageBox>
|
||||
#include <QWindow>
|
||||
|
||||
namespace gui
|
||||
{
|
||||
@ -226,6 +227,8 @@ namespace gui
|
||||
const gui_save gs_height = gui_save(gs_frame, "height", 720);
|
||||
const gui_save gs_hideMouseIdle = gui_save(gs_frame, "hideMouseOnIdle", false);
|
||||
const gui_save gs_hideMouseIdleTime = gui_save(gs_frame, "hideMouseOnIdleTime", 2000);
|
||||
const gui_save gs_geometry = gui_save(gs_frame, "geometry", QRect());
|
||||
const gui_save gs_visibility = gui_save(gs_frame, "visibility", QWindow::Visibility::AutomaticVisibility);
|
||||
|
||||
const gui_save tr_icon_color = gui_save(trophy, "icon_color", gl_icon_color);
|
||||
const gui_save tr_icon_height = gui_save(trophy, "icon_height", 75);
|
||||
|
Loading…
Reference in New Issue
Block a user