Merge pull request #421 from AttorneyOnline/fix/tooltip-shenanigans

Label truncation fixes
This commit is contained in:
oldmud0 2021-01-20 11:15:51 -06:00 committed by GitHub
commit 56750c343b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5402,6 +5402,10 @@ void Courtroom::truncate_label_text(QWidget *p_widget, QString p_identifier)
QString label_text_tr = QString label_text_tr =
QCoreApplication::translate(p_widget->metaObject()->className(), "%1") QCoreApplication::translate(p_widget->metaObject()->className(), "%1")
.arg((p_label != nullptr ? p_label->text() : p_checkbox->text())); .arg((p_label != nullptr ? p_label->text() : p_checkbox->text()));
if (label_text_tr.endsWith("") || label_text_tr.endsWith("")) {
qInfo() << "Truncation aborted for label text" << label_text_tr << ", label text was already truncated!";
return;
}
int label_theme_width = int label_theme_width =
(p_label != nullptr (p_label != nullptr
? design_ini_result.width ? design_ini_result.width
@ -5410,7 +5414,8 @@ void Courtroom::truncate_label_text(QWidget *p_widget, QString p_identifier)
// padding, TODO: fetch the actual size // padding, TODO: fetch the actual size
int label_px_width = int label_px_width =
p_widget->fontMetrics().boundingRect(label_text_tr).width(); // pixel width of our translated text p_widget->fontMetrics().boundingRect(label_text_tr).width(); // pixel width of our translated text
p_widget->setToolTip(label_text_tr + "\n" + p_widget->toolTip()); if (!p_widget->toolTip().startsWith(label_text_tr)) // don't want to append this multiple times
p_widget->setToolTip(label_text_tr + "\n" + p_widget->toolTip());
// qInfo() << "I: Width of label text: " << label_px_width << "px. Theme's // qInfo() << "I: Width of label text: " << label_px_width << "px. Theme's
// width: " << label_theme_width << "px."; // width: " << label_theme_width << "px.";