mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-10-21 15:39:43 +00:00
The `QtUtils::AdjustSizeWithinScreen()` function now centers the widget on their parent window after the widget's size is adjusted. This is required in some desktop environments (generally on Linux systems) to ensure that the just-resized widget remains aligned with its parent window. The creation of the **Cheats Manager** dialog is now deferred to first show, as creating it within the main window's constructor prevents the dialog from knowing the real position of its parent window, which is only properly calculated on first show. For the same reasons, the analytics prompt is now shown only when the application is ready (i.e. when the main window has been shown). | Before | After | | ------ | ----- | | <img width="1920" height="1080" alt="[Dolphin Emulator] Misplaced analytics prompt" title="[Dolphin Emulator] Misplaced analytics prompt" src="https://github.com/user-attachments/assets/c3e43b3b-cf79-4398-b531-7de6068c583e" /> | <img width="1920" height="1080" alt="[Dolphin Emulator] Centered analytics prompt" title="[Dolphin Emulator] Centered analytics prompt" src="https://github.com/user-attachments/assets/a10d06d9-7438-4032-b96c-dfcb48826349" /> | | <img width="1920" height="1080" alt="[Dolphin Emulator] Misplaced Settings dialog" title="[Dolphin Emulator] Misplaced Settings dialog" src="https://github.com/user-attachments/assets/f35b10ee-4f07-48d4-86f9-2537ad5ca7ca" /> | <img width="1920" height="1080" alt="[Dolphin Emulator] Centered Settings dialog" title="[Dolphin Emulator] Centered Settings dialog" src="https://github.com/user-attachments/assets/33e37237-77a4-44f6-a0e2-b709f65b672b" /> | | <img width="1920" height="1080" alt="[Dolphin Emulator] Misplaced Cheats Manager dialog" title="[Dolphin Emulator] Misplaced Cheats Manager dialog" src="https://github.com/user-attachments/assets/1fbd3836-5639-4d5a-b57e-e2e21f21c9db" /> | <img width="1920" height="1080" alt="[Dolphin Emulator] Centered Cheats Manager dialog" title="[Dolphin Emulator] Centered Cheats Manager dialog" src="https://github.com/user-attachments/assets/3f2b1b50-de16-49b7-bac4-c444c6cab0bc" /> |
286 lines
7.4 KiB
C++
286 lines
7.4 KiB
C++
// Copyright 2015 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <QMainWindow>
|
|
#include <QStringList>
|
|
|
|
#include <array>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
|
#include "Common/Config/Config.h"
|
|
#endif // USE_RETRO_ACHIEVEMENTS
|
|
|
|
#include "Core/Boot/Boot.h"
|
|
#include "DolphinQt/FIFO/FIFOPlayerWindow.h"
|
|
|
|
class QMenu;
|
|
class QStackedWidget;
|
|
class QString;
|
|
|
|
class AchievementsWindow;
|
|
class AssemblerWidget;
|
|
class BreakpointWidget;
|
|
struct BootParameters;
|
|
class CheatsManager;
|
|
class CodeWidget;
|
|
class DiscordHandler;
|
|
class DragEnterEvent;
|
|
class FreeLookWindow;
|
|
class GameList;
|
|
class GBATASInputWindow;
|
|
class GCTASInputWindow;
|
|
class HotkeyScheduler;
|
|
class InfinityBaseWindow;
|
|
class JITWidget;
|
|
class LogConfigWidget;
|
|
class LogWidget;
|
|
class MappingWindow;
|
|
class MemoryWidget;
|
|
class MenuBar;
|
|
class NetPlayDialog;
|
|
class NetPlaySetupDialog;
|
|
class NetworkWidget;
|
|
class RegisterWidget;
|
|
class RenderWidget;
|
|
class SearchBar;
|
|
class SettingsWindow;
|
|
class SkylanderPortalWindow;
|
|
class ThreadWidget;
|
|
class ToolBar;
|
|
class WatchWidget;
|
|
class WiiTASInputWindow;
|
|
class WiiSpeakWindow;
|
|
struct WindowSystemInfo;
|
|
|
|
namespace Core
|
|
{
|
|
class System;
|
|
}
|
|
|
|
namespace DiscIO
|
|
{
|
|
enum class Region;
|
|
}
|
|
|
|
namespace UICommon
|
|
{
|
|
class GameFile;
|
|
}
|
|
|
|
namespace X11Utils
|
|
{
|
|
class XRRConfiguration;
|
|
}
|
|
|
|
class MainWindow final : public QMainWindow
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit MainWindow(Core::System& system, std::unique_ptr<BootParameters> boot_parameters,
|
|
const std::string& movie_path);
|
|
~MainWindow() override;
|
|
|
|
WindowSystemInfo GetWindowSystemInfo() const;
|
|
|
|
bool eventFilter(QObject* object, QEvent* event) override;
|
|
QMenu* createPopupMenu() override;
|
|
|
|
signals:
|
|
void ReadOnlyModeChanged(bool read_only);
|
|
void RecordingStatusChanged(bool recording);
|
|
|
|
private:
|
|
void Open();
|
|
void RefreshGameList();
|
|
void Play(const std::optional<std::string>& savestate_path = {});
|
|
void Pause();
|
|
void TogglePause();
|
|
|
|
// May ask for confirmation. Returns whether or not it actually stopped.
|
|
bool RequestStop();
|
|
void ForceStop();
|
|
void Reset();
|
|
void FrameAdvance();
|
|
void StateLoad();
|
|
void StateSave();
|
|
void StateLoadSlot();
|
|
void StateSaveSlot();
|
|
void StateLoadSlotAt(int slot);
|
|
void StateSaveSlotAt(int slot);
|
|
void StateLoadLastSavedAt(int slot);
|
|
void StateLoadUndo();
|
|
void StateSaveUndo();
|
|
void StateSaveOldest();
|
|
void SetStateSlot(int slot);
|
|
void IncrementSelectedStateSlot();
|
|
void DecrementSelectedStateSlot();
|
|
void BootWiiSystemMenu();
|
|
|
|
void PerformOnlineUpdate(const std::string& region);
|
|
|
|
void SetFullScreenResolution(bool fullscreen);
|
|
|
|
void FullScreen();
|
|
void UnlockCursor();
|
|
void ScreenShot();
|
|
|
|
void CreateComponents();
|
|
|
|
void ConnectGameList();
|
|
void ConnectHost();
|
|
void ConnectHotkeys();
|
|
void ConnectMenuBar();
|
|
void ConnectRenderWidget();
|
|
void ConnectStack();
|
|
void ConnectToolBar();
|
|
|
|
void InitControllers();
|
|
void ShutdownControllers();
|
|
|
|
void InitCoreCallbacks();
|
|
|
|
enum class ScanForSecondDisc
|
|
{
|
|
Yes,
|
|
No,
|
|
};
|
|
|
|
void ScanForSecondDiscAndStartGame(const UICommon::GameFile& game,
|
|
std::unique_ptr<BootSessionData> boot_session_data = nullptr);
|
|
void StartGame(const QString& path, ScanForSecondDisc scan,
|
|
std::unique_ptr<BootSessionData> boot_session_data = nullptr);
|
|
void StartGame(const std::string& path, ScanForSecondDisc scan,
|
|
std::unique_ptr<BootSessionData> boot_session_data = nullptr);
|
|
void StartGame(const std::vector<std::string>& paths,
|
|
std::unique_ptr<BootSessionData> boot_session_data = nullptr);
|
|
void StartGame(std::unique_ptr<BootParameters>&& parameters);
|
|
void ShowRenderWidget();
|
|
void HideRenderWidget(bool reinit = true, bool is_exit = false);
|
|
|
|
void ShowSettingsWindow();
|
|
void ShowGeneralWindow();
|
|
void ShowAudioWindow();
|
|
void ShowControllersWindow();
|
|
void ShowGraphicsWindow();
|
|
void ShowFreeLookWindow();
|
|
void ShowAboutDialog();
|
|
void ShowHotkeyDialog();
|
|
void ShowNetPlaySetupDialog();
|
|
void ShowNetPlayBrowser();
|
|
void ShowFIFOPlayer();
|
|
void ShowSkylanderPortal();
|
|
void ShowInfinityBase();
|
|
void ShowWiiSpeakWindow();
|
|
void ShowMemcardManager();
|
|
void ShowResourcePackManager();
|
|
void ShowCheatsManager();
|
|
void ShowRiivolutionBootWidget(const UICommon::GameFile& game);
|
|
|
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
|
void ShowAchievementsWindow();
|
|
void ShowAchievementSettings();
|
|
void OnHardcoreChanged();
|
|
#endif // USE_RETRO_ACHIEVEMENTS
|
|
|
|
void NetPlayInit();
|
|
bool NetPlayJoin();
|
|
bool NetPlayHost(const UICommon::GameFile& game);
|
|
void NetPlayQuit();
|
|
|
|
void OnBootGameCubeIPL(DiscIO::Region region);
|
|
void OnImportNANDBackup();
|
|
void OnConnectWiiRemote(int id);
|
|
|
|
#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
|
|
void OnSignal();
|
|
#endif
|
|
|
|
void OnPlayRecording();
|
|
void OnStartRecording();
|
|
void OnStopRecording();
|
|
void OnExportRecording();
|
|
void OnActivateChat();
|
|
void OnRequestGolfControl();
|
|
void ShowTASInput();
|
|
|
|
void ChangeDisc();
|
|
void EjectDisc();
|
|
|
|
void OpenUserFolder();
|
|
|
|
QStringList PromptFileNames();
|
|
|
|
void UpdateScreenSaverInhibition();
|
|
|
|
void OnStopComplete();
|
|
void dragEnterEvent(QDragEnterEvent* event) override;
|
|
void dropEvent(QDropEvent* event) override;
|
|
QSize sizeHint() const override;
|
|
|
|
Core::System& m_system;
|
|
|
|
#ifdef HAVE_XRANDR
|
|
std::unique_ptr<X11Utils::XRRConfiguration> m_xrr_config;
|
|
#endif
|
|
|
|
QStackedWidget* m_stack;
|
|
ToolBar* m_tool_bar;
|
|
MenuBar* m_menu_bar;
|
|
SearchBar* m_search_bar;
|
|
GameList* m_game_list;
|
|
RenderWidget* m_render_widget = nullptr;
|
|
bool m_rendering_to_main;
|
|
bool m_stop_confirm_showing = false;
|
|
bool m_stop_requested = false;
|
|
bool m_exit_requested = false;
|
|
bool m_fullscreen_requested = false;
|
|
bool m_is_screensaver_inhibited = false;
|
|
u32 m_state_slot = 1;
|
|
std::unique_ptr<BootParameters> m_pending_boot;
|
|
|
|
SettingsWindow* m_settings_window = nullptr;
|
|
// m_fifo_window doesn't set MainWindow as its parent so that the fifo can be focused without
|
|
// raising the main window, so use a unique_ptr to make sure it gets destroyed.
|
|
std::unique_ptr<FIFOPlayerWindow> m_fifo_window = nullptr;
|
|
SkylanderPortalWindow* m_skylander_window = nullptr;
|
|
InfinityBaseWindow* m_infinity_window = nullptr;
|
|
WiiSpeakWindow* m_wii_speak_window = nullptr;
|
|
MappingWindow* m_hotkey_window = nullptr;
|
|
FreeLookWindow* m_freelook_window = nullptr;
|
|
|
|
HotkeyScheduler* m_hotkey_scheduler;
|
|
NetPlayDialog* m_netplay_dialog;
|
|
DiscordHandler* m_netplay_discord;
|
|
NetPlaySetupDialog* m_netplay_setup_dialog;
|
|
static constexpr int num_gc_controllers = 4;
|
|
std::array<GCTASInputWindow*, num_gc_controllers> m_gc_tas_input_windows{};
|
|
std::array<GBATASInputWindow*, num_gc_controllers> m_gba_tas_input_windows{};
|
|
static constexpr int num_wii_controllers = 4;
|
|
std::array<WiiTASInputWindow*, num_wii_controllers> m_wii_tas_input_windows{};
|
|
|
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
|
AchievementsWindow* m_achievements_window = nullptr;
|
|
Config::ConfigChangedCallbackID m_config_changed_callback_id;
|
|
bool m_former_hardcore_setting = false;
|
|
#endif // USE_RETRO_ACHIEVEMENTS
|
|
|
|
AssemblerWidget* m_assembler_widget;
|
|
BreakpointWidget* m_breakpoint_widget;
|
|
CodeWidget* m_code_widget;
|
|
JITWidget* m_jit_widget;
|
|
LogWidget* m_log_widget;
|
|
LogConfigWidget* m_log_config_widget;
|
|
MemoryWidget* m_memory_widget;
|
|
NetworkWidget* m_network_widget;
|
|
RegisterWidget* m_register_widget;
|
|
ThreadWidget* m_thread_widget;
|
|
WatchWidget* m_watch_widget;
|
|
CheatsManager* m_cheats_manager{};
|
|
QByteArray m_render_widget_geometry;
|
|
};
|