mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-06-20 18:09:29 -04:00
- Remove unnecessary icon update code (the UI reloads this stuff anyways); test on Windows please - Cleaned up a bunch of duplicated/unused code within the game list - Fix the game list constantly reloading on macOS * When you reconstruct the entire directory list on the watcher the directoryChanged signal fires on macOS--seems like a behavioral change that occurred somewhere in the 6.8 release cycle--and it would enter an infinite loop very quickly * To fix this, only the differences between the current and old watch list are accounted for on both ends. * Since this bug is now fixed, macOS uses Qt 6.11.1 now. Should theoretically improve our situation. - Fix the external content watcher crashing; the worker would attempt to read files that didn't exist without any bounds since its cache was still pointing to that file. This supersedes and replaces #4099. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4106 Reviewed-by: Lizzie <lizzie@eden-emu.dev> Reviewed-by: MaranBr <maranbr@eden-emu.dev>
104 lines
2.8 KiB
C++
104 lines
2.8 KiB
C++
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#include <QScroller>
|
|
#include <QScrollerProperties>
|
|
|
|
#include "qt_common/config/uisettings.h"
|
|
#include "qt_common/game_list/model.h"
|
|
#include "yuzu/game/common.h"
|
|
#include "yuzu/game/game_card.h"
|
|
#include "yuzu/game/game_grid.h"
|
|
|
|
GameGrid::GameGrid(QWidget* parent) : QListView{parent} {
|
|
m_gameCard = new GameCard(this);
|
|
setItemDelegate(m_gameCard);
|
|
|
|
setViewMode(QListView::ListMode);
|
|
setResizeMode(QListView::Fixed);
|
|
setUniformItemSizes(true);
|
|
setSelectionMode(QAbstractItemView::SingleSelection);
|
|
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
|
setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
|
|
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
|
setGridSize(QSize(140, 160));
|
|
m_gameCard->setSize(gridSize(), 0, 4);
|
|
|
|
setSpacing(10);
|
|
setWordWrap(true);
|
|
setTextElideMode(Qt::ElideRight);
|
|
setFlow(QListView::LeftToRight);
|
|
setWrapping(true);
|
|
}
|
|
|
|
void GameGrid::SetModel(GameListModel* model) {
|
|
QListView::setModel(model);
|
|
UpdateIconSize();
|
|
}
|
|
|
|
void GameGrid::ApplyFilter(const QString& edit_filter_text, GameListModel* model) {
|
|
int row_count = model->rowCount();
|
|
|
|
for (int i = 0; i < row_count; ++i) {
|
|
QStandardItem* item = model->item(i, 0);
|
|
if (!item)
|
|
continue;
|
|
|
|
if (Yuzu::FilterMatches(edit_filter_text, item)) {
|
|
setRowHidden(i, false);
|
|
} else {
|
|
setRowHidden(i, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
void GameGrid::UpdateIconSize() {
|
|
const u32 icon_size = UISettings::values.game_icon_size.GetValue();
|
|
|
|
int heightMargin = 0;
|
|
int widthMargin = 80;
|
|
|
|
if (UISettings::values.show_game_name) {
|
|
switch (icon_size) {
|
|
case 128:
|
|
heightMargin = 65;
|
|
break;
|
|
case 0:
|
|
widthMargin = 120;
|
|
heightMargin = 120;
|
|
break;
|
|
case 64:
|
|
heightMargin = 77;
|
|
break;
|
|
case 32:
|
|
case 256:
|
|
heightMargin = 81;
|
|
break;
|
|
}
|
|
} else {
|
|
widthMargin = 24;
|
|
heightMargin = 24;
|
|
}
|
|
|
|
const int view_width = viewport()->width();
|
|
|
|
const double spacing = 0.01;
|
|
const int min_item_width = icon_size + widthMargin;
|
|
|
|
int columns = std::max(1, (view_width - 16) / min_item_width);
|
|
int stretched_width = ((view_width) - (spacing * (columns - 1))) / columns;
|
|
|
|
QSize grid_size(stretched_width, icon_size + heightMargin);
|
|
if (gridSize() != grid_size) {
|
|
setUpdatesEnabled(false);
|
|
|
|
setGridSize(grid_size);
|
|
m_gameCard->setSize(grid_size, stretched_width - min_item_width, columns);
|
|
|
|
setUpdatesEnabled(true);
|
|
}
|
|
}
|