mirror of https://github.com/PCSX2/pcsx2.git
parent
9dde599e00
commit
d25700e241
|
@ -127,12 +127,12 @@ const char* GameListModel::getColumnName(Column col)
|
|||
return s_column_names[static_cast<int>(col)];
|
||||
}
|
||||
|
||||
GameListModel::GameListModel(QObject* parent /* = nullptr */)
|
||||
GameListModel::GameListModel(float cover_scale, bool show_cover_titles, QObject* parent /* = nullptr */)
|
||||
: QAbstractTableModel(parent)
|
||||
, m_cover_pixmap_cache(MIN_COVER_CACHE_SIZE)
|
||||
, m_show_titles_for_covers(show_cover_titles)
|
||||
{
|
||||
loadCommonImages();
|
||||
setCoverScale(1.0f);
|
||||
setCoverScale(cover_scale);
|
||||
setColumnDisplayNames();
|
||||
}
|
||||
GameListModel::~GameListModel() = default;
|
||||
|
@ -153,6 +153,8 @@ void GameListModel::setCoverScale(float scale)
|
|||
m_cover_scale_counter.fetch_add(1, std::memory_order_release);
|
||||
m_loading_pixmap = QPixmap(getCoverArtWidth(), getCoverArtHeight());
|
||||
m_loading_pixmap.fill(QColor(0, 0, 0, 0));
|
||||
|
||||
emit coverScaleChanged();
|
||||
}
|
||||
|
||||
void GameListModel::refreshCovers()
|
||||
|
@ -386,7 +388,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
|
|||
return m_compatibility_pixmaps[static_cast<u32>(
|
||||
(static_cast<u32>(ge->compatibility_rating) >= GameList::CompatibilityRatingCount) ?
|
||||
GameList::CompatibilityRating::Unknown :
|
||||
ge->compatibility_rating)];
|
||||
ge->compatibility_rating)];
|
||||
}
|
||||
|
||||
case Column_Cover:
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
static QIcon getIconForType(GameList::EntryType type);
|
||||
static QIcon getIconForRegion(GameList::Region region);
|
||||
|
||||
GameListModel(QObject* parent = nullptr);
|
||||
GameListModel(float cover_scale, bool show_cover_titles, QObject* parent = nullptr);
|
||||
~GameListModel();
|
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
|
@ -83,6 +83,9 @@ public:
|
|||
void refreshCovers();
|
||||
void updateCacheSize(int width, int height);
|
||||
|
||||
Q_SIGNALS:
|
||||
void coverScaleChanged();
|
||||
|
||||
private:
|
||||
void loadCommonImages();
|
||||
void loadThemeSpecificImages();
|
||||
|
|
|
@ -115,9 +115,9 @@ GameListWidget::~GameListWidget() = default;
|
|||
|
||||
void GameListWidget::initialize()
|
||||
{
|
||||
m_model = new GameListModel(this);
|
||||
m_model->setCoverScale(Host::GetBaseFloatSettingValue("UI", "GameListCoverArtScale", 0.45f));
|
||||
m_model->setShowCoverTitles(Host::GetBaseBoolSettingValue("UI", "GameListShowCoverTitles", true));
|
||||
const float cover_scale = Host::GetBaseFloatSettingValue("UI", "GameListCoverArtScale", 0.45f);
|
||||
const bool show_cover_titles = Host::GetBaseBoolSettingValue("UI", "GameListShowCoverTitles", true);
|
||||
m_model = new GameListModel(cover_scale, show_cover_titles, this);
|
||||
m_model->updateCacheSize(width(), height());
|
||||
|
||||
m_sort_model = new GameListSortModel(m_model);
|
||||
|
@ -189,11 +189,9 @@ void GameListWidget::initialize()
|
|||
m_list_view->setItemAlignment(Qt::AlignHCenter);
|
||||
m_list_view->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
m_list_view->setFrameStyle(QFrame::NoFrame);
|
||||
m_list_view->setSpacing(m_model->getCoverArtSpacing());
|
||||
m_list_view->setVerticalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel);
|
||||
m_list_view->verticalScrollBar()->setSingleStep(15);
|
||||
|
||||
updateListFont();
|
||||
onCoverScaleChanged();
|
||||
|
||||
connect(m_list_view->selectionModel(), &QItemSelectionModel::currentChanged, this,
|
||||
&GameListWidget::onSelectionModelCurrentChanged);
|
||||
|
@ -201,6 +199,7 @@ void GameListWidget::initialize()
|
|||
connect(m_list_view, &GameListGridListView::zoomOut, this, &GameListWidget::gridZoomOut);
|
||||
connect(m_list_view, &QListView::activated, this, &GameListWidget::onListViewItemActivated);
|
||||
connect(m_list_view, &QListView::customContextMenuRequested, this, &GameListWidget::onListViewContextMenuRequested);
|
||||
connect(m_model, &GameListModel::coverScaleChanged, this, &GameListWidget::onCoverScaleChanged);
|
||||
|
||||
m_ui.stack->insertWidget(1, m_list_view);
|
||||
|
||||
|
@ -354,14 +353,23 @@ void GameListWidget::onTableViewHeaderSortIndicatorChanged(int, Qt::SortOrder)
|
|||
saveTableViewColumnSortSettings();
|
||||
}
|
||||
|
||||
void GameListWidget::onCoverScaleChanged()
|
||||
{
|
||||
m_model->updateCacheSize(width(), height());
|
||||
|
||||
m_list_view->setSpacing(m_model->getCoverArtSpacing());
|
||||
|
||||
QFont font;
|
||||
font.setPointSizeF(16.0f * m_model->getCoverScale());
|
||||
m_list_view->setFont(font);
|
||||
}
|
||||
|
||||
void GameListWidget::listZoom(float delta)
|
||||
{
|
||||
const float new_scale = std::clamp(m_model->getCoverScale() + delta, MIN_SCALE, MAX_SCALE);
|
||||
Host::SetBaseFloatSettingValue("UI", "GameListCoverArtScale", new_scale);
|
||||
Host::CommitBaseSettingChanges();
|
||||
m_model->setCoverScale(new_scale);
|
||||
m_model->updateCacheSize(width(), height());
|
||||
updateListFont();
|
||||
updateToolbar();
|
||||
}
|
||||
|
||||
|
@ -382,8 +390,6 @@ void GameListWidget::gridIntScale(int int_scale)
|
|||
Host::SetBaseFloatSettingValue("UI", "GameListCoverArtScale", new_scale);
|
||||
Host::CommitBaseSettingChanges();
|
||||
m_model->setCoverScale(new_scale);
|
||||
m_model->updateCacheSize(width(), height());
|
||||
updateListFont();
|
||||
updateToolbar();
|
||||
}
|
||||
|
||||
|
@ -439,13 +445,6 @@ void GameListWidget::setShowCoverTitles(bool enabled)
|
|||
emit layoutChange();
|
||||
}
|
||||
|
||||
void GameListWidget::updateListFont()
|
||||
{
|
||||
QFont font;
|
||||
font.setPointSizeF(16.0f * m_model->getCoverScale());
|
||||
m_list_view->setFont(font);
|
||||
}
|
||||
|
||||
void GameListWidget::updateToolbar()
|
||||
{
|
||||
const bool grid_view = isShowingGameGrid();
|
||||
|
|
|
@ -92,6 +92,7 @@ private Q_SLOTS:
|
|||
void onTableViewHeaderSortIndicatorChanged(int, Qt::SortOrder);
|
||||
void onListViewItemActivated(const QModelIndex& index);
|
||||
void onListViewContextMenuRequested(const QPoint& point);
|
||||
void onCoverScaleChanged();
|
||||
|
||||
public Q_SLOTS:
|
||||
void showGameList();
|
||||
|
@ -112,7 +113,6 @@ private:
|
|||
void loadTableViewColumnSortSettings();
|
||||
void saveTableViewColumnSortSettings();
|
||||
void listZoom(float delta);
|
||||
void updateListFont();
|
||||
void updateToolbar();
|
||||
|
||||
Ui::GameListWidget m_ui;
|
||||
|
|
Loading…
Reference in New Issue