Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/widgets/psitabwidget.cpp b/src/widgets/psitabwidget.cpp
- index b0087c4b..ba8ea93c 100644
- --- a/src/widgets/psitabwidget.cpp
- +++ b/src/widgets/psitabwidget.cpp
- @@ -266,10 +266,31 @@ void PsiTabWidget::setTabText(QWidget *widget, const QString &label)
- {
- int index = widgets_.indexOf(widget);
- if (index != -1) {
- - QString shortLabel = label;
- - if (label.length() > 40) {
- + auto shortLabel = label;
- + auto textLength = label.length();
- + if (textLength > 40) {
- +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- shortLabel = label.left(37) + "...";
- - tabBar_->setTabToolTip(index, label);
- +#else
- + shortLabel = label.first(37) + "...";
- +#endif
- + auto maxLength = 80;
- + if(textLength > maxLength) {
- + auto multilineLabel = label;
- + int rows = ((textLength % maxLength) > 0) ? textLength / maxLength : textLength / maxLength - 1;
- + while(rows > 0) {
- +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- + multilineLabel.insert(multilineLabel.left(rows*maxLength).lastIndexOf(" ") + 1 , "\n");
- +#else
- + multilineLabel.insert(multilineLabel.first(rows*maxLength).lastIndexOf(" ") + 1 , "\n");
- +#endif
- + rows -= 1;
- + }
- + tabBar_->setTabToolTip(index, multilineLabel);
- + }
- + else {
- + tabBar_->setTabToolTip(index, label);
- + }
- }
- tabBar_->setTabText(index, shortLabel);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement