Merge pull request #421 from AttorneyOnline/fix/tooltip-shenanigans
Label truncation fixes
This commit is contained in:
commit
56750c343b
@ -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,6 +5414,7 @@ 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
|
||||||
|
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());
|
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.";
|
||||||
|
Loading…
Reference in New Issue
Block a user