mirror of
https://github.com/stenzek/duckstation.git
synced 2026-02-11 00:44:32 +00:00
Qt: Move list background config logic to GameListWidget
This commit is contained in:
@@ -1482,6 +1482,22 @@ void GameListWidget::reloadThemeSpecificImages()
|
||||
m_model->reloadThemeSpecificImages();
|
||||
}
|
||||
|
||||
void GameListWidget::setBackgroundPath(const std::string_view path)
|
||||
{
|
||||
if (!path.empty())
|
||||
{
|
||||
Host::SetBaseStringSettingValue("UI", "GameListBackgroundPath",
|
||||
Path::MakeRelative(path, EmuFolders::DataRoot).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
Host::DeleteBaseSettingValue("UI", "GameListBackgroundPath");
|
||||
}
|
||||
|
||||
Host::CommitBaseSettingChanges();
|
||||
updateBackground(true);
|
||||
}
|
||||
|
||||
void GameListWidget::updateBackground(bool reload_image)
|
||||
{
|
||||
const bool had_image = !m_background_image.isNull();
|
||||
@@ -1529,6 +1545,11 @@ void GameListWidget::updateBackground(bool reload_image)
|
||||
});
|
||||
}
|
||||
|
||||
bool GameListWidget::hasBackground() const
|
||||
{
|
||||
return !m_background_image.isNull();
|
||||
}
|
||||
|
||||
void GameListWidget::onRefreshProgress(const QString& status, int current, int total, int entry_count, float time)
|
||||
{
|
||||
// Avoid spamming the UI on very short refresh (e.g. game exit).
|
||||
|
||||
@@ -242,7 +242,8 @@ public:
|
||||
void refresh(bool invalidate_cache);
|
||||
void cancelRefresh();
|
||||
void reloadThemeSpecificImages();
|
||||
void updateBackground(bool reload_image);
|
||||
void setBackgroundPath(const std::string_view path);
|
||||
bool hasBackground() const;
|
||||
|
||||
bool isShowingGameList() const;
|
||||
bool isShowingGameGrid() const;
|
||||
@@ -293,6 +294,7 @@ protected:
|
||||
|
||||
private:
|
||||
void setViewMode(int stack_index);
|
||||
void updateBackground(bool reload_image);
|
||||
|
||||
Ui::GameListWidget m_ui;
|
||||
|
||||
|
||||
@@ -539,7 +539,7 @@ void MainWindow::updateGameListRelatedActions()
|
||||
|
||||
const bool game_grid = m_game_list_widget->isShowingGameGrid();
|
||||
const bool game_list = m_game_list_widget->isShowingGameList();
|
||||
const bool has_background = Host::GetBaseStringSettingValue("UI", "GameListBackgroundPath") != "";
|
||||
const bool has_background = m_game_list_widget->hasBackground();
|
||||
|
||||
m_ui.menuSortBy->setDisabled(disable);
|
||||
m_ui.actionMergeDiscSets->setDisabled(disable);
|
||||
@@ -2741,18 +2741,13 @@ void MainWindow::onViewChangeGameListBackgroundTriggered()
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
|
||||
std::string relative_path = Path::MakeRelative(QDir::toNativeSeparators(path).toStdString(), EmuFolders::DataRoot);
|
||||
Host::SetBaseStringSettingValue("UI", "GameListBackgroundPath", relative_path.c_str());
|
||||
Host::CommitBaseSettingChanges();
|
||||
m_game_list_widget->updateBackground(true);
|
||||
m_game_list_widget->setBackgroundPath(QDir::toNativeSeparators(path).toStdString());
|
||||
m_ui.actionClearGameListBackground->setEnabled(true);
|
||||
}
|
||||
|
||||
void MainWindow::onViewClearGameListBackgroundTriggered()
|
||||
{
|
||||
Host::DeleteBaseSettingValue("UI", "GameListBackgroundPath");
|
||||
Host::CommitBaseSettingChanges();
|
||||
m_game_list_widget->updateBackground(true);
|
||||
m_game_list_widget->setBackgroundPath({});
|
||||
m_ui.actionClearGameListBackground->setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user