Advertisement
KukuRuzo

psi tabs patch

May 3rd, 2024 (edited)
958
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.57 KB | None | 0 0
  1.  
  2.  
  3. diff --git a/src/widgets/psitabwidget.cpp b/src/widgets/psitabwidget.cpp
  4. index b0087c4b..ba8ea93c 100644
  5. --- a/src/widgets/psitabwidget.cpp
  6. +++ b/src/widgets/psitabwidget.cpp
  7. @@ -266,10 +266,31 @@ void PsiTabWidget::setTabText(QWidget *widget, const QString &label)
  8.  {
  9.      int index = widgets_.indexOf(widget);
  10.      if (index != -1) {
  11. -        QString shortLabel = label;
  12. -        if (label.length() > 40) {
  13. +        auto shortLabel = label;
  14. +        auto textLength = label.length();
  15. +        if (textLength > 40) {
  16. +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  17.              shortLabel = label.left(37) + "...";
  18. -            tabBar_->setTabToolTip(index, label);
  19. +#else
  20. +            shortLabel = label.first(37) + "...";
  21. +#endif
  22. +            auto maxLength = 80;
  23. +            if(textLength > maxLength) {
  24. +                auto multilineLabel = label;
  25. +                int rows = ((textLength % maxLength) > 0) ? textLength / maxLength : textLength / maxLength - 1;
  26. +                while(rows > 0) {
  27. +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  28. +                    multilineLabel.insert(multilineLabel.left(rows*maxLength).lastIndexOf(" ") + 1 , "\n");
  29. +#else
  30. +                    multilineLabel.insert(multilineLabel.first(rows*maxLength).lastIndexOf(" ") + 1 , "\n");
  31. +#endif
  32. +                    rows -= 1;
  33. +                }
  34. +                tabBar_->setTabToolTip(index,  multilineLabel);
  35. +            }
  36. +            else {
  37. +                tabBar_->setTabToolTip(index, label);
  38. +            }
  39.          }
  40.          tabBar_->setTabText(index, shortLabel);
  41.      }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement