コード例 #1
0
ファイル: shortcutbutton.cpp プロジェクト: ext5/CopyQ
void ShortcutButton::updateIcons()
{
    const QColor color = getDefaultIconColor(*m_buttonAddShortcut, QPalette::Window);
    m_buttonAddShortcut->setIcon( getIcon("list-add", IconPlus, color, color) );
    const int h = m_buttonAddShortcut->sizeHint().height();
    m_buttonAddShortcut->setMaximumSize(h, h);
}
コード例 #2
0
ファイル: notification.cpp プロジェクト: wizardofozzie/CopyQ
void Notification::updateIcon()
{
    const QColor color = getDefaultIconColor(*this);
    IconFactory *iconFactory = ConfigurationManager::instance()->iconFactory();
    const int height = m_msgLabel->fontMetrics().lineSpacing() * 1.2;
    const QPixmap pixmap = iconFactory->createPixmap(m_icon, color, height);
    m_iconLabel->setPixmap(pixmap);
    m_iconLabel->resize(pixmap.size());
}
コード例 #3
0
ファイル: iconfactory.cpp プロジェクト: wizardofozzie/CopyQ
QColor getDefaultIconColor(const QWidget &widget, bool selected)
{
    const QWidget *parent = &widget;
    while ( parent->parentWidget()
            && !parent->isTopLevel()
            && !parent->testAttribute(Qt::WA_OpaquePaintEvent) )
    {
        parent = parent->parentWidget();
    }

    QPalette::ColorRole role = selected ? QPalette::Highlight : parent->backgroundRole();
    return getDefaultIconColor( parent->palette().color(QPalette::Active, role) );
}
コード例 #4
0
ファイル: iconfactory.cpp プロジェクト: rygwdn/CopyQ
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) );
}
コード例 #5
0
ファイル: iconfactory.cpp プロジェクト: rygwdn/CopyQ
QColor getDefaultIconColor(const QWidget &widget, QPalette::ColorRole colorRole)
{
    return getDefaultIconColor( widget.palette().color(QPalette::Active, colorRole) );
}
コード例 #6
0
ファイル: shortcutbutton.cpp プロジェクト: rygwdn/CopyQ
void ShortcutButton::updateIcons()
{
    const QColor color = getDefaultIconColor(*m_buttonAddShortcut, QPalette::Window);
    m_buttonAddShortcut->setIcon( getIcon("list-add", IconPlus, color, color) );
}