2024-02-29 23:00:35 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QFutureWatcher>
|
|
|
|
#include <QGraphicsBlurEffect>
|
|
|
|
#include <QHeaderView>
|
|
|
|
#include <QLabel>
|
2024-03-29 06:43:46 +01:00
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QScrollBar>
|
|
|
|
#include <QStyleOptionViewItem>
|
|
|
|
#include <QTableWidget>
|
|
|
|
#include <QTableWidgetItem>
|
2024-02-29 23:00:35 +01:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QWidget>
|
2024-03-29 06:43:46 +01:00
|
|
|
#include <QtConcurrent/QtConcurrent>
|
|
|
|
#include "game_info.h"
|
2024-02-29 23:00:35 +01:00
|
|
|
#include "game_list_utils.h"
|
2024-03-29 06:43:46 +01:00
|
|
|
#include "gui_context_menus.h"
|
2024-02-29 23:00:35 +01:00
|
|
|
|
2024-03-29 06:43:46 +01:00
|
|
|
class GameListFrame : public QTableWidget {
|
2024-02-29 23:00:35 +01:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2024-03-29 06:43:46 +01:00
|
|
|
explicit GameListFrame(std::shared_ptr<GameInfoClass> game_info_get,
|
|
|
|
std::shared_ptr<GuiSettings> m_gui_settings, QWidget* parent = nullptr);
|
|
|
|
Q_SIGNALS:
|
|
|
|
void GameListFrameClosed();
|
2024-02-29 23:00:35 +01:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void SetListBackgroundImage(QTableWidgetItem* item);
|
|
|
|
void RefreshListBackgroundImage();
|
2024-03-29 06:43:46 +01:00
|
|
|
void SortNameAscending(int columnIndex);
|
|
|
|
void SortNameDescending(int columnIndex);
|
2024-02-29 23:00:35 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
QList<QAction*> m_columnActs;
|
2024-03-29 06:43:46 +01:00
|
|
|
GameInfoClass* game_inf_get = nullptr;
|
|
|
|
bool ListSortedAsc = true;
|
2024-02-29 23:00:35 +01:00
|
|
|
|
2024-03-29 06:43:46 +01:00
|
|
|
public:
|
|
|
|
void PopulateGameList();
|
|
|
|
void ResizeIcons(int iconSize);
|
2024-02-29 23:00:35 +01:00
|
|
|
|
|
|
|
QImage backgroundImage;
|
2024-03-29 06:43:46 +01:00
|
|
|
GameListUtils m_game_list_utils;
|
|
|
|
GuiContextMenus m_gui_context_menus;
|
|
|
|
std::shared_ptr<GameInfoClass> m_game_info;
|
2024-02-29 23:00:35 +01:00
|
|
|
|
2024-03-29 06:43:46 +01:00
|
|
|
int icon_size;
|
|
|
|
|
|
|
|
void SetTableItem(QTableWidget* game_list, int row, int column, QString itemStr) {
|
2024-02-29 23:00:35 +01:00
|
|
|
QWidget* widget = new QWidget();
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout();
|
|
|
|
QLabel* label = new QLabel(itemStr);
|
|
|
|
QTableWidgetItem* item = new QTableWidgetItem();
|
|
|
|
|
|
|
|
label->setStyleSheet("color: white; font-size: 15px; font-weight: bold;");
|
|
|
|
|
|
|
|
// Create shadow effect
|
|
|
|
QGraphicsDropShadowEffect* shadowEffect = new QGraphicsDropShadowEffect();
|
|
|
|
shadowEffect->setBlurRadius(5); // Set the blur radius of the shadow
|
|
|
|
shadowEffect->setColor(QColor(0, 0, 0, 160)); // Set the color and opacity of the shadow
|
|
|
|
shadowEffect->setOffset(2, 2); // Set the offset of the shadow
|
|
|
|
|
|
|
|
label->setGraphicsEffect(shadowEffect); // Apply shadow effect to the QLabel
|
|
|
|
|
|
|
|
layout->addWidget(label);
|
|
|
|
if (column != 7 && column != 1)
|
|
|
|
layout->setAlignment(Qt::AlignCenter);
|
|
|
|
widget->setLayout(layout);
|
|
|
|
game_list->setItem(row, column, item);
|
|
|
|
game_list->setCellWidget(row, column, widget);
|
|
|
|
}
|
2024-03-29 06:43:46 +01:00
|
|
|
|
|
|
|
static bool CompareStringsAscending(GameInfo a, GameInfo b, int columnIndex) {
|
|
|
|
if (columnIndex == 1) {
|
|
|
|
return a.name < b.name;
|
|
|
|
} else if (columnIndex == 2) {
|
|
|
|
return a.serial < b.serial;
|
|
|
|
} else if (columnIndex == 3) {
|
|
|
|
return a.fw < b.fw;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool CompareStringsDescending(GameInfo a, GameInfo b, int columnIndex) {
|
|
|
|
if (columnIndex == 1) {
|
|
|
|
return a.name > b.name;
|
|
|
|
} else if (columnIndex == 2) {
|
|
|
|
return a.serial > b.serial;
|
|
|
|
} else if (columnIndex == 3) {
|
|
|
|
return a.fw > b.fw;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|