Example #1
0
void Communicate::timerEvent(QTimerEvent *e)
{
    if (e->timerId() == m_timerId) {
        killTimer(m_timerId);
        if (!underMouse())
            close();
        return;
    }
    QLabel::timerEvent(e);
}
Example #2
0
	QPixmap downArrowPixmap() const
	{
		// if (isDown())
		// 	return QPixmap(":/images/down-arrow/pressed.png");

		if (underMouse() || isDown())
			return QPixmap(":/images/down-arrow/hover.png");

		return QPixmap(":/images/down-arrow/normal.png");
	}
void QBalloonTip::timerEvent(QTimerEvent *e)
{
    if (e->timerId() == timerId) {
        killTimer(timerId);
        if (!underMouse())
            close();
        return;
    }
    QWidget::timerEvent(e);
}
Example #4
0
void PlayPauseButton::reloadContent( const QSize &sz )
{
    const int width  = sz.width();
    const int height = sz.height();
    //NOTICE this is a bit cumbersome, as Qt renders faster to images than to pixmaps
    // However we need the Image and generate the pixmap ourself - maybe extend the SvgHandler API
    m_icon.play[0] = The::svgHandler()->renderSvg( "PLAYpause", width, height, "PLAYpause", true ).toImage();
    m_icon.play[1] = The::svgHandler()->renderSvg( "PLAYpause_active", width, height, "PLAYpause_active", true ).toImage();
    m_icon.pause[0] = The::svgHandler()->renderSvg( "playPAUSE", width, height, "playPAUSE", true ).toImage();
    m_icon.pause[1] = The::svgHandler()->renderSvg( "playPAUSE_active", width, height, "playPAUSE_active", true ).toImage();
    if( layoutDirection() == Qt::RightToLeft )
    {
        for ( int i = 0; i < 2; ++i )
        {
            m_icon.play[i] = m_icon.play[i].mirrored( true, false );
            m_icon.pause[i] = m_icon.pause[i].mirrored( true, false );
        }
    }
    setIcon( m_isPlaying ? m_icon.pause[underMouse()] : m_icon.play[underMouse()] );
}
Example #5
0
void TabBarWidget::removeTab(int index)
{
	if (underMouse())
	{
		const bool isHorizontal = (shape() == QTabBar::RoundedNorth || shape() == QTabBar::RoundedSouth);
		const QSize size = tabSizeHint(count() - 1);

		m_tabSize = (isHorizontal ? size.width() : size.height());
	}

	QTabBar::removeTab(index);

	if (underMouse() && tabAt(mapFromGlobal(QCursor::pos())) < 0)
	{
		m_tabSize = 0;

		updateGeometry();
		adjustSize();
	}
}
  void OutputPlugWidget::mouseMoveEvent(QMouseEvent* e)
  {
    if (m_lineDrawMode)
      {
       emit redrawLine(this->pos()+parentWidget()->pos() + QPoint(this->width() / 2,this->height() / 2),
			this->pos()+e->pos()+parentWidget()->pos());
      }
    else
      {
	emit underMouse(this);
      }
  }
Example #7
0
void KateTabButton::paintEvent(QPaintEvent *ev)
{
    Q_UNUSED(ev)

    QColor barColor(palette().color(QPalette::Highlight));

    // read from the parent widget (=KateTabBar) the isActiveViewSpace property
    if (isActiveViewSpace()) {
        // if inactive, convert color to gray value
        const int g = qGray(barColor.rgb());
        barColor = QColor(g, g, g);
    }

    // compute sane margins
    const int margin = style()->pixelMetric(QStyle::PM_ButtonMargin, 0, this);
    const int barMargin = margin / 2;
    const int barHeight = ceil(height() / 10.0);

    QPainter p(this);

    // paint bar if inactive but hovered
    if (!isChecked() && underMouse()) {
        barColor.setAlpha(80);
        p.fillRect(QRect(barMargin, height() - barHeight, width() - 2 * barMargin, barHeight), barColor);
    }

    // paint bar
    if (isChecked()) {
        barColor.setAlpha(255);
        p.fillRect(QRect(barMargin, height() - barHeight, width() - 2 * barMargin, barHeight), barColor);
    }

    // icon, if applicable
    int leftMargin = margin;
    if (! icon().isNull()) {
        const int y = (height() - 16) / 2;
        icon().paint(&p, margin, y, 16, 16);
        leftMargin += 16;
        leftMargin += margin;
    }

    // the width of the text is reduced by the close button + 2 * margin
    const int w = width() // width of widget
                - m_closeButton->width() - 2 * margin // close button
                - leftMargin; // modified button

    // draw text, we need to elide to xxx...xxx is too long
    const QString elidedText = QFontMetrics(font()).elidedText (text(), Qt::ElideMiddle, w);
    const QRect textRect(leftMargin, 0, w, height());
    const QPalette pal = QApplication::palette();
    style()->drawItemText(&p, textRect, Qt::AlignHCenter | Qt::AlignVCenter, pal, true, elidedText);
}
Example #8
0
void  CImgButton::paintEvent( QPaintEvent * e )
{
    QPainter p( this );
    if ( !underMouse() )
    {
        if ( isDown() || isChecked() )
        {
            const QPixmap & pm = image( m_cName, m_cKey );
            p.drawPixmap( QPoint( 0, 0 ), pm );
        }
        else
        {
            const QPixmap & pm = image( m_uName, m_uKey );
            p.drawPixmap( QPoint( 0, 0 ), pm );
        }
    }
    else
    {
        if ( m_hovered )
        {
            if ( isDown() || isChecked() )
            {
                const QPixmap & pm = image( m_chName, m_chKey );
                p.drawPixmap( QPoint( 0, 0 ), pm );
            }
            else
            {
                const QPixmap & pm = image( m_uhName, m_uhKey );
                p.drawPixmap( QPoint( 0, 0 ), pm );
            }
        }
        else
        {
            if ( isDown() || isChecked() )
            {
                const QPixmap & pm = image( m_cName, m_cKey );
                p.drawPixmap( QPoint( 0, 0 ), pm );
            }
            else
            {
                const QPixmap & pm = image( m_uName, m_uKey );
                p.drawPixmap( QPoint( 0, 0 ), pm );
            }
            // А поверх рисуем прямоугольник.
            QPen   pen   = QPen( QColor( 170, 170, 210, 150 ) );
            QBrush brush = QBrush( QColor( 170, 170, 210, 150 ) );
            p.setPen( pen );
            p.setBrush( brush );
            p.drawRect( QRect( 0, 0, size().width(), size().height() ) );
        }
    }
}
Example #9
0
void KateTabBar::tabButtonCloseRequest(KateTabButton *tabButton)
{
    // keep width
    if (underMouse()) {
        m_keepTabWidth = true;
    }

    const int id = m_idToTab.key(tabButton, -1);
    Q_ASSERT(id >= 0);
    if (id >= 0) {
        emit closeTabRequested(id);
    }
}
void SelectorActionButton::paintEvent( QPaintEvent *event )
{
    QPainter p( this );
    QColor color = palette().color( QPalette::HighlightedText );
    color.setAlpha( 80 );
    if( underMouse() )
        p.fillRect( rect(), color );
    p.setPen( color );
    int frame = style()->pixelMetric( QStyle::PM_DefaultFrameWidth, 0, this );
    p.drawLine( rect().topLeft() + QPoint( 0, frame ),
                rect().bottomLeft() - QPoint( 0, frame ) );
    QFramelessButton::paintEvent( event );
}
Example #11
0
/*!
    \overload
    \internal
    Draws the background.
    Event \a ev not used.
*/
void QtScrollDial::paintEvent(QPaintEvent* ev)
{
    Q_UNUSED(ev);
    QPainter p(this);
    p.save();
    p.scale(width(), height());
    if (underMouse() || m_popup->isVisible()) {
        m_hoverBackground.play(&p);
    } else {
        m_background.play(&p);
    }
    p.restore();
}
Example #12
0
void SessionBar::updateTimer()
{
    if (!underMouse()) {
        QList<SBSeg>::iterator i;

        for (i=segments.begin();i!=segments.end();++i) {
            (*i).highlight=false;
        }
    } else {
        timer.singleShot(50,this, SLOT(updateTimer()));
    }
    update();
}
Example #13
0
	// reimplemented
	void paintEvent(QPaintEvent*)
	{
		QPainter p(this);
		// p.drawPixmap(0, 0, moodButton_->currentPixmap());
		//XMPP::Status::Type status = enableRotation_ ? XMPP::Status::Reconnecting : status_;
		XMPP::Status::Type status = status_;
		p.drawPixmap(0, 0, Ya::VisualUtil::statusPixmap(status, underMouse() || isDown()));

		p.drawPixmap(10, 4, downArrowPixmap());

		// p.setPen(Qt::black);
		// p.drawRect(rect().adjusted(0, 0, -1, -1));
	}
Example #14
0
void MyTextBrowser::mouseReleaseEvent(QMouseEvent *event)
{
  char buf[80];

  if(event == NULL) return;
  sprintf(buf,"QPushButtonReleased(%d) -xy=%d,%d\n",id, event->x(), event->y());
  if(underMouse()) tcp_send(s,buf,strlen(buf));
#ifdef NO_WEBKIT
  QTextBrowser::mouseReleaseEvent(event);
#else
  QWebView::mouseReleaseEvent(event);
#endif  
}
Example #15
0
/*! \reimp */
void QCommandLinkButton::paintEvent(QPaintEvent *)
{
    Q_D(QCommandLinkButton);
    QStylePainter p(this);
    p.save();

    QStyleOptionButton option;
    initStyleOption(&option);

    //Enable command link appearence on Vista
    option.features |= QStyleOptionButton::CommandLinkButton;
    option.text = QString();
    option.icon = QIcon(); //we draw this ourselves
    QSize pixmapSize = icon().actualSize(iconSize());

    int vOffset = isDown() ? style()->pixelMetric(QStyle::PM_ButtonShiftVertical) : 0;
    int hOffset = isDown() ? style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal) : 0;

    //Draw icon
    p.drawControl(QStyle::CE_PushButton, option);
    if (!icon().isNull())
        p.drawPixmap(d->leftMargin() + hOffset, d->topMargin() + vOffset,
        icon().pixmap(pixmapSize, isEnabled() ? QIcon::Normal : QIcon::Disabled,
                                  isChecked() ? QIcon::On : QIcon::Off));

    //Draw title
    QColor textColor = palette().buttonText().color();
    if (isEnabled() && d->usingVistaStyle()) {
        textColor = QColor(21, 28, 85);
        if (underMouse() && !isDown())
            textColor = QColor(7, 64, 229);
        //A simple text color transition
        d->currentColor = d->mergedColors(textColor, d->currentColor, 60);
        option.palette.setColor(QPalette::ButtonText, d->currentColor);
    }

    int textflags = Qt::TextShowMnemonic;
    if (!style()->styleHint(QStyle::SH_UnderlineShortcut, &option, this))
        textflags |= Qt::TextHideMnemonic;

    p.setFont(d->titleFont());
    p.drawItemText(d->titleRect().translated(hOffset, vOffset),
                    textflags, option.palette, isEnabled(), text(), QPalette::ButtonText);

    //Draw description
    textflags |= Qt::TextWordWrap | Qt::ElideRight;
    p.setFont(d->descriptionFont());
    p.drawItemText(d->descriptionRect().translated(hOffset, vOffset), textflags,
                    option.palette, isEnabled(), description(), QPalette::ButtonText);
    p.restore();
}
Example #16
0
void CloseButton::paintEvent(QPaintEvent *AEvent)
{
	Q_UNUSED(AEvent);
	if (icon().isNull())
	{
		QStyleOption opt;
		opt.init(this);
		opt.state |= QStyle::State_AutoRaise;
		if (isEnabled() && underMouse() && !isChecked() && !isDown())
			opt.state |= QStyle::State_Raised;
		if (isChecked())
			opt.state |= QStyle::State_On;
		if (isDown())
			opt.state |= QStyle::State_Sunken;

		QPainter p(this);
		style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, &p, this);
	}
	else
	{
		QIcon::Mode mode = QIcon::Normal;
		if (!isEnabled())
			mode = QIcon::Disabled;
		else if (underMouse())
			mode = QIcon::Active;

		QIcon::State state = QIcon::Off;
		if (isChecked())
			state = QIcon::On;

		QPixmap pixmap = icon().pixmap(iconSize(),mode,state);
		QRect pixmapRect = QRect(0, 0, pixmap.width(), pixmap.height());
		pixmapRect.moveCenter(rect().center());

		QPainter p(this);
		p.drawPixmap(pixmapRect, pixmap);
	}
}
Example #17
0
void QTerrain::keyPressEvent(QKeyEvent* Event)
{
	if(underMouse())
	{
		if(Event->key() == Qt::Key_Up)
			m_ScrollVeritcal->setValue(m_ScrollVeritcal->value() - 30);
		if(Event->key() == Qt::Key_Down)
			m_ScrollVeritcal->setValue(m_ScrollVeritcal->value() + 30);
		if(Event->key() == Qt::Key_Left)
			m_ScrollHorizontal->setValue(m_ScrollHorizontal->value() - 30);	
		if(Event->key() == Qt::Key_Right)
			m_ScrollHorizontal->setValue(m_ScrollHorizontal->value() + 30);
	}
}
Example #18
0
void VideoContainer::mouseMoveEvent( QMouseEvent* event )
{
	if ( underMouse() || m_oVideoWidget->underMouse() || m_oMediaControls->underMouse() )
	{
		if ( !m_oMediaControls->isVisible() )
		{
			m_oMediaControls->show();
		}

		m_tMediaControls->start( 5000 );
	}

	QWidget::mouseMoveEvent( event );
}
Example #19
0
void MoodLineEdit::paintEvent(QPaintEvent *e)
{
    QPainter p( this );
    QFontMetrics fm = p.fontMetrics();
    if ( underMouse() )
    {
        p.save();
        p.setPen( QPen( Qt::lightGray ));
        p.drawRect( this->rect().adjusted( 1, 1, -1, -1 ) ) ;
        p.restore();
    }
    p.drawText( this->rect().adjusted( 2, 1, -1, -1 ),
                Qt::AlignVCenter,
                fm.elidedText( lineEdit->text().isEmpty() ? strMood : lineEdit->text(),
                               Qt::ElideRight, this->rect().width() ));
}
Example #20
0
/*!
    \reimp
*/
void QCheckBox::mouseMoveEvent(QMouseEvent *e)
{
    Q_D(QCheckBox);
    if (testAttribute(Qt::WA_Hover)) {
        bool hit = false;
        if (underMouse())
            hit = hitButton(e->pos());

        if (hit != d->hovering) {
            update(rect());
            d->hovering = hit;
        }
    }

    QAbstractButton::mouseMoveEvent(e);
}
Example #21
0
void TabBarWidget::contextMenuEvent(QContextMenuEvent *event)
{
	m_clickedTab = tabAt(event->pos());

	hidePreview();

	QMenu menu(this);
	menu.addAction(ActionsManager::getAction(QLatin1String("NewTab"), this));
	menu.addAction(ActionsManager::getAction(QLatin1String("NewTabPrivate"), this));

	if (m_clickedTab >= 0)
	{
		const bool isPinned = getTabProperty(m_clickedTab, QLatin1String("isPinned"), false).toBool();

		menu.addAction(tr("Clone Tab"), this, SLOT(cloneTab()))->setEnabled(getTabProperty(m_clickedTab, QLatin1String("canClone"), false).toBool());
		menu.addAction((isPinned ? tr("Unpin Tab") : tr("Pin Tab")), this, SLOT(pinTab()));
		menu.addSeparator();
		menu.addAction(tr("Detach Tab"), this, SLOT(detachTab()))->setEnabled(count() > 1);
		menu.addSeparator();

		if (isPinned)
		{
			QAction *closeAction = menu.addAction(Utils::getIcon(QLatin1String("tab-close")), tr("Close Tab"));

			ActionsManager::setupLocalAction(ActionsManager::getAction(QLatin1String("CloseTab"), this), closeAction, true);

			closeAction->setEnabled(false);
		}
		else
		{
			menu.addAction(ActionsManager::getAction(QLatin1String("CloseTab"), this));
		}

		const int amount = (count() - getPinnedTabsAmount());

		menu.addAction(Utils::getIcon(QLatin1String("tab-close-other")), tr("Close Other Tabs"), this, SLOT(closeOther()))->setEnabled(amount > 0 && !(amount == 1 && !isPinned));
	}

	menu.exec(event->globalPos());

	m_clickedTab = -1;

	if (underMouse())
	{
		m_previewTimer = startTimer(250);
	}
}
Example #22
0
void TrackActionButton::reloadContent( const QSize &sz )
{
    if ( sz.isNull() )
        return;
    int r,g,b;
    palette().color(foregroundRole()).getRgb(&r,&g,&b);
    
    m_icon.image[2] = m_icon.icon.pixmap( sz ).toImage();
    QImage img = m_icon.image[2].convertToFormat(QImage::Format_ARGB32);
    int n = img.width() * img.height();
    
    const uchar *bits = img.bits();
    QRgb *pixel = (QRgb*)(const_cast<uchar*>(bits));

    // this creates a (slightly) translucent monochromactic version of the
    // image using the foreground color
    // the gray value is turned into the opacity
#define ALPHA qAlpha(pixel[i])
#define GRAY qGray(pixel[i])
    if ( qMax( qMax(r,g), b ) > 128 ) // value > 50%, bright foreground
        for (int i = 0; i < n; ++i)
            pixel[i] = qRgba( r,g,b, ( ALPHA * ( (160*GRAY) / 255 ) ) / 255 );
    else // inverse
        for (int i = 0; i < n; ++i)
            pixel[i] = qRgba( r,g,b, ( ALPHA * ( (160*(255-GRAY)) / 255 ) ) / 255 );

    // premultiplied is much faster on painting / alphablending
    m_icon.image[1] = img.convertToFormat(QImage::Format_ARGB32_Premultiplied);

    // and a very translucent variant
    for (int i = 0; i < n; ++i)
        pixel[i] = qRgba(r,g,b, ALPHA/6);

#undef ALPHA
#undef GRAY

    m_icon.image[0] = img.convertToFormat(QImage::Format_ARGB32_Premultiplied);

    int i = 0;
    if ( underMouse() )
        i = 2;
    else if ( !parentWidget() || parentWidget()->underMouse() )
        i = 1;

    setIcon( m_icon.image[i] );
}
bool KoPageNavigator::eventFilter(QObject *watched, QEvent *event)
{
    if (event->type() == QEvent::FocusOut && watched == d->pageNumberEdit) {
        if (! underMouse()) {
            setCurrentIndex(Display);
        }

        // reset editor in any case
        KoPADocument *const kopaDocument = d->view->kopaDocument();
        KoPAPageBase *const activePage = d->view->activePage();
        const int pageNumber = kopaDocument->pageIndex(activePage) + 1;
        const QString text = (pageNumber > 0) ? QString::number(pageNumber) : QString();
        d->pageNumberEdit->setText(text);
    } else if (event->type() == QEvent::Wheel) {
        // Scroll the pages by the wheel
        // Because the numbers are representatives of the actual pages
        // and the list of pages is ordered by smaller number first,
        // here an increasing delta means going up in the list, so go to
        // smaller page numbers, and vice versa.
        QWheelEvent *wheelEvent = static_cast<QWheelEvent*>(event);
        const int delta = wheelEvent->delta();

        // trigger the respective actions
        if (delta > 0) {
            QAction *gotoPreviousPageAction = d->gotoPreviousPageButton->action();
            if (gotoPreviousPageAction->isEnabled()) {
                gotoPreviousPageAction->activate(QAction::Trigger);
            }
        } else if (delta < 0) {
            QAction *gotoNextPageAction = d->gotoNextPageButton->action();
            if (gotoNextPageAction->isEnabled()) {
                gotoNextPageAction->activate(QAction::Trigger);
            }
        }

        // scroll wheel events also cancel the editing,
        // so move focus out of the pageNumberEdit
        if (d->pageNumberEdit->hasFocus()) {
            d->view->setFocus();
        }
    }

    return false;
}
void PlainToolButton::paintEvent(QPaintEvent *e) {
  Q_UNUSED(e)

  QPainter p(this);
  QRect rect(QPoint(0, 0), size());

  // Set padding.
  rect.adjust(m_padding, m_padding, -m_padding, -m_padding);

  // Paint the icon.
  if (!isEnabled()) {
    p.setOpacity(0.4);
  }
  else if (underMouse() || hasFocus()) {
    p.setOpacity(0.7);
  }

  icon().paint(&p, rect);
}
Example #25
0
/*!
    Initialize \a option with the values from this QRadioButton. This method is useful
    for subclasses when they need a QStyleOptionButton, but don't want to fill
    in all the information themselves.

    \sa QStyleOption::initFrom()
*/
void QRadioButton::initStyleOption(QStyleOptionButton *option) const
{
    if (!option)
        return;
    Q_D(const QRadioButton);
    option->initFrom(this);
    option->text = d->text;
    option->icon = d->icon;
    option->iconSize = iconSize();
    if (d->down)
        option->state |= QStyle::State_Sunken;
    option->state |= (d->checked) ? QStyle::State_On : QStyle::State_Off;
    if (testAttribute(Qt::WA_Hover) && underMouse()) {
        if (d->hovering)
            option->state |= QStyle::State_MouseOver;
        else
            option->state &= ~QStyle::State_MouseOver;
    }
}
void ExtendedButton::paintEvent(QPaintEvent* event)
{
    if (!isVisible())
        return;

    QStylePainter p(this);
    QStyleOptionButton option;
    initStyleOption(&option);

    if (option.features & QStyleOptionButton::Flat)
    {
        if (isChecked() || isDown())
            p.setOpacity(m_pressedOpacity / 100.0);
        else if (underMouse())
            p.setOpacity(m_hoveredOpacity / 100.0);
        else
            p.setOpacity(m_normalOpacity / 100.0);

        option.features = option.features & ~QStyleOptionButton::Flat;
    }

    p.drawControl(QStyle::CE_PushButtonBevel, option);

    if (p.opacity() != 1.0)
        p.setOpacity(1.0);

    if (m_contentOrientation == Qt::Horizontal)
    {
        p.drawControl(QStyle::CE_PushButtonLabel, option);
    }
    else
    {
        long x = option.rect.left() + (option.rect.width() - option.iconSize.width()) / 2;
        long y = option.rect.top() + (option.rect.height() - option.iconSize.height() -
                                      m_contentInterval - option.fontMetrics.height()) / 2;

        p.drawPixmap(x, y, option.iconSize.width(), option.iconSize.height(), option.icon.pixmap(option.iconSize));

        y += option.iconSize.height() + m_contentInterval;

        p.drawText(QRect(option.rect.left(), y, option.rect.width(), option.fontMetrics.height()), Qt::AlignHCenter | Qt::AlignTop, option.text);
    }
}
void SeExprEdSlider::paintEvent(QPaintEvent* e)
{
    Q_UNUSED(e);
    QPainter p(this);
    
    float v = value();
    float r = maximum()-minimum();
    int linepos = (int)((v-minimum())/r*(width()-5)+2);
    
    QColor qcol = palette().color(QPalette::Dark);
    QColor bcol = palette().color(QPalette::Midlight);
    QColor dcol = bcol.lighter(140);
    QColor bgcol = palette().color(QPalette::Base);
    
    if (underMouse())
    {
        bcol = bcol.lighter(110);
        bgcol = bgcol.lighter(110);
        int mx = mapFromGlobal(QCursor::pos()).x();
        if (abs(linepos-mx)<4) dcol = dcol.lighter(200);
    }
    
    p.fillRect(1,1,width()-1,height()-2,bgcol);
    p.fillRect(1,1,linepos-1,height()-2,bcol);
    
    QPen pen = p.pen();
    
    pen.setColor(dcol);
    p.setPen(pen);
    pen.setWidth(3);
    p.setPen(pen);
    p.drawLine(linepos,2,linepos,height()-2);
    pen.setWidth(1);
    pen.setColor(qcol);
    p.setPen(pen);
    p.drawLine(linepos-2,1,linepos-2,height()-1);
    p.drawLine(linepos+2,1,linepos+2,height()-1);
    
    pen.setWidth(1);
    pen.setColor(qcol);
    p.setPen(pen);
    p.drawRect(0,0,width()-1,height()-1);
}
Example #28
0
void Q3TitleBar::paintEvent(QPaintEvent *)
{
    Q_D(Q3TitleBar);
    QStyleOptionTitleBar opt = d->getStyleOption();
    opt.subControls = QStyle::SC_TitleBarLabel;
    opt.activeSubControls = d->buttonDown;
    if (d->flags & Qt::WindowSystemMenuHint) {
        opt.subControls |= QStyle::SC_TitleBarSysMenu | QStyle::SC_TitleBarCloseButton;
        if (d->window && (d->flags & Qt::WindowShadeButtonHint)) {
            if (d->window->isMinimized())
                opt.subControls |= QStyle::SC_TitleBarUnshadeButton;
            else
                opt.subControls |= QStyle::SC_TitleBarShadeButton;
        }
        if (d->window && (d->flags & Qt::WindowMinMaxButtonsHint)) {
            if(d->window && d->window->isMinimized())
                opt.subControls |= QStyle::SC_TitleBarNormalButton;
            else
                opt.subControls |= QStyle::SC_TitleBarMinButton;
        }
        if (d->window && (d->flags & Qt::WindowMaximizeButtonHint) && !d->window->isMaximized())
            opt.subControls |= QStyle::SC_TitleBarMaxButton;
    }
    QStyle::SubControl under_mouse = QStyle::SC_None;
    
    if (underMouse()) {
        under_mouse = style()->hitTestComplexControl(QStyle::CC_TitleBar, &opt,
                                                     mapFromGlobal(QCursor::pos()), this);
        opt.activeSubControls |= under_mouse;
        if (d->pressed)
            opt.state |= QStyle::State_Sunken;
        else if(autoRaise())
            opt.state |= QStyle::State_MouseOver;
    }
    
    opt.palette.setCurrentColorGroup(usesActiveColor() ? QPalette::Active : QPalette::Inactive);

    QPainter p(this);
    if (!windowTitle().isEmpty())
        opt.titleBarFlags |= Qt::WindowTitleHint;
    style()->drawComplexControl(QStyle::CC_TitleBar, &opt, &p, this);
}
Example #29
0
void StatusArrowButton::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);
	}

	QStyleOptionComboBox opt;
	opt.initFrom(this);
	opt.rect = QRect(width() - 15, height() / 2 - 6, 11, 13);
	painter.drawPrimitive(QStyle::PE_IndicatorArrowDown, opt);
}
Example #30
0
void
GcScopeButton::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.save();
    painter.setRenderHints(QPainter::Antialiasing|QPainter::TextAntialiasing, true);

    // widget rectangle
    QRectF body(0,0,width(), height());
    QRectF off(0,1,width(), height());
    QRectF inside(0,2,width(), height()-4);

    QPainterPath clip;
    clip.addRect(inside);
    painter.setClipPath(clip);
    painter.setPen(Qt::NoPen);

    if (checked && underMouse()) {
        painter.setBrush(QBrush(QColor(150,150,150)));     
        painter.drawRoundedRect(body, 19, 11);
        if (highlighted) {
            QColor over = GColor(CCALCURRENT);
            over.setAlpha(180);
            painter.setBrush(over);
            painter.drawRoundedRect(body, 19, 11);
        }
    } else if (checked && !underMouse()) {
        painter.setBrush(QBrush(QColor(120,120,120)));     
        painter.drawRoundedRect(body, 19, 11);
        if (highlighted) {
            QColor over = GColor(CCALCURRENT);
            over.setAlpha(180);
            painter.setBrush(over);
            painter.drawRoundedRect(body, 19, 11);
        }
    } else if (!checked && underMouse()) {
        painter.setBrush(QBrush(QColor(180,180,180)));     
        painter.drawRoundedRect(body, 19, 11);
    } else if (!checked && !underMouse()) {
    }

    // now paint the text
    painter.setPen((underMouse() || checked) ? QColor(50,50,50) : Qt::white);
    painter.drawText(off, text, Qt::AlignVCenter | Qt::AlignCenter);
    painter.setPen((underMouse() || checked) ? QColor(240,240,240) : QColor(30,30,30,200));
    painter.drawText(body, text, Qt::AlignVCenter | Qt::AlignCenter);
    painter.restore();
}