- Timestamp:
- Apr 3, 2020 3:45:35 PM (5 years ago)
- 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 213 213 { 214 214 /* Configure text-label: */ 215 m_pLabelText->setText( m_strMessage);215 m_pLabelText->setText(compressLongWords(m_strMessage)); 216 216 /* Add text-label into top-layout: */ 217 217 pTopLayout->addWidget(m_pLabelText); … … 367 367 return icon.pixmap(iSize, iSize); 368 368 } 369 370 /* static */ 371 QString 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 155 155 /** Generates standard pixmap for passed @a iconType using @a pWidget as hint. */ 156 156 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); 157 160 158 161 /** Holds the title. */
Note:
See TracChangeset
for help on using the changeset viewer.