2024-07-30 11:42:36 +00:00
|
|
|
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
|
|
|
|
// SPDX-License-Identifier: GPL-3.0+
|
2022-02-15 14:59:15 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-03-25 09:24:41 +00:00
|
|
|
#include <array>
|
|
|
|
#include <optional>
|
|
|
|
#include <string>
|
2022-02-15 14:59:15 +00:00
|
|
|
|
2022-03-25 09:24:41 +00:00
|
|
|
#include <QtGui/QResizeEvent>
|
|
|
|
#include <QtWidgets/QWidget>
|
|
|
|
#include <QtWidgets/QTreeWidget>
|
|
|
|
#include <QtWidgets/QToolButton>
|
|
|
|
#include <QtWidgets/QListWidget>
|
2022-02-15 14:59:15 +00:00
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
class SettingsWindow;
|
2022-02-15 14:59:15 +00:00
|
|
|
|
2022-03-25 09:24:41 +00:00
|
|
|
struct AvailableMcdInfo;
|
|
|
|
|
|
|
|
class MemoryCardListWidget final : public QTreeWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit MemoryCardListWidget(QWidget* parent);
|
|
|
|
~MemoryCardListWidget() override;
|
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
void refresh(SettingsWindow* dialog);
|
2022-03-25 09:24:41 +00:00
|
|
|
|
|
|
|
protected:
|
2022-03-26 08:48:23 +00:00
|
|
|
void mousePressEvent(QMouseEvent* event) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent* event) override;
|
2022-03-25 09:24:41 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QPoint m_dragStartPos = {};
|
|
|
|
};
|
|
|
|
|
|
|
|
class MemoryCardSlotWidget final : public QListWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit MemoryCardSlotWidget(QWidget* parent);
|
|
|
|
~MemoryCardSlotWidget() override;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void cardDropped(const QString& newCard);
|
|
|
|
|
|
|
|
public:
|
2023-05-29 10:42:46 +00:00
|
|
|
void setCard(const std::optional<std::string>& name, bool inherited);
|
2022-03-25 09:24:41 +00:00
|
|
|
|
|
|
|
protected:
|
2022-03-26 08:48:23 +00:00
|
|
|
void dragEnterEvent(QDragEnterEvent* event) override;
|
|
|
|
void dragMoveEvent(QDragMoveEvent* event) override;
|
|
|
|
void dropEvent(QDropEvent* event) override;
|
2022-03-25 09:24:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Must be included *after* the custom widgets.
|
|
|
|
#include "ui_MemoryCardSettingsWidget.h"
|
|
|
|
|
2022-02-15 14:59:15 +00:00
|
|
|
class MemoryCardSettingsWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-03-25 09:24:41 +00:00
|
|
|
enum : u32
|
|
|
|
{
|
|
|
|
MAX_SLOTS = 2
|
|
|
|
};
|
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
MemoryCardSettingsWidget(SettingsWindow* dialog, QWidget* parent);
|
2022-02-15 14:59:15 +00:00
|
|
|
~MemoryCardSettingsWidget();
|
|
|
|
|
2022-03-25 09:24:41 +00:00
|
|
|
protected:
|
|
|
|
void resizeEvent(QResizeEvent* event);
|
|
|
|
bool eventFilter(QObject* watched, QEvent* event);
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void listContextMenuRequested(const QPoint& pos);
|
|
|
|
void refresh();
|
2022-06-06 13:04:14 +00:00
|
|
|
void swapCards();
|
2022-03-25 09:24:41 +00:00
|
|
|
|
2022-02-15 14:59:15 +00:00
|
|
|
private:
|
2022-03-25 09:24:41 +00:00
|
|
|
struct SlotGroup
|
|
|
|
{
|
|
|
|
QWidget* root;
|
|
|
|
QCheckBox* enable;
|
|
|
|
QToolButton* eject;
|
|
|
|
MemoryCardSlotWidget* slot;
|
|
|
|
};
|
|
|
|
|
|
|
|
void createSlotWidgets(SlotGroup* port, u32 slot);
|
2022-06-06 13:04:14 +00:00
|
|
|
void setupAdditionalUi();
|
2022-03-25 09:24:41 +00:00
|
|
|
void autoSizeUI();
|
|
|
|
|
|
|
|
void tryInsertCard(u32 slot, const QString& newCard);
|
|
|
|
void ejectSlot(u32 slot);
|
|
|
|
|
|
|
|
void createCard();
|
|
|
|
|
|
|
|
QString getSelectedCard() const;
|
|
|
|
void updateCardActions();
|
|
|
|
void deleteCard();
|
|
|
|
void renameCard();
|
|
|
|
void convertCard();
|
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
SettingsWindow* m_dialog;
|
2022-02-15 14:59:15 +00:00
|
|
|
Ui::MemoryCardSettingsWidget m_ui;
|
2022-03-25 09:24:41 +00:00
|
|
|
|
|
|
|
std::array<SlotGroup, MAX_SLOTS> m_slots;
|
2022-02-15 14:59:15 +00:00
|
|
|
};
|