Exemple #1
0
QIcon appIcon(AppIconType iconType)
{
    const bool running = iconType == AppIconRunning;
    const QString suffix = running ? "-busy" : "-normal";
    const QString sessionName = qApp->property("CopyQ_session_name").toString();

    QIcon icon;

    if (sessionName.isEmpty())
        icon = QIcon::fromTheme("copyq" + suffix);
    else
        icon = QIcon::fromTheme("copyq-" + sessionName + "-" + suffix);

    if (icon.isNull()) {
        const QString resourceSuffix = running ? "-running" : "";
        QPixmap pix = imageFromPrefix(suffix + ".svg", "icon" + resourceSuffix);

        if (!sessionName.isEmpty()) {
            const QColor color1(0x7f, 0xca, 0x9b);
            const QColor color2 = sessionNameToColor(sessionName);
            replaceColor(&pix, color1, color2);
        }

        icon.addPixmap(pix);

        // This makes the icon smoother on some systems.
        updateIcon(&icon, pix, 48);
        updateIcon(&icon, pix, 32);
        updateIcon(&icon, pix, 24);
        updateIcon(&icon, pix, 16);
    }

    return icon;
}
Exemple #2
0
QIcon IconFactory::appIcon(AppIconFlags flags)
{
    const bool running = flags.testFlag(AppIconRunning);
    const QString suffix = running ? "-busy" : "-normal";
    const QString sessionName = qApp->property("CopyQ_session_name").toString();

    QIcon icon;

    if (sessionName.isEmpty())
        icon = QIcon::fromTheme("copyq" + suffix);

    if (icon.isNull()) {
        const QString resourceSuffix = running ? "-running" : "";
        QPixmap pix = imageFromPrefix(suffix + ".svg", "icon" + resourceSuffix);

        if (!sessionName.isEmpty()) {
            const QColor color1(0x7f, 0xca, 0x9b);
            const QColor color2 = sessionNameToColor(sessionName);
            replaceColor(&pix, color1, color2);
        }

        icon.addPixmap(pix);
    }

    if (flags.testFlag(AppIconDisabled)) {
        QIcon disabledIcon;
        foreach (const QSize &size, icon.availableSizes())
            disabledIcon.addPixmap(icon.pixmap(size, QIcon::Disabled));
        return disabledIcon;
    }
Exemple #3
0
QIcon IconFactory::appIcon(AppIconFlags flags)
{
    QPixmap pix = flags.testFlag(AppIconRunning)
            ? imageFromPrefix("-busy.svg", "icon-running")
            : imageFromPrefix("-normal.svg", "icon");

    const QString sessionName = qApp->property("CopyQ_session_name").toString();
    if (!sessionName.isEmpty()) {
        const QColor color1 = QColor(0x7f, 0xca, 0x9b);
        const QColor color2 = sessionNameToColor(sessionName);
        replaceColor(&pix, color1, color2);
    }

    if (flags.testFlag(AppIconDisabled)) {
        QPainter p(&pix);
        p.setCompositionMode(QPainter::CompositionMode_DestinationOut);
        p.fillRect(pix.rect(), QColor(100, 100, 100, 100));
    }

    return QIcon(pix);
}