Example #1
0
IconFactory::IconFactory()
    : m_iconColor()
    , m_iconColorActive()
    , m_useSystemIcons(true)
    , m_loaded(false)
    , m_iconCache()
    , m_resourceIconCache()
{
    m_loaded = QFontDatabase::addApplicationFont(":/images/fontawesome-webfont.ttf") != -1;

    // Try to get menu color more precisely by rendering dummy widget and getting color of pixel
    // that is presumably menu background.
    QMenu menu;

    QImage img(1, 1, QImage::Format_RGB32);
    menu.resize(16, 16);

    menu.render(&img, QPoint(-8, -8));
    m_iconColor = getDefaultIconColor( img.pixel(0, 0) );

    menu.setActiveAction( menu.addAction(QString()) );
    menu.render(&img, QPoint(-8, -8));
    m_iconColorActive = getDefaultIconColor( img.pixel(0, 0) );
}