Пример #1
0
void StatusChangeButton::paintEvent(QPaintEvent *event)
{
	QStylePainter painter(this);

	if(underMouse()) {
		QStyleOptionButton opt;
		opt.initFrom(this);

		if(isDown()) {
			opt.state |= QStyle::State_Sunken;
		}

		painter.drawControl(QStyle::CE_PushButton, opt);
	}

	painter.setPen(palette().color(QPalette::Text));

	QRect textRect = rect();
	textRect.moveLeft(iconSize().width() + 4);
	painter.drawText(textRect, Qt::AlignVCenter | Qt::TextSingleLine, text());

	painter.drawPixmap(QPoint(2, (height() - iconSize().height()) / 2), icon().pixmap(iconSize()));

	QStyleOptionComboBox opt;
	opt.initFrom(this);
	opt.rect = QRect(width() - 15, height() / 2 - 6, 11, 13);
	painter.drawPrimitive(QStyle::PE_IndicatorArrowDown, opt);
}
Пример #2
0
bool RenderThemeQt::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
{
    StylePainter p(i);
    if (!p.isValid())
       return true;

    QStyleOptionButton option;
    if (p.widget)
       option.initFrom(p.widget);

    option.rect = r;
    option.state |= QStyle::State_Small;

    EAppearance appearance = applyTheme(option, o);
    if(appearance == PushButtonAppearance || appearance == ButtonAppearance) {
        option.rect = inflateButtonRect(option.rect);
        p.drawControl(QStyle::CE_PushButton, option);
    } else if(appearance == RadioAppearance) {
       p.drawControl(QStyle::CE_RadioButton, option);
    } else if(appearance == CheckboxAppearance) {
       p.drawControl(QStyle::CE_CheckBox, option);
    }

    return false;
}
Пример #3
0
    VerticalButton::VerticalButton(QWidget * parent) : QPushButton(parent)
    {
        setMouseTracking ( true );
        installEventFilter(this);

        pointeurSouris = 0;
        clickSouris = 0;

        QStyleOptionButton option;
        option.initFrom(this);
        couleurSelection = option.palette.highlight().color();

        red = 255;
        green = 255;
        blue = 255;
        h = 255;
        s = 255;

        v= 255.0;
        dv = couleurSelection.value()/400.0;

        xBoundingRect = 0;
        yBoundingRect = 0;

        _id = _staticId;
        _staticId++;
    }
Пример #4
0
void LocationButton::paintEvent ( QPaintEvent * )
{
    QStyleOptionButton option;
    option.initFrom( this );
    option.state |= QStyle::State_Enabled;
    QPainter p( this );

    if( underMouse() )
    {
        p.save();
        p.setRenderHint( QPainter::Antialiasing, true );
        QColor c = palette().color( QPalette::Highlight );
        p.setPen( c );
        p.setBrush( c.lighter( 150 ) );
        p.setOpacity( 0.2 );
        p.drawRoundedRect( option.rect.adjusted( 0, 2, 0, -2 ), 5, 5 );
        p.restore();
    }

    QRect r = option.rect.adjusted( PADDING, 0, -PADDING - (b_arrow ? 10 : 0), 0 );

    QString str( text() );
    /* This check is absurd, but either it is not done properly inside elidedText(),
       or boundingRect() is wrong */
    if( r.width() < fontMetrics().boundingRect( text() ).width() )
        str = fontMetrics().elidedText( text(), Qt::ElideRight, r.width() );
    p.drawText( r, Qt::AlignVCenter | Qt::AlignLeft, str );

    if( b_arrow )
    {
        option.rect.setWidth( 10 );
        option.rect.moveRight( rect().right() );
        style()->drawPrimitive( QStyle::PE_IndicatorArrowRight, &option, &p );
    }
}
Пример #5
0
QStyleOptionButton QxtPushButtonPrivate::getStyleOption() const
{
    QStyleOptionButton option;
    option.initFrom(&qxt_p());
    if (rot & Vertical_Mask)
    {
        QSize size = option.rect.size();
        size.transpose();
        option.rect.setSize(size);
    }
    option.features = QStyleOptionButton::None;
    if (qxt_p().isFlat())
        option.features |= QStyleOptionButton::Flat;
    if (qxt_p().menu())
        option.features |= QStyleOptionButton::HasMenu;
    if (qxt_p().autoDefault() || qxt_p().isDefault())
        option.features |= QStyleOptionButton::AutoDefaultButton;
    if (qxt_p().isDefault())
        option.features |= QStyleOptionButton::DefaultButton;
    if (qxt_p().isDown() || (qxt_p().menu() && qxt_p().menu()->isVisible()))
        option.state |= QStyle::State_Sunken;
    if (qxt_p().isChecked())
        option.state |= QStyle::State_On;
    if (!qxt_p().isFlat() && !qxt_p().isDown())
        option.state |= QStyle::State_Raised;
    if (!isRichText())
    {
        option.text = qxt_p().text();
        option.icon = qxt_p().icon();
        option.iconSize = qxt_p().iconSize();
    }
    return option;
}
Пример #6
0
void VESPERSDeadTimeButton::paintEvent(QPaintEvent *e)
{
	Q_UNUSED(e)

	QPainter painter(this);
	painter.setRenderHint(QPainter::Antialiasing);

	// Main button box.  Uses the standand push button style for the basic aspects of the box.
	QStyleOptionButton option;
	option.initFrom(this);
	option.state = QStyle::State_Off;

	if (!isEnabled())
		option.palette = QPalette(Qt::black, QColor(170, 170, 170, 100), Qt::gray, Qt::gray, QColor(170, 170, 170), Qt::gray, Qt::gray, Qt::gray, QColor(170, 170, 170));
	else if (!isChecked()){

		if (current() < good())
			option.palette = QPalette(Qt::black, QColor(20, 220, 20), Qt::gray, Qt::darkGray, QColor(170, 170, 170), Qt::black, Qt::red, Qt::green, QColor(0, 200, 0));
		else if (current() >= good() && current() < bad())
			option.palette = QPalette(Qt::black, QColor(220, 220, 20), Qt::gray, Qt::darkGray, QColor(170, 170, 170), Qt::black, Qt::red, Qt::yellow, QColor(200, 200, 0));
		else
			option.palette = QPalette(Qt::black, QColor(220, 20, 20), Qt::gray, Qt::darkGray, QColor(170, 170, 170), Qt::black, Qt::red, Qt::red, QColor(200, 0, 0));
	}
	else
		option.palette = QPalette(Qt::black, QColor(225, 225, 225, 100), Qt::gray, Qt::gray, QColor(225, 225, 225), Qt::gray, Qt::gray, Qt::gray, QColor(225, 225, 225));

	style()->drawControl(QStyle::CE_PushButton, &option, &painter, this);
}
Пример #7
0
void StatusLineEdit::paintEvent(QPaintEvent *event)
{
	if(hasFocus()) {
		QLineEdit::paintEvent(event);
	} else {
		QStylePainter painter(this);

		if(underMouse()) {
			QStyleOptionButton opt;
			opt.initFrom(this);

			opt.state &= ~QStyle::State_HasFocus;

			painter.drawControl(QStyle::CE_PushButton, opt);
		}

		painter.setPen(palette().color(QPalette::Text));

		QRect textRect = rect();
		textRect.moveLeft(4);
		textRect.moveTop(1);

		if(text().isEmpty()) {
			painter.setPen(palette().color(QPalette::Dark));

			QFont font = painter.font();
			font.setItalic(true);
			painter.setFont(font);

			painter.drawText(textRect, Qt::AlignVCenter | Qt::TextSingleLine, tr("Description..."));
		} else {
			painter.drawText(textRect, Qt::AlignVCenter | Qt::TextSingleLine, painter.fontMetrics().elidedText(text(), Qt::ElideRight, width() - 4));
		}
	}
}
Пример #8
0
void QColorButton::paintEvent (QPaintEvent *p)
{
  QPushButton::paintEvent (p);
  QStyleOptionButton option;
  option.initFrom (this);

  int x, y, w, h;
  QRect r = style()->subElementRect (QStyle::SE_PushButtonContents, &option, this);
  r.getRect (&x, &y, &w, &h);

  int margin = style()->pixelMetric (QStyle::PM_ButtonMargin, &option, this);
  x += margin;
  y += margin;
  w -= 2*margin;
  h -= 2*margin;

  if (isChecked() || isDown()) {
    x += style()->pixelMetric (QStyle::PM_ButtonShiftHorizontal, &option, this );
    y += style()->pixelMetric (QStyle::PM_ButtonShiftVertical, &option, this );
  }

  QPainter painter (this);
  QColor fillCol = isEnabled() ? col : palette().brush(QPalette::Window).color();
  qDrawShadePanel (&painter, x, y, w, h, palette(), true, 1, NULL);
  if (fillCol.isValid())
    painter.fillRect (x+1, y+1, w-2, h-2, fillCol);

  if (hasFocus()) {
    style()->subElementRect (QStyle::SE_PushButtonFocusRect, &option, this);
    style()->drawPrimitive (QStyle::PE_FrameFocusRect, &option, &painter, this);
  }
}
QStyleOptionButton OrientationButton::getStyleOption() const
{
    QStyleOptionButton opt;
    opt.initFrom(this);
    if (orientation_ == Qt::Vertical)
    {
        QSize size = opt.rect.size();
        size.transpose();
        opt.rect.setSize(size);
    }
    opt.features = QStyleOptionButton::None;
    if (isFlat())
        opt.features |= QStyleOptionButton::Flat;
    if (menu())
        opt.features |= QStyleOptionButton::HasMenu;
    if (autoDefault() || isDefault())
        opt.features |= QStyleOptionButton::AutoDefaultButton;
    if (isDefault())
        opt.features |= QStyleOptionButton::DefaultButton;
    if (isDown() || (menu() && menu()->isVisible()))
        opt.state |= QStyle::State_Sunken;
    if (isChecked())
        opt.state |= QStyle::State_On;
    if (!isFlat() && !isDown())
        opt.state |= QStyle::State_Raised;
    opt.text = text();
    opt.icon = icon();
    opt.iconSize = iconSize();
    return opt;
}
Пример #10
0
//-----------------------------------------------------------------------------
QSize ctkPushButtonPrivate::buttonSizeHint()const
{
  Q_Q(const ctkPushButton);
  int w = 0, h = 0;

  QStyleOptionButton opt;
  opt.initFrom(q);

  // icon
  QSize iconSize = q->iconSize();
  int ih = iconSize.height();
  int iw = iconSize.width() + this->IconSpacing;
  w += iw;
  h = qMax(h, ih);

  // text
  QString string(q->text());
  bool empty = string.isEmpty();
  if (empty)
    {
    string = QString::fromLatin1("XXXX");
    }
  QFontMetrics fm = q->fontMetrics();
  QSize sz = fm.size(Qt::TextShowMnemonic, string);
  if(!empty || !w)
    {
    w += sz.width();
    }
  h = qMax(h, sz.height());
  //opt.rect.setSize(QSize(w, h)); // PM_MenuButtonIndicator depends on the height
  QSize buttonSize = (q->style()->sizeFromContents(QStyle::CT_PushButton, &opt, QSize(w, h), q).
                      expandedTo(QApplication::globalStrut()));
  return buttonSize;
}
Пример #11
0
void TestTreeItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QStyleOptionViewItem opt = option;
    initStyleOption(&opt, index);

    bool italic = index.data(ItalicRole).toBool();
    if (italic) {
        QFont font(option.font);
        font.setItalic(true);
        opt.font = font;

        // correct margin of items without a checkbox (except for root items)
        QStyleOptionButton styleOpt;
        styleOpt.initFrom(opt.widget);
        const QSize sz; // no text, no icon - we just need the size of the check box
        QSize cbSize = opt.widget->style()->sizeFromContents(QStyle::CT_CheckBox, &styleOpt, sz);
        // the 6 results from hard coded margins of the checkbox itself (2x2) and the item (1x2)
        opt.rect.setLeft(opt.rect.left() + cbSize.width() + 6);

        // HACK make sure the pixels that have been moved right are painted for selections
        if (opt.state & QStyle::State_Selected) {
            QPalette::ColorGroup cg = opt.state & QStyle::State_Enabled
                    ? QPalette::Normal : QPalette::Disabled;
            if (cg == QPalette::Normal && !(opt.state & QStyle::State_Active))
                cg = QPalette::Inactive;
            painter->fillRect(option.rect, opt.palette.brush(cg, QPalette::Highlight));
        }
    }

    // paint disabled items in gray
    if (!index.data(EnabledRole).toBool())
        opt.palette.setColor(QPalette::Text, QColor(0xa0, 0xa0, 0xa0));

    QStyledItemDelegate::paint(painter, opt, index);
}
Пример #12
0
bool RenderThemeQt::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
{
    QStyle* style = 0;
    QPainter* painter = 0;
    QWidget* widget = 0;

    if (!getStylePainterAndWidgetFromPaintInfo(i, style, painter, widget))
        return true;

    QStyleOptionButton option;
    option.initFrom(widget);
    option.rect = r;

    // Get the correct theme data for a button
    EAppearance appearance = applyTheme(option, o);

    if(appearance == PushButtonAppearance || appearance == ButtonAppearance)
        style->drawControl(QStyle::CE_PushButton, &option, painter);
    else if(appearance == RadioAppearance)
        style->drawControl(QStyle::CE_RadioButton, &option, painter);
    else if(appearance == CheckboxAppearance)
        style->drawControl(QStyle::CE_CheckBox, &option, painter);

    return false;
}
Пример #13
0
/*!
  Reimplementation of QCheckBox::paintEvent.\n
  Draws a custom checkbox suitable for fixed modifier.
  */
void FixedCheckBox::paintEvent(QPaintEvent *event)
{
  Q_UNUSED(event);
  QStylePainter p(this);
  QStyleOptionButton opt;
  opt.initFrom(this);
  if (mDefaultValue) {
    p.setBrush(QColor(225, 225, 225));
  } else {
    p.setBrush(Qt::white);
  }
  p.drawRect(opt.rect.adjusted(0, 0, -1, -1));
  // if is checked then draw a tick
  if (mTickState) {
    p.setRenderHint(QPainter::Antialiasing);
    QPen pen = p.pen();
    pen.setWidthF(1.5);
    p.setPen(pen);
    QVector<QPoint> lines;
    lines << QPoint(opt.rect.left() + 3, opt.rect.center().y());
    lines << QPoint(opt.rect.center().x() - 1, opt.rect.bottom() - 3);
    lines << QPoint(opt.rect.center().x() - 1, opt.rect.bottom() - 3);
    lines << QPoint(opt.rect.width() - 3, opt.rect.top() + 3);
    p.drawLines(lines);
  }
}
Пример #14
0
QStyleOptionButton RichTextPushButton::getStyleOption() const
{
    QStyleOptionButton opt;
    opt.initFrom(this);
    opt.features = QStyleOptionButton::None;
    if (isFlat())
        opt.features |= QStyleOptionButton::Flat;
    if (menu())
        opt.features |= QStyleOptionButton::HasMenu;
    if (autoDefault() || isDefault())
        opt.features |= QStyleOptionButton::AutoDefaultButton;
    if (isDefault())
        opt.features |= QStyleOptionButton::DefaultButton;
    if (isDown() || (menu() && menu()->isVisible()))
        opt.state |= QStyle::State_Sunken;
    if (isChecked())
        opt.state |= QStyle::State_On;
    if (!isFlat() && !isDown())
        opt.state |= QStyle::State_Raised;
    if (!isRichText)
        opt.text = QPushButton::text();
    opt.icon = icon();
    opt.iconSize = iconSize();
    return opt;
}
Пример #15
0
//-----------------------------------------------------------------------------
QSize ctkCollapsibleButton::buttonSizeHint()const
{
  int w = 0, h = 0;

  QStyleOptionButton opt;
  opt.initFrom(this);
  
  // indicator
  QSize indicatorSize = QSize(style()->pixelMetric(QStyle::PM_IndicatorWidth, &opt, this),
                              style()->pixelMetric(QStyle::PM_IndicatorHeight, &opt, this));
  int indicatorSpacing = style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing, &opt, this);
  int ih = indicatorSize.height();
  int iw = indicatorSize.width() + indicatorSpacing;
  w += iw;
  h = qMax(h, ih);
  
  // text 
  QString string(this->text());
  bool empty = string.isEmpty();
  if (empty)
    {
    string = QString::fromLatin1("XXXX");
    }
  QFontMetrics fm = this->fontMetrics();
  QSize sz = fm.size(Qt::TextShowMnemonic, string);
  if(!empty || !w)
    {
    w += sz.width();
    }
  h = qMax(h, sz.height());
  //opt.rect.setSize(QSize(w, h)); // PM_MenuButtonIndicator depends on the height
  QSize buttonSize = (style()->sizeFromContents(QStyle::CT_PushButton, &opt, QSize(w, h), this).
                      expandedTo(QApplication::globalStrut()));
  return buttonSize;
}
QSize caToggleButton::calculateTextSpace()
{
    QStyleOptionButton option;
    option.initFrom(this);
    d_savedTextSpace = style()->subElementRect(QStyle::SE_CheckBoxContents, &option, this).size();
    return d_savedTextSpace;
}
Пример #17
0
/** Intializes the PartResizerWidget
	@param d the Device the Partition is on
	@param p the Partition to show and/or resize
	@param minFirst the minimum value for the first sector
	@param maxLast the maximum value for the last sector
*/
void PartResizerWidget::init(Device& d, Partition& p, qint64 minFirst, qint64 maxLast, bool read_only, bool move_allowed)
{
    setDevice(d);
    setPartition(p);

    setMinimumFirstSector(minFirst);
    setMaximumLastSector(maxLast);

    setReadOnly(read_only);
    setMoveAllowed(move_allowed);

    setMinimumLength(qMax(partition().sectorsUsed(), partition().minimumSectors()));
    setMaximumLength(qMin(totalSectors(), partition().maximumSectors()));

    // set margins to accommodate to top/bottom button asymmetric layouts
    QStyleOptionButton bOpt;
    bOpt.initFrom(this);

    QRect buttonRect(style()->subElementRect(QStyle::SE_PushButtonContents, &bOpt));

    int asym = (rect().bottom() - buttonRect.bottom()) - (buttonRect.top() - rect().top());
    if (asym > 0)
        setContentsMargins(0, asym, 0, 0);
    else
        setContentsMargins(0, 0, 0, asym);

    if (!readOnly())
    {
        QPixmap pixmap(handleWidth(), handleHeight());
        pixmap.fill(Qt::transparent);
        QPainter p(&pixmap);
        QStyleOption opt;
        opt.state |= QStyle::State_Horizontal;
        opt.rect = pixmap.rect().adjusted(0, 2, 0, -2);
        style()->drawControl(QStyle::CE_Splitter, &opt, &p, this);

        leftHandle().setPixmap(pixmap);
        rightHandle().setPixmap(pixmap);

        leftHandle().setFixedSize(handleWidth(), handleHeight());
        rightHandle().setFixedSize(handleWidth(), handleHeight());
    }

    delete m_PartWidget;
    m_PartWidget = new PartWidget(this, &partition());

    if (!readOnly())
    {
        leftHandle().setCursor(Qt::SizeHorCursor);
        rightHandle().setCursor(Qt::SizeHorCursor);
    }

    if (moveAllowed())
        partWidget().setCursor(Qt::SizeAllCursor);

    partWidget().setToolTip(QString());

    updatePositions();
}
Пример #18
0
void PrimitiveButton::paintEvent( QPaintEvent * /*event*/ )
{
	QStylePainter painter(this);
	QStyleOptionButton option;
	option.initFrom(this);
	//painter.drawControl(QStyle::CE_PushButton,option);
	painter.drawPrimitive (elem,option);
}
/** Redefined. */
void AddressBarButton::paintEvent(QPaintEvent *)
{
	QStylePainter p(this);
	QRect r = rect().adjusted(0, 1, -1, -2);
	if (_atLeastOneSubDir) {
		_arrowRect = QRect(r.width() - 15, r.y(), 15, r.height());
		_textRect = QRect(r.x(), r.y(), r.width() - 15, r.height());
	} else {
		_textRect = r;
	}
	QDir dir(_path);

	QPoint pos = mapFromGlobal(QCursor::pos());
	p.save();
	if (_textRect.contains(pos)) {
		p.setPen(QApplication::palette().highlight().color());
		p.setBrush(QApplication::palette().highlight().color().lighter());
		p.drawRect(_textRect);
		if (_atLeastOneSubDir) {
			p.drawRect(_arrowRect);
		}
	} else if (_arrowRect.contains(pos)) {
		p.setPen(QApplication::palette().highlight().color());
		p.drawRect(_textRect);
		p.setBrush(QApplication::palette().highlight().color().lighter());
		if (_atLeastOneSubDir) {
			p.drawRect(_arrowRect);
		}
	} else {
		p.setPen(Qt::NoPen);
		p.setBrush(Qt::NoBrush);
		p.drawRect(_textRect);
		if (_atLeastOneSubDir) {
			p.drawRect(_arrowRect);
		}
	}
	p.restore();

	if (_atLeastOneSubDir) {
		QStyleOptionButton o;
		o.initFrom(this);
		o.rect = _arrowRect.adjusted(4, 7, -2, -4);
		p.drawPrimitive(QStyle::PE_IndicatorArrowRight, o);
	}

	if (dir.isRoot()) {
		bool absRoot = true;
		foreach (QFileInfo fileInfo, QDir::drives()) {
			if (QDir::toNativeSeparators(fileInfo.absolutePath()) == _path) {
				p.drawText(_textRect, Qt::AlignLeft | Qt::AlignVCenter, _path);
				absRoot = false;
				break;
			}
		}
		if (absRoot) {
			p.drawPixmap(QRect(0, 0, 20, 20), style()->standardPixmap(QStyle::SP_ComputerIcon), QRect(0, 0, 20, 20));
		}
	} else {
Пример #20
0
void KMultiTabBarButton::paintEvent(QPaintEvent *) {
        QStyleOptionButton opt;
	opt.initFrom(this);
	opt.icon = icon();
	opt.iconSize = iconSize();
	// removes the QStyleOptionButton::HasMenu ButtonFeature
	opt.features = QStyleOptionButton::Flat;
	QPainter painter(this);
	style()->drawControl(QStyle::CE_PushButton, &opt, &painter, this);
}
Пример #21
0
    //_______________________________________________________________________
    void Simulator::click( QWidget* receiver, int delay  )
    {

        QPoint position;
        if( QCheckBox* checkbox = qobject_cast<QCheckBox*>( receiver ) )
        {

            QStyleOptionButton option;
            option.initFrom( checkbox );
            position = checkbox->style()->subElementRect(
                QStyle::SE_CheckBoxIndicator,
                &option,
                checkbox).center();

        } else if( QRadioButton* radiobutton = qobject_cast<QRadioButton*>( receiver ) ) {

            QStyleOptionButton option;
            option.initFrom( radiobutton );
            position = radiobutton->style()->subElementRect(
                QStyle::SE_RadioButtonIndicator,
                &option,
                radiobutton).center();

        } else if( const QMdiSubWindow* window = qobject_cast<QMdiSubWindow*>( receiver ) ) {

            QStyleOptionTitleBar option;
            option.initFrom( window );
            int titleBarHeight( window->style()->pixelMetric( QStyle::PM_TitleBarHeight, &option, window ) );
            QRect titleBarRect( QPoint(0,0), QSize( window->width(), titleBarHeight ) );
            if( !titleBarRect.isValid() ) return;
            position = titleBarRect.center();

        } else {

            position = receiver->rect().center();

        }

        click( receiver, position, delay );

    }
Пример #22
0
QPushButton *minimumSizeButton(const std::string &text, QWidget *parent)
{
    QPushButton *button = new QPushButton(text.c_str(), parent);
    QSize textSize = button->fontMetrics().size(Qt::TextShowMnemonic, button->text());
    QStyleOptionButton opt;
    opt.initFrom(button);
    opt.rect.setSize(textSize);
    button->setMinimumSize(button->style()->sizeFromContents(QStyle::CT_PushButton, &opt, textSize, button));
    button->setMaximumSize(button->style()->sizeFromContents(QStyle::CT_PushButton, &opt, textSize, button));

    return button;
}
Пример #23
0
UIWizardNewVMPageBasic3::UIWizardNewVMPageBasic3()
{
    /* Create widgets: */
    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    {
        m_pLabel = new QIRichTextLabel(this);
        QGridLayout *pDiskLayout = new QGridLayout;
        {
            m_pDiskSkip = new QRadioButton(this);
            m_pDiskCreate = new QRadioButton(this);
            m_pDiskPresent = new QRadioButton(this);
            QStyleOptionButton options;
            options.initFrom(m_pDiskPresent);
            int iWidth = m_pDiskPresent->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, &options, m_pDiskPresent);
            pDiskLayout->setColumnMinimumWidth(0, iWidth);
            m_pDiskSelector = new VBoxMediaComboBox(this);
            {
                m_pDiskSelector->setType(UIMediumType_HardDisk);
                m_pDiskSelector->repopulate();
            }
            m_pVMMButton = new QIToolButton(this);
            {
                m_pVMMButton->setAutoRaise(true);
                m_pVMMButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_disabled_16px.png"));
            }
            pDiskLayout->addWidget(m_pDiskSkip, 0, 0, 1, 3);
            pDiskLayout->addWidget(m_pDiskCreate, 1, 0, 1, 3);
            pDiskLayout->addWidget(m_pDiskPresent, 2, 0, 1, 3);
            pDiskLayout->addWidget(m_pDiskSelector, 3, 1);
            pDiskLayout->addWidget(m_pVMMButton, 3, 2);
        }
        pMainLayout->addWidget(m_pLabel);
        pMainLayout->addLayout(pDiskLayout);
        pMainLayout->addStretch();
        updateVirtualDiskSource();
    }

    /* Setup connections: */
    connect(m_pDiskSkip, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged()));
    connect(m_pDiskCreate, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged()));
    connect(m_pDiskPresent, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged()));
    connect(m_pDiskSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(sltVirtualDiskSourceChanged()));
    connect(m_pVMMButton, SIGNAL(clicked()), this, SLOT(sltGetWithFileOpenDialog()));

    /* Register classes: */
    qRegisterMetaType<CMedium>();
    /* Register fields: */
    registerField("virtualDisk", this, "virtualDisk");
    registerField("virtualDiskId", this, "virtualDiskId");
    registerField("virtualDiskName", this, "virtualDiskName");
    registerField("virtualDiskLocation", this, "virtualDiskLocation");
}
Пример #24
0
void TupConfigurationArea::paintEvent(QPaintEvent *event)
{
    QDockWidget::paintEvent(event);
    bool draw = false;

    if (widget()) {
        if (widget()->isVisible())
            draw = false;
        else
            draw = true;
    } else {
            draw = false;
    }

    if (draw) {
        QPainter painter(this);
        painter.setRenderHint(QPainter::Antialiasing, true);
        painter.setRenderHint(QPainter::TextAntialiasing, true);

        // painter.setBrush( palette().highlight());
        // QPainterPath path;
        // 		
        // QPolygon pol;
        // pol << rect().topRight()-QPoint(0, -40) << QPoint(2, height()/2) << rect().bottomRight()-QPoint(0, 40);
        // path.addPolygon(pol);
        // 		
        // painter.drawPath(path);
        // painter.rotate(-90);

        QFont font("Times", 16, QFont::Bold);
        painter.setFont(font);

        QStyleOptionButton buttonOption;
        buttonOption.initFrom(this);
		
        buttonOption.text = tr("Properties");
        buttonOption.icon = QIcon();
        buttonOption.palette = palette();
        // buttonOption.rect = QRect(rect().x(), rect().y()+(rect().width()-rect().y()), 
        // rect().height(), rect().width());
        buttonOption.rect = rect();
        buttonOption.state = QStyle::State_On;

        buttonOption.features = QStyleOptionButton::DefaultButton;

        style()->drawControl(QStyle::CE_PushButton, &buttonOption, &painter, this);
		
        // QString text = tr("Properties");
        // QFontMetricsF fm(painter.font());
        // painter.drawText(QPointF(height()/2-fm.width(text)/2, -(width()-fm.height()/2) ), text);
    }
}
Пример #25
0
/**
 * Draw widget contents on screen
 * @param event event info
 */
void ColorButton::paintEvent(QPaintEvent *)
{
	QStylePainter painter(this);

	QStyleOptionButton option;
	option.initFrom(this);
	option.state = isdown_ ? QStyle::State_Sunken : QStyle::State_Raised;

	painter.drawControl(QStyle::CE_PushButtonBevel,option);
	const int adj = qMin(width(),height()) / 5;
	QRect rect = contentsRect().adjusted(adj, adj, -adj, -adj);
	painter.fillRect(rect, color_);
}
Пример #26
0
//! [0]
void MyPushButton::paintEvent(QPaintEvent *)
{
    QStyleOptionButton option;
    option.initFrom(this);
    option.state = isDown() ? QStyle::State_Sunken : QStyle::State_Raised;
    if (isDefault())
        option.features |= QStyleOptionButton::DefaultButton;
    option.text = text();
    option.icon = icon();

    QPainter painter(this);
    style()->drawControl(QStyle::CE_PushButton, &option, &painter, this);
}
Пример #27
0
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tMediaBarPopup::paintEvent( QPaintEvent* /*pEvent*/ )
{
    QPainter painter( this );

    QStyleOptionButton option;
    option.initFrom( this );
    tNOSStyle* nemStyle = qobject_cast< tNOSStyle* >( style() );
    if( nemStyle )
    {        
        nemStyle->DrawMediaBar( &option, &painter, true );
        nemStyle->drawPrimitive( QStyle::PE_Frame, &option, &painter, this );
    }    
}
Пример #28
0
void KexiLinkButton::init()
{
    setFlat(true);
    setText(QString());
    setCursor(QCursor(Qt::PointingHandCursor));
    setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    setForegroundRole(QPalette::Text);
    QStyleOptionButton option;
    option.initFrom(this);
    int m = style()->pixelMetric(QStyle::PM_ButtonMargin, &option, this);
    setFixedSize(iconSize() + QSize(m*2, m*2));
    d->origIcon = KIcon(icon());
}
Пример #29
0
VolumePopup::VolumePopup(QWidget* parent):
    QDialog(parent, Qt::Dialog | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::Popup | Qt::X11BypassWindowManagerHint),
    m_pos(0,0),
    m_anchor(Qt::TopLeftCorner),
    m_device(0)
{
    m_mixerButton = new QPushButton(this);
    m_mixerButton->setObjectName("MixerLink");
    m_mixerButton->setMinimumWidth(1);
    m_mixerButton->setFlat(true);
    m_mixerButton->setToolTip(tr("Launch mixer"));
    m_mixerButton->setText(tr("Mixer"));
    QSize textSize = m_mixerButton->fontMetrics().size(Qt::TextShowMnemonic, m_mixerButton->text());
    QStyleOptionButton opt;
    opt.initFrom(m_mixerButton);
    opt.rect.setSize(textSize);
    m_mixerButton->setMaximumSize(m_mixerButton->style()->sizeFromContents(QStyle::CT_PushButton,
                                  &opt,
                                  textSize,
                                  m_mixerButton));
    m_mixerButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

    m_volumeSlider = new QSlider(Qt::Vertical, this);
    m_volumeSlider->setTickPosition(QSlider::TicksBothSides);
    m_volumeSlider->setTickInterval(10);
    // the volume slider shows 0-100 and volumes of all devices
    // should be converted to percentages.
    m_volumeSlider->setRange(0, 100);

    m_muteToggleButton = new QPushButton(this);
    m_muteToggleButton->setIcon(XdgIcon::fromTheme(QStringList() << "audio-volume-muted"));
    m_muteToggleButton->setCheckable(true);
    m_muteToggleButton->setFlat(true);

    QVBoxLayout *l = new QVBoxLayout(this);
    l->setSpacing(0);
    l->setMargin(2);

    l->addWidget(m_mixerButton, 0, Qt::AlignHCenter);
    l->addWidget(m_volumeSlider, 0, Qt::AlignHCenter);
    l->addWidget(m_muteToggleButton, 0, Qt::AlignHCenter);

    connect(m_mixerButton, SIGNAL(released()), this, SIGNAL(launchMixer()));
    connect(m_volumeSlider, SIGNAL(valueChanged(int)), this, SLOT(handleSliderValueChanged(int)));
    connect(m_muteToggleButton, SIGNAL(clicked()), this, SLOT(handleMuteToggleClicked()));
}
Пример #30
0
void ColorButton::paintEvent(QPaintEvent *event)
{
  QPushButton::paintEvent(event);

  QPainter painter(this);
  QStyleOptionButton option;

  option.initFrom(this);
  option.text = (_color.alpha())? QString() : tr("Auto");
  painter.setRenderHint(QPainter::Antialiasing,true);

  QRect rect = QApplication::style()->subElementRect(QStyle::SE_PushButtonContents,&option,this);

  if (_color.alpha())
    painter.fillRect(rect.adjusted(rect.width() / 8,rect.height() / 3,-rect.width() / 8,-rect.height() / 3),color());
  else
    painter.drawText(rect,Qt::AlignCenter,tr("Auto"));
}