shadPS4/src/qt_gui/main_window.h
rainmakerv2 fa32537f40
Some checks failed
Build and Release / reuse (push) Has been cancelled
Build and Release / clang-format (push) Has been cancelled
Build and Release / get-info (push) Has been cancelled
Build and Release / windows-sdl (push) Has been cancelled
Build and Release / windows-qt (push) Has been cancelled
Build and Release / macos-sdl (push) Has been cancelled
Build and Release / macos-qt (push) Has been cancelled
Build and Release / linux-sdl (push) Has been cancelled
Build and Release / linux-qt (push) Has been cancelled
Build and Release / linux-sdl-gcc (push) Has been cancelled
Build and Release / linux-qt-gcc (push) Has been cancelled
Build and Release / pre-release (push) Has been cancelled
Controller Remapping GUI v2 (#3144)
* Remapping GUI V2 - initial commit

* Unmap button with escape key

* Allow combination inputs

* Use separate class for SDL event signals so that i can work with the SDL window event loop

* Automatically pause game when GUI open to better manage event queue

* Move sd;_gamepad_added event from remap object to GUI object to avoid conflicts with sdl window

* Use signals on button/trigger to release to make GUI more responsive

* pause game while KBM window is open for consistency

* don't check gamepad when game is running to avoid conflicts

* Block all other sdl events instead of pausing game, automatic parse inputs after saving

* Don't block window restored or window exposed cases

* Properly exit event loop thread on exit
2025-06-27 15:55:52 +02:00

124 lines
3.5 KiB
C++

// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <QActionGroup>
#include <QDragEnterEvent>
#include <QProcess>
#include <QTranslator>
#include "background_music_player.h"
#include "common/config.h"
#include "common/path_util.h"
#include "compatibility_info.h"
#include "core/file_format/psf.h"
#include "core/file_sys/fs.h"
#include "elf_viewer.h"
#include "emulator.h"
#include "game_grid_frame.h"
#include "game_info.h"
#include "game_list_frame.h"
#include "game_list_utils.h"
#include "gui_settings.h"
#include "main_window_themes.h"
#include "main_window_ui.h"
class GameListFrame;
class MainWindow : public QMainWindow {
Q_OBJECT
signals:
void WindowResized(QResizeEvent* event);
public:
explicit MainWindow(QWidget* parent = nullptr);
~MainWindow();
bool Init();
void InstallDirectory();
void StartGame();
void PauseGame();
bool showLabels;
private Q_SLOTS:
void ConfigureGuiFromSettings();
void SaveWindowState();
void SearchGameTable(const QString& text);
void ShowGameList();
void RefreshGameTable();
void HandleResize(QResizeEvent* event);
void OnLanguageChanged(const QString& locale);
void toggleLabelsUnderIcons();
private:
Ui_MainWindow* ui;
void AddUiWidgets();
void UpdateToolbarLabels();
void UpdateToolbarButtons();
QWidget* createButtonWithLabel(QPushButton* button, const QString& labelText, bool showLabel);
void CreateActions();
void toggleFullscreen();
void CreateRecentGameActions();
void CreateDockWindows();
void LoadGameLists();
#ifdef ENABLE_UPDATER
void CheckUpdateMain(bool checkSave);
#endif
void CreateConnects();
void SetLastUsedTheme();
void SetLastIconSizeBullet();
void SetUiIcons(bool isWhite);
void BootGame();
void AddRecentFiles(QString filePath);
void LoadTranslation();
void PlayBackgroundMusic();
QIcon RecolorIcon(const QIcon& icon, bool isWhite);
void StartEmulator(std::filesystem::path);
bool isIconBlack = false;
bool isTableList = true;
bool isGameRunning = false;
bool isWhite = false;
bool is_paused = false;
std::string runningGameSerial = "";
QActionGroup* m_icon_size_act_group = nullptr;
QActionGroup* m_list_mode_act_group = nullptr;
QActionGroup* m_theme_act_group = nullptr;
QActionGroup* m_recent_files_group = nullptr;
// Dockable widget frames
WindowThemes m_window_themes;
GameListUtils m_game_list_utils;
QScopedPointer<QDockWidget> m_dock_widget;
// Game Lists
QScopedPointer<GameListFrame> m_game_list_frame;
QScopedPointer<GameGridFrame> m_game_grid_frame;
QScopedPointer<ElfViewer> m_elf_viewer;
// Status Bar.
QScopedPointer<QStatusBar> statusBar;
PSF psf;
std::shared_ptr<GameInfoClass> m_game_info = std::make_shared<GameInfoClass>();
std::shared_ptr<CompatibilityInfoClass> m_compat_info =
std::make_shared<CompatibilityInfoClass>();
QTranslator* translator;
std::shared_ptr<gui_settings> m_gui_settings;
protected:
bool eventFilter(QObject* obj, QEvent* event) override;
void dragEnterEvent(QDragEnterEvent* event1) override {
if (event1->mimeData()->hasUrls()) {
event1->acceptProposedAction();
}
}
void resizeEvent(QResizeEvent* event) override;
std::filesystem::path last_install_dir = "";
bool delete_file_on_install = false;
bool use_for_all_queued = false;
};