From 029cc77c4bb78b41278602e4adc19a9a3267c98c Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Sun, 22 Sep 2019 17:27:01 +0200 Subject: [PATCH 1/4] Backport changes from yuzu-emu/yuzu#2444 --- src/citra_qt/configuration/config.cpp | 2 +- src/citra_qt/game_list.cpp | 95 +++++++++++++-------------- src/citra_qt/game_list.h | 13 ++-- src/citra_qt/game_list_p.h | 24 +++---- src/citra_qt/game_list_worker.cpp | 8 +-- src/citra_qt/game_list_worker.h | 5 +- src/citra_qt/main.cpp | 18 +++-- src/citra_qt/main.h | 2 +- src/citra_qt/uisettings.h | 3 +- 9 files changed, 83 insertions(+), 87 deletions(-) diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index 4adc8e5ee..7189ccba0 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -609,7 +609,7 @@ void Config::SaveValues() { qt_config->beginWriteArray("gamedirs"); for (int i = 0; i < UISettings::values.game_dirs.size(); ++i) { qt_config->setArrayIndex(i); - const auto& game_dir = UISettings::values.game_dirs.at(i); + const auto& game_dir = UISettings::values.game_dirs[i]; WriteSetting("path", game_dir.path); WriteSetting("deep_scan", game_dir.deep_scan, false); WriteSetting("expanded", game_dir.expanded, true); diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index e7fbfba9c..933077a7e 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -99,16 +99,16 @@ void GameListSearchField::setFilterResult(int visible, int total) { QString("%1 %2 %3 %4").arg(visible).arg(result_of_text).arg(total).arg(result_text)); } -QString GameList::getLastFilterResultItem() { +QString GameList::getLastFilterResultItem() const { QStandardItem* folder; QStandardItem* child; QString file_path; - int folderCount = item_model->rowCount(); + const int folderCount = item_model->rowCount(); for (int i = 0; i < folderCount; ++i) { folder = item_model->item(i, 0); - QModelIndex folder_index = folder->index(); - int childrenCount = folder->rowCount(); - for (int j = 0; j < childrenCount; ++j) { + const QModelIndex folder_index = folder->index(); + const int children_count = folder->rowCount(); + for (int j = 0; j < children_count; ++j) { if (!tree_view->isRowHidden(j, folder_index)) { child = folder->child(j, 0); file_path = child->data(GameListItemPath::FullPathRole).toString(); @@ -175,7 +175,7 @@ static bool ContainsAllWords(const QString& haystack, const QString& userinput) // Syncs the expanded state of Game Directories with settings to persist across sessions void GameList::onItemExpanded(const QModelIndex& item) { - GameListItemType type = item.data(GameListItem::TypeRole).value(); + const auto type = item.data(GameListItem::TypeRole).value(); if (type == GameListItemType::CustomDir || type == GameListItemType::InstalledDir || type == GameListItemType::SystemDir) item.data(GameListDir::GameDirRole).value()->expanded = @@ -184,32 +184,32 @@ void GameList::onItemExpanded(const QModelIndex& item) { // Event in order to filter the gamelist after editing the searchfield void GameList::onTextChanged(const QString& newText) { - int folderCount = tree_view->model()->rowCount(); + const int folderCount = tree_view->model()->rowCount(); QString edit_filter_text = newText.toLower(); QStandardItem* folder; - int childrenTotal = 0; + int children_total = 0; // If the searchfield is empty every item is visible // Otherwise the filter gets applied if (edit_filter_text.isEmpty()) { for (int i = 0; i < folderCount; ++i) { folder = item_model->item(i, 0); - QModelIndex folder_index = folder->index(); - int childrenCount = folder->rowCount(); - for (int j = 0; j < childrenCount; ++j) { - ++childrenTotal; + const QModelIndex folder_index = folder->index(); + const int children_count = folder->rowCount(); + for (int j = 0; j < children_count; ++j) { + ++children_total; tree_view->setRowHidden(j, folder_index, false); } } - search_field->setFilterResult(childrenTotal, childrenTotal); + search_field->setFilterResult(children_total, children_total); } else { int result_count = 0; for (int i = 0; i < folderCount; ++i) { folder = item_model->item(i, 0); - QModelIndex folder_index = folder->index(); - int childrenCount = folder->rowCount(); - for (int j = 0; j < childrenCount; ++j) { - ++childrenTotal; + const QModelIndex folder_index = folder->index(); + const int children_count = folder->rowCount(); + for (int j = 0; j < children_count; ++j) { + ++children_total; const QStandardItem* child = folder->child(j, 0); const QString file_path = child->data(GameListItemPath::FullPathRole).toString().toLower(); @@ -231,7 +231,7 @@ void GameList::onTextChanged(const QString& newText) { } else { tree_view->setRowHidden(j, folder_index, true); } - search_field->setFilterResult(result_count, childrenTotal); + search_field->setFilterResult(result_count, children_total); } } } @@ -251,7 +251,7 @@ void GameList::onUpdateThemedIcons() { case GameListItemType::CustomDir: { const UISettings::GameDir* game_dir = child->data(GameListDir::GameDirRole).value(); - QString icon_name = QFileInfo::exists(game_dir->path) ? "folder" : "bad_folder"; + const QString icon_name = QFileInfo::exists(game_dir->path) ? "folder" : "bad_folder"; child->setData(QIcon::fromTheme(icon_name).pixmap(48), Qt::DecorationRole); break; } @@ -353,14 +353,14 @@ void GameList::AddEntry(const QList& entry_items, GameListDir* p } void GameList::ValidateEntry(const QModelIndex& item) { - auto selected = item.sibling(item.row(), 0); + const auto selected = item.sibling(item.row(), 0); switch (selected.data(GameListItem::TypeRole).value()) { case GameListItemType::Game: { - QString file_path = selected.data(GameListItemPath::FullPathRole).toString(); + const QString file_path = selected.data(GameListItemPath::FullPathRole).toString(); if (file_path.isEmpty()) return; - QFileInfo file_info(file_path); + const QFileInfo file_info(file_path); if (!file_info.exists() || file_info.isDir()) return; // Users usually want to run a different game after closing one @@ -374,10 +374,10 @@ void GameList::ValidateEntry(const QModelIndex& item) { } } -bool GameList::isEmpty() { +bool GameList::isEmpty() const { for (int i = 0; i < item_model->rowCount(); i++) { const QStandardItem* child = item_model->invisibleRootItem()->child(i); - GameListItemType type = static_cast(child->type()); + const auto type = static_cast(child->type()); if (!child->hasChildren() && (type == GameListItemType::InstalledDir || type == GameListItemType::SystemDir)) { item_model->invisibleRootItem()->removeRow(child->row()); @@ -408,16 +408,13 @@ void GameList::DonePopulating(QStringList watch_list) { QCoreApplication::processEvents(); } tree_view->setEnabled(true); - int folderCount = tree_view->model()->rowCount(); - int childrenTotal = 0; + const int folderCount = tree_view->model()->rowCount(); + int children_total = 0; for (int i = 0; i < folderCount; ++i) { - int childrenCount = item_model->item(i, 0)->rowCount(); - for (int j = 0; j < childrenCount; ++j) { - ++childrenTotal; - } + children_total += item_model->item(i, 0)->rowCount(); } - search_field->setFilterResult(childrenTotal, childrenTotal); - if (childrenTotal > 0) { + search_field->setFilterResult(children_total, children_total); + if (children_total > 0) { search_field->setFocus(); } @@ -429,7 +426,7 @@ void GameList::PopupContextMenu(const QPoint& menu_location) { if (!item.isValid()) return; - auto selected = item.sibling(item.row(), 0); + const auto selected = item.sibling(item.row(), 0); QMenu context_menu; switch (selected.data(GameListItem::TypeRole).value()) { case GameListItemType::Game: @@ -528,18 +525,18 @@ void GameList::AddPermDirPopup(QMenu& context_menu, QModelIndex selected) { QAction* move_down = context_menu.addAction(tr(u8"\U000025bc Move Down ")); QAction* open_directory_location = context_menu.addAction(tr("Open Directory Location")); - int row = selected.row(); + const int row = selected.row(); move_up->setEnabled(row > 0); move_down->setEnabled(row < item_model->rowCount() - 2); connect(move_up, &QAction::triggered, [this, selected, row, &game_dir] { // find the indices of the items in settings and swap them - UISettings::values.game_dirs.swap( - UISettings::values.game_dirs.indexOf(game_dir), - UISettings::values.game_dirs.indexOf(*selected.sibling(selected.row() - 1, 0) - .data(GameListDir::GameDirRole) - .value())); + std::swap(UISettings::values.game_dirs[UISettings::values.game_dirs.indexOf(game_dir)], + UISettings::values.game_dirs[UISettings::values.game_dirs.indexOf( + *selected.sibling(row - 1, 0) + .data(GameListDir::GameDirRole) + .value())]); // move the treeview items QList item = item_model->takeRow(row); item_model->invisibleRootItem()->insertRow(row - 1, item); @@ -548,13 +545,13 @@ void GameList::AddPermDirPopup(QMenu& context_menu, QModelIndex selected) { connect(move_down, &QAction::triggered, [this, selected, row, &game_dir] { // find the indices of the items in settings and swap them - UISettings::values.game_dirs.swap( - UISettings::values.game_dirs.indexOf(game_dir), - UISettings::values.game_dirs.indexOf(*selected.sibling(selected.row() + 1, 0) - .data(GameListDir::GameDirRole) - .value())); + std::swap(UISettings::values.game_dirs[UISettings::values.game_dirs.indexOf(game_dir)], + UISettings::values.game_dirs[UISettings::values.game_dirs.indexOf( + *selected.sibling(row + 1, 0) + .data(GameListDir::GameDirRole) + .value())]); // move the treeview items - QList item = item_model->takeRow(row); + const QList item = item_model->takeRow(row); item_model->invisibleRootItem()->insertRow(row + 1, item); tree_view->setExpanded(selected, game_dir.expanded); }); @@ -609,7 +606,7 @@ QStandardItemModel* GameList::GetModel() const { return item_model; } -void GameList::PopulateAsync(QList& game_dirs) { +void GameList::PopulateAsync(QVector& game_dirs) { tree_view->setEnabled(false); // Delete any rows that might already exist if we're repopulating item_model->removeRows(0, item_model->rowCount()); @@ -677,9 +674,7 @@ QString GameList::FindGameByProgramID(QStandardItem* current_item, u64 program_i } GameListPlaceholder::GameListPlaceholder(GMainWindow* parent) : QWidget{parent} { - this->main_window = parent; - - connect(main_window, &GMainWindow::UpdateThemedIcons, this, + connect(parent, &GMainWindow::UpdateThemedIcons, this, &GameListPlaceholder::onUpdateThemedIcons); layout = new QVBoxLayout; @@ -688,7 +683,7 @@ GameListPlaceholder::GameListPlaceholder(GMainWindow* parent) : QWidget{parent} layout->setAlignment(Qt::AlignCenter); image->setPixmap(QIcon::fromTheme("plus_folder").pixmap(200)); - text->setText(tr("Double-click to add a new folder to the game list ")); + text->setText(tr("Double-click to add a new folder to the game list")); QFont font = text->font(); font.setPointSize(20); text->setFont(font); diff --git a/src/citra_qt/game_list.h b/src/citra_qt/game_list.h index 2797dd09d..2491d2c00 100644 --- a/src/citra_qt/game_list.h +++ b/src/citra_qt/game_list.h @@ -4,8 +4,10 @@ #pragma once +#include #include #include +#include #include #include "citra_qt/compatibility_list.h" #include "common/common_types.h" @@ -19,8 +21,6 @@ class QFileSystemWatcher; class QHBoxLayout; class QLabel; class QLineEdit; -template -class QList; class QModelIndex; class QStandardItem; class QStandardItemModel; @@ -46,15 +46,15 @@ public: explicit GameList(GMainWindow* parent = nullptr); ~GameList() override; - QString getLastFilterResultItem(); + QString getLastFilterResultItem() const; void clearFilter(); void setFilterFocus(); void setFilterVisible(bool visibility); void setDirectoryWatcherEnabled(bool enabled); - bool isEmpty(); + bool isEmpty() const; void LoadCompatibilityList(); - void PopulateAsync(QList& game_dirs); + void PopulateAsync(QVector& game_dirs); void SaveInterfaceLayout(); void LoadInterfaceLayout(); @@ -73,7 +73,7 @@ signals: void OpenFolderRequested(u64 program_id, GameListOpenTarget target); void NavigateToGamedbEntryRequested(u64 program_id, const CompatibilityList& compatibility_list); - void OpenDirectory(QString directory); + void OpenDirectory(const QString& directory); void AddDirectory(); void ShowList(bool show); void PopulatingCompleted(); @@ -127,7 +127,6 @@ protected: void mouseDoubleClickEvent(QMouseEvent* event) override; private: - GMainWindow* main_window = nullptr; QVBoxLayout* layout = nullptr; QLabel* image = nullptr; QLabel* text = nullptr; diff --git a/src/citra_qt/game_list_p.h b/src/citra_qt/game_list_p.h index 1bb26f759..fb64c34c0 100644 --- a/src/citra_qt/game_list_p.h +++ b/src/citra_qt/game_list_p.h @@ -350,18 +350,20 @@ public: UISettings::GameDir* game_dir = &directory; setData(QVariant::fromValue(game_dir), GameDirRole); - int icon_size = IconSizes.at(UISettings::values.game_list_icon_size); + const int icon_size = IconSizes.at(UISettings::values.game_list_icon_size); switch (dir_type) { case GameListItemType::InstalledDir: - setData(QIcon::fromTheme("sd_card").pixmap(icon_size), Qt::DecorationRole); - setData("Installed Titles", Qt::DisplayRole); + setData(QIcon::fromTheme(QStringLiteral("sd_card")).pixmap(icon_size), + Qt::DecorationRole); + setData(QObject::tr("Installed Titles"), Qt::DisplayRole); break; case GameListItemType::SystemDir: - setData(QIcon::fromTheme("chip").pixmap(icon_size), Qt::DecorationRole); - setData("System Titles", Qt::DisplayRole); + setData(QIcon::fromTheme(QStringLiteral("chip")).pixmap(icon_size), Qt::DecorationRole); + setData(QObject::tr("System Titles"), Qt::DisplayRole); break; case GameListItemType::CustomDir: - QString icon_name = QFileInfo::exists(game_dir->path) ? "folder" : "bad_folder"; + QString icon_name = QFileInfo::exists(game_dir->path) ? QStringLiteral("folder") + : QStringLiteral("bad_folder"); setData(QIcon::fromTheme(icon_name).pixmap(icon_size), Qt::DecorationRole); setData(game_dir->path, Qt::DisplayRole); break; @@ -382,8 +384,8 @@ public: setData(type(), TypeRole); int icon_size = IconSizes.at(UISettings::values.game_list_icon_size); - setData(QIcon::fromTheme("plus").pixmap(icon_size), Qt::DecorationRole); - setData("Add New Game Directory", Qt::DisplayRole); + setData(QIcon::fromTheme(QStringLiteral("plus")).pixmap(icon_size), Qt::DecorationRole); + setData(QObject::tr("Add New Game Directory"), Qt::DisplayRole); } int type() const override { @@ -409,9 +411,6 @@ public: void clear(); void setFocus(); - int visible; - int total; - private: class KeyReleaseEater : public QObject { public: @@ -425,6 +424,9 @@ private: // EventFilter in order to process systemkeys while editing the searchfield bool eventFilter(QObject* obj, QEvent* event) override; }; + int visible; + int total; + QHBoxLayout* layout_filter = nullptr; QTreeView* tree_view = nullptr; QLabel* label_filter = nullptr; diff --git a/src/citra_qt/game_list_worker.cpp b/src/citra_qt/game_list_worker.cpp index 42d748ece..13ba8c676 100644 --- a/src/citra_qt/game_list_worker.cpp +++ b/src/citra_qt/game_list_worker.cpp @@ -26,7 +26,7 @@ bool HasSupportedFileExtension(const std::string& file_name) { } } // Anonymous namespace -GameListWorker::GameListWorker(QList& game_dirs, +GameListWorker::GameListWorker(QVector& game_dirs, const CompatibilityList& compatibility_list) : game_dirs(game_dirs), compatibility_list(compatibility_list) {} @@ -134,7 +134,7 @@ void GameListWorker::run() { "00040002"; watch_list.append(games_path); watch_list.append(demos_path); - GameListDir* game_list_dir = new GameListDir(game_dir, GameListItemType::InstalledDir); + auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::InstalledDir); emit DirEntryReady({game_list_dir}); AddFstEntriesToGameList(games_path.toStdString(), 2, game_list_dir); AddFstEntriesToGameList(demos_path.toStdString(), 2, game_list_dir); @@ -143,12 +143,12 @@ void GameListWorker::run() { QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)) + "00000000000000000000000000000000/title/00040010"; watch_list.append(path); - GameListDir* game_list_dir = new GameListDir(game_dir, GameListItemType::SystemDir); + auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SystemDir); emit DirEntryReady({game_list_dir}); AddFstEntriesToGameList(path.toStdString(), 2, game_list_dir); } else { watch_list.append(game_dir.path); - GameListDir* game_list_dir = new GameListDir(game_dir); + auto* const game_list_dir = new GameListDir(game_dir); emit DirEntryReady({game_list_dir}); AddFstEntriesToGameList(game_dir.path.toStdString(), game_dir.deep_scan ? 256 : 0, game_list_dir); diff --git a/src/citra_qt/game_list_worker.h b/src/citra_qt/game_list_worker.h index a955e6376..91adbd212 100644 --- a/src/citra_qt/game_list_worker.h +++ b/src/citra_qt/game_list_worker.h @@ -13,6 +13,7 @@ #include #include #include +#include #include "citra_qt/compatibility_list.h" #include "common/common_types.h" @@ -26,7 +27,7 @@ class GameListWorker : public QObject, public QRunnable { Q_OBJECT public: - GameListWorker(QList& game_dirs, + GameListWorker(QVector& game_dirs, const CompatibilityList& compatibility_list); ~GameListWorker() override; @@ -57,6 +58,6 @@ private: QStringList watch_list; const CompatibilityList& compatibility_list; - QList& game_dirs; + QVector& game_dirs; std::atomic_bool stop_processing; }; diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 599420fae..7fa5fe388 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -1111,18 +1111,16 @@ void GMainWindow::OnGameListNavigateToGamedbEntry(u64 program_id, QDesktopServices::openUrl(QUrl("https://citra-emu.org/game/" + directory)); } -void GMainWindow::OnGameListOpenDirectory(QString directory) { +void GMainWindow::OnGameListOpenDirectory(const QString& directory) { QString path; if (directory == "INSTALLED") { - path = - QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir).c_str() + - std::string("Nintendo " - "3DS/00000000000000000000000000000000/" - "00000000000000000000000000000000/title/00040000")); + path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir) + + "Nintendo " + "3DS/00000000000000000000000000000000/" + "00000000000000000000000000000000/title/00040000"); } else if (directory == "SYSTEM") { - path = - QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir).c_str() + - std::string("00000000000000000000000000000000/title/00040010")); + path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + + "00000000000000000000000000000000/title/00040010"); } else { path = directory; } @@ -1134,7 +1132,7 @@ void GMainWindow::OnGameListOpenDirectory(QString directory) { } void GMainWindow::OnGameListAddDirectory() { - QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory")); + const QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory")); if (dir_path.isEmpty()) return; UISettings::GameDir game_dir{dir_path, false, true}; diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index 3ff40f976..7b6a1b367 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h @@ -161,7 +161,7 @@ private slots: void OnGameListOpenFolder(u64 program_id, GameListOpenTarget target); void OnGameListNavigateToGamedbEntry(u64 program_id, const CompatibilityList& compatibility_list); - void OnGameListOpenDirectory(QString path); + void OnGameListOpenDirectory(const QString& directory); void OnGameListAddDirectory(); void OnGameListShowList(bool show); void OnMenuLoadFile(); diff --git a/src/citra_qt/uisettings.h b/src/citra_qt/uisettings.h index ef56ea722..0736db6ff 100644 --- a/src/citra_qt/uisettings.h +++ b/src/citra_qt/uisettings.h @@ -12,6 +12,7 @@ #include #include #include +#include #include "common/common_types.h" namespace UISettings { @@ -100,7 +101,7 @@ struct Values { QString video_dumping_path; QString game_dir_deprecated; bool game_dir_deprecated_deepscan; - QList game_dirs; + QVector game_dirs; QStringList recent_files; QString language; From 0a3f75c25ff5a61dd210c320f163c6844a5d29fe Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Sun, 22 Sep 2019 17:40:04 +0200 Subject: [PATCH 2/4] Backport changes from yuzu-emu/yuzu#2806 --- src/core/perf_stats.cpp | 12 +++++++----- src/core/perf_stats.h | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp index 8015ef731..94d6c17ca 100644 --- a/src/core/perf_stats.cpp +++ b/src/core/perf_stats.cpp @@ -33,13 +33,13 @@ PerfStats::~PerfStats() { return; } - std::time_t t = std::time(nullptr); + const std::time_t t = std::time(nullptr); std::ostringstream stream; std::copy(perf_history.begin() + IgnoreFrames, perf_history.begin() + current_index, std::ostream_iterator(stream, "\n")); - std::string path = FileUtil::GetUserPath(FileUtil::UserPath::LogDir); + const std::string& path = FileUtil::GetUserPath(FileUtil::UserPath::LogDir); // %F Date format expanded is "%Y-%m-%d" - std::string filename = + const std::string filename = fmt::format("{}/{:%F-%H-%M}_{:016X}.csv", path, *std::localtime(&t), title_id); FileUtil::IOFile file(filename, "w"); file.WriteString(stream.str()); @@ -74,11 +74,13 @@ void PerfStats::EndGameFrame() { } double PerfStats::GetMeanFrametime() { + std::lock_guard lock{object_mutex}; + if (current_index <= IgnoreFrames) { return 0; } - double sum = std::accumulate(perf_history.begin() + IgnoreFrames, - perf_history.begin() + current_index, 0); + const double sum = std::accumulate(perf_history.begin() + IgnoreFrames, + perf_history.begin() + current_index, 0); return sum / (current_index - IgnoreFrames); } diff --git a/src/core/perf_stats.h b/src/core/perf_stats.h index e0b023059..0ef5168fa 100644 --- a/src/core/perf_stats.h +++ b/src/core/perf_stats.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "common/common_types.h" #include "common/thread.h" From a5d880979ce1c6a07b296eac6028769cae697ee1 Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Sun, 22 Sep 2019 17:47:18 +0200 Subject: [PATCH 3/4] Backport changes from yuzu-emu/yuzu#2057 --- .../configuration/configure_graphics.cpp | 24 ++++++++++--------- .../configuration/configure_graphics.h | 2 ++ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/citra_qt/configuration/configure_graphics.cpp b/src/citra_qt/configuration/configure_graphics.cpp index ff8af9fe8..191450f74 100644 --- a/src/citra_qt/configuration/configure_graphics.cpp +++ b/src/citra_qt/configuration/configure_graphics.cpp @@ -49,11 +49,7 @@ ConfigureGraphics::ConfigureGraphics(QWidget* parent) if (!new_bg_color.isValid()) { return; } - bg_color = new_bg_color; - QPixmap pixmap(ui->bg_button->size()); - pixmap.fill(bg_color); - const QIcon color_icon(pixmap); - ui->bg_button->setIcon(color_icon); + UpdateBackgroundColorButton(new_bg_color); }); } @@ -71,12 +67,8 @@ void ConfigureGraphics::SetConfiguration() { ui->toggle_linear_filter->setChecked(Settings::values.filter_mode); ui->layout_combobox->setCurrentIndex(static_cast(Settings::values.layout_option)); ui->swap_screen->setChecked(Settings::values.swap_screen); - bg_color = QColor::fromRgbF(Settings::values.bg_red, Settings::values.bg_green, - Settings::values.bg_blue); - QPixmap pixmap(ui->bg_button->size()); - pixmap.fill(bg_color); - const QIcon color_icon(pixmap); - ui->bg_button->setIcon(color_icon); + UpdateBackgroundColorButton(QColor::fromRgbF(Settings::values.bg_red, Settings::values.bg_green, + Settings::values.bg_blue)); } void ConfigureGraphics::ApplyConfiguration() { @@ -117,6 +109,16 @@ void ConfigureGraphics::updateShaders(bool anaglyph) { } } +void ConfigureGraphics::UpdateBackgroundColorButton(QColor color) { + bg_color = color; + + QPixmap pixmap(ui->bg_button->size()); + pixmap.fill(bg_color); + + const QIcon color_icon(pixmap); + ui->bg_button->setIcon(color_icon); +} + void ConfigureGraphics::RetranslateUI() { ui->retranslateUi(this); } diff --git a/src/citra_qt/configuration/configure_graphics.h b/src/citra_qt/configuration/configure_graphics.h index f2fb3b0b0..9f7cc5565 100644 --- a/src/citra_qt/configuration/configure_graphics.h +++ b/src/citra_qt/configuration/configure_graphics.h @@ -22,6 +22,8 @@ public: void RetranslateUI(); void SetConfiguration(); + void UpdateBackgroundColorButton(QColor color); + std::unique_ptr ui; QColor bg_color; From 1e93f568b5f1b9a754030b39d24de36ff77f7d7f Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Sun, 22 Sep 2019 20:48:32 +0200 Subject: [PATCH 4/4] Address review comments --- src/citra_qt/configuration/configure_graphics.cpp | 2 +- src/citra_qt/configuration/configure_graphics.h | 2 +- src/citra_qt/game_list.h | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/citra_qt/configuration/configure_graphics.cpp b/src/citra_qt/configuration/configure_graphics.cpp index 191450f74..8edcdb491 100644 --- a/src/citra_qt/configuration/configure_graphics.cpp +++ b/src/citra_qt/configuration/configure_graphics.cpp @@ -109,7 +109,7 @@ void ConfigureGraphics::updateShaders(bool anaglyph) { } } -void ConfigureGraphics::UpdateBackgroundColorButton(QColor color) { +void ConfigureGraphics::UpdateBackgroundColorButton(const QColor& color) { bg_color = color; QPixmap pixmap(ui->bg_button->size()); diff --git a/src/citra_qt/configuration/configure_graphics.h b/src/citra_qt/configuration/configure_graphics.h index 9f7cc5565..e3e6c6a18 100644 --- a/src/citra_qt/configuration/configure_graphics.h +++ b/src/citra_qt/configuration/configure_graphics.h @@ -22,7 +22,7 @@ public: void RetranslateUI(); void SetConfiguration(); - void UpdateBackgroundColorButton(QColor color); + void UpdateBackgroundColorButton(const QColor& color); std::unique_ptr ui; QColor bg_color; diff --git a/src/citra_qt/game_list.h b/src/citra_qt/game_list.h index 2491d2c00..bef23f31b 100644 --- a/src/citra_qt/game_list.h +++ b/src/citra_qt/game_list.h @@ -4,7 +4,6 @@ #pragma once -#include #include #include #include @@ -21,6 +20,8 @@ class QFileSystemWatcher; class QHBoxLayout; class QLabel; class QLineEdit; +template +class QList; class QModelIndex; class QStandardItem; class QStandardItemModel;