From 9849ce261024dfce474538418fba5e68c75c988c Mon Sep 17 00:00:00 2001 From: Rosemary Witchaven <32779090+in1tiate@users.noreply.github.com> Date: Mon, 18 Jul 2022 07:01:53 -0500 Subject: [PATCH] Use QStyle to fetch checkbox size and spacing info instead of relying on magic numbers for label truncation (#805) * Use QStyle to fetch checkbox size and spacing info * remove unnecessary use of auto* * access static member the correct way --- src/courtroom.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 563c5cc..7bde837 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -5614,12 +5614,10 @@ void Courtroom::truncate_label_text(QWidget *p_widget, QString p_identifier) qInfo() << "Truncation aborted for label text" << label_text_tr << ", label text was already truncated!"; return; } - int label_theme_width = - (p_label != nullptr - ? design_ini_result.width - : design_ini_result.width - - 18); // 18 is the width of a checkbox on win10 + 5px of - // padding, TODO: fetch the actual size + + int checkbox_width = AOApplication::style()->pixelMetric(QStyle::PM_IndicatorWidth) + AOApplication::style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing); + + int label_theme_width = (p_label != nullptr ? design_ini_result.width : (design_ini_result.width - checkbox_width)); int label_px_width = p_widget->fontMetrics().boundingRect(label_text_tr).width(); // pixel width of our translated text if (!p_widget->toolTip().startsWith(label_text_tr)) // don't want to append this multiple times