Qt: Add cover refresh menu option

This commit is contained in:
Connor McLaughlin 2020-09-24 00:08:29 +10:00
parent 43b0d84a1d
commit 692c2d4aff
6 changed files with 33 additions and 12 deletions

View file

@ -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<int>(static_cast<float>(COVER_ART_WIDTH) * m_cover_scale), 1);

View file

@ -54,6 +54,7 @@ public:
int getCoverArtWidth() const;
int getCoverArtHeight() const;
int getCoverArtSpacing() const;
void refreshCovers();
private:
void loadCommonImages();

View file

@ -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)

View file

@ -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);

View file

@ -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);

View file

@ -189,6 +189,7 @@
<addaction name="actionGridViewShowTitles"/>
<addaction name="actionGridViewZoomIn"/>
<addaction name="actionGridViewZoomOut"/>
<addaction name="actionGridViewRefreshCovers"/>
</widget>
<widget class="QMenu" name="menu_Tools">
<property name="title">
@ -658,7 +659,7 @@
</action>
<action name="actionViewGameList">
<property name="text">
<string>&amp;Game List</string>
<string>Game &amp;List</string>
</property>
</action>
<action name="actionViewSystemDisplay">
@ -676,7 +677,7 @@
</action>
<action name="actionViewGameGrid">
<property name="text">
<string>Game Grid</string>
<string>Game &amp;Grid</string>
</property>
</action>
<action name="actionGridViewShowTitles">
@ -692,7 +693,7 @@
</action>
<action name="actionGridViewZoomIn">
<property name="text">
<string>Zoom In (Grid View)</string>
<string>Zoom &amp;In (Grid View)</string>
</property>
<property name="shortcut">
<string>Ctrl++</string>
@ -700,12 +701,17 @@
</action>
<action name="actionGridViewZoomOut">
<property name="text">
<string>Zoom Out (Grid View)</string>
<string>Zoom &amp;Out (Grid View)</string>
</property>
<property name="shortcut">
<string>Ctrl+-</string>
</property>
</action>
<action name="actionGridViewRefreshCovers">
<property name="text">
<string>Refresh &amp;Covers (Grid View)</string>
</property>
</action>
</widget>
<resources>
<include location="resources/resources.qrc"/>