From 1b3c416f77cbc45772d812e7632b9b4af79f59db Mon Sep 17 00:00:00 2001 From: Dino Date: Mon, 6 Oct 2025 23:37:28 -0400 Subject: [PATCH] #1672 - Mac only fix for qt client disappearing "About..." menu items --- client/helpdata.c | 15 +++++++++++++++ client/include/helpdlg_g.h | 17 ++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/client/helpdata.c b/client/helpdata.c index c87de80624..f502f84fa1 100644 --- a/client/helpdata.c +++ b/client/helpdata.c @@ -1359,6 +1359,21 @@ get_help_item_spec(const char *name, enum help_page_type htype, int *pos) while (*p == ' ') { p++; } + +#ifdef __APPLE__ + // See comment in helpdlg_g.h about Qt client issue with menu entries + // starting with "About". + // If help list item starts with "About" and name contains "About", + // then line them up. + // Note - the invisible character is unicode and becomes 3 bytes. + { + char *ptr = strstr(name, "About"); + if ((strncmp(p, "About", strlen("About")) == 0) && (ptr != NULL)) { + name = ptr; + } + } +#endif // __APPLE__ + if (strcmp(name, p) == 0 && (htype == HELP_ANY || htype == ptmp->type)) { pitem = ptmp; break; diff --git a/client/include/helpdlg_g.h b/client/include/helpdlg_g.h index b90f847e61..475c5f68b3 100644 --- a/client/include/helpdlg_g.h +++ b/client/include/helpdlg_g.h @@ -38,10 +38,26 @@ GUI_FUNC_PROTO(void, popdown_help_dialog, void) #define HELP_WORKLIST_EDITOR_ITEM N_("Worklist Editor") #define HELP_CMA_ITEM N_("Citizen Governor") #define HELP_CONTROLS_ITEM N_("Controls") + +#ifdef __APPLE__ + // On Mac, Qt moves any menu entry that starts with "About" to the + // application menu, which is the Mac standard UI but not what we want. + // To work around, prepend an invisible unicode character so the string + // comparison fails. Also have to hack get_help_item_spec() in helpdata.c + // to skip over that invisible character when it does its string comparison. +#define HELP_RULESET_ITEM N_("\u200B""About Current Ruleset") +#define HELP_TILESET_ITEM N_("\u200B""About Current Tileset") +#define HELP_MUSICSET_ITEM N_("\u200B""About Current Musicset") +#define HELP_NATIONS_ITEM N_("\u200B""About Nations") +#define HELP_ABOUT_ITEM N_("\u200B""About Freeciv") +#else // __APPLE__ #define HELP_RULESET_ITEM N_("About Current Ruleset") #define HELP_TILESET_ITEM N_("About Current Tileset") #define HELP_MUSICSET_ITEM N_("About Current Musicset") #define HELP_NATIONS_ITEM N_("About Nations") +#define HELP_ABOUT_ITEM N_("About Freeciv") +#endif // __APPLE__ + #define HELP_ECONOMY_ITEM N_("Economy") #define HELP_CITIES_ITEM N_("Cities") #define HELP_IMPROVEMENTS_ITEM N_("City Improvements") @@ -56,7 +72,6 @@ GUI_FUNC_PROTO(void, popdown_help_dialog, void) #define HELP_DIPLOMACY_ITEM N_("Diplomacy") #define HELP_SPACE_RACE_ITEM N_("Space Race") #define HELP_COPYING_ITEM N_("Copying") -#define HELP_ABOUT_ITEM N_("About Freeciv") #define HELP_MULTIPLIER_ITEM N_("Policies") #define HELP_COUNTER_ITEM N_("Counters") -- 2.31.0