aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRosemary Witchaven <32779090+in1tiate@users.noreply.github.com>2022-07-18 07:01:53 -0500
committerGitHub <noreply@github.com>2022-07-18 15:01:53 +0300
commit9849ce261024dfce474538418fba5e68c75c988c (patch)
tree82f8ce09c9055febb740c110dff8f48da40a918b
parent2977016b5f8d80d8c73d1f026618445bbe849394 (diff)
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
-rw-r--r--src/courtroom.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index 563c5cc1..7bde8377 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