Пример #1
0
void QColorPickerTool::paintEvent ( QPaintEvent * )
{

   QStyleOptionToolButton option;
   option.initFrom( this );

   option.features = QStyleOptionToolButton::HasMenu;
   //option.state = this->style()->stat

   QPixmap icon( 10, 10 );
   QPainter iconPainter( &icon );
   iconPainter.fillRect( 0, 0, 10, 10, _selectedColor );
   //option.icon = icon;

   QPainter painter ( this );
   //option.text = "COLOR";
   option.text = text();
   //painter.fillRect( 0, 0, 10, 10, _selectedColor );
   //painter.setPen( _selectedColor );
   //painter.drawText( 0 ,20, "A" );
   //this->setIcon( icon );

   style()->drawComplexControl( QStyle::CC_ToolButton, &option, &painter, this );

}
Пример #2
0
void
IconShack::GenerateIpodScrobblingIcons( MooseEnums::UserIconColour eColour )
{
    for( int i = 0; i < 4; i++ )
    {
        QImage icon = maGoodIcons[ eColour ].toImage();
        QPainter iconPainter( &icon );
        iconPainter.setCompositionMode( QPainter::CompositionMode_SourceOver );
        QPixmap overlay( MooseUtils::dataPath( QString( "icons/ipod_overlay_%1.png" ).arg( i ) ) );
        iconPainter.drawPixmap( 0, 0, overlay );
        mIpodScrobblingIcons[ eColour ].push_back( QPixmap::fromImage( icon ) );
    }
}
void ContentBlockingInformationWidget::updateState()
{
	m_icon = (isCustomized() ? getOptions().value(QLatin1String("icon")).value<QIcon>() : QIcon());

	if (m_icon.isNull())
	{
		m_icon = ThemesManager::createIcon(QLatin1String("content-blocking"));
	}

	const int iconSize(this->iconSize().width());
	const int fontSize(qMax((iconSize / 2), 12));
	QFont font(this->font());
	font.setBold(true);
	font.setPixelSize(fontSize);

	QString label;

	if (m_amount > 999999)
	{
		label = QString::number(m_amount / 1000000) + QLatin1Char('M');
	}
	else if (m_amount > 999)
	{
		label = QString::number(m_amount / 1000) + QLatin1Char('K');
	}
	else
	{
		label = QString::number(m_amount);
	}

	const qreal labelWidth(QFontMetricsF(font).width(label));

	font.setPixelSize(fontSize * 0.8);

	QRectF rectangle((iconSize - labelWidth), (iconSize - fontSize), labelWidth, fontSize);
	QPixmap pixmap(m_icon.pixmap(iconSize, iconSize, (m_isContentBlockingEnabled ? QIcon::Normal : QIcon::Disabled)));
	QPainter iconPainter(&pixmap);
	iconPainter.fillRect(rectangle, (m_isContentBlockingEnabled ? Qt::darkRed : Qt::darkGray));
	iconPainter.setFont(font);
	iconPainter.setPen(QColor(255, 255, 255, 230));
	iconPainter.drawText(rectangle, Qt::AlignCenter, label);

	m_icon = QIcon(pixmap);

	setText(getText());
	setToolTip(text());
	setIcon(m_icon);

	m_elementsMenu->setEnabled(m_amount > 0);
}
Пример #4
0
void QColorPicker::on_popup_selected( QColor color )
{
   if(color==QColor())
      setText(tr("Automatic"));
   else
      setText(color.name().toUpper());

   QPixmap icon( 10, 10 );
   QPainter iconPainter( &icon );
   iconPainter.fillRect( 0, 0, 10, 10, _selectedColor );
   setIcon(icon);

   _selectedColor = color;
   update();
}
Пример #5
0
void MainConfigurationWindow::setIconThemes()
{
    ConfigListWidget *iconThemes = static_cast<ConfigListWidget *>(widget()->widgetById("iconThemes"));
    iconThemes->clear();

    m_iconThemeManager->loadThemes();

    (void)QT_TRANSLATE_NOOP("@default", "default");

    QStringList values;
    QStringList captions;
    for (auto const &theme : m_iconThemeManager->themes())
    {
        values.append(theme.name());
        captions.append(QCoreApplication::translate("@default", theme.name().toUtf8().constData()));
    }

    iconThemes->setItems(values, captions);
    iconThemes->setCurrentItem(m_iconThemeManager->currentTheme().name());

    QStringList iconPaths;
    iconPaths << "protocols/xmpp/online"
              << "protocols/gadu-gadu/online"
              << "protocols/common/message"
              << "preferences-other";

    QList<QIcon> icons;
    for (auto const &theme : m_iconThemeManager->themes())
    {
        QPixmap combinedIcon(iconPaths.count() * 36, 36);
        combinedIcon.fill(Qt::transparent);

        QPainter iconPainter(&combinedIcon);

        for (int i = 0; i < iconPaths.count(); i++)
        {
            KaduIcon kaduIcon(iconPaths.at(i));
            kaduIcon.setThemePath(theme.path());
            QIcon icon = m_iconsManager->iconByPath(kaduIcon);
            icon.paint(&iconPainter, 2 + 36 * i, 2, 32, 32);
        }

        icons.append(QIcon(combinedIcon));
    }

    iconThemes->setIconSize(QSize(iconPaths.count() * 36, 36));
    iconThemes->setIcons(icons);
}
Пример #6
0
void QColorPicker::paintEvent ( QPaintEvent * )
{
   QStyleOptionButton option;
   option.initFrom( this );

   option.features = QStyleOptionButton::HasMenu;

   option.text = _selectedColor.name();// text();
   QPixmap icon( 10, 10 );
   QPainter iconPainter( &icon );
   iconPainter.fillRect( 0, 0, 10, 10, _selectedColor );
   this->setIcon( icon );
   option.icon = icon;//();

   QPainter painter ( this );

   style()->drawControl( QStyle::CE_PushButton, &option, &painter, this );
}
Пример #7
0
QColorPicker::QColorPicker(QWidget *parent, bool toolbarMode) :
    QPushButton( parent ), _toolbarMode(toolbarMode)
{
   popup = new QColorPickerPopup( this );
   popup->setVisible(false);
   popup->setObjectName( QString::fromUtf8("popup") );
   popup->setFrameShape(QFrame::StyledPanel);
   popup->setFrameShadow(QFrame::Plain);

   setText("Automatic");

//   setMinimumWidth( _toolbarMode ? 35 : 100 );
   _selectedColor = Qt::black;

   QPixmap icon( 10, 10 );
   QPainter iconPainter( &icon );
   iconPainter.fillRect( 0, 0, 10, 10, _selectedColor );
   this->setIcon( icon );

   QMetaObject::connectSlotsByName( this );
}
Пример #8
0
//QColorPickerTool
QColorPickerTool::QColorPickerTool(QWidget *parent) :
    QToolButton( parent )
{
   popup = new QColorPickerPopup( this );
   popup->setVisible(false);
   popup->setObjectName( QString::fromUtf8("popup") );
   popup->setFrameShape(QFrame::StyledPanel);
   popup->setFrameShadow(QFrame::Plain);

   //setMinimumWidth( 350 );
   _selectedColor = Qt::black;
   this->setToolButtonStyle( Qt::ToolButtonIconOnly );
   QPixmap icon( 10, 10 );
   QPainter iconPainter( &icon );
   iconPainter.fillRect( 0, 0, 10, 10, _selectedColor );
   this->setIcon( icon );
this->setArrowType( Qt::DownArrow );
this->setCheckable( false );
this->setToolButtonStyle( Qt::ToolButtonFollowStyle );

   QMetaObject::connectSlotsByName( this );
}