Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI fixes and play button shenanigans #7712

Merged
merged 11 commits into from
Mar 7, 2020
5 changes: 5 additions & 0 deletions rpcs3/Emu/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ class Emulator final
return m_title;
}

const std::string GetTitleAndTitleID() const
{
return m_title + (m_title_id.empty() ? "" : " [" + m_title_id + "]");
}

const std::string& GetCat() const
{
return m_cat;
Expand Down
3 changes: 2 additions & 1 deletion rpcs3/rpcs3qt/game_list.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#pragma once

#include <QTableWidget>
#include <QMouseEvent>
Expand All @@ -15,6 +15,7 @@ class game_list : public QTableWidget
if (!indexAt(event->pos()).isValid() || itemAt(event->pos())->data(Qt::UserRole) < 0)
{
clearSelection();
setCurrentItem(nullptr); // Needed for currentItemChanged
}
QTableWidget::mousePressEvent(event);
}
Expand Down
683 changes: 363 additions & 320 deletions rpcs3/rpcs3qt/game_list_frame.cpp

Large diffs are not rendered by default.

46 changes: 24 additions & 22 deletions rpcs3/rpcs3qt/game_list_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class game_list_frame : public custom_dock_widget
Q_OBJECT

public:
explicit game_list_frame(std::shared_ptr<gui_settings> guiSettings, std::shared_ptr<emu_settings> emuSettings, std::shared_ptr<persistent_settings> persistent_settings, QWidget *parent = nullptr);
explicit game_list_frame(std::shared_ptr<gui_settings> gui_settings, std::shared_ptr<emu_settings> emu_settings, std::shared_ptr<persistent_settings> persistent_settings, QWidget *parent = nullptr);
~game_list_frame();

/** Fix columns with width smaller than the minimal section size */
Expand All @@ -49,7 +49,7 @@ class game_list_frame : public custom_dock_widget
void ResizeColumnsToContents(int spacing = 20);

/** Refresh the gamelist with/without loading game data from files. Public so that main frame can refresh after vfs or install */
void Refresh(const bool fromDrive = false, const bool scrollAfter = true);
void Refresh(const bool from_drive = false, const bool scroll_after = true);

/** Adds/removes categories that should be shown on gamelist. Public so that main frame menu actions can apply them */
void ToggleCategoryFilter(const QStringList& categories, bool show);
Expand All @@ -61,10 +61,10 @@ class game_list_frame : public custom_dock_widget
void SaveSettings();

/** Resize Gamelist Icons to size given by slider position */
void ResizeIcons(const int& sliderPos);
void ResizeIcons(const int& slider_pos);

/** Repaint Gamelist Icons with new background color */
void RepaintIcons(const bool& fromSettings = false);
void RepaintIcons(const bool& from_settings = false);

void SetShowHidden(bool show);

Expand All @@ -75,16 +75,18 @@ public Q_SLOTS:
void BatchRemoveCustomConfigurations();
void BatchRemoveCustomPadConfigurations();
void BatchRemoveShaderCaches();
void SetListMode(const bool& isList);
void SetListMode(const bool& is_list);
void SetSearchText(const QString& text);
void SetShowCompatibilityInGrid(bool show);

private Q_SLOTS:
void OnColClicked(int col);
void ShowContextMenu(const QPoint &pos);
void doubleClickedSlot(QTableWidgetItem *item);
void itemSelectionChangedSlot();
Q_SIGNALS:
void GameListFrameClosed();
void NotifyGameSelection(const game_info& game);
void RequestBoot(const game_info& game, bool force_global_config = false);
void RequestIconSizeChange(const int& val);
void NotifyEmuSettingsChange();
Expand All @@ -97,11 +99,10 @@ private Q_SLOTS:
QPixmap PaintedPixmap(const QPixmap& icon, bool paint_config_icon = false, bool paint_pad_config_icon = false, const QColor& color = QColor());
QColor getGridCompatibilityColor(const QString& string);
void ShowCustomConfigIcon(game_info game);
void PopulateGameList();
void PopulateGameGrid(int maxCols, const QSize& image_size, const QColor& image_color);
bool IsEntryVisible(const game_info& game);
void SortGameList();

int PopulateGameList();
bool SearchMatchesApp(const QString& name, const QString& serial) const;

bool RemoveCustomConfiguration(const std::string& title_id, game_info game = nullptr, bool is_interactive = false);
Expand All @@ -118,30 +119,31 @@ private Q_SLOTS:
std::string CurrentSelectionIconPath();
std::string GetStringFromU32(const u32& key, const std::map<u32, QString>& map, bool combined = false);

game_info GetGameInfoFromItem(QTableWidgetItem* item);
game_info GetGameInfoByMode(const QTableWidgetItem* item);
game_info GetGameInfoFromItem(const QTableWidgetItem* item);

// Which widget we are displaying depends on if we are in grid or list mode.
QMainWindow* m_Game_Dock;
QStackedWidget* m_Central_Widget;
QMainWindow* m_game_dock;
QStackedWidget* m_central_widget;

// Game Grid
game_list_grid* m_xgrid;
game_list_grid* m_game_grid;

// Game List
game_list* m_gameList;
game_list* m_game_list;
std::unique_ptr<game_compatibility> m_game_compat;
QList<QAction*> m_columnActs;
Qt::SortOrder m_colSortOrder;
int m_sortColumn;
Qt::SortOrder m_col_sort_order;
int m_sort_column;
QMap<QString, QString> m_notes;
QMap<QString, QString> m_titles;

// Categories
QStringList m_categoryFilters;
QStringList m_category_filters;

// List Mode
bool m_isListLayout = true;
bool m_oldLayoutIsList = true;
bool m_is_list_layout = true;
bool m_old_layout_is_list = true;

// Data
std::shared_ptr<gui_settings> m_gui_settings;
Expand All @@ -158,9 +160,9 @@ private Q_SLOTS:
int m_icon_size_index = 0;

// Icons
QColor m_Icon_Color;
QSize m_Icon_Size;
qreal m_Margin_Factor;
qreal m_Text_Factor;
bool m_drawCompatStatusToGrid = false;
QColor m_icon_color;
QSize m_icon_size;
qreal m_margin_factor;
qreal m_text_factor;
bool m_draw_compat_status_to_grid = false;
};
107 changes: 48 additions & 59 deletions rpcs3/rpcs3qt/gui_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ inline std::string sstr(const QString& _in) { return _in.toStdString(); }
gui_settings::gui_settings(QObject* parent) : settings(parent)
{
m_current_name = gui::Settings;
m_settings = new QSettings(ComputeSettingsDir() + gui::Settings + ".ini", QSettings::Format::IniFormat, parent);
m_settings.reset(new QSettings(ComputeSettingsDir() + gui::Settings + ".ini", QSettings::Format::IniFormat, parent));

const QString settings_name = GetValue(gui::m_currentConfig).toString();

Expand All @@ -41,51 +41,37 @@ QString gui_settings::GetCurrentUser()
return QString();
}

bool gui_settings::ChangeToConfig(const QString& friendly_name)
bool gui_settings::ChangeToConfig(const QString& config_name)
{
if (m_current_name == friendly_name)
if (m_current_name == config_name)
{
return false;
}

if (friendly_name != gui::Settings)
{
if (m_current_name == gui::Settings)
{
SetValue(gui::m_currentConfig, friendly_name);
}
else
{
QSettings tmp(m_settings_dir.absoluteFilePath(gui::Settings + ".ini"), QSettings::Format::IniFormat, parent());
tmp.beginGroup(gui::m_currentConfig.key);
tmp.setValue(gui::m_currentConfig.name, friendly_name);
tmp.endGroup();
}
}

m_settings->sync();
// Backup current config
SaveCurrentConfig(m_current_name);

Reset(true);
// Save new config name to the default config
SaveConfigNameToDefault(config_name);

QSettings other(m_settings_dir.absoluteFilePath(friendly_name + ".ini"), QSettings::IniFormat);

for (const QString& key : other.allKeys())
{
m_settings->setValue(key, other.value(key));
}
// Sync file just in case
m_settings->sync();

SetValue(gui::m_currentConfig, friendly_name);
// Load new config
m_settings.reset(new QSettings(m_settings_dir.absoluteFilePath(config_name + ".ini"), QSettings::IniFormat));

// Save own name to new config
SetValue(gui::m_currentConfig, config_name);
m_settings->sync();

m_current_name = friendly_name;
m_current_name = config_name;

return true;
}

void gui_settings::Reset(bool removeMeta)
void gui_settings::Reset(bool remove_meta)
{
if (removeMeta)
if (remove_meta)
{
m_settings->clear();
}
Expand Down Expand Up @@ -238,26 +224,11 @@ void gui_settings::SetCustomColor(int col, const QColor& val)
SetValue(gui_save(gui::meta, "CustomColor" + QString::number(col), gui::gl_icon_color), val);
}

void gui_settings::SaveCurrentConfig(const QString& friendly_name)
void gui_settings::SaveCurrentConfig(const QString& config_name)
{
if (friendly_name != gui::Settings)
{
if (m_current_name == gui::Settings)
{
SetValue(gui::m_currentConfig, friendly_name);
m_settings->sync();
}
else
{
QSettings tmp(m_settings_dir.absoluteFilePath(gui::Settings + ".ini"), QSettings::Format::IniFormat, parent());
tmp.beginGroup(gui::m_currentConfig.key);
tmp.setValue(gui::m_currentConfig.name, friendly_name);
tmp.endGroup();
}
}

BackupSettingsToTarget(friendly_name);
ChangeToConfig(friendly_name);
SaveConfigNameToDefault(config_name);
BackupSettingsToTarget(config_name);
ChangeToConfig(config_name);
}

logs::level gui_settings::GetLogLevel()
Expand All @@ -277,10 +248,11 @@ QColor gui_settings::GetCustomColor(int col)

QStringList gui_settings::GetConfigEntries()
{
QStringList nameFilter;
nameFilter << "*.ini";
QFileInfoList entries = m_settings_dir.entryInfoList(nameFilter, QDir::Files);
const QStringList name_filter = QStringList("*.ini");
const QFileInfoList entries = m_settings_dir.entryInfoList(name_filter, QDir::Files);

QStringList res;

for (const QFileInfo &entry : entries)
{
res.append(entry.baseName());
Expand All @@ -289,9 +261,26 @@ QStringList gui_settings::GetConfigEntries()
return res;
}

void gui_settings::BackupSettingsToTarget(const QString& friendly_name)
// Save the name of the used config to the default settings file
void gui_settings::SaveConfigNameToDefault(const QString& config_name)
{
if (m_current_name == gui::Settings)
{
SetValue(gui::m_currentConfig, config_name);
m_settings->sync();
}
else
{
QSettings tmp(m_settings_dir.absoluteFilePath(gui::Settings + ".ini"), QSettings::Format::IniFormat, parent());
tmp.beginGroup(gui::m_currentConfig.key);
tmp.setValue(gui::m_currentConfig.name, config_name);
tmp.endGroup();
}
}

void gui_settings::BackupSettingsToTarget(const QString& config_name)
{
QSettings target(ComputeSettingsDir() + friendly_name + ".ini", QSettings::Format::IniFormat);
QSettings target(ComputeSettingsDir() + config_name + ".ini", QSettings::Format::IniFormat);

for (const QString& key : m_settings->allKeys())
{
Expand All @@ -306,16 +295,16 @@ void gui_settings::BackupSettingsToTarget(const QString& friendly_name)

QStringList gui_settings::GetStylesheetEntries()
{
QStringList nameFilter = QStringList("*.qss");
QStringList res = gui::utils::get_dir_entries(m_settings_dir, nameFilter);
const QStringList name_filter = QStringList("*.qss");
QStringList res = gui::utils::get_dir_entries(m_settings_dir, name_filter);
#if !defined(_WIN32)
// Makes stylesheets load if using AppImage (App Bundle) or installed to /usr/bin
#ifdef __APPLE__
QDir platformStylesheetDir = QCoreApplication::applicationDirPath() + "/../Resources/GuiConfigs/";
#else
QDir platformStylesheetDir = QCoreApplication::applicationDirPath() + "/../share/rpcs3/GuiConfigs/";
#endif
res.append(gui::utils::get_dir_entries(platformStylesheetDir, nameFilter));
res.append(gui::utils::get_dir_entries(platformStylesheetDir, name_filter));
res.removeDuplicates();
#endif
res.sort(Qt::CaseInsensitive);
Expand All @@ -326,7 +315,7 @@ QString gui_settings::GetCurrentStylesheetPath()
{
const Localized localized;

QString stylesheet = GetValue(gui::m_currentStylesheet).toString();
const QString stylesheet = GetValue(gui::m_currentStylesheet).toString();

if (stylesheet == gui::Default)
{
Expand All @@ -348,6 +337,6 @@ QSize gui_settings::SizeFromSlider(int pos)
gui_save gui_settings::GetGuiSaveForColumn(int col)
{
// hide sound format, parental level, firmware version and path by default
bool show = col != gui::column_sound && col != gui::column_parental && col != gui::column_firmware && col != gui::column_path;
const bool show = col != gui::column_sound && col != gui::column_parental && col != gui::column_firmware && col != gui::column_path;
return gui_save{ gui::game_list, "visibility_" + gui::get_game_list_column_name(static_cast<gui::game_list_columns>(col)), show };
}
9 changes: 5 additions & 4 deletions rpcs3/rpcs3qt/gui_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class gui_settings : public settings
QString GetCurrentUser();

/** Changes the settings file to the destination preset*/
bool ChangeToConfig(const QString& friendly_name);
bool ChangeToConfig(const QString& config_name);

bool GetCategoryVisibility(int cat);

Expand All @@ -249,7 +249,7 @@ class gui_settings : public settings
QStringList GetGameListCategoryFilters();

public Q_SLOTS:
void Reset(bool removeMeta = false);
void Reset(bool remove_meta = false);

/** Sets the visibility of the chosen category. */
void SetCategoryVisibility(int cat, const bool& val);
Expand All @@ -258,13 +258,14 @@ public Q_SLOTS:

void SetCustomColor(int col, const QColor& val);

void SaveCurrentConfig(const QString& friendly_name);
void SaveCurrentConfig(const QString& config_name);

static QSize SizeFromSlider(int pos);
static gui_save GetGuiSaveForColumn(int col);

private:
void BackupSettingsToTarget(const QString& friendly_name);
void SaveConfigNameToDefault(const QString& config_name);
void BackupSettingsToTarget(const QString& config_name);
void ShowBox(bool confirm, const QString& title, const QString& text, const gui_save& entry, int* result, QWidget* parent, bool always_on_top);

QString m_current_name;
Expand Down