Bring the recent system files checks changes to Qt menu (#16251)

This commit is contained in:
Bobby Smith 2024-02-18 17:22:57 +01:00 committed by GitHub
parent 47df5e6547
commit de8e33c6b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 56 additions and 8 deletions

View File

@ -722,8 +722,6 @@ static int menu_displaylist_parse_core_info(
* adjust the path to check for firmware files */
if (systemfiles_in_content_dir && content_is_inited)
{
size_t len;
strlcpy(tmp_path, path_get(RARCH_PATH_CONTENT), sizeof(tmp_path));
path_basedir(tmp_path);
@ -775,7 +773,7 @@ static int menu_displaylist_parse_core_info(
/* If 'System Files are in Content Directory' is enabled, let's add a note about it. */
if (systemfiles_in_content_dir)
{
len = strlcpy(tmp,
strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_IN_CONTENT_DIRECTORY),
sizeof(tmp));
if (menu_entries_append(list, tmp, "",
@ -784,7 +782,7 @@ static int menu_displaylist_parse_core_info(
}
/* Show the path that was checked */
len = snprintf(tmp, sizeof(tmp),
snprintf(tmp, sizeof(tmp),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_PATH),
firmware_info.directory.system);
if (menu_entries_append(list, tmp, "",

View File

@ -2416,12 +2416,42 @@ QVector<QHash<QString, QString> > MainWindow::getCoreInfo()
if (core_info->firmware_count > 0)
{
core_info_ctx_firmware_t firmware_info;
bool update_missing_firmware = false;
bool set_missing_firmware = false;
settings_t *settings = config_get_ptr();
bool update_missing_firmware = false;
bool set_missing_firmware = false;
settings_t *settings = config_get_ptr();
uint8_t flags = content_get_flags();
bool systemfiles_in_content_dir = settings->bools.systemfiles_in_content_dir;
bool content_is_inited = flags & CONTENT_ST_FLAG_IS_INITED;
char tmp_path[PATH_MAX_LENGTH];
firmware_info.path = core_info->path;
firmware_info.directory.system = settings->paths.directory_system;
/* If 'System Files are in Content Directory' is enabled and content is inited,
* adjust the path to check for firmware files */
if (systemfiles_in_content_dir && content_is_inited)
{
strlcpy(tmp_path, path_get(RARCH_PATH_CONTENT), sizeof(tmp_path));
path_basedir(tmp_path);
/* If content path is empty, fall back to global system dir path */
if (string_is_empty(tmp_path))
firmware_info.directory.system = settings->paths.directory_system;
else
{
size_t len = strlen(tmp_path);
/* Removes trailing slash (unless root dir), doesn't really matter
* but it's more consistent with how the path is stored and
* displayed without 'System Files are in Content Directory' */
if ( string_count_occurrences_single_character(tmp_path, PATH_DEFAULT_SLASH_C()) > 1
&& tmp_path[len - 1] == PATH_DEFAULT_SLASH_C())
tmp_path[len - 1] = '\0';
firmware_info.directory.system = tmp_path;
}
}
else
firmware_info.directory.system = settings->paths.directory_system;
update_missing_firmware = core_info_list_update_missing_firmware(&firmware_info, &set_missing_firmware);
@ -2432,6 +2462,7 @@ QVector<QHash<QString, QString> > MainWindow::getCoreInfo()
if (update_missing_firmware)
{
char tmp[PATH_MAX_LENGTH];
QHash<QString, QString> hash;
hash["key"] = QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE)) + ":";
@ -2439,6 +2470,25 @@ QVector<QHash<QString, QString> > MainWindow::getCoreInfo()
infoList.append(hash);
/* If 'System Files are in Content Directory' is enabled, let's add a note about it. */
if (systemfiles_in_content_dir)
{
hash["key"] = QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_IN_CONTENT_DIRECTORY));
hash["value"] = "";
infoList.append(hash);
}
/* Show the path that was checked */
snprintf(tmp, sizeof(tmp),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_PATH),
firmware_info.directory.system);
hash["key"] = QString(tmp);
hash["value"] = "";
infoList.append(hash);
/* FIXME: This looks hacky and probably
* needs to be improved for good translation support. */