Qt: Prefer eliding source over the middle of the binding

Makes arrows more readable.
This commit is contained in:
Stenzek
2025-11-20 14:08:34 +10:00
parent 542a2cf0d5
commit e7862b9ca7
2 changed files with 20 additions and 3 deletions

View File

@@ -594,8 +594,17 @@ bool Achievements::CreateClient(rc_client_t** client, std::unique_ptr<HTTPDownlo
rc_client_set_userdata(new_client, http->get());
// Allow custom host to be overridden through config.
if (const std::string host = Host::GetBaseStringSettingValue("Cheevos", "Host"); !host.empty())
rc_client_set_host(new_client, host.c_str());
if (std::string host = Host::GetBaseStringSettingValue("Cheevos", "Host"); !host.empty())
{
// drop trailing hash, rc_client appends its own
while (!host.empty() && host.back() == '/')
host.pop_back();
if (!host.empty())
{
INFO_COLOR_LOG(StrongOrange, "Using alternative host for achievements: {}", host);
rc_client_set_host(new_client, host.c_str());
}
}
*client = new_client;
return true;

View File

@@ -66,7 +66,15 @@ void InputBindingWidget::updateElidedText()
const int button_margin = style()->pixelMetric(QStyle::PM_ButtonMargin, nullptr, this);
const int frame_width = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, this);
const int text_width = std::max(1, width() - button_margin - frame_width * 2);
QString elided = fontMetrics().elidedText(m_full_text, Qt::ElideMiddle, text_width);
const QFontMetrics fm = fontMetrics();
QString elided = fm.elidedText(m_full_text, Qt::ElideMiddle, text_width);
// prefer removing the source part first
if (elided != m_full_text)
{
if (const qsizetype pos = m_full_text.indexOf('/'); pos >= 0)
elided = fm.elidedText(m_full_text.mid(pos + 1), Qt::ElideMiddle, text_width);
}
// fix up accelerators
if (elided.contains('&'))