Merge pull request #4952 from FearlessTobi/backport-everything

Backport various review changes from yuzu
This commit is contained in:
James Rowe 2019-09-24 22:39:06 -06:00 committed by GitHub
commit 80c9137a02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 105 additions and 101 deletions

View File

@ -609,7 +609,7 @@ void Config::SaveValues() {
qt_config->beginWriteArray("gamedirs"); qt_config->beginWriteArray("gamedirs");
for (int i = 0; i < UISettings::values.game_dirs.size(); ++i) { for (int i = 0; i < UISettings::values.game_dirs.size(); ++i) {
qt_config->setArrayIndex(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("path", game_dir.path);
WriteSetting("deep_scan", game_dir.deep_scan, false); WriteSetting("deep_scan", game_dir.deep_scan, false);
WriteSetting("expanded", game_dir.expanded, true); WriteSetting("expanded", game_dir.expanded, true);

View File

@ -49,11 +49,7 @@ ConfigureGraphics::ConfigureGraphics(QWidget* parent)
if (!new_bg_color.isValid()) { if (!new_bg_color.isValid()) {
return; return;
} }
bg_color = new_bg_color; UpdateBackgroundColorButton(new_bg_color);
QPixmap pixmap(ui->bg_button->size());
pixmap.fill(bg_color);
const QIcon color_icon(pixmap);
ui->bg_button->setIcon(color_icon);
}); });
} }
@ -71,12 +67,8 @@ void ConfigureGraphics::SetConfiguration() {
ui->toggle_linear_filter->setChecked(Settings::values.filter_mode); ui->toggle_linear_filter->setChecked(Settings::values.filter_mode);
ui->layout_combobox->setCurrentIndex(static_cast<int>(Settings::values.layout_option)); ui->layout_combobox->setCurrentIndex(static_cast<int>(Settings::values.layout_option));
ui->swap_screen->setChecked(Settings::values.swap_screen); ui->swap_screen->setChecked(Settings::values.swap_screen);
bg_color = QColor::fromRgbF(Settings::values.bg_red, Settings::values.bg_green, UpdateBackgroundColorButton(QColor::fromRgbF(Settings::values.bg_red, Settings::values.bg_green,
Settings::values.bg_blue); 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);
} }
void ConfigureGraphics::ApplyConfiguration() { void ConfigureGraphics::ApplyConfiguration() {
@ -117,6 +109,16 @@ void ConfigureGraphics::updateShaders(bool anaglyph) {
} }
} }
void ConfigureGraphics::UpdateBackgroundColorButton(const 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() { void ConfigureGraphics::RetranslateUI() {
ui->retranslateUi(this); ui->retranslateUi(this);
} }

View File

@ -22,6 +22,8 @@ public:
void RetranslateUI(); void RetranslateUI();
void SetConfiguration(); void SetConfiguration();
void UpdateBackgroundColorButton(const QColor& color);
std::unique_ptr<Ui::ConfigureGraphics> ui; std::unique_ptr<Ui::ConfigureGraphics> ui;
QColor bg_color; QColor bg_color;

View File

@ -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("%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* folder;
QStandardItem* child; QStandardItem* child;
QString file_path; QString file_path;
int folderCount = item_model->rowCount(); const int folderCount = item_model->rowCount();
for (int i = 0; i < folderCount; ++i) { for (int i = 0; i < folderCount; ++i) {
folder = item_model->item(i, 0); folder = item_model->item(i, 0);
QModelIndex folder_index = folder->index(); const QModelIndex folder_index = folder->index();
int childrenCount = folder->rowCount(); const int children_count = folder->rowCount();
for (int j = 0; j < childrenCount; ++j) { for (int j = 0; j < children_count; ++j) {
if (!tree_view->isRowHidden(j, folder_index)) { if (!tree_view->isRowHidden(j, folder_index)) {
child = folder->child(j, 0); child = folder->child(j, 0);
file_path = child->data(GameListItemPath::FullPathRole).toString(); 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 // Syncs the expanded state of Game Directories with settings to persist across sessions
void GameList::onItemExpanded(const QModelIndex& item) { void GameList::onItemExpanded(const QModelIndex& item) {
GameListItemType type = item.data(GameListItem::TypeRole).value<GameListItemType>(); const auto type = item.data(GameListItem::TypeRole).value<GameListItemType>();
if (type == GameListItemType::CustomDir || type == GameListItemType::InstalledDir || if (type == GameListItemType::CustomDir || type == GameListItemType::InstalledDir ||
type == GameListItemType::SystemDir) type == GameListItemType::SystemDir)
item.data(GameListDir::GameDirRole).value<UISettings::GameDir*>()->expanded = item.data(GameListDir::GameDirRole).value<UISettings::GameDir*>()->expanded =
@ -184,32 +184,32 @@ void GameList::onItemExpanded(const QModelIndex& item) {
// Event in order to filter the gamelist after editing the searchfield // Event in order to filter the gamelist after editing the searchfield
void GameList::onTextChanged(const QString& newText) { 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(); QString edit_filter_text = newText.toLower();
QStandardItem* folder; QStandardItem* folder;
int childrenTotal = 0; int children_total = 0;
// If the searchfield is empty every item is visible // If the searchfield is empty every item is visible
// Otherwise the filter gets applied // Otherwise the filter gets applied
if (edit_filter_text.isEmpty()) { if (edit_filter_text.isEmpty()) {
for (int i = 0; i < folderCount; ++i) { for (int i = 0; i < folderCount; ++i) {
folder = item_model->item(i, 0); folder = item_model->item(i, 0);
QModelIndex folder_index = folder->index(); const QModelIndex folder_index = folder->index();
int childrenCount = folder->rowCount(); const int children_count = folder->rowCount();
for (int j = 0; j < childrenCount; ++j) { for (int j = 0; j < children_count; ++j) {
++childrenTotal; ++children_total;
tree_view->setRowHidden(j, folder_index, false); tree_view->setRowHidden(j, folder_index, false);
} }
} }
search_field->setFilterResult(childrenTotal, childrenTotal); search_field->setFilterResult(children_total, children_total);
} else { } else {
int result_count = 0; int result_count = 0;
for (int i = 0; i < folderCount; ++i) { for (int i = 0; i < folderCount; ++i) {
folder = item_model->item(i, 0); folder = item_model->item(i, 0);
QModelIndex folder_index = folder->index(); const QModelIndex folder_index = folder->index();
int childrenCount = folder->rowCount(); const int children_count = folder->rowCount();
for (int j = 0; j < childrenCount; ++j) { for (int j = 0; j < children_count; ++j) {
++childrenTotal; ++children_total;
const QStandardItem* child = folder->child(j, 0); const QStandardItem* child = folder->child(j, 0);
const QString file_path = const QString file_path =
child->data(GameListItemPath::FullPathRole).toString().toLower(); child->data(GameListItemPath::FullPathRole).toString().toLower();
@ -231,7 +231,7 @@ void GameList::onTextChanged(const QString& newText) {
} else { } else {
tree_view->setRowHidden(j, folder_index, true); 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: { case GameListItemType::CustomDir: {
const UISettings::GameDir* game_dir = const UISettings::GameDir* game_dir =
child->data(GameListDir::GameDirRole).value<UISettings::GameDir*>(); child->data(GameListDir::GameDirRole).value<UISettings::GameDir*>();
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); child->setData(QIcon::fromTheme(icon_name).pixmap(48), Qt::DecorationRole);
break; break;
} }
@ -353,14 +353,14 @@ void GameList::AddEntry(const QList<QStandardItem*>& entry_items, GameListDir* p
} }
void GameList::ValidateEntry(const QModelIndex& item) { 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<GameListItemType>()) { switch (selected.data(GameListItem::TypeRole).value<GameListItemType>()) {
case GameListItemType::Game: { case GameListItemType::Game: {
QString file_path = selected.data(GameListItemPath::FullPathRole).toString(); const QString file_path = selected.data(GameListItemPath::FullPathRole).toString();
if (file_path.isEmpty()) if (file_path.isEmpty())
return; return;
QFileInfo file_info(file_path); const QFileInfo file_info(file_path);
if (!file_info.exists() || file_info.isDir()) if (!file_info.exists() || file_info.isDir())
return; return;
// Users usually want to run a different game after closing one // 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++) { for (int i = 0; i < item_model->rowCount(); i++) {
const QStandardItem* child = item_model->invisibleRootItem()->child(i); const QStandardItem* child = item_model->invisibleRootItem()->child(i);
GameListItemType type = static_cast<GameListItemType>(child->type()); const auto type = static_cast<GameListItemType>(child->type());
if (!child->hasChildren() && if (!child->hasChildren() &&
(type == GameListItemType::InstalledDir || type == GameListItemType::SystemDir)) { (type == GameListItemType::InstalledDir || type == GameListItemType::SystemDir)) {
item_model->invisibleRootItem()->removeRow(child->row()); item_model->invisibleRootItem()->removeRow(child->row());
@ -408,16 +408,13 @@ void GameList::DonePopulating(QStringList watch_list) {
QCoreApplication::processEvents(); QCoreApplication::processEvents();
} }
tree_view->setEnabled(true); tree_view->setEnabled(true);
int folderCount = tree_view->model()->rowCount(); const int folderCount = tree_view->model()->rowCount();
int childrenTotal = 0; int children_total = 0;
for (int i = 0; i < folderCount; ++i) { for (int i = 0; i < folderCount; ++i) {
int childrenCount = item_model->item(i, 0)->rowCount(); children_total += item_model->item(i, 0)->rowCount();
for (int j = 0; j < childrenCount; ++j) {
++childrenTotal;
} }
} search_field->setFilterResult(children_total, children_total);
search_field->setFilterResult(childrenTotal, childrenTotal); if (children_total > 0) {
if (childrenTotal > 0) {
search_field->setFocus(); search_field->setFocus();
} }
@ -429,7 +426,7 @@ void GameList::PopupContextMenu(const QPoint& menu_location) {
if (!item.isValid()) if (!item.isValid())
return; return;
auto selected = item.sibling(item.row(), 0); const auto selected = item.sibling(item.row(), 0);
QMenu context_menu; QMenu context_menu;
switch (selected.data(GameListItem::TypeRole).value<GameListItemType>()) { switch (selected.data(GameListItem::TypeRole).value<GameListItemType>()) {
case GameListItemType::Game: 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* move_down = context_menu.addAction(tr(u8"\U000025bc Move Down "));
QAction* open_directory_location = context_menu.addAction(tr("Open Directory Location")); 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_up->setEnabled(row > 0);
move_down->setEnabled(row < item_model->rowCount() - 2); move_down->setEnabled(row < item_model->rowCount() - 2);
connect(move_up, &QAction::triggered, [this, selected, row, &game_dir] { connect(move_up, &QAction::triggered, [this, selected, row, &game_dir] {
// find the indices of the items in settings and swap them // find the indices of the items in settings and swap them
UISettings::values.game_dirs.swap( std::swap(UISettings::values.game_dirs[UISettings::values.game_dirs.indexOf(game_dir)],
UISettings::values.game_dirs.indexOf(game_dir), UISettings::values.game_dirs[UISettings::values.game_dirs.indexOf(
UISettings::values.game_dirs.indexOf(*selected.sibling(selected.row() - 1, 0) *selected.sibling(row - 1, 0)
.data(GameListDir::GameDirRole) .data(GameListDir::GameDirRole)
.value<UISettings::GameDir*>())); .value<UISettings::GameDir*>())]);
// move the treeview items // move the treeview items
QList<QStandardItem*> item = item_model->takeRow(row); QList<QStandardItem*> item = item_model->takeRow(row);
item_model->invisibleRootItem()->insertRow(row - 1, item); 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] { connect(move_down, &QAction::triggered, [this, selected, row, &game_dir] {
// find the indices of the items in settings and swap them // find the indices of the items in settings and swap them
UISettings::values.game_dirs.swap( std::swap(UISettings::values.game_dirs[UISettings::values.game_dirs.indexOf(game_dir)],
UISettings::values.game_dirs.indexOf(game_dir), UISettings::values.game_dirs[UISettings::values.game_dirs.indexOf(
UISettings::values.game_dirs.indexOf(*selected.sibling(selected.row() + 1, 0) *selected.sibling(row + 1, 0)
.data(GameListDir::GameDirRole) .data(GameListDir::GameDirRole)
.value<UISettings::GameDir*>())); .value<UISettings::GameDir*>())]);
// move the treeview items // move the treeview items
QList<QStandardItem*> item = item_model->takeRow(row); const QList<QStandardItem*> item = item_model->takeRow(row);
item_model->invisibleRootItem()->insertRow(row + 1, item); item_model->invisibleRootItem()->insertRow(row + 1, item);
tree_view->setExpanded(selected, game_dir.expanded); tree_view->setExpanded(selected, game_dir.expanded);
}); });
@ -609,7 +606,7 @@ QStandardItemModel* GameList::GetModel() const {
return item_model; return item_model;
} }
void GameList::PopulateAsync(QList<UISettings::GameDir>& game_dirs) { void GameList::PopulateAsync(QVector<UISettings::GameDir>& game_dirs) {
tree_view->setEnabled(false); tree_view->setEnabled(false);
// Delete any rows that might already exist if we're repopulating // Delete any rows that might already exist if we're repopulating
item_model->removeRows(0, item_model->rowCount()); 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} { GameListPlaceholder::GameListPlaceholder(GMainWindow* parent) : QWidget{parent} {
this->main_window = parent; connect(parent, &GMainWindow::UpdateThemedIcons, this,
connect(main_window, &GMainWindow::UpdateThemedIcons, this,
&GameListPlaceholder::onUpdateThemedIcons); &GameListPlaceholder::onUpdateThemedIcons);
layout = new QVBoxLayout; layout = new QVBoxLayout;

View File

@ -6,6 +6,7 @@
#include <QMenu> #include <QMenu>
#include <QString> #include <QString>
#include <QVector>
#include <QWidget> #include <QWidget>
#include "citra_qt/compatibility_list.h" #include "citra_qt/compatibility_list.h"
#include "common/common_types.h" #include "common/common_types.h"
@ -46,15 +47,15 @@ public:
explicit GameList(GMainWindow* parent = nullptr); explicit GameList(GMainWindow* parent = nullptr);
~GameList() override; ~GameList() override;
QString getLastFilterResultItem(); QString getLastFilterResultItem() const;
void clearFilter(); void clearFilter();
void setFilterFocus(); void setFilterFocus();
void setFilterVisible(bool visibility); void setFilterVisible(bool visibility);
void setDirectoryWatcherEnabled(bool enabled); void setDirectoryWatcherEnabled(bool enabled);
bool isEmpty(); bool isEmpty() const;
void LoadCompatibilityList(); void LoadCompatibilityList();
void PopulateAsync(QList<UISettings::GameDir>& game_dirs); void PopulateAsync(QVector<UISettings::GameDir>& game_dirs);
void SaveInterfaceLayout(); void SaveInterfaceLayout();
void LoadInterfaceLayout(); void LoadInterfaceLayout();
@ -73,7 +74,7 @@ signals:
void OpenFolderRequested(u64 program_id, GameListOpenTarget target); void OpenFolderRequested(u64 program_id, GameListOpenTarget target);
void NavigateToGamedbEntryRequested(u64 program_id, void NavigateToGamedbEntryRequested(u64 program_id,
const CompatibilityList& compatibility_list); const CompatibilityList& compatibility_list);
void OpenDirectory(QString directory); void OpenDirectory(const QString& directory);
void AddDirectory(); void AddDirectory();
void ShowList(bool show); void ShowList(bool show);
void PopulatingCompleted(); void PopulatingCompleted();
@ -127,7 +128,6 @@ protected:
void mouseDoubleClickEvent(QMouseEvent* event) override; void mouseDoubleClickEvent(QMouseEvent* event) override;
private: private:
GMainWindow* main_window = nullptr;
QVBoxLayout* layout = nullptr; QVBoxLayout* layout = nullptr;
QLabel* image = nullptr; QLabel* image = nullptr;
QLabel* text = nullptr; QLabel* text = nullptr;

View File

@ -350,18 +350,20 @@ public:
UISettings::GameDir* game_dir = &directory; UISettings::GameDir* game_dir = &directory;
setData(QVariant::fromValue(game_dir), GameDirRole); 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) { switch (dir_type) {
case GameListItemType::InstalledDir: case GameListItemType::InstalledDir:
setData(QIcon::fromTheme("sd_card").pixmap(icon_size), Qt::DecorationRole); setData(QIcon::fromTheme(QStringLiteral("sd_card")).pixmap(icon_size),
setData("Installed Titles", Qt::DisplayRole); Qt::DecorationRole);
setData(QObject::tr("Installed Titles"), Qt::DisplayRole);
break; break;
case GameListItemType::SystemDir: case GameListItemType::SystemDir:
setData(QIcon::fromTheme("chip").pixmap(icon_size), Qt::DecorationRole); setData(QIcon::fromTheme(QStringLiteral("chip")).pixmap(icon_size), Qt::DecorationRole);
setData("System Titles", Qt::DisplayRole); setData(QObject::tr("System Titles"), Qt::DisplayRole);
break; break;
case GameListItemType::CustomDir: 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(QIcon::fromTheme(icon_name).pixmap(icon_size), Qt::DecorationRole);
setData(game_dir->path, Qt::DisplayRole); setData(game_dir->path, Qt::DisplayRole);
break; break;
@ -382,8 +384,8 @@ public:
setData(type(), TypeRole); setData(type(), TypeRole);
int icon_size = IconSizes.at(UISettings::values.game_list_icon_size); int icon_size = IconSizes.at(UISettings::values.game_list_icon_size);
setData(QIcon::fromTheme("plus").pixmap(icon_size), Qt::DecorationRole); setData(QIcon::fromTheme(QStringLiteral("plus")).pixmap(icon_size), Qt::DecorationRole);
setData("Add New Game Directory", Qt::DisplayRole); setData(QObject::tr("Add New Game Directory"), Qt::DisplayRole);
} }
int type() const override { int type() const override {
@ -409,9 +411,6 @@ public:
void clear(); void clear();
void setFocus(); void setFocus();
int visible;
int total;
private: private:
class KeyReleaseEater : public QObject { class KeyReleaseEater : public QObject {
public: public:
@ -425,6 +424,9 @@ private:
// EventFilter in order to process systemkeys while editing the searchfield // EventFilter in order to process systemkeys while editing the searchfield
bool eventFilter(QObject* obj, QEvent* event) override; bool eventFilter(QObject* obj, QEvent* event) override;
}; };
int visible;
int total;
QHBoxLayout* layout_filter = nullptr; QHBoxLayout* layout_filter = nullptr;
QTreeView* tree_view = nullptr; QTreeView* tree_view = nullptr;
QLabel* label_filter = nullptr; QLabel* label_filter = nullptr;

View File

@ -26,7 +26,7 @@ bool HasSupportedFileExtension(const std::string& file_name) {
} }
} // Anonymous namespace } // Anonymous namespace
GameListWorker::GameListWorker(QList<UISettings::GameDir>& game_dirs, GameListWorker::GameListWorker(QVector<UISettings::GameDir>& game_dirs,
const CompatibilityList& compatibility_list) const CompatibilityList& compatibility_list)
: game_dirs(game_dirs), compatibility_list(compatibility_list) {} : game_dirs(game_dirs), compatibility_list(compatibility_list) {}
@ -134,7 +134,7 @@ void GameListWorker::run() {
"00040002"; "00040002";
watch_list.append(games_path); watch_list.append(games_path);
watch_list.append(demos_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}); emit DirEntryReady({game_list_dir});
AddFstEntriesToGameList(games_path.toStdString(), 2, game_list_dir); AddFstEntriesToGameList(games_path.toStdString(), 2, game_list_dir);
AddFstEntriesToGameList(demos_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)) + QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)) +
"00000000000000000000000000000000/title/00040010"; "00000000000000000000000000000000/title/00040010";
watch_list.append(path); 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}); emit DirEntryReady({game_list_dir});
AddFstEntriesToGameList(path.toStdString(), 2, game_list_dir); AddFstEntriesToGameList(path.toStdString(), 2, game_list_dir);
} else { } else {
watch_list.append(game_dir.path); 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}); emit DirEntryReady({game_list_dir});
AddFstEntriesToGameList(game_dir.path.toStdString(), game_dir.deep_scan ? 256 : 0, AddFstEntriesToGameList(game_dir.path.toStdString(), game_dir.deep_scan ? 256 : 0,
game_list_dir); game_list_dir);

View File

@ -13,6 +13,7 @@
#include <QObject> #include <QObject>
#include <QRunnable> #include <QRunnable>
#include <QString> #include <QString>
#include <QVector>
#include "citra_qt/compatibility_list.h" #include "citra_qt/compatibility_list.h"
#include "common/common_types.h" #include "common/common_types.h"
@ -26,7 +27,7 @@ class GameListWorker : public QObject, public QRunnable {
Q_OBJECT Q_OBJECT
public: public:
GameListWorker(QList<UISettings::GameDir>& game_dirs, GameListWorker(QVector<UISettings::GameDir>& game_dirs,
const CompatibilityList& compatibility_list); const CompatibilityList& compatibility_list);
~GameListWorker() override; ~GameListWorker() override;
@ -57,6 +58,6 @@ private:
QStringList watch_list; QStringList watch_list;
const CompatibilityList& compatibility_list; const CompatibilityList& compatibility_list;
QList<UISettings::GameDir>& game_dirs; QVector<UISettings::GameDir>& game_dirs;
std::atomic_bool stop_processing; std::atomic_bool stop_processing;
}; };

View File

@ -1111,18 +1111,16 @@ void GMainWindow::OnGameListNavigateToGamedbEntry(u64 program_id,
QDesktopServices::openUrl(QUrl("https://citra-emu.org/game/" + directory)); QDesktopServices::openUrl(QUrl("https://citra-emu.org/game/" + directory));
} }
void GMainWindow::OnGameListOpenDirectory(QString directory) { void GMainWindow::OnGameListOpenDirectory(const QString& directory) {
QString path; QString path;
if (directory == "INSTALLED") { if (directory == "INSTALLED") {
path = path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir) +
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir).c_str() + "Nintendo "
std::string("Nintendo "
"3DS/00000000000000000000000000000000/" "3DS/00000000000000000000000000000000/"
"00000000000000000000000000000000/title/00040000")); "00000000000000000000000000000000/title/00040000");
} else if (directory == "SYSTEM") { } else if (directory == "SYSTEM") {
path = path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) +
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir).c_str() + "00000000000000000000000000000000/title/00040010");
std::string("00000000000000000000000000000000/title/00040010"));
} else { } else {
path = directory; path = directory;
} }
@ -1134,7 +1132,7 @@ void GMainWindow::OnGameListOpenDirectory(QString directory) {
} }
void GMainWindow::OnGameListAddDirectory() { 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()) if (dir_path.isEmpty())
return; return;
UISettings::GameDir game_dir{dir_path, false, true}; UISettings::GameDir game_dir{dir_path, false, true};

View File

@ -161,7 +161,7 @@ private slots:
void OnGameListOpenFolder(u64 program_id, GameListOpenTarget target); void OnGameListOpenFolder(u64 program_id, GameListOpenTarget target);
void OnGameListNavigateToGamedbEntry(u64 program_id, void OnGameListNavigateToGamedbEntry(u64 program_id,
const CompatibilityList& compatibility_list); const CompatibilityList& compatibility_list);
void OnGameListOpenDirectory(QString path); void OnGameListOpenDirectory(const QString& directory);
void OnGameListAddDirectory(); void OnGameListAddDirectory();
void OnGameListShowList(bool show); void OnGameListShowList(bool show);
void OnMenuLoadFile(); void OnMenuLoadFile();

View File

@ -12,6 +12,7 @@
#include <QMetaType> #include <QMetaType>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QVector>
#include "common/common_types.h" #include "common/common_types.h"
namespace UISettings { namespace UISettings {
@ -100,7 +101,7 @@ struct Values {
QString video_dumping_path; QString video_dumping_path;
QString game_dir_deprecated; QString game_dir_deprecated;
bool game_dir_deprecated_deepscan; bool game_dir_deprecated_deepscan;
QList<UISettings::GameDir> game_dirs; QVector<UISettings::GameDir> game_dirs;
QStringList recent_files; QStringList recent_files;
QString language; QString language;

View File

@ -33,13 +33,13 @@ PerfStats::~PerfStats() {
return; return;
} }
std::time_t t = std::time(nullptr); const std::time_t t = std::time(nullptr);
std::ostringstream stream; std::ostringstream stream;
std::copy(perf_history.begin() + IgnoreFrames, perf_history.begin() + current_index, std::copy(perf_history.begin() + IgnoreFrames, perf_history.begin() + current_index,
std::ostream_iterator<double>(stream, "\n")); std::ostream_iterator<double>(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" // %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); fmt::format("{}/{:%F-%H-%M}_{:016X}.csv", path, *std::localtime(&t), title_id);
FileUtil::IOFile file(filename, "w"); FileUtil::IOFile file(filename, "w");
file.WriteString(stream.str()); file.WriteString(stream.str());
@ -74,10 +74,12 @@ void PerfStats::EndGameFrame() {
} }
double PerfStats::GetMeanFrametime() { double PerfStats::GetMeanFrametime() {
std::lock_guard lock{object_mutex};
if (current_index <= IgnoreFrames) { if (current_index <= IgnoreFrames) {
return 0; return 0;
} }
double sum = std::accumulate(perf_history.begin() + IgnoreFrames, const double sum = std::accumulate(perf_history.begin() + IgnoreFrames,
perf_history.begin() + current_index, 0); perf_history.begin() + current_index, 0);
return sum / (current_index - IgnoreFrames); return sum / (current_index - IgnoreFrames);
} }

View File

@ -7,6 +7,7 @@
#include <array> #include <array>
#include <atomic> #include <atomic>
#include <chrono> #include <chrono>
#include <cstddef>
#include <mutex> #include <mutex>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/thread.h" #include "common/thread.h"