VirtualBox

Changeset 363 in vbox for trunk


Ignore:
Timestamp:
Jan 26, 2007 4:27:01 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
17927
Message:

FE/Qt: Moved highlight() from VBoxProblemReporter to VBoxGlobal.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h

    r284 r363  
    355355    static QString formatSize (Q_UINT64, int aMode = 0);
    356356
     357    static QString highlight (const QString &aStr, bool aToolTip = false);
     358
    357359signals:
    358360
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h

    r281 r363  
    199199                           const QString &errorMsg);
    200200
    201     static QString highlight (const QString &str);
    202201    static QString formatErrorInfo (const COMErrorInfo &info,
    203202                                    HRESULT wrapperRC = S_OK);
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r284 r363  
    16161616   
    16171617    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 */
     1635QString 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;
    16181671}
    16191672
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp

    r281 r363  
    464464                                                  const QString &error)
    465465{
    466     message (
    467         mainWindowShown(),
    468         Critical,
     466    message (mainWindowShown(), Critical,
    469467        tr ("<p>Failed to load the global GUI configuration.</p>"
    470468            "<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)));
    473471}
    474472
     
    13361334                              "<tr><td><p>%1.</p></td></tr>"
    13371335                              "</table><p></p>")
    1338                               .arg (highlight (errorMsg));
     1336                              .arg (VBoxGlobal::highlight (errorMsg));
    13391337
    13401338    if (!errorID.isEmpty())
     
    13901388
    13911389/* 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 */
    14111390QString VBoxProblemReporter::formatErrorInfo (const COMErrorInfo &info,
    14121391                                              HRESULT wrapperRC)
     
    14191398                              "<tr><td><p>%1.</p></td></tr>"
    14201399                              "</table><p></p>")
    1421                               .arg (highlight (info.text()));
     1400                              .arg (VBoxGlobal::highlight (info.text()));
    14221401
    14231402    formatted += "<table bgcolor=#EEEEEE border=0 cellspacing=0 "
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxDiskImageManagerDlg.ui.h

    r254 r363  
    965965            tip = tr ("<nobr><b>%1</b></nobr><br>%2", "HDD")
    966966                      .arg (location)
    967                       .arg (aHd.GetLastAccessError());
     967                      .arg (VBoxGlobal::highlight (aHd.GetLastAccessError(),
     968                                                   true /* aToolTip */));
    968969            break;
    969970        }
Note: See TracChangeset for help on using the changeset viewer.

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