- Timestamp:
- Jan 26, 2007 4:27:01 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 17927
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r284 r363 355 355 static QString formatSize (Q_UINT64, int aMode = 0); 356 356 357 static QString highlight (const QString &aStr, bool aToolTip = false); 358 357 359 signals: 358 360 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h
r281 r363 199 199 const QString &errorMsg); 200 200 201 static QString highlight (const QString &str);202 201 static QString formatErrorInfo (const COMErrorInfo &info, 203 202 HRESULT wrapperRC = S_OK); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r284 r363 1616 1616 1617 1617 return QString ("%1 %2").arg (number).arg (Suffixes [suffix]); 1618 } 1619 1620 /* static */ 1621 /** 1622 * Reformats the input string @a aStr so that: 1623 * - strings in single quotes will be put inside <nobr> and marked 1624 * with blue color; 1625 * - UUIDs be put inside <nobr> and marked 1626 * with green color; 1627 * - replaces new line chars with </p><p> constructs to form paragraphs 1628 * (note that <p> and </p> are not appended to the beginnign and to the 1629 * end of the string respectively, to allow the result be appended 1630 * or prepended to the existing paragraph). 1631 * 1632 * If @a aToolTip is true, colouring is not applied, only the <nobr> tag 1633 * is added. Also, new line chars are replaced with <br> instead of <p>. 1634 */ 1635 QString VBoxGlobal::highlight (const QString &aStr, bool aToolTip /* = false */) 1636 { 1637 QString strFont; 1638 QString uuidFont; 1639 QString endFont; 1640 if (!aToolTip) 1641 { 1642 strFont = "<font color=#0000CC>"; 1643 uuidFont = "<font color=#008000>"; 1644 endFont = "</font>"; 1645 } 1646 1647 QString text = aStr; 1648 1649 /* mark strings in single quotes with color */ 1650 QRegExp rx = QRegExp ("((?:^|\\s)[(]?)'([^']*)'(?=[:.-!);]?(?:\\s|$))"); 1651 rx.setMinimal (true); 1652 text.replace (rx, 1653 QString ("\\1%1<nobr>'\\2'</nobr>%2") 1654 .arg (strFont). arg (endFont)); 1655 1656 /* mark UUIDs with color */ 1657 text.replace (QRegExp ( 1658 "((?:^|\\s)[(]?)" 1659 "(\\{[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\\})" 1660 "(?=[:.-!);]?(?:\\s|$))"), 1661 QString ("\\1%1<nobr>\\2</nobr>%2") 1662 .arg (uuidFont). arg (endFont)); 1663 1664 /* split to paragraphs at \n chars */ 1665 if (!aToolTip) 1666 text.replace ('\n', "</p><p>"); 1667 else 1668 text.replace ('\n', "<br>"); 1669 1670 return text; 1618 1671 } 1619 1672 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp
r281 r363 464 464 const QString &error) 465 465 { 466 message ( 467 mainWindowShown(), 468 Critical, 466 message (mainWindowShown(), Critical, 469 467 tr ("<p>Failed to load the global GUI configuration.</p>" 470 468 "<p>The application will now terminate.</p>"), 471 !vbox.isOk() ? formatErrorInfo (vbox) : highlight (error)472 );469 !vbox.isOk() ? formatErrorInfo (vbox) 470 : QString ("<p>%1</p>").arg (VBoxGlobal::highlight (error))); 473 471 } 474 472 … … 1336 1334 "<tr><td><p>%1.</p></td></tr>" 1337 1335 "</table><p></p>") 1338 .arg ( highlight (errorMsg));1336 .arg (VBoxGlobal::highlight (errorMsg)); 1339 1337 1340 1338 if (!errorID.isEmpty()) … … 1390 1388 1391 1389 /* static */ 1392 QString VBoxProblemReporter::highlight (const QString &str)1393 {1394 QString text = str;1395 /* mark strings in single quotes with color */1396 QRegExp rx = QRegExp ("((?:^|\\s)[(]?)'([^']*)'(?=[:.-!);]?(?:\\s|$))");1397 rx.setMinimal (true);1398 text.replace (rx, "\\1'<font color=#0000CC>\\2</font>'");1399 /* mark UUIDs with color */1400 text.replace (QRegExp (1401 "((?:^|\\s)[(]?)"1402 "(\\{[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\\})"1403 "(?=[:.-!);]?(?:\\s|$))"),1404 "\\1<font color=#008000>\\2</font>");1405 /* split to paragraphs at \n chars */1406 text.replace ('\n', "</p><p>");1407 return text;1408 }1409 1410 /* static */1411 1390 QString VBoxProblemReporter::formatErrorInfo (const COMErrorInfo &info, 1412 1391 HRESULT wrapperRC) … … 1419 1398 "<tr><td><p>%1.</p></td></tr>" 1420 1399 "</table><p></p>") 1421 .arg ( highlight (info.text()));1400 .arg (VBoxGlobal::highlight (info.text())); 1422 1401 1423 1402 formatted += "<table bgcolor=#EEEEEE border=0 cellspacing=0 " -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxDiskImageManagerDlg.ui.h
r254 r363 965 965 tip = tr ("<nobr><b>%1</b></nobr><br>%2", "HDD") 966 966 .arg (location) 967 .arg (aHd.GetLastAccessError()); 967 .arg (VBoxGlobal::highlight (aHd.GetLastAccessError(), 968 true /* aToolTip */)); 968 969 break; 969 970 }
Note:
See TracChangeset
for help on using the changeset viewer.