Desktop companions: tooltips wrap instead of running across the screen

Tatsuya79, on the Qt settings dialog after 9eaa3750bd: "that's a
concise tip" - the Threaded Video sublabel rendered as one line the
width of a 2560 px desktop.

Qt shows a plain-text tooltip on a single line whatever its length
and only wraps rich text, so every tip now goes in as escaped rich
text (<qt>...</qt>), which Qt wraps to its usual tooltip width. The
core-option tips, which word_wrap() already breaks at 50 columns,
keep their breaks inside <pre>.

The Win32 list-view info tip has the same habit until its tooltip
control is given TTM_SETMAXTIPWIDTH; both the settings and core
options lists now set one (420 px at 96 DPI, scaled). Cocoa wraps
tooltips on its own.

Checked: Qt6 build, tools/companion_qt_persist_test.sh,
tools/companion_win32_test.sh under Wine, mingw_syntax_check.
This commit is contained in:
libretroadmin committed 2026-09-10 22:14:54 +02:00
1 parent d91aa4e0de
commit ee37994dc3
2 files changed
+29 -4

No files matched your search

+16 -4
View File
@@ -103,6 +103,15 @@ static void qt_set_playlist_hidden(const QString &path, bool hidden)
#ifdef HAVE_MENU
static const QRegularExpression decimalsRegex("%.(\\d)f");
/* Qt shows a plain-text tooltip on one line however long it is - a
* sublabel paragraph ran the width of a 2560 px desktop. It wraps
* rich text to a sane width, so tips go in as escaped rich text. */
static inline QString wrapped_tooltip(const char *text)
{
return QStringLiteral("<qt>") + QString::fromUtf8(text).toHtmlEscaped()
+ QStringLiteral("</qt>");
}
static inline void add_sublabel_and_whats_this(
QWidget *widget, rarch_setting_t *setting)
{
@@ -111,7 +120,7 @@ static inline void add_sublabel_and_whats_this(
if (menu_cbs_sublabel_for_enum((enum msg_hash_enums)setting->enum_idx,
(unsigned)setting->type, setting->size, tmp, sizeof(tmp)))
widget->setToolTip(tmp);
widget->setToolTip(wrapped_tooltip(tmp));
msg_hash_get_help_enum((enum msg_hash_enums)setting->enum_idx,
tmp, sizeof(tmp));
@@ -2668,7 +2677,7 @@ ViewOptionsWidget::ViewOptionsWidget(MainWindow *mainwindow, QWidget *parent) :
};
for (size_t i = 0; i < sizeof(tips) / sizeof(tips[0]); i++)
{
const char *tip = msg_hash_to_str(tips[i].help);
QString tip = wrapped_tooltip(msg_hash_to_str(tips[i].help));
tips[i].w->setToolTip(tip);
if (QWidget *label = form->labelForField(tips[i].w))
label->setToolTip(tip);
@@ -3101,8 +3110,11 @@ void CoreOptionsDialog::buildLayout()
word_wrap(new_info, new_info_len, option->info,
option_info_len, 50, 100, 0);
descLabel->setToolTip(new_info);
combo_box->setToolTip(new_info);
/* already wrapped to 50 columns: keep the line breaks */
descLabel->setToolTip(QStringLiteral("<qt><pre>")
+ QString::fromUtf8(new_info).toHtmlEscaped()
+ QStringLiteral("</pre></qt>"));
combo_box->setToolTip(descLabel->toolTip());
free(new_info);
}
+13
View File
@@ -2805,6 +2805,17 @@ static LRESULT CALLBACK cw_opts_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPAR
}
/* Shared shape of the two secondary windows: class, frame, list. */
/* A list view's info tip is one line however long unless its tooltip
* control is given a maximum width; give it one so a paragraph wraps
* instead of running off the screen. The control exists once the
* extended style is set; a missing one is harmless. */
static void cw_infotip_wrap(ui_companion_win32_wimp_t *w, HWND list)
{
HWND tip = (HWND)SendMessageA(list, LVM_GETTOOLTIPS, 0, 0);
if (tip)
SendMessageA(tip, TTM_SETMAXTIPWIDTH, 0, CW_S(w, 420));
}
static HWND cw_table_window(ui_companion_win32_wimp_t *w, const char *cls,
WNDPROC proc, const char *title, int width, HWND *list_out, int list_id)
{
@@ -2871,6 +2882,7 @@ static void cw_opts_show(ui_companion_win32_wimp_t *w)
/* The core's own description of each option, on hover. */
SendMessageA(w->opts_list, LVM_SETEXTENDEDLISTVIEWSTYLE,
LVS_EX_INFOTIP, LVS_EX_INFOTIP);
cw_infotip_wrap(w, w->opts_list);
cw_table_button(w->opts_hwnd, "Reset", IDC_CW_OPTS_RESET, false);
cw_table_button(w->opts_hwnd, "Reset All", IDC_CW_OPTS_RESET_ALL, false);
cw_table_button(w->opts_hwnd, "Close", IDC_CW_OPTS_CLOSE, true);
@@ -3178,6 +3190,7 @@ static void cw_set_show(ui_companion_win32_wimp_t *w)
/* Hover help per row, served from LVN_GETINFOTIP below. */
SendMessageA(w->set_list, LVM_SETEXTENDEDLISTVIEWSTYLE,
LVS_EX_INFOTIP, LVS_EX_INFOTIP);
cw_infotip_wrap(w, w->set_list);
w->set_edit = CreateWindowExA(WS_EX_CLIENTEDGE, "EDIT", "",
WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_AUTOHSCROLL,
0, 0, 0, 0, w->set_hwnd, (HMENU)IDC_CW_SET_EDIT, inst, NULL);