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

Qt: move some more settings to persistent_settings #8671

Merged
merged 3 commits into from Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
79 changes: 50 additions & 29 deletions rpcs3/rpcs3qt/game_list_frame.cpp
Expand Up @@ -571,10 +571,10 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after)
mutex_cat.lock();

const QString serial = qstr(game.serial);
const QString note = m_gui_settings->GetValue(gui::notes, serial, "").toString();
const QString title = m_gui_settings->GetValue(gui::titles, serial, "").toString().simplified();

// Read persistent_settings values
QString note = m_persistent_settings->GetValue(gui::persistent::notes, serial, "").toString();
QString title = m_persistent_settings->GetValue(gui::persistent::titles, serial, "").toString().simplified();
QString last_played = m_persistent_settings->GetValue(gui::persistent::last_played, serial, "").toString();
int playtime = m_persistent_settings->GetValue(gui::persistent::playtime, serial, 0).toInt();

Expand All @@ -588,6 +588,27 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after)
{
playtime = m_gui_settings->GetValue(gui::persistent::playtime, serial, 0).toInt();
}
// Deprecated values older than August 2nd 2020
if (note.isEmpty())
{
note = m_gui_settings->GetValue(gui::persistent::notes, serial, "").toString();

// Move to persistent settings
if (!note.isEmpty())
{
m_persistent_settings->SetValue(gui::persistent::notes, serial, note);
}
}
if (title.isEmpty())
{
title = m_gui_settings->GetValue(gui::persistent::titles, serial, "").toString().simplified();

// Move to persistent settings
if (!title.isEmpty())
{
m_persistent_settings->SetValue(gui::persistent::titles, serial, title);
}
}

// Set persistent_settings values if values exist
if (!last_played.isEmpty())
Expand Down Expand Up @@ -870,7 +891,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
? tr("&Reboot with custom configuration")
: tr("&Boot with custom configuration"));
boot_custom->setFont(font);
connect(boot_custom, &QAction::triggered, [=, this]
connect(boot_custom, &QAction::triggered, [this, gameinfo]
{
sys_log.notice("Booting from gamelist per context menu...");
Q_EMIT RequestBoot(gameinfo);
Expand Down Expand Up @@ -902,7 +923,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
if (gameinfo->hasCustomConfig)
{
QAction* remove_custom_config = remove_menu->addAction(tr("&Remove Custom Configuration"));
connect(remove_custom_config, &QAction::triggered, [=, this]()
connect(remove_custom_config, &QAction::triggered, [this, current_game, gameinfo]()
{
if (RemoveCustomConfiguration(current_game.serial, gameinfo, true))
{
Expand All @@ -913,7 +934,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
if (gameinfo->hasCustomPadConfig)
{
QAction* remove_custom_pad_config = remove_menu->addAction(tr("&Remove Custom Gamepad Configuration"));
connect(remove_custom_pad_config, &QAction::triggered, [=, this]()
connect(remove_custom_pad_config, &QAction::triggered, [this, current_game, gameinfo]()
{
if (RemoveCustomPadConfiguration(current_game.serial, gameinfo, true))
{
Expand All @@ -925,22 +946,22 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
{
remove_menu->addSeparator();
QAction* remove_shaders_cache = remove_menu->addAction(tr("&Remove Shaders Cache"));
connect(remove_shaders_cache, &QAction::triggered, [=, this]()
connect(remove_shaders_cache, &QAction::triggered, [this, cache_base_dir]()
{
RemoveShadersCache(cache_base_dir, true);
});
QAction* remove_ppu_cache = remove_menu->addAction(tr("&Remove PPU Cache"));
connect(remove_ppu_cache, &QAction::triggered, [=, this]()
connect(remove_ppu_cache, &QAction::triggered, [this, cache_base_dir]()
{
RemovePPUCache(cache_base_dir, true);
});
QAction* remove_spu_cache = remove_menu->addAction(tr("&Remove SPU Cache"));
connect(remove_spu_cache, &QAction::triggered, [=, this]()
connect(remove_spu_cache, &QAction::triggered, [this, cache_base_dir]()
{
RemoveSPUCache(cache_base_dir, true);
});
QAction* remove_all_caches = remove_menu->addAction(tr("&Remove All Caches"));
connect(remove_all_caches, &QAction::triggered, [=, this]()
connect(remove_all_caches, &QAction::triggered, [this, cache_base_dir]()
{
if (QMessageBox::question(this, tr("Confirm Removal"), tr("Remove all caches?")) != QMessageBox::Yes)
return;
Expand All @@ -955,7 +976,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
if (gameinfo->hasCustomConfig)
{
QAction* open_config_dir = menu.addAction(tr("&Open Custom Config Folder"));
connect(open_config_dir, &QAction::triggered, [=, this]()
connect(open_config_dir, &QAction::triggered, [current_game]()
{
const std::string new_config_path = Emulator::GetCustomConfigPath(current_game.serial);

Expand All @@ -971,7 +992,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
if (fs::is_dir(data_base_dir))
{
QAction* open_data_dir = menu.addAction(tr("&Open Data Folder"));
connect(open_data_dir, &QAction::triggered, [=, this]()
connect(open_data_dir, &QAction::triggered, [data_base_dir]()
{
gui::utils::open_dir(data_base_dir);
});
Expand All @@ -986,12 +1007,12 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
QAction* copy_name = info_menu->addAction(tr("&Copy Name"));
QAction* copy_serial = info_menu->addAction(tr("&Copy Serial"));

connect(boot, &QAction::triggered, [=, this]()
connect(boot, &QAction::triggered, [this, gameinfo]()
{
sys_log.notice("Booting from gamelist per context menu...");
Q_EMIT RequestBoot(gameinfo, gameinfo->hasCustomConfig);
});
connect(configure, &QAction::triggered, [=, this]()
connect(configure, &QAction::triggered, [this, current_game, gameinfo]()
{
settings_dialog dlg(m_gui_settings, m_emu_settings, 0, this, &current_game);
connect(&dlg, &settings_dialog::EmuSettingsApplied, [this, gameinfo]()
Expand All @@ -1005,7 +1026,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
});
dlg.exec();
});
connect(pad_configure, &QAction::triggered, [=, this]()
connect(pad_configure, &QAction::triggered, [this, current_game, gameinfo]()
{
pad_settings_dialog dlg(m_gui_settings, this, &current_game);

Expand All @@ -1032,7 +1053,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
CreatePPUCache(gameinfo);
}
});
connect(remove_game, &QAction::triggered, [=, this]
connect(remove_game, &QAction::triggered, [this, current_game, gameinfo, cache_base_dir, name]
{
if (current_game.path.empty())
{
Expand Down Expand Up @@ -1069,22 +1090,22 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
}
}
});
connect(open_game_folder, &QAction::triggered, [=, this]()
connect(open_game_folder, &QAction::triggered, [current_game]()
{
gui::utils::open_dir(current_game.path);
});
connect(check_compat, &QAction::triggered, [=, this]
connect(check_compat, &QAction::triggered, [serial]
{
const QString link = "https://rpcs3.net/compatibility?g=" + serial;
QDesktopServices::openUrl(QUrl(link));
});
connect(download_compat, &QAction::triggered, [=, this]
connect(download_compat, &QAction::triggered, [this]
{
m_game_compat->RequestCompatibility(true);
});
connect(rename_title, &QAction::triggered, [=, this]
connect(rename_title, &QAction::triggered, [this, name, serial, global_pos]
{
const QString custom_title = m_gui_settings->GetValue(gui::titles, serial, "").toString();
const QString custom_title = m_persistent_settings->GetValue(gui::persistent::titles, serial, "").toString();
const QString old_title = custom_title.isEmpty() ? name : custom_title;
QString new_title;

Expand All @@ -1100,46 +1121,46 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
if (new_title.isEmpty() || new_title == name)
{
m_titles.remove(serial);
m_gui_settings->RemoveValue(gui::titles, serial);
m_persistent_settings->RemoveValue(gui::persistent::titles, serial);
}
else
{
m_titles.insert(serial, new_title);
m_gui_settings->SetValue(gui::titles, serial, new_title);
m_persistent_settings->SetValue(gui::persistent::titles, serial, new_title);
}
Refresh(true); // full refresh in order to reliably sort the list
}
});
connect(edit_notes, &QAction::triggered, [=, this]
connect(edit_notes, &QAction::triggered, [this, name, serial]
{
bool accepted;
const QString old_notes = m_gui_settings->GetValue(gui::notes, serial, "").toString();
const QString old_notes = m_persistent_settings->GetValue(gui::persistent::notes, serial, "").toString();
const QString new_notes = QInputDialog::getMultiLineText(this, tr("Edit Tooltip Notes"), tr("%0\n%1").arg(name).arg(serial), old_notes, &accepted);

if (accepted)
{
if (new_notes.simplified().isEmpty())
{
m_notes.remove(serial);
m_gui_settings->RemoveValue(gui::notes, serial);
m_persistent_settings->RemoveValue(gui::persistent::notes, serial);
}
else
{
m_notes.insert(serial, new_notes);
m_gui_settings->SetValue(gui::notes, serial, new_notes);
m_persistent_settings->SetValue(gui::persistent::notes, serial, new_notes);
}
Refresh();
}
});
connect(copy_info, &QAction::triggered, [=, this]
connect(copy_info, &QAction::triggered, [name, serial]
{
QApplication::clipboard()->setText(name % QStringLiteral(" [") % serial % QStringLiteral("]"));
});
connect(copy_name, &QAction::triggered, [=, this]
connect(copy_name, &QAction::triggered, [name]
{
QApplication::clipboard()->setText(name);
});
connect(copy_serial, &QAction::triggered, [=, this]
connect(copy_serial, &QAction::triggered, [serial]
{
QApplication::clipboard()->setText(serial);
});
Expand Down
8 changes: 7 additions & 1 deletion rpcs3/rpcs3qt/gui_application.cpp
Expand Up @@ -58,8 +58,14 @@ void gui_application::Init()
m_gui_settings.reset(new gui_settings());
m_persistent_settings.reset(new persistent_settings());

// Get deprecated active user (before August 2nd 2020)
QString active_user = m_gui_settings->GetValue(gui::um_active_user).toString();

// Get active user with deprecated active user as fallback
active_user = m_persistent_settings->GetCurrentUser(active_user.isEmpty() ? "00000001" : active_user);

// Force init the emulator
InitializeEmulator(m_gui_settings->GetCurrentUser().toStdString(), true, m_show_gui);
InitializeEmulator(active_user.toStdString(), true, m_show_gui);

// Create the main window
if (m_show_gui)
Expand Down
17 changes: 0 additions & 17 deletions rpcs3/rpcs3qt/gui_settings.cpp
Expand Up @@ -26,23 +26,6 @@ gui_settings::gui_settings(QObject* parent) : settings(parent)
}
}

QString gui_settings::GetCurrentUser()
{
// load user
bool is_valid_user;
const QString user = GetValue(gui::um_active_user).toString();
const u32 user_id = user.toInt(&is_valid_user);

// set user if valid
if (is_valid_user && user_id > 0)
{
return user;
}

cfg_log.fatal("Could not parse user setting: '%s' = '%d'.", user.toStdString(), user_id);
return QString();
}

bool gui_settings::ChangeToConfig(const QString& config_name)
{
if (m_current_name == config_name)
Expand Down
10 changes: 2 additions & 8 deletions rpcs3/rpcs3qt/gui_settings.h
Expand Up @@ -107,10 +107,6 @@ namespace gui
const QString gs_frame = "GSFrame";
const QString trophy = "Trophy";
const QString patches = "Patches";
const QString savedata = "SaveData";
const QString users = "Users";
const QString notes = "Notes";
const QString titles = "Titles";
const QString localization = "Localization";
const QString pad_settings = "PadSettings";

Expand Down Expand Up @@ -186,7 +182,7 @@ namespace gui

const gui_save m_currentConfig = gui_save(meta, "currentConfig", Settings);
const gui_save m_currentStylesheet = gui_save(meta, "currentStylesheet", Default);
const gui_save m_saveNotes = gui_save(meta, "saveNotes", QVariantMap());
const gui_save m_saveNotes = gui_save(meta, "saveNotes", QVariantMap()); // Deprecated
const gui_save m_showDebugTab = gui_save(meta, "showDebugTab", false);
const gui_save m_enableUIColors = gui_save(meta, "enableUIColors", false);
const gui_save m_richPresence = gui_save(meta, "useRichPresence", true);
Expand Down Expand Up @@ -224,7 +220,7 @@ namespace gui
const gui_save sd_icon_color = gui_save(savedata, "icon_color", gl_icon_color);

const gui_save um_geometry = gui_save(users, "geometry", QByteArray());
const gui_save um_active_user = gui_save(users, "active_user", "00000001");
const gui_save um_active_user = gui_save(users, "active_user", ""); // Deprecated

const gui_save loc_language = gui_save(localization, "language", "en");

Expand All @@ -240,8 +236,6 @@ class gui_settings : public settings
public:
explicit gui_settings(QObject* parent = nullptr);

QString GetCurrentUser();

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

Expand Down
4 changes: 2 additions & 2 deletions rpcs3/rpcs3qt/main_window.cpp
Expand Up @@ -1551,7 +1551,7 @@ void main_window::CreateConnects()

connect(ui->confSavedataManagerAct, &QAction::triggered, [this]
{
save_manager_dialog* save_manager = new save_manager_dialog(m_gui_settings);
save_manager_dialog* save_manager = new save_manager_dialog(m_gui_settings, m_persistent_settings);
connect(this, &main_window::RequestTrophyManagerRepaint, save_manager, &save_manager_dialog::HandleRepaintUiRequest);
save_manager->show();
});
Expand Down Expand Up @@ -1594,7 +1594,7 @@ void main_window::CreateConnects()

connect(ui->actionManage_Users, &QAction::triggered, [this]
{
user_manager_dialog user_manager(m_gui_settings, this);
user_manager_dialog user_manager(m_gui_settings, m_persistent_settings, this);
user_manager.exec();
m_game_list_frame->Refresh(true); // New user may have different games unlocked.
});
Expand Down
22 changes: 11 additions & 11 deletions rpcs3/rpcs3qt/patch_manager_dialog.cpp
Expand Up @@ -70,11 +70,11 @@ patch_manager_dialog::patch_manager_dialog(std::shared_ptr<gui_settings> gui_set

// Create connects
connect(ui->patch_filter, &QLineEdit::textChanged, this, &patch_manager_dialog::filter_patches);
connect(ui->patch_tree, &QTreeWidget::currentItemChanged, this, &patch_manager_dialog::on_item_selected);
connect(ui->patch_tree, &QTreeWidget::itemChanged, this, &patch_manager_dialog::on_item_changed);
connect(ui->patch_tree, &QTreeWidget::customContextMenuRequested, this, &patch_manager_dialog::on_custom_context_menu_requested);
connect(ui->cb_enable_legacy_patches, &QCheckBox::stateChanged, this, &patch_manager_dialog::on_legacy_patches_enabled);
connect(ui->cb_owned_games_only, &QCheckBox::stateChanged, this, &patch_manager_dialog::on_show_owned_games_only);
connect(ui->patch_tree, &QTreeWidget::currentItemChanged, this, &patch_manager_dialog::handle_item_selected);
connect(ui->patch_tree, &QTreeWidget::itemChanged, this, &patch_manager_dialog::handle_item_changed);
connect(ui->patch_tree, &QTreeWidget::customContextMenuRequested, this, &patch_manager_dialog::handle_custom_context_menu_requested);
connect(ui->cb_enable_legacy_patches, &QCheckBox::stateChanged, this, &patch_manager_dialog::handle_legacy_patches_enabled);
connect(ui->cb_owned_games_only, &QCheckBox::stateChanged, this, &patch_manager_dialog::handle_show_owned_games_only);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QWidget::close);
connect(ui->buttonBox, &QDialogButtonBox::clicked, [this](QAbstractButton* button)
{
Expand Down Expand Up @@ -423,7 +423,7 @@ void patch_manager_dialog::update_patch_info(const patch_manager_dialog::gui_pat
ui->label_app_version->setText(info.app_version);
}

void patch_manager_dialog::on_item_selected(QTreeWidgetItem *current, QTreeWidgetItem * /*previous*/)
void patch_manager_dialog::handle_item_selected(QTreeWidgetItem *current, QTreeWidgetItem * /*previous*/)
{
if (!current)
{
Expand Down Expand Up @@ -487,7 +487,7 @@ void patch_manager_dialog::on_item_selected(QTreeWidgetItem *current, QTreeWidge
update_patch_info(info);
}

void patch_manager_dialog::on_item_changed(QTreeWidgetItem *item, int /*column*/)
void patch_manager_dialog::handle_item_changed(QTreeWidgetItem *item, int /*column*/)
{
if (!item)
{
Expand Down Expand Up @@ -531,13 +531,13 @@ void patch_manager_dialog::on_item_changed(QTreeWidgetItem *item, int /*column*/
if (!container.is_legacy && container.patch_info_map.find(description) != container.patch_info_map.end())
{
m_map[hash].patch_info_map[description].titles[title][serial][app_version] = enabled;
on_item_selected(item, nullptr);
handle_item_selected(item, nullptr);
return;
}
}
}

void patch_manager_dialog::on_custom_context_menu_requested(const QPoint &pos)
void patch_manager_dialog::handle_custom_context_menu_requested(const QPoint &pos)
{
QTreeWidgetItem* item = ui->patch_tree->itemAt(pos);

Expand Down Expand Up @@ -773,12 +773,12 @@ void patch_manager_dialog::dropEvent(QDropEvent* event)
}
}

void patch_manager_dialog::on_legacy_patches_enabled(int state)
void patch_manager_dialog::handle_legacy_patches_enabled(int state)
{
m_legacy_patches_enabled = state == Qt::CheckState::Checked;
}

void patch_manager_dialog::on_show_owned_games_only(int state)
void patch_manager_dialog::handle_show_owned_games_only(int state)
{
m_show_owned_games_only = state == Qt::CheckState::Checked;
m_gui_settings->SetValue(gui::pm_show_owned, m_show_owned_games_only);
Expand Down