Skip to content

Commit

Permalink
Bring the recent system files checks changes to Qt menu (#16251)
Browse files Browse the repository at this point in the history
  • Loading branch information
bslenul authored Feb 18, 2024
1 parent 47df5e6 commit de8e33c
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 8 deletions.
6 changes: 2 additions & 4 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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, "",
Expand All @@ -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, "",
Expand Down
58 changes: 54 additions & 4 deletions ui/drivers/ui_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -2432,13 +2462,33 @@ 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)) + ":";
hash["value"] = "";

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. */

Expand Down

0 comments on commit de8e33c

Please sign in to comment.