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
This commit is contained in:
Rosemary Witchaven 2022-07-18 07:01:53 -05:00 committed by GitHub
parent 2977016b5f
commit 9849ce2610
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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