Example #1
0
void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
                     const QPalette &pal, bool sunken,
                     const QBrush *fill)
{
    if (sunken)
        qDrawWinShades(p, x, y, w, h,
                       pal.shadow().color(), pal.light().color(), pal.dark().color(),
                       pal.button().color(), fill);
    else
        qDrawWinShades(p, x, y, w, h,
                       pal.light().color(), pal.shadow().color(), pal.button().color(),
                       pal.dark().color(), fill);
}
Example #2
0
/**
  ScriptMonitor constructor

  @param[in] parent The parent widget (nothing)
*/
  AbstractMonitorItem::AbstractMonitorItem(QWidget* parent, QString scriptName) : QFrame(parent) {
    second =0;
    this->scriptName = scriptName;
    QPalette aPalette;
    QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
    sizePolicy.setHorizontalStretch(0);
    sizePolicy.setVerticalStretch(0);
    sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth());
    this->setSizePolicy(sizePolicy);
    this->setFrameShape(QFrame::StyledPanel);
    this->setFrameShadow(QFrame::Raised);
    mainLayout = new QGridLayout(this);
    mainLayout->setObjectName(QString::fromUtf8("mainLayout"));
    actionLayout = new QHBoxLayout();
    isRunning = new KLed(this);
    isRunning->setObjectName(QString::fromUtf8("isRunning"));
    mainLayout->addWidget(isRunning,0,0);

    lblTitle = new QLabel(this);
    lblTitle->setObjectName(QString::fromUtf8("lblTitle"));
    lblTitle->setText("<b>"+ scriptName +"</b>");
    lblTitle->setStyleSheet("background-color:transparent;border-radius:0;");
    mainLayout->addWidget(lblTitle,0,1);

    horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    mainLayout->addItem(horizontalSpacer,0,2);

    lblTime = new QLabel(this);
    lblTime->setObjectName(QString::fromUtf8("lblTime"));
    mainLayout->addWidget(lblTime,0,3);

    verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Expanding);
    mainLayout->addItem(verticalSpacer,1,0);

    lblCmd = new QLabel(this);
    lblCmd->setObjectName(QString::fromUtf8("lblCmd"));
    lblCmd->setStyleSheet("background-color:transparent;border-radius:0;");
    lblCmd->setText("Current command: - ");
    mainLayout->addWidget(lblCmd,2,0,1,4);

    lblNextCmd = new QLabel(this);
    lblNextCmd->setObjectName(QString::fromUtf8("lblNextCmd"));
    lblNextCmd->setStyleSheet("background-color:transparent;border-radius:0;");
    lblNextCmd->setText("Next command: - ");
    mainLayout->addWidget(lblNextCmd,3,0,1,4);

    progressBar = new QProgressBar(this);
    progressBar->setObjectName(QString::fromUtf8("progressBar"));
    progressBar->setValue(0);
    progressBar->setStyleSheet("background-color:" + aPalette.button().color().name() + ";border-radius:0;color:black;text-align:center;");

    mainLayout->addWidget(progressBar,4,0,1,4);

    mainLayout->addLayout(actionLayout,5,0,1,4);


    //string defaultColor = aPalette.button().color().name();
    setStyleSheet("background-color:qlineargradient( y1:0, y2:1,stop:0 " + aPalette.window().color().name() + ", stop:1 " + aPalette.button().color().name() + ");border-radius:10;border-color:black;border-width:1px;");

  }
Example #3
0
void TupConfigurationArea::hideConfigurator()
{
    QWidget *widget = this->widget();

    if (widget && !isFloating ()) {
        // widget->setMinimumWidth(10);
        widget->setVisible(false);
        setFeatures(QDockWidget::NoDockWidgetFeatures);

        // =================

        QPalette pal = palette();
        pal.setBrush(QPalette::Background, pal.button());
        setPalette(pal);
        setAutoFillBackground(true);

        //==================

        for (int i = 0; i < 2; ++i) 
             qApp->processEvents();

        shrink();

        if (!k->toolTipShowed) {
            QToolTip::showText (k->mousePos, tr("Cursor here for expand"), this);
            k->toolTipShowed = true;
        }
    }

    k->mousePos = QCursor::pos();
}
Example #4
0
 QColor buttonColor(const QPalette& pal) const
 {
     QColor buttonColor = pal.button().color();
     const int val = qGray(buttonColor.rgb());
     buttonColor = buttonColor.lighter(100 + qMax(1, (180 - val)/6));
     buttonColor.setHsv(buttonColor.hue(), buttonColor.saturation() * 0.75, buttonColor.value());
     return buttonColor;
 }
Example #5
0
void FormStyle::GlobalColorButtonCliked()
{
	QColor initialColor;
	if ( focusWidget()->objectName() == "bC1_1" )
		initialColor = applicationPalette.button().color().rgba();
	else if ( focusWidget()->objectName() == "bC1_2" )
		initialColor = applicationPalette.window().color().rgba();
	else if ( focusWidget()->objectName() == "bC1_3" )
		initialColor = applicationPalette.shadow().color().rgba();
	else if ( focusWidget()->objectName() == "bC1_4" )
		initialColor = applicationPalette.highlight().color().rgba();
	else if ( focusWidget()->objectName() == "bC1_5" )
		initialColor = applicationPalette.base().color().rgba();
	else if ( focusWidget()->objectName() == "bC1_6" )
		initialColor = applicationPalette.text().color().rgba();
	else if ( focusWidget()->objectName() == "bC1_7" )
		initialColor = applicationPalette.highlightedText().color().rgba();
	else if ( focusWidget()->objectName() == "bC1_8" )
		initialColor = sliderButtonColor.rgb();
	else
		initialColor = Qt::white;

	QColor color = QColorDialog::getColor( initialColor, this, Texts[ 119 ] /*Wybierz kolor*/, QColorDialog::DontUseNativeDialog );

	if ( !color.isValid() )
		return;

	if ( focusWidget()->objectName() == "bC1_1" )
		applicationPalette.setBrush( QPalette::Button, color );
	else if ( focusWidget()->objectName() == "bC1_2" )
		applicationPalette.setBrush( QPalette::Window, color );
	else if ( focusWidget()->objectName() == "bC1_3" )
	{
		applicationPalette.setBrush( QPalette::Shadow, color );
		applicationPalette.setBrush( QPalette::Light, color );
		applicationPalette.setBrush( QPalette::Dark, color );
	} else if ( focusWidget()->objectName() == "bC1_4" )
		applicationPalette.setBrush( QPalette::Highlight, color );
	else if ( focusWidget()->objectName() == "bC1_5" )
		applicationPalette.setBrush( QPalette::Base, color );
	else if ( focusWidget()->objectName() == "bC1_6" )
	{
		applicationPalette.setBrush( QPalette::Text, color );
		applicationPalette.setBrush( QPalette::WindowText, color );
		applicationPalette.setBrush( QPalette::ButtonText, color );
	} else if ( focusWidget()->objectName() == "bC1_7" )
		applicationPalette.setBrush( QPalette::HighlightedText, color );
	else if ( focusWidget()->objectName() == "bC1_8" )
		sliderButtonColor = color;

	setButtonsColor();
}
Example #6
0
/*! \~russian
 * \brief Метод инициализирует элементы настройки цвета в соответствии с переданной палитрой.
 * \param palette - палитра для инициализации
 */
void Settings::initColorPickers(QPalette palette)
{
    ui->Frame_Style_Window->setColor( palette.window().color() );
    ui->Frame_Style_WindowText->setColor( palette.windowText().color() );
    ui->Frame_Style_Base->setColor( palette.base().color() );
    ui->Frame_Style_AlternateBase->setColor( palette.alternateBase().color() );
    ui->Frame_Style_ToolTipBase->setColor( palette.toolTipBase().color() );
    ui->Frame_Style_ToolTipText->setColor( palette.toolTipText().color() );
    ui->Frame_Style_Text->setColor( palette.text().color() );
    ui->Frame_Style_Button->setColor( palette.button().color() );
    ui->Frame_Style_ButtonText->setColor( palette.buttonText().color() );
    ui->Frame_Style_BrightText->setColor( palette.brightText().color() );
    ui->Frame_Style_Link->setColor( palette.link().color() );
    ui->Frame_Style_Highlight->setColor( palette.highlight().color() );
    ui->Frame_Style_HighlightedText->setColor( palette.highlightedText().color() );
}
Example #7
0
void FormStyle::setButtonsColor()
{
	if ( ui.ccB->isChecked() )
	{
		QPalette tmpPalette;

		tmpPalette.setBrush( QPalette::Button, applicationPalette.button() );
		ui.bC1_1->setPalette( tmpPalette );
		tmpPalette.setBrush( QPalette::Button, applicationPalette.window() );
		ui.bC1_2->setPalette( tmpPalette );
		tmpPalette.setBrush( QPalette::Button, applicationPalette.shadow() );
		ui.bC1_3->setPalette( tmpPalette );
		tmpPalette.setBrush( QPalette::Button, applicationPalette.highlight() );
		ui.bC1_4->setPalette( tmpPalette );
		tmpPalette.setBrush( QPalette::Button, applicationPalette.base() );
		ui.bC1_5->setPalette( tmpPalette );
		tmpPalette.setBrush( QPalette::Button, applicationPalette.text() );
		ui.bC1_6->setPalette( tmpPalette );
		tmpPalette.setBrush( QPalette::Button, applicationPalette.highlightedText() );
		ui.bC1_7->setPalette( tmpPalette );
		tmpPalette.setBrush( QPalette::Button, sliderButtonColor );
		ui.bC1_8->setPalette( tmpPalette );

		if ( !mainWindowPixmap.isNull() )
		{
			QBrush brushW( mainWindowPixmap.scaled( ui.bP2_2->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
			tmpPalette.setBrush( QPalette::Button, brushW );
			ui.bP2_2->setPalette( tmpPalette );
		}
		else
			ui.bP2_2->setPalette( qApp->palette() );
	}
	else
	{
		ui.bC1_1->setPalette( qApp->palette() );
		ui.bC1_2->setPalette( qApp->palette() );
		ui.bC1_3->setPalette( qApp->palette() );
		ui.bC1_4->setPalette( qApp->palette() );
		ui.bC1_5->setPalette( qApp->palette() );
		ui.bC1_6->setPalette( qApp->palette() );
		ui.bC1_7->setPalette( qApp->palette() );
		ui.bC1_8->setPalette( qApp->palette() );

		ui.bP2_2->setPalette( qApp->palette() );
	}
}
void KisCategorizedItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
    painter->resetTransform();

    if(!index.data(__CategorizedListModelBase::IsHeaderRole).toBool()) {
        QStyleOptionViewItem sovi(option);

        if (index.data(__CategorizedListModelBase::isLockableRole).toBool()) {
            bool locked = index.data(__CategorizedListModelBase::isLockedRole).toBool();
            const QIcon icon = locked ? KisIconUtils::loadIcon(koIconName("locked")) : KisIconUtils::loadIcon(koIconName("unlocked"));
            const int iconSize = qMax(16, m_minimumItemHeight - 2);

            sovi.decorationPosition = QStyleOptionViewItem::Right;
            sovi.decorationAlignment = Qt::AlignRight;
            sovi.decorationSize = QSize(iconSize, iconSize);
            sovi.features |= QStyleOptionViewItem::HasDecoration;
            sovi.icon = icon;
        }

        QStyledItemDelegate::paint(painter, sovi, index);
        painter->setOpacity(1);
    }
    else {
        QPalette palette = QApplication::palette();
        if(option.state & QStyle::State_MouseOver)
            painter->fillRect(option.rect, palette.midlight());
        else
            painter->fillRect(option.rect, palette.button());

        painter->setBrush(palette.buttonText());
        painter->drawText(option.rect, index.data().toString(), QTextOption(Qt::AlignVCenter|Qt::AlignHCenter));

        paintTriangle(
            painter,
            option.rect.x(),
            option.rect.y(),
            option.rect.height(),
            !index.data(__CategorizedListModelBase::ExpandCategoryRole).toBool()
        );
    }
    painter->resetTransform();
}
Example #9
0
// motif arrows look the same whether they are used or not
// is this correct?
static void qDrawMotifArrow(QPainter *p, Qt::ArrowType type, bool down,
                             int x, int y, int w, int h,
                             const QPalette &pal, bool)
{
    QPolygon bFill;                                // fill polygon
    QPolygon bTop;                                // top shadow.
    QPolygon bBot;                                // bottom shadow.
    QPolygon bLeft;                                // left shadow.
    QTransform matrix;                            // xform matrix
    bool vertical = type == Qt::UpArrow || type == Qt::DownArrow;
    bool horizontal = !vertical;
    int         dim = w < h ? w : h;
    int         colspec = 0x0000;                        // color specification array

    if (dim < 2)                                // too small arrow
        return;

    if (dim > 3) {
        if (dim > 6)
            bFill.resize(dim & 1 ? 3 : 4);
        bTop.resize((dim/2)*2);
        bBot.resize(dim & 1 ? dim + 1 : dim);
        bLeft.resize(dim > 4 ? 4 : 2);
        bLeft.putPoints(0, 2, 0,0, 0,dim-1);
        if (dim > 4)
            bLeft.putPoints(2, 2, 1,2, 1,dim-3);
        bTop.putPoints(0, 4, 1,0, 1,1, 2,1, 3,1);
        bBot.putPoints(0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2);

        for(int i=0; i<dim/2-2 ; i++) {
            bTop.putPoints(i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i);
            bBot.putPoints(i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i);
        }
        if (dim & 1)                                // odd number size: extra line
            bBot.putPoints(dim-1, 2, dim-3,dim/2, dim-1,dim/2);
        if (dim > 6) {                        // dim>6: must fill interior
            bFill.putPoints(0, 2, 1,dim-3, 1,2);
            if (dim & 1)                        // if size is an odd number
                bFill.setPoint(2, dim - 3, dim / 2);
            else
                bFill.putPoints(2, 2, dim-4,dim/2-1, dim-4,dim/2);
        }
    }
    else {
        if (dim == 3) {                        // 3x3 arrow pattern
            bLeft.setPoints(4, 0,0, 0,2, 1,1, 1,1);
            bTop .setPoints(2, 1,0, 1,0);
            bBot .setPoints(2, 1,2, 2,1);
        }
        else {                                        // 2x2 arrow pattern
            bLeft.setPoints(2, 0,0, 0,1);
            bTop .setPoints(2, 1,0, 1,0);
            bBot .setPoints(2, 1,1, 1,1);
        }
    }

    if (type == Qt::UpArrow || type == Qt::LeftArrow) {
        matrix.translate(x, y);
        if (vertical) {
            matrix.translate(0, h - 1);
            matrix.rotate(-90);
        } else {
            matrix.translate(w - 1, h - 1);
            matrix.rotate(180);
        }
        if (down)
            colspec = horizontal ? 0x2334 : 0x2343;
        else
            colspec = horizontal ? 0x1443 : 0x1434;
    }
    else if (type == Qt::DownArrow || type == Qt::RightArrow) {
        matrix.translate(x, y);
        if (vertical) {
            matrix.translate(w-1, 0);
            matrix.rotate(90);
        }
        if (down)
            colspec = horizontal ? 0x2443 : 0x2434;
        else
            colspec = horizontal ? 0x1334 : 0x1343;
    }

    const QColor *cols[5];
    cols[0] = 0;
    cols[1] = &pal.button().color();
    cols[2] = &pal.mid().color();
    cols[3] = &pal.light().color();
    cols[4] = &pal.dark().color();
#define CMID        *cols[(colspec>>12) & 0xf]
#define CLEFT        *cols[(colspec>>8) & 0xf]
#define CTOP        *cols[(colspec>>4) & 0xf]
#define CBOT        *cols[colspec & 0xf]

    QPen     savePen   = p->pen();                // save current pen
    QBrush   saveBrush = p->brush();                // save current brush
    QTransform wxm = p->transform();
    QPen     pen(Qt::NoPen);
    const QBrush &brush = pal.brush(QPalette::Button);

    p->setPen(pen);
    p->setBrush(brush);
    p->setTransform(matrix, true);                // set transformation matrix
    p->drawPolygon(bFill);                        // fill arrow
    p->setBrush(Qt::NoBrush);                        // don't fill

    p->setPen(CLEFT);
    p->drawLines(bLeft);
    p->setPen(CTOP);
    p->drawLines(bTop);
    p->setPen(CBOT);
    p->drawLines(bBot);

    p->setTransform(wxm);
    p->setBrush(saveBrush);                        // restore brush
    p->setPen(savePen);                        // restore pen

#undef CMID
#undef CLEFT
#undef CTOP
#undef CBOT
}
void KTThemeSelector::setupChooseColor()
{
	DVHBox *hbox = new DVHBox(this, Qt::Horizontal);
	DVHBox *box1 = new DVHBox(hbox, Qt::Vertical);
	box1->boxLayout()->setMargin(10);
	m_general = new QGroupBox(tr("General"), box1);
	
	QGridLayout *layout1 = new QGridLayout(m_general);
	
	QStringList labels1 = QStringList() << tr("Text") << tr("Base") << tr("Foreground") << tr("Background") << tr("Button") << tr("Button Text");
	
	QStringList names = QStringList() << "Text" << "Base" << "Foreground" << "Background" << "Button" << "ButtonText";
	
	QPalette colorGroup = QApplication::palette();
	
	
	QList<QColor> colors = QList<QColor>() << colorGroup.text ().color() << colorGroup.base().color() << colorGroup.foreground().color() << colorGroup.background().color() << colorGroup.button().color() << colorGroup.buttonText().color();
	
	for(int i = 0; i < labels1.count(); i++)
	{
		layout1->addWidget(new QLabel(labels1[i], m_general), i, 0 );
		DColorButton *button = new DColorButton(m_general);
		button->setObjectName(names[i]);
		QPalette pal = button->palette();
		pal.setColor(QPalette::Button, colors[i]);
		button->setPalette(pal);
		
		m_generalButtonGroup.addButton(button);
		layout1->addWidget(button, i, 1);
		m_generalSection.insert(names[i], colors[i].name());
	}
	
	m_effects = new QGroupBox(tr("Effects"), box1);
	
	QGridLayout *layout2 = new QGridLayout(m_effects);
	
	QStringList labels2 = QStringList() << tr("Light") << tr("Midlight") << tr("Dark") << tr("Mid");
	QStringList names2 = QStringList() << "Light" << "Midlight" << "Dark" << "Mid";
	
	colors.clear();
	colors << colorGroup.light().color() << colorGroup.midlight().color() << colorGroup.dark().color() << colorGroup.mid().color();
	
	for(int i = 0; i < labels2.count(); i++)
	{
		layout2->addWidget(new QLabel(labels2[i], m_effects), i, 0 );
		DColorButton *button = new DColorButton(m_effects);
		button->setObjectName(names2[i]);
		QPalette pal = button->palette();
		pal.setColor(QPalette::Button, colors[i]);
		button->setPalette(pal);
		m_effectsButtonGroup.addButton(button);
		layout2->addWidget(button, i, 1);
		m_effectsSection.insert(names2[i], colors[i].name());
	}
	////////////
	
	DVHBox *box2 = new DVHBox(hbox, Qt::Vertical);
	box2->boxLayout()->setMargin(10);
	m_selections = new QGroupBox(tr("Selections"), box2);
	
	QGridLayout *layout3 = new QGridLayout(m_selections);
	
	QStringList labels3 = QStringList() << tr("Highlight") << tr("Highlighted Text");
	QStringList names3 = QStringList() << "Highlight" << "HighlightedText";
	colors.clear();
	colors << colorGroup.highlight().color() << colorGroup.highlightedText().color();
	
	for(int i = 0; i < labels3.count(); i++)
	{
		layout3->addWidget(new QLabel(labels3[i], m_selections), i, 0 );
		DColorButton *button = new DColorButton(m_selections);
		button->setObjectName(names3[i]);
		QPalette pal = button->palette();
		pal.setColor(QPalette::Button, colors[i]);
		button->setPalette(pal);
		m_selectionsButtonGroup.addButton(button);
		layout3->addWidget(button, i, 1);
		m_selectionsSection.insert(names3[i], colors[i].name());
	}
	
	m_textEffects = new QGroupBox(tr("Text effects"), box2);
	
	QGridLayout *layout4 = new QGridLayout(m_textEffects);
	QStringList labels4 = QStringList() << tr("Bright Text") << tr("Link") << tr("Link Visited");
	QStringList names4 = QStringList() << "BrightText" << "Link" << "LinkVisited";
	
	colors.clear();
	colors << colorGroup.brightText().color() << colorGroup.link().color() << colorGroup.linkVisited().color();
	
	for(int i = 0; i < labels4.count(); i++)
	{
		layout4->addWidget(new QLabel(labels4[i], m_textEffects), i, 0 );
		DColorButton *button = new DColorButton(m_textEffects);
		button->setObjectName(names4[i]);
		QPalette pal = button->palette();
		pal.setColor(QPalette::Button, colors[i]);
		button->setPalette(pal);
		m_textEffectsButtonGroup.addButton(button);
		layout4->addWidget(button, i, 1);
		m_textEffectsSection.insert(names4[i], colors[i].name());
	}
	
	QGroupBox *schemeWidget = new QGroupBox(tr("Schema"), box2); // FIXME: add vertical layout
	QVBoxLayout *schemaLayout = new QVBoxLayout;
	
	m_allSchemes = new QTreeWidget;
	m_allSchemes->setHeaderLabels ( QStringList() << tr("Schema") << tr( "Owner" ) << tr( "Date" ) );
	m_allSchemes->header()->setResizeMode(QHeaderView::Stretch);
	
	schemaLayout->addWidget(m_allSchemes);
	
	connect(m_allSchemes, SIGNAL(itemDoubleClicked (QTreeWidgetItem *, int )), this, SLOT(loadSchemaFromListView( QTreeWidgetItem *, int )));
	
	QPushButton *saveSchemeButton = new QPushButton(tr("Save schema"));
	connect(saveSchemeButton, SIGNAL(clicked()), SLOT(saveSchema()));
	
	schemaLayout->addWidget(saveSchemeButton);
	
	schemeWidget->setLayout(schemaLayout);
	
	new DSeparator(this);
	new QLabel(tr("Style"), this);
	DStyleComboBox *styleComboBox = new DStyleComboBox(this);
	Q_UNUSED(styleComboBox);
	new DSeparator(this);
	m_useColors = new QCheckBox(tr("Use this colors"), this);
	
	connect(&m_generalButtonGroup, SIGNAL(buttonClicked(QAbstractButton * )), SLOT(chooseGeneralColor(QAbstractButton * )));
	connect(&m_effectsButtonGroup, SIGNAL(buttonClicked(QAbstractButton * )), SLOT(chooseEffectsColor(QAbstractButton * )));
	connect(&m_selectionsButtonGroup, SIGNAL(buttonClicked(QAbstractButton * )), SLOT(chooseSelectionsColor(QAbstractButton * )));
	connect(&m_textEffectsButtonGroup, SIGNAL(buttonClicked(QAbstractButton * )), SLOT(chooseTextEffectsColor(QAbstractButton * )));
}
Example #11
0
void drawDial(const QStyleOptionSlider *option, QPainter *painter)
{
    QPalette pal = option->palette;
    QColor buttonColor = pal.button().color();
    const int width = option->rect.width();
    const int height = option->rect.height();
    const bool enabled = option->state & QStyle::State_Enabled;
    qreal r = qMin(width, height) / 2;
    r -= r/50;
    const qreal penSize = r/20.0;

    painter->save();

    // Draw notches
    if (option->subControls & QStyle::SC_DialTickmarks) {
        painter->setPen(option->palette.dark().color().darker(120));
        painter->drawLines(QStyleHelper::calcLines(option));
    }

    // Cache dial background
    BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("qdial"));

    const qreal d_ = r / 6;
    const qreal dx = option->rect.x() + d_ + (width - 2 * r) / 2 + 1;
    const qreal dy = option->rect.y() + d_ + (height - 2 * r) / 2 + 1;

    QRectF br = QRectF(dx + 0.5, dy + 0.5,
                       int(r * 2 - 2 * d_ - 2),
                       int(r * 2 - 2 * d_ - 2));
    buttonColor.setHsv(buttonColor .hue(),
                       qMin(140, buttonColor .saturation()),
                       qMax(180, buttonColor.value()));
    QColor shadowColor(0, 0, 0, 20);

    if (enabled) {
        // Drop shadow
        qreal shadowSize = qMax(1.0, penSize/2.0);
        QRectF shadowRect= br.adjusted(-2*shadowSize, -2*shadowSize,
                                       2*shadowSize, 2*shadowSize);
        QRadialGradient shadowGradient(shadowRect.center().x(),
                                       shadowRect.center().y(), shadowRect.width()/2.0,
                                       shadowRect.center().x(), shadowRect.center().y());
        shadowGradient.setColorAt(qreal(0.91), QColor(0, 0, 0, 40));
        shadowGradient.setColorAt(qreal(1.0), Qt::transparent);
        p->setBrush(shadowGradient);
        p->setPen(Qt::NoPen);
        p->translate(shadowSize, shadowSize);
        p->drawEllipse(shadowRect);
        p->translate(-shadowSize, -shadowSize);

        // Main gradient
        QRadialGradient gradient(br.center().x() - br.width()/3, dy,
                                 br.width()*1.3, br.center().x(),
                                 br.center().y() - br.height()/2);
        gradient.setColorAt(0, buttonColor.lighter(110));
        gradient.setColorAt(qreal(0.5), buttonColor);
        gradient.setColorAt(qreal(0.501), buttonColor.darker(102));
        gradient.setColorAt(1, buttonColor.darker(115));
        p->setBrush(gradient);
    } else {
        p->setBrush(Qt::NoBrush);
    }

    p->setPen(QPen(buttonColor.darker(280)));
    p->drawEllipse(br);
    p->setBrush(Qt::NoBrush);
    p->setPen(buttonColor.lighter(110));
    p->drawEllipse(br.adjusted(1, 1, -1, -1));

    if (option->state & QStyle::State_HasFocus) {
        QColor highlight = pal.highlight().color();
        highlight.setHsv(highlight.hue(),
                         qMin(160, highlight.saturation()),
                         qMax(230, highlight.value()));
        highlight.setAlpha(127);
        p->setPen(QPen(highlight, 2.0));
        p->setBrush(Qt::NoBrush);
        p->drawEllipse(br.adjusted(-1, -1, 1, 1));
    }

    END_STYLE_PIXMAPCACHE

    QPointF dp = calcRadialPos(option, qreal(0.70));
    buttonColor = buttonColor.lighter(104);
    buttonColor.setAlphaF(qreal(0.8));
    const qreal ds = r/qreal(7.0);
    QRectF dialRect(dp.x() - ds, dp.y() - ds, 2*ds, 2*ds);
    QRadialGradient dialGradient(dialRect.center().x() + dialRect.width()/2,
                                 dialRect.center().y() + dialRect.width(),
                                 dialRect.width()*2,
                                 dialRect.center().x(), dialRect.center().y());
    dialGradient.setColorAt(1, buttonColor.darker(140));
    dialGradient.setColorAt(qreal(0.4), buttonColor.darker(120));
    dialGradient.setColorAt(0, buttonColor.darker(110));
    if (penSize > 3.0) {
        painter->setPen(QPen(QColor(0, 0, 0, 25), penSize));
        painter->drawLine(calcRadialPos(option, qreal(0.90)), calcRadialPos(option, qreal(0.96)));
    }

    painter->setBrush(dialGradient);
    painter->setPen(QColor(255, 255, 255, 150));
    painter->drawEllipse(dialRect.adjusted(-1, -1, 1, 1));
    painter->setPen(QColor(0, 0, 0, 80));
    painter->drawEllipse(dialRect);
    painter->restore();
}
Example #12
0
static
void drawDial ( const QStyleOptionSlider *option, QPainter *painter )
{
	QPalette pal = option->palette;
	QColor buttonColor = pal.button().color();
	const int width = option->rect.width();
	const int height = option->rect.height();
	const bool enabled = option->state & QStyle::State_Enabled;
	qreal r = qMin(width, height) / 2;
	r -= r/50;
	const qreal penSize = r/20.0;

	painter->save();
	painter->setRenderHint(QPainter::Antialiasing);

	// Draw notches
	if (option->subControls & QStyle::SC_DialTickmarks) {
		painter->setPen(option->palette.dark().color().darker(120));
		painter->drawLines(calcLines(option));
	}

	// Cache dial background
	QString a = QString::fromLatin1("qdial");
	QRect rect = option->rect;
	QPixmap internalPixmapCache;
	QImage imageCache;
	QPainter *p = painter;
	QString unique = uniqueName((a), option, option->rect.size());
	int txType = painter->deviceTransform().type() | painter->worldTransform().type();
	bool doPixmapCache = txType <= QTransform::TxTranslate;
	if (doPixmapCache && QPixmapCache::find(unique, internalPixmapCache)) {
		painter->drawPixmap(option->rect.topLeft(), internalPixmapCache);
	} else {
		if (doPixmapCache) {
			rect.setRect(0, 0, option->rect.width(), option->rect.height());
			imageCache = QImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
			imageCache.fill(0);
			p = new QPainter(&imageCache);
		}
	//--BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("qdial"));

		p->setRenderHint(QPainter::Antialiasing);

		const qreal d_ = r / 6;
		const qreal dx = option->rect.x() + d_ + (width - 2 * r) / 2 + 1;
		const qreal dy = option->rect.y() + d_ + (height - 2 * r) / 2 + 1;

		QRectF br = QRectF(dx + 0.5, dy + 0.5,
						   int(r * 2 - 2 * d_ - 2),
						   int(r * 2 - 2 * d_ - 2));
		buttonColor.setHsv(buttonColor .hue(),
						   qMin(140, buttonColor .saturation()),
						   qMax(180, buttonColor.value()));
		QColor shadowColor(0, 0, 0, 20);

		if (enabled) {
			// Drop shadow
			qreal shadowSize = qMax(1.0, penSize/2.0);
			QRectF shadowRect= br.adjusted(-2*shadowSize, -2*shadowSize,
										   2*shadowSize, 2*shadowSize);
			QRadialGradient shadowGradient(shadowRect.center().x(),
										   shadowRect.center().y(), shadowRect.width()/2.0,
										   shadowRect.center().x(), shadowRect.center().y());
			shadowGradient.setColorAt(qreal(0.91), QColor(0, 0, 0, 40));
			shadowGradient.setColorAt(qreal(1.0), Qt::transparent);
			p->setBrush(shadowGradient);
			p->setPen(Qt::NoPen);
			p->translate(shadowSize, shadowSize);
			p->drawEllipse(shadowRect);
			p->translate(-shadowSize, -shadowSize);

			// Main gradient
			QRadialGradient gradient(br.center().x() - br.width()/3, dy,
									 br.width()*1.3, br.center().x(),
									 br.center().y() - br.height()/2);
			gradient.setColorAt(0, buttonColor.lighter(110));
			gradient.setColorAt(qreal(0.5), buttonColor);
			gradient.setColorAt(qreal(0.501), buttonColor.darker(102));
			gradient.setColorAt(1, buttonColor.darker(115));
			p->setBrush(gradient);
		} else {
			p->setBrush(Qt::NoBrush);
		}

		p->setPen(QPen(buttonColor.darker(280)));
		p->drawEllipse(br);
		p->setBrush(Qt::NoBrush);
		p->setPen(buttonColor.lighter(110));
		p->drawEllipse(br.adjusted(1, 1, -1, -1));

		if (option->state & QStyle::State_HasFocus) {
			QColor highlight = pal.highlight().color();
			highlight.setHsv(highlight.hue(),
							 qMin(160, highlight.saturation()),
							 qMax(230, highlight.value()));
			highlight.setAlpha(127);
			p->setPen(QPen(highlight, 2.0));
			p->setBrush(Qt::NoBrush);
			p->drawEllipse(br.adjusted(-1, -1, 1, 1));
		}
	//--END_STYLE_PIXMAPCACHE
		if (doPixmapCache) {
			p->end();
			delete p;
			internalPixmapCache = QPixmap::fromImage(imageCache);
			painter->drawPixmap(option->rect.topLeft(), internalPixmapCache);
			QPixmapCache::insert(unique, internalPixmapCache);
		}
	}


	QPointF dp = calcRadialPos(option, qreal(0.70));
	buttonColor = buttonColor.lighter(104);
	buttonColor.setAlphaF(qreal(0.8));
	const qreal ds = r/qreal(7.0);
	QRectF dialRect(dp.x() - ds, dp.y() - ds, 2*ds, 2*ds);
	QRadialGradient dialGradient(dialRect.center().x() + dialRect.width()/2,
								 dialRect.center().y() + dialRect.width(),
								 dialRect.width()*2,
								 dialRect.center().x(), dialRect.center().y());
	dialGradient.setColorAt(1, buttonColor.darker(140));
	dialGradient.setColorAt(qreal(0.4), buttonColor.darker(120));
	dialGradient.setColorAt(0, buttonColor.darker(110));
	if (penSize > 3.0) {
		painter->setPen(QPen(QColor(0, 0, 0, 25), penSize));
		painter->drawLine(calcRadialPos(option, qreal(0.90)), calcRadialPos(option, qreal(0.96)));
	}

	painter->setBrush(dialGradient);
	painter->setPen(QColor(255, 255, 255, 150));
	painter->drawEllipse(dialRect.adjusted(-1, -1, 1, 1));
	painter->setPen(QColor(0, 0, 0, 80));
	painter->drawEllipse(dialRect);
	painter->restore();
}
Example #13
0
void FormStyle::quickSetColor()
{
	QFont globalFont = SystemFont;

	if ( ui.ccB->isChecked() && !ResetColor )
	{
		qApp->setPalette( applicationPalette );

		QPalette qSliderPalette;
		qSliderPalette.setBrush( QPalette::Button, sliderButtonColor );
		qApp->setPalette( qSliderPalette, "QSlider" );

		if ( ui.use2->isChecked() )
		{
			QPalette tmpPalette = qApp->palette();

			if ( !mainWindowPixmap.isNull() )
			{
				QBrush brushW( mainWindowPixmap.scaled( f1.size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
				tmpPalette.setBrush( QPalette::Window, brushW );
			}

			QColor colorA;

			colorA = tmpPalette.button().color();
			colorA.setAlphaF( ui.bP2_1->value() );
			tmpPalette.setBrush( QPalette::Button, colorA );

			colorA = tmpPalette.base().color();
			colorA.setAlphaF( ui.bP2_1->value() );
			tmpPalette.setBrush( QPalette::Base, colorA );

			if ( ui.bHt2->isChecked() )
			{
				colorA = tmpPalette.highlight().color();
				colorA.setAlphaF( ui.bP2_1->value() );
				tmpPalette.setBrush( QPalette::Highlight, colorA );
			}

			if ( ui.bSt2->isChecked() )
			{
				colorA = tmpPalette.shadow().color();
				colorA.setAlphaF( ui.bP2_1->value() );
				tmpPalette.setBrush( QPalette::Shadow, colorA );
			}

			f1.setPalette( tmpPalette );
		}
		else
		{
			f1.setPalette( qApp->palette() );
		}

		globalFont = ui.bF1->currentFont();
		globalFont.setPointSize( ui.bFSize1->value() );
	}
	else
	{
		qApp->setPalette( systemPalette );
		f1.setPalette( qApp->palette() );
		sliderButtonColor = qApp->palette().brush( QPalette::Button ).color();
	}

	if ( ResetColor )
	{
		ResetColor = false;
		applicationPalette = systemPalette;
		ui.bF1->setCurrentFont( SystemFont.toString() );
		ui.bFSize1->setValue( SystemFont.pointSize() );
	}

	QColor col = qApp->palette().window().color();
	col.setAlphaF( ui.bP2_1->value() );
	fsl.SetColor( col );

	f1.ui.pbL->setPalette( qApp->palette() );
	f1.ui.pbR->setPalette( qApp->palette() );

	globalFont.setBold( false );
	globalFont.setItalic( false );
	globalFont.setUnderline( false );
	if ( globalFont.pointSize() > 14 )
		globalFont.setPointSize( 14 );
	else if ( globalFont.pointSize() < 6 )
		globalFont.setPointSize( 6 );
#ifndef Q_OS_MAC
	qApp->setFont( globalFont );
#endif
}
Example #14
0
 QColor tabFrameColor(const QPalette& pal) const
 {
     if (! pal.button().texture().isNull())
         return QColor(255, 255, 255, 8);
     return buttonColor(pal).lighter(104);
 }
void DColorButton::setPalette ( const QPalette & pal)
{
	m_color = pal.button().color();
}