From 692c2d4aff32e7fa60dc4ce7e3a8f18fe0d99678 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Thu, 24 Sep 2020 00:08:29 +1000 Subject: [PATCH] Qt: Add cover refresh menu option --- src/duckstation-qt/gamelistmodel.cpp | 6 ++++++ src/duckstation-qt/gamelistmodel.h | 1 + src/duckstation-qt/gamelistwidget.cpp | 13 +++++++++---- src/duckstation-qt/gamelistwidget.h | 5 +++-- src/duckstation-qt/mainwindow.cpp | 6 ++++-- src/duckstation-qt/mainwindow.ui | 14 ++++++++++---- 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/duckstation-qt/gamelistmodel.cpp b/src/duckstation-qt/gamelistmodel.cpp index 2ff16b600..685c6a7d8 100644 --- a/src/duckstation-qt/gamelistmodel.cpp +++ b/src/duckstation-qt/gamelistmodel.cpp @@ -97,6 +97,12 @@ void GameListModel::setCoverScale(float scale) m_cover_scale = scale; } +void GameListModel::refreshCovers() +{ + m_cover_pixmap_cache.clear(); + refresh(); +} + int GameListModel::getCoverArtWidth() const { return std::max(static_cast(static_cast(COVER_ART_WIDTH) * m_cover_scale), 1); diff --git a/src/duckstation-qt/gamelistmodel.h b/src/duckstation-qt/gamelistmodel.h index 3ff3209d1..216fd0a86 100644 --- a/src/duckstation-qt/gamelistmodel.h +++ b/src/duckstation-qt/gamelistmodel.h @@ -54,6 +54,7 @@ public: int getCoverArtWidth() const; int getCoverArtHeight() const; int getCoverArtSpacing() const; + void refreshCovers(); private: void loadCommonImages(); diff --git a/src/duckstation-qt/gamelistwidget.cpp b/src/duckstation-qt/gamelistwidget.cpp index 95049cf39..c733e8fbb 100644 --- a/src/duckstation-qt/gamelistwidget.cpp +++ b/src/duckstation-qt/gamelistwidget.cpp @@ -92,8 +92,8 @@ void GameListWidget::initialize(QtHostInterface* host_interface) connect(m_list_view->selectionModel(), &QItemSelectionModel::currentChanged, this, &GameListWidget::onSelectionModelCurrentChanged); - connect(m_list_view, &GameListGridListView::zoomIn, this, &GameListWidget::listZoomIn); - connect(m_list_view, &GameListGridListView::zoomOut, this, &GameListWidget::listZoomOut); + connect(m_list_view, &GameListGridListView::zoomIn, this, &GameListWidget::gridZoomIn); + connect(m_list_view, &GameListGridListView::zoomOut, this, &GameListWidget::gridZoomOut); connect(m_list_view, &QListView::doubleClicked, this, &GameListWidget::onListViewItemDoubleClicked); connect(m_list_view, &QListView::customContextMenuRequested, this, &GameListWidget::onListViewContextMenuRequested); @@ -218,16 +218,21 @@ void GameListWidget::listZoom(float delta) m_model->refresh(); } -void GameListWidget::listZoomIn() +void GameListWidget::gridZoomIn() { listZoom(0.05f); } -void GameListWidget::listZoomOut() +void GameListWidget::gridZoomOut() { listZoom(-0.05f); } +void GameListWidget::refreshGridCovers() +{ + m_model->refreshCovers(); +} + void GameListWidget::showGameList() { if (currentIndex() == 0) diff --git a/src/duckstation-qt/gamelistwidget.h b/src/duckstation-qt/gamelistwidget.h index 2aba47573..64876ff01 100644 --- a/src/duckstation-qt/gamelistwidget.h +++ b/src/duckstation-qt/gamelistwidget.h @@ -60,8 +60,9 @@ public Q_SLOTS: void showGameList(); void showGameGrid(); void setShowCoverTitles(bool enabled); - void listZoomIn(); - void listZoomOut(); + void gridZoomIn(); + void gridZoomOut(); + void refreshGridCovers(); protected: void resizeEvent(QResizeEvent* event); diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 541eb6c16..ed285f7ba 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -698,12 +698,14 @@ void MainWindow::connectSignals() connect(m_ui.actionGridViewShowTitles, &QAction::triggered, m_game_list_widget, &GameListWidget::setShowCoverTitles); connect(m_ui.actionGridViewZoomIn, &QAction::triggered, m_game_list_widget, [this]() { if (isShowingGameList()) - m_game_list_widget->listZoomIn(); + m_game_list_widget->gridZoomIn(); }); connect(m_ui.actionGridViewZoomOut, &QAction::triggered, m_game_list_widget, [this]() { if (isShowingGameList()) - m_game_list_widget->listZoomOut(); + m_game_list_widget->gridZoomOut(); }); + connect(m_ui.actionGridViewRefreshCovers, &QAction::triggered, m_game_list_widget, + &GameListWidget::refreshGridCovers); connect(m_host_interface, &QtHostInterface::errorReported, this, &MainWindow::reportError, Qt::BlockingQueuedConnection); diff --git a/src/duckstation-qt/mainwindow.ui b/src/duckstation-qt/mainwindow.ui index f8a6e0dfa..c73e064be 100644 --- a/src/duckstation-qt/mainwindow.ui +++ b/src/duckstation-qt/mainwindow.ui @@ -189,6 +189,7 @@ + @@ -658,7 +659,7 @@ - &Game List + Game &List @@ -676,7 +677,7 @@ - Game Grid + Game &Grid @@ -692,7 +693,7 @@ - Zoom In (Grid View) + Zoom &In (Grid View) Ctrl++ @@ -700,12 +701,17 @@ - Zoom Out (Grid View) + Zoom &Out (Grid View) Ctrl+- + + + Refresh &Covers (Grid View) + +