2024-02-29 23:00:35 +01:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2024-06-11 04:42:21 +02:00
|
|
|
#include <QAbstractButton>
|
2024-02-29 23:00:35 +01:00
|
|
|
#include <QActionGroup>
|
|
|
|
#include <QDragEnterEvent>
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QMimeData>
|
2024-06-11 04:42:21 +02:00
|
|
|
#include <QScopedPointer>
|
|
|
|
#include <fmt/core.h>
|
|
|
|
#include "common/config.h"
|
|
|
|
#include "common/path_util.h"
|
|
|
|
#include "core/file_format/psf.h"
|
|
|
|
#include "core/file_sys/fs.h"
|
|
|
|
#include "elf_viewer.h"
|
2024-07-31 12:25:55 +02:00
|
|
|
#include "emulator.h"
|
2024-03-29 06:43:46 +01:00
|
|
|
#include "game_grid_frame.h"
|
|
|
|
#include "game_info.h"
|
|
|
|
#include "game_list_frame.h"
|
|
|
|
#include "game_list_utils.h"
|
2024-02-29 23:00:35 +01:00
|
|
|
#include "main_window_themes.h"
|
|
|
|
#include "main_window_ui.h"
|
2024-03-29 06:43:46 +01:00
|
|
|
#include "pkg_viewer.h"
|
2024-02-29 23:00:35 +01:00
|
|
|
|
|
|
|
class GameListFrame;
|
|
|
|
|
|
|
|
class MainWindow : public QMainWindow {
|
|
|
|
Q_OBJECT
|
2024-03-29 06:43:46 +01:00
|
|
|
signals:
|
|
|
|
void WindowResized(QResizeEvent* event);
|
2024-06-11 04:42:21 +02:00
|
|
|
void ExtractionFinished();
|
2024-02-29 23:00:35 +01:00
|
|
|
|
|
|
|
public:
|
2024-06-11 04:42:21 +02:00
|
|
|
explicit MainWindow(QWidget* parent = nullptr);
|
2024-02-29 23:00:35 +01:00
|
|
|
~MainWindow();
|
|
|
|
bool Init();
|
2024-06-11 04:42:21 +02:00
|
|
|
void InstallDragDropPkg(std::filesystem::path file, int pkgNum, int nPkg);
|
2024-02-29 23:00:35 +01:00
|
|
|
void InstallDirectory();
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void ConfigureGuiFromSettings();
|
|
|
|
void SaveWindowState() const;
|
2024-03-29 06:43:46 +01:00
|
|
|
void SearchGameTable(const QString& text);
|
|
|
|
void RefreshGameTable();
|
|
|
|
void HandleResize(QResizeEvent* event);
|
2024-02-29 23:00:35 +01:00
|
|
|
|
|
|
|
private:
|
2024-06-11 04:42:21 +02:00
|
|
|
Ui_MainWindow* ui;
|
2024-03-01 09:47:28 +01:00
|
|
|
void AddUiWidgets();
|
2024-02-29 23:00:35 +01:00
|
|
|
void CreateActions();
|
2024-06-11 04:42:21 +02:00
|
|
|
void CreateRecentGameActions();
|
2024-02-29 23:00:35 +01:00
|
|
|
void CreateDockWindows();
|
2024-03-29 06:43:46 +01:00
|
|
|
void LoadGameLists();
|
2024-02-29 23:00:35 +01:00
|
|
|
void CreateConnects();
|
|
|
|
void SetLastUsedTheme();
|
2024-03-29 06:43:46 +01:00
|
|
|
void SetLastIconSizeBullet();
|
2024-03-01 09:47:28 +01:00
|
|
|
void SetUiIcons(bool isWhite);
|
2024-06-11 04:42:21 +02:00
|
|
|
void InstallPkg();
|
|
|
|
void AddRecentFiles(QString filePath);
|
2024-03-29 06:43:46 +01:00
|
|
|
QIcon RecolorIcon(const QIcon& icon, bool isWhite);
|
2024-03-01 09:47:28 +01:00
|
|
|
bool isIconBlack = false;
|
2024-03-29 06:43:46 +01:00
|
|
|
bool isTableList = true;
|
2024-02-29 23:00:35 +01:00
|
|
|
QActionGroup* m_icon_size_act_group = nullptr;
|
|
|
|
QActionGroup* m_list_mode_act_group = nullptr;
|
|
|
|
QActionGroup* m_theme_act_group = nullptr;
|
2024-06-11 04:42:21 +02:00
|
|
|
QActionGroup* m_recent_files_group = nullptr;
|
|
|
|
PKG pkg;
|
2024-02-29 23:00:35 +01:00
|
|
|
// Dockable widget frames
|
|
|
|
WindowThemes m_window_themes;
|
2024-03-29 06:43:46 +01:00
|
|
|
GameListUtils m_game_list_utils;
|
2024-06-11 04:42:21 +02:00
|
|
|
QScopedPointer<QDockWidget> m_dock_widget;
|
2024-03-29 06:43:46 +01:00
|
|
|
// Game Lists
|
2024-06-11 04:42:21 +02:00
|
|
|
QScopedPointer<GameListFrame> m_game_list_frame;
|
|
|
|
QScopedPointer<GameGridFrame> m_game_grid_frame;
|
|
|
|
QScopedPointer<ElfViewer> m_elf_viewer;
|
2024-03-29 06:43:46 +01:00
|
|
|
// Status Bar.
|
2024-06-11 04:42:21 +02:00
|
|
|
QScopedPointer<QStatusBar> statusBar;
|
|
|
|
|
|
|
|
PSF psf;
|
2024-02-29 23:00:35 +01:00
|
|
|
|
2024-03-29 06:43:46 +01:00
|
|
|
std::shared_ptr<GameInfoClass> m_game_info = std::make_shared<GameInfoClass>();
|
2024-02-29 23:00:35 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void dragEnterEvent(QDragEnterEvent* event1) override {
|
|
|
|
if (event1->mimeData()->hasUrls()) {
|
|
|
|
event1->acceptProposedAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void dropEvent(QDropEvent* event1) override {
|
|
|
|
const QMimeData* mimeData = event1->mimeData();
|
|
|
|
if (mimeData->hasUrls()) {
|
|
|
|
QList<QUrl> urlList = mimeData->urls();
|
|
|
|
int pkgNum = 0;
|
|
|
|
int nPkg = urlList.size();
|
|
|
|
for (const QUrl& url : urlList) {
|
|
|
|
pkgNum++;
|
2024-06-11 04:42:21 +02:00
|
|
|
std::filesystem::path path(url.toLocalFile().toStdString());
|
|
|
|
#ifdef _WIN64
|
|
|
|
path = std::filesystem::path(url.toLocalFile().toStdWString());
|
|
|
|
#endif
|
|
|
|
InstallDragDropPkg(path, pkgNum, nPkg);
|
2024-02-29 23:00:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-03-29 06:43:46 +01:00
|
|
|
|
|
|
|
void resizeEvent(QResizeEvent* event) override;
|
2024-02-29 23:00:35 +01:00
|
|
|
};
|