VirtualBox

Changeset 83535 in vbox for trunk/src


Ignore:
Timestamp:
Apr 3, 2020 3:45:35 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9669: QIMessageBox: Compress long words of more than 100 symbols in size (consisting of alphanumeric characters) with ellipsiss; This is so far related to message only, not details.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/extensions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMessageBox.cpp

    r83524 r83535  
    213213            {
    214214                /* Configure text-label: */
    215                 m_pLabelText->setText(m_strMessage);
     215                m_pLabelText->setText(compressLongWords(m_strMessage));
    216216                /* Add text-label into top-layout: */
    217217                pTopLayout->addWidget(m_pLabelText);
     
    367367    return icon.pixmap(iSize, iSize);
    368368}
     369
     370/* static */
     371QString QIMessageBox::compressLongWords(QString strText)
     372{
     373    // WORKAROUND:
     374    // The idea is to compress long words of more than 100 symbols in size consisting of alphanumeric
     375    // characters with ellipsiss using the following template:
     376    // "[50 first symbols]...[50 last symbols]"
     377    QRegExp re("[a-zA-Z0-9]{101,}");
     378    int iPosition = re.indexIn(strText);
     379    bool fChangeAllowed = iPosition != -1;
     380    while (fChangeAllowed)
     381    {
     382        QString strNewText = strText;
     383        const QString strFound = re.cap(0);
     384        strNewText.replace(iPosition, strFound.size(), strFound.left(50) + "..." + strFound.right(50));
     385        fChangeAllowed = fChangeAllowed && strText != strNewText;
     386        strText = strNewText;
     387        iPosition = re.indexIn(strText);
     388        fChangeAllowed = fChangeAllowed && iPosition != -1;
     389    }
     390    return strText;
     391}
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMessageBox.h

    r83524 r83535  
    155155    /** Generates standard pixmap for passed @a iconType using @a pWidget as hint. */
    156156    static QPixmap standardPixmap(AlertIconType iconType, QWidget *pWidget = 0);
     157
     158    /** Compresses @a strText with ellipsis on the basis of certain logic. */
     159    static QString compressLongWords(QString strText);
    157160
    158161    /** Holds the title. */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette