Пример #1
0
static Icon createIcon(bool isPlus)
{
    Icon icon;
    QColor stdColor=QColor(QApplication::palette().color(QPalette::Active, QPalette::ButtonText));
    QColor highlightColor=stdColor.red()<100 ? stdColor.lighter(50) : stdColor.darker(50);
    QList<int> sizes=QList<int>() << 16 << 22;

    foreach (int s, sizes) {
        icon.addPixmap(createPixmap(s, stdColor, 1.0, isPlus));
        icon.addPixmap(createPixmap(s, stdColor, 0.5, isPlus), QIcon::Disabled);
        icon.addPixmap(createPixmap(s, highlightColor, 1.0, isPlus), QIcon::Active);
    }
Пример #2
0
Icon Icon::getMediaIcon(const QString &name)
{
    static QList<QIcon::Mode> modes=QList<QIcon::Mode>() << QIcon::Normal << QIcon::Disabled << QIcon::Active << QIcon::Selected;
    Icon icn;
    Icon icon(name);

    foreach (QIcon::Mode mode, modes) {
        icn.addPixmap(icon.pixmap(QSize(64, 64), mode).scaled(QSize(28, 28), Qt::KeepAspectRatio, Qt::SmoothTransformation), mode);
        icn.addPixmap(icon.pixmap(QSize(48, 48), mode), mode);
        icn.addPixmap(icon.pixmap(QSize(32, 32), mode), mode);
        icn.addPixmap(icon.pixmap(QSize(24, 24), mode), mode);
        icn.addPixmap(icon.pixmap(QSize(22, 22), mode), mode);
        icn.addPixmap(icon.pixmap(QSize(16, 16), mode), mode);
    }