Duckstation/src/duckstation-qt/mainwindow.h

172 lines
5.8 KiB
C
Raw Normal View History

2019-12-31 06:17:17 +00:00
#pragma once
#include <QtCore/QThread>
#include <QtWidgets/QLabel>
#include <QtWidgets/QMainWindow>
#include <memory>
#include "core/types.h"
2019-12-31 06:17:17 +00:00
#include "settingsdialog.h"
#include "ui_mainwindow.h"
class QLabel;
class QThread;
2019-12-31 06:17:17 +00:00
class GameListWidget;
class QtHostInterface;
class QtDisplayWidget;
2020-08-06 12:08:22 +00:00
class AutoUpdaterDialog;
2020-09-18 14:28:07 +00:00
class MemoryCardEditorDialog;
2020-10-19 15:14:49 +00:00
class CheatManagerDialog;
2020-12-16 15:18:13 +00:00
class DebuggerWindow;
2019-12-31 06:17:17 +00:00
class HostDisplay;
struct GameListEntry;
2020-12-17 17:32:29 +00:00
class GDBServer;
class MainWindow final : public QMainWindow
2019-12-31 06:17:17 +00:00
{
Q_OBJECT
public:
explicit MainWindow(QtHostInterface* host_interface);
~MainWindow();
/// Initializes the window. Call once at startup.
void initializeAndShow();
2020-08-06 12:08:22 +00:00
/// Performs update check if enabled in settings.
void startupUpdateCheck();
/// Opens memory card editor with the specified paths.
void openMemoryCardEditor(const QString& card_a_path, const QString& card_b_path);
2021-03-03 09:14:01 +00:00
/// Updates the state of the controls which should be disabled by achievements challenge mode.
void onAchievementsChallengeModeToggled(bool enabled);
2020-08-18 14:01:57 +00:00
public Q_SLOTS:
/// Updates debug menu visibility (hides if disabled).
void updateDebugMenuVisibility();
2020-12-21 16:47:48 +00:00
void checkForUpdates(bool display_message);
2020-01-06 06:27:39 +00:00
private Q_SLOTS:
void reportError(const QString& message);
void reportMessage(const QString& message);
bool confirmMessage(const QString& message);
QtDisplayWidget* createDisplay(QThread* worker_thread, bool fullscreen, bool render_to_main);
QtDisplayWidget* updateDisplay(QThread* worker_thread, bool fullscreen, bool render_to_main);
2020-11-18 13:15:16 +00:00
void displaySizeRequested(qint32 width, qint32 height);
void destroyDisplay();
void focusDisplayWidget();
2020-12-27 04:08:13 +00:00
void onMouseModeRequested(bool relative_mode, bool hide_cursor);
void updateMouseMode(bool paused);
2020-06-24 15:31:23 +00:00
void setTheme(const QString& theme);
void updateTheme();
void onEmulationStarting();
2019-12-31 06:17:17 +00:00
void onEmulationStarted();
void onEmulationStopped();
void onEmulationPaused(bool paused);
void onStateSaved(const QString& game_code, bool global, qint32 slot);
void onSystemPerformanceCountersUpdated(float speed, float fps, float vps, float average_frame_time,
float worst_frame_time, GPURenderer renderer, quint32 render_width,
quint32 render_height, bool render_interlaced);
void onRunningGameChanged(const QString& filename, const QString& game_code, const QString& game_title);
void onApplicationStateChanged(Qt::ApplicationState state);
2019-12-31 06:17:17 +00:00
void onStartDiscActionTriggered();
void onStartBIOSActionTriggered();
2020-01-24 04:50:40 +00:00
void onChangeDiscFromFileActionTriggered();
void onChangeDiscFromGameListActionTriggered();
2021-03-27 04:14:52 +00:00
void onChangeDiscMenuAboutToShow();
void onChangeDiscMenuAboutToHide();
2020-09-09 13:44:21 +00:00
void onCheatsMenuAboutToShow();
void onRemoveDiscActionTriggered();
2020-08-20 13:39:29 +00:00
void onViewToolbarActionToggled(bool checked);
2021-02-09 13:56:24 +00:00
void onViewLockToolbarActionToggled(bool checked);
2020-08-20 13:39:29 +00:00
void onViewStatusBarActionToggled(bool checked);
void onViewGameListActionTriggered();
2020-09-23 14:02:13 +00:00
void onViewGameGridActionTriggered();
2020-08-20 13:39:29 +00:00
void onViewSystemDisplayTriggered();
void onViewGamePropertiesActionTriggered();
2019-12-31 06:17:17 +00:00
void onGitHubRepositoryActionTriggered();
void onIssueTrackerActionTriggered();
void onDiscordServerActionTriggered();
2019-12-31 06:17:17 +00:00
void onAboutActionTriggered();
void onCheckForUpdatesActionTriggered();
2020-09-18 14:28:07 +00:00
void onToolsMemoryCardEditorTriggered();
2020-10-19 15:14:49 +00:00
void onToolsCheatManagerTriggered();
void onToolsOpenDataDirectoryTriggered();
2019-12-31 06:17:17 +00:00
void onGameListEntrySelected(const GameListEntry* entry);
void onGameListEntryDoubleClicked(const GameListEntry* entry);
void onGameListContextMenuRequested(const QPoint& point, const GameListEntry* entry);
void onGameListSetCoverImageRequested(const GameListEntry* entry);
2020-08-06 12:08:22 +00:00
void onUpdateCheckComplete();
void openCPUDebugger();
void onCPUDebuggerClosed();
protected:
void closeEvent(QCloseEvent* event) override;
void changeEvent(QEvent* event) override;
void dragEnterEvent(QDragEnterEvent* event) override;
void dropEvent(QDropEvent* event) override;
2019-12-31 06:17:17 +00:00
private:
void setupAdditionalUi();
void connectSignals();
2020-06-24 15:31:23 +00:00
void addThemeToMenu(const QString& name, const QString& key);
2021-03-03 09:14:01 +00:00
void updateEmulationActions(bool starting, bool running, bool cheevos_challenge_mode);
2020-09-23 14:02:13 +00:00
bool isShowingGameList() const;
2019-12-31 06:17:17 +00:00
void switchToGameListView();
void switchToEmulationView();
void startGameOrChangeDiscs(const std::string& path);
void saveStateToConfig();
void restoreStateFromConfig();
void saveDisplayWindowGeometryToConfig();
void restoreDisplayWindowGeometryFromConfig();
void destroyDisplayWidget();
void setDisplayFullscreen(const std::string& fullscreen_mode);
bool shouldHideCursorInFullscreen() const;
SettingsDialog* getSettingsDialog();
2019-12-31 06:17:17 +00:00
void doSettings(SettingsDialog::Category category = SettingsDialog::Category::Count);
2020-02-05 08:43:25 +00:00
void updateDebugMenuCPUExecutionMode();
2020-01-24 04:49:51 +00:00
void updateDebugMenuGPURenderer();
void updateDebugMenuCropMode();
2019-12-31 06:17:17 +00:00
Ui::MainWindow m_ui;
QString m_unthemed_style_name;
2019-12-31 06:17:17 +00:00
QtHostInterface* m_host_interface = nullptr;
GameListWidget* m_game_list_widget = nullptr;
HostDisplay* m_host_display = nullptr;
QtDisplayWidget* m_display_widget = nullptr;
2019-12-31 06:17:17 +00:00
QLabel* m_status_speed_widget = nullptr;
QLabel* m_status_fps_widget = nullptr;
QLabel* m_status_frame_time_widget = nullptr;
QLabel* m_status_renderer_widget = nullptr;
QLabel* m_status_resolution_widget = nullptr;
2019-12-31 06:17:17 +00:00
SettingsDialog* m_settings_dialog = nullptr;
2020-08-06 12:08:22 +00:00
AutoUpdaterDialog* m_auto_updater_dialog = nullptr;
2020-09-18 14:28:07 +00:00
MemoryCardEditorDialog* m_memory_card_editor_dialog = nullptr;
2020-10-19 15:14:49 +00:00
CheatManagerDialog* m_cheat_manager_dialog = nullptr;
2020-12-16 15:18:13 +00:00
DebuggerWindow* m_debugger_window = nullptr;
2019-12-31 06:17:17 +00:00
bool m_emulation_running = false;
bool m_was_paused_by_focus_loss = false;
bool m_open_debugger_on_start = false;
2020-12-27 04:08:13 +00:00
bool m_relative_mouse_mode = false;
bool m_mouse_cursor_hidden = false;
2020-12-17 17:32:29 +00:00
GDBServer* m_gdb_server = nullptr;
2019-12-31 06:17:17 +00:00
};