MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / initialize

Method initialize

pcsx2-qt/GameList/GameListWidget.cpp:238–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236GameListWidget::~GameListWidget() = default;
237
238void GameListWidget::initialize()
239{
240 const float cover_scale = Host::GetBaseFloatSettingValue("UI", "GameListCoverArtScale", 0.45f);
241 const bool show_cover_titles = Host::GetBaseBoolSettingValue("UI", "GameListShowCoverTitles", true);
242 const bool show_full_cover_titles = Host::GetBaseBoolSettingValue("UI", "GameListShowFullCoverTitles", true);
243 m_model = new GameListModel(cover_scale, show_cover_titles, show_full_cover_titles, devicePixelRatioF(), this);
244 m_model->updateCacheSize(width(), height());
245
246 m_sort_model = new GameListSortModel(m_model);
247 m_sort_model->setSourceModel(m_model);
248
249 m_ui.setupUi(this);
250 m_ui.stack->installEventFilter(this);
251 m_ui.stack->setAutoFillBackground(false);
252
253 for (u32 type = 0; type < static_cast<u32>(GameList::EntryType::Count); type++)
254 {
255 if (type != static_cast<u32>(GameList::EntryType::Invalid))
256 {
257 m_ui.filterType->addItem(GameListModel::getIconForType(static_cast<GameList::EntryType>(type)),
258 GameList::EntryTypeToString(static_cast<GameList::EntryType>(type), true));
259 }
260 }
261
262 for (u32 region = 0; region < static_cast<u32>(GameList::Region::Count); region++)
263 {
264 m_ui.filterRegion->addItem(GameListModel::getIconForRegion(static_cast<GameList::Region>(region)),
265 GameList::RegionToString(static_cast<GameList::Region>(region), true));
266 }
267
268 connect(m_ui.viewGameList, &QPushButton::clicked, this, &GameListWidget::showGameList);
269 connect(m_ui.viewGameGrid, &QPushButton::clicked, this, &GameListWidget::showGameGrid);
270 connect(m_ui.gridScale, &QSlider::valueChanged, this, &GameListWidget::gridIntScale);
271 connect(m_ui.viewGridTitles, &QPushButton::toggled, this, &GameListWidget::setShowCoverTitles);
272 connect(m_ui.viewFullGridTitles, &QPushButton::toggled, this, &GameListWidget::setShowFullCoverTitles);
273 connect(m_ui.filterType, &QComboBox::currentIndexChanged, this, [this](int index) {
274 m_sort_model->setFilterType((index == 0) ? GameList::EntryType::Count : static_cast<GameList::EntryType>(index - 1));
275 });
276 connect(m_ui.filterRegion, &QComboBox::currentIndexChanged, this, [this](int index) {
277 m_sort_model->setFilterRegion((index == 0) ? GameList::Region::Count : static_cast<GameList::Region>(index - 1));
278 });
279 connect(m_ui.searchText, &QLineEdit::textChanged, this, [this](const QString& text) {
280 m_sort_model->setFilterName(text);
281 });
282
283 connect(new QShortcut(QKeySequence::Find, this), &QShortcut::activated, [this]() {
284 m_ui.searchText->setFocus();
285 });
286
287 m_table_view = new QTableView(m_ui.stack);
288 m_table_view->setModel(m_sort_model);
289 m_table_view->setSelectionMode(QAbstractItemView::SingleSelection);
290 m_table_view->setSelectionBehavior(QAbstractItemView::SelectRows);
291 m_table_view->setContextMenuPolicy(Qt::CustomContextMenu);
292 m_table_view->setAlternatingRowColors(true);
293 m_table_view->setMouseTracking(true);
294 m_table_view->setShowGrid(false);
295 m_table_view->setCurrentIndex(QModelIndex());

Callers

nothing calls this directly

Calls 8

updateCacheSizeMethod · 0.80
setFilterTypeMethod · 0.80
setFilterRegionMethod · 0.80
setFilterNameMethod · 0.80
setFocusMethod · 0.80
widthFunction · 0.50
heightFunction · 0.50
setupUiMethod · 0.45

Tested by

no test coverage detected