Exemple #1
0
/* static */
void UIIconPool::addName(QIcon &icon, const QString &strName,
                         QIcon::Mode mode /* = QIcon::Normal */, QIcon::State state /* = QIcon::Off */)
{
    /* Prepare pixmap on the basis of passed value: */
    QPixmap pixmap(strName);
    /* Add pixmap: */
    icon.addPixmap(pixmap, mode, state);

#ifdef Q_WS_MAC
# ifdef VBOX_GUI_WITH_HIDPI
    /* Test if HiDPI icons are enabled. Works only with a patched version of Qt 4.x
     * with the changes from https://codereview.qt-project.org/#change,54636 applied. */
    if (qApp->testAttribute(Qt::AA_UseHighDpiPixmaps))
    {
        /* Parse name to prefix and suffix: */
        QString strPrefix = strName.section('.', 0, -2);
        QString strSuffix = strName.section('.', -1, -1);
        /* Prepare HiDPI pixmap on the basis of values above: */
        QPixmap pixmapHiDPI(strPrefix + "_hidpi." + strSuffix);
        /* Add HiDPI pixmap (if any): */
        if (!pixmapHiDPI.isNull())
            icon.addPixmap(pixmapHiDPI, mode, state);
    }
# endif /* VBOX_GUI_WITH_HIDPI */
#endif /* Q_WS_MAC */
}
/* static */
void UIIconPool::addName(QIcon &icon, const QString &strName,
                         QIcon::Mode mode /* = QIcon::Normal */, QIcon::State state /* = QIcon::Off */)
{
    /* Prepare pixmap on the basis of passed value: */
    QPixmap pixmap(strName);
    /* Add pixmap: */
    icon.addPixmap(pixmap, mode, state);

#ifdef VBOX_WS_MAC
    /* Test if HiDPI icons are enabled: */
    if (!qApp->testAttribute(Qt::AA_UseHighDpiPixmaps))
        return;
#endif /* VBOX_WS_MAC */

    /* Parse name to prefix and suffix: */
    QString strPrefix = strName.section('.', 0, -2);
    QString strSuffix = strName.section('.', -1, -1);
    /* Prepare HiDPI pixmaps: */
    const QStringList aPixmapNames = QStringList() << (strPrefix + "_x2." + strSuffix)
                                                   /*<< (strPrefix + "_x3." + strSuffix)
                                                   << (strPrefix + "_x4." + strSuffix)*/;
    foreach (const QString &strPixmapName, aPixmapNames)
    {
        QPixmap pixmapHiDPI(strPixmapName);
        if (!pixmapHiDPI.isNull())
            icon.addPixmap(pixmapHiDPI, mode, state);
    }