2022-02-15 14:59:15 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
|
|
|
* Copyright (C) 2002-2022 PCSX2 Dev Team
|
|
|
|
*
|
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
class SettingsDialog;
|
|
|
|
|
2022-03-25 09:24:41 +00:00
|
|
|
struct AvailableMcdInfo;
|
|
|
|
|
|
|
|
class MemoryCardListWidget final : public QTreeWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit MemoryCardListWidget(QWidget* parent);
|
|
|
|
~MemoryCardListWidget() override;
|
|
|
|
|
|
|
|
void refresh(SettingsDialog* dialog);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void mousePressEvent(QMouseEvent* event);
|
|
|
|
void mouseMoveEvent(QMouseEvent* event);
|
|
|
|
|
|
|
|
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:
|
|
|
|
void setCard(const std::optional<std::string>& name);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void dragEnterEvent(QDragEnterEvent* event);
|
|
|
|
void dragMoveEvent(QDragMoveEvent* event);
|
|
|
|
void dropEvent(QDropEvent* event);
|
|
|
|
};
|
|
|
|
|
|
|
|
// 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
|
|
|
|
};
|
|
|
|
|
2022-02-15 14:59:15 +00:00
|
|
|
MemoryCardSettingsWidget(SettingsDialog* dialog, QWidget* parent);
|
|
|
|
~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-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);
|
|
|
|
void autoSizeUI();
|
|
|
|
|
|
|
|
void tryInsertCard(u32 slot, const QString& newCard);
|
|
|
|
void ejectSlot(u32 slot);
|
|
|
|
|
|
|
|
void createCard();
|
|
|
|
|
|
|
|
QString getSelectedCard() const;
|
|
|
|
void updateCardActions();
|
|
|
|
void duplicateCard();
|
|
|
|
void deleteCard();
|
|
|
|
void renameCard();
|
|
|
|
void convertCard();
|
|
|
|
|
|
|
|
SettingsDialog* 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
|
|
|
};
|