Exemple #1
0
void FbTextAction::updateAction()
{
    if (QAction * act = action()) {
        if (isCheckable()) setChecked(act->isChecked());
        setEnabled(act->isEnabled());
    }
}
void LinkLabel::mouseReleaseEvent(QMouseEvent* event)
{
    if((event->button() == Qt::LeftButton) && (isEnabled())) {
        if(isCheckable()) {
            if(isText()) {
                if(_down)
                    setStyleSheet("QLabel { color : blue; }");
            } else {
                if(_down)
                    setPixmap(_upImg);
            }
            _down = !_down;
            emit toggled(_down);
        } else {
            if(isText())
                setStyleSheet("QLabel { color : blue; }");
            else
                setPixmap(_upImg);
            _down = false;
            emit clicked();
            emit clicked(this);
        }
    }
    if (!_hyperlink) setStyleSheet("");

    QLabel::mouseReleaseEvent(event);
}
Exemple #3
0
//*****************************************************************************
void Kwave::MenuItem::actionSelected()
{
    if (isCheckable() && !m_exclusive_group.length())
	setChecked(true);

    Kwave::MenuNode::actionSelected();
}
void MButton::setChecked(bool buttonChecked)
{
    // FIXME: these checks could be done in model side, the group needs moved to model first
    if (isCheckable() && buttonChecked != isChecked()) {

        /* The active button in an exclusive group cannot be deselected */
        if (group() && group()->exclusive() && group()->checkedButton() == this) {
            return;
        }

        //TODO This is here just because of the delayed model initialization, this
        //     call should be removed when the delayed model initialization bug/feature
        //     is properly fixed.
        //
        //     The bug causes invalid functionaliy for buttons inside a buttongroup,
        //     if state of a button(s) is changed before messageloop is run first
        //     time. The updateData() slot does does not get called and toggled
        //     signal is not emitted. Exclusive buttongroup uses the toggled signal
        //     to uncheck buttons.
        bool shouldEmit = (model()->checked() != buttonChecked);
        toggleEmitted = false;

        model()->setChecked(buttonChecked);

        //TODO Remove this when delayed model initialization bug is properly fixed.
        if (shouldEmit && !toggleEmitted)
            emit toggled(model()->checked());
    }
}
void BlurPushButton::paintEvent(QPaintEvent *event)
{
	QPainter p(this);

	QPoint point = mapToGlobal(rect().topLeft());
	p.drawImage(0, 0, background);//, point.x(), point.y());
	
	p.drawPixmap(0, 0, blur);

	if(isCheckable() && isChecked())
	{
		p.setPen(QPen(QBrush(Qt::white), 20));
		p.setBrush(Qt::transparent);
		p.drawRect(0, 0, width(), height());
	}
	else if(handOnTop)
	{
		p.setPen(Qt::transparent);
		p.setBrush(Qt::white);
		p.drawRect(0, 0, progress, height());
	}
		

	QPushButton::paintEvent(event);
}
Exemple #6
0
void QgsExtentGroupBox::updateTitle()
{
  QString msg;
  switch ( mExtentState )
  {
    case OriginalExtent:
      msg = tr( "layer" );
      break;
    case CurrentExtent:
      msg = tr( "map view" );
      break;
    case UserExtent:
      msg = tr( "user defined" );
      break;
    case ProjectLayerExtent:
      msg = mExtentLayerName;
      break;
    case DrawOnCanvas:
      msg = tr( "drawn on canvas" );
      break;
  }
  if ( isCheckable() && !isChecked() )
    msg = tr( "none" );
  msg = tr( "%1 (current: %2)" ).arg( mTitleBase, msg );

  setTitle( msg );
}
Exemple #7
0
void QgsExtentGroupBox::setOutputExtent( const QgsRectangle &r, const QgsCoordinateReferenceSystem &srcCrs, ExtentState state )
{
  QgsRectangle extent;
  if ( mOutputCrs == srcCrs )
  {
    extent = r;
  }
  else
  {
    try
    {
      QgsCoordinateTransform ct( srcCrs, mOutputCrs );
      extent = ct.transformBoundingBox( r );
    }
    catch ( QgsCsException & )
    {
      // can't reproject
      extent = r;
    }
  }

  mXMinLineEdit->setText( QgsRasterBlock::printValue( extent.xMinimum() ) );
  mXMaxLineEdit->setText( QgsRasterBlock::printValue( extent.xMaximum() ) );
  mYMinLineEdit->setText( QgsRasterBlock::printValue( extent.yMinimum() ) );
  mYMaxLineEdit->setText( QgsRasterBlock::printValue( extent.yMaximum() ) );

  mExtentState = state;

  if ( isCheckable() && !isChecked() )
    setChecked( true );

  updateTitle();

  emit extentChanged( extent );
}
Exemple #8
0
void WMenuItem::setChecked(bool checked)
{
  if (isCheckable()) {
    WCheckBox *cb = dynamic_cast<WCheckBox *>(anchor()->widget(0));
    cb->setChecked(checked);
  }
}
QString ButtonGroup::currentState() const
{
  if (!isCheckable() || isChecked())
    return "checked";
  else
    return "unchecked";
}
void TimelineToolButton::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
    painter->save();

    if (m_state == Normal)
        setOpacity(0.8);
    else if (m_state == Pressed)
        setOpacity(0.3);
    else
        setOpacity(1.0);

    if (!isEnabled())
        setOpacity(0.5);

    if (isCheckable()) {
        if (isChecked() || isDisabled())
            m_action->icon().paint(painter,
                                   rect().toRect(),
                                   Qt::AlignCenter,
                                   QIcon::Normal,
                                   QIcon::On);
        else
            m_action->icon().paint(painter,
                                   rect().toRect(),
                                   Qt::AlignCenter,
                                   QIcon::Normal,
                                   QIcon::Off);
    } else
        m_action->icon().paint(painter, rect().toRect());

    painter->restore();
}
void AutomatableButton::mousePressEvent( QMouseEvent * _me )
{
	if( _me->button() == Qt::LeftButton &&
			! ( _me->modifiers() & Qt::ControlModifier ) )
	{
        // User simply clicked, toggle if needed
		if( isCheckable() )
		{
			toggle();
		}
		_me->accept();
	}
	else
	{
		// Ctrl-clicked, need to prepare drag-drop
		if( m_group )
		{
			// A group, we must get process it instead
			AutomatableModelView* groupView = (AutomatableModelView*)m_group;
			new StringPairDrag( "automatable_model",
					QString::number( groupView->modelUntyped()->id() ),
					QPixmap(), widget() );
			// TODO: ^^ Maybe use a predefined icon instead of the button they happened to select
			_me->accept();
		}
		else
		{
			// Otherwise, drag the standalone button
			AutomatableModelView::mousePressEvent( _me );
			QPushButton::mousePressEvent( _me );
		}
	}
}
Exemple #12
0
QSize
CQGroupBox::
minimumSizeHint() const
{
  QFontMetrics fm(titleFont_);

  int baseWidth  = fm.width(title_) + 4;
  int baseHeight = fm.height();

  if (isCheckable())
    baseWidth += fm.height() + 4;

  if (isCollapsible())
    baseWidth += fm.height();

  QSize size;

  if (! isCollapsed()) {
    QStyleOptionGroupBox option;

    size = style()->sizeFromContents(QStyle::CT_GroupBox, &option,
                                     QSize(baseWidth, baseHeight), this);
  }
  else {
    size = QSize(baseWidth, baseHeight);
  }

  return size.expandedTo(QWidget::minimumSizeHint());
}
Exemple #13
0
void
CQGroupBox::
updateEnabled()
{
  bool enabled = isEnabled();

  QObjectList childList = children();

  for (int i = 0; i < childList.size(); ++i) {
    QObject *o = childList.at(i);

    if (! o->isWidgetType()) continue;

    QWidget *w = static_cast<QWidget *>(o);

    if (isCheckable()) {
      if (isChecked()) {
//      if (! w->isEnabled()) {
//        if (! w->testAttribute(Qt::WA_ForceDisabled))
            w->setEnabled(true);
//      }
      }
      else {
//      if (w->isEnabled())
          w->setEnabled(false);
      }
    }
    else {
      w->setEnabled(enabled);
    }
  }
}
Exemple #14
0
void
CQGroupBox::
mouseReleaseEvent(QMouseEvent *e)
{
  if (isCheckable()) {
    bool inside = checkRect_.contains(e->pos()) || titleRect_.contains(e->pos());

    if (inside) {
      setChecked(! isChecked());

      checkPress_ = false;

      emit clicked(isChecked());

      update();
    }
  }

  if (isCollapsible()) {
    bool inside = collapseRect_.contains(e->pos());

    if (inside) {
      setCollapsed(! isCollapsed());

      collapsePress_ = false;

      update();
    }
  }

  QWidget::mouseReleaseEvent(e);
}
Exemple #15
0
void
CQGroupBox::
mousePressEvent(QMouseEvent *e)
{
  if (isCheckable()) {
    bool inside = checkRect_.contains(e->pos()) || titleRect_.contains(e->pos());

    if (inside) {
      checkPress_ = true;

      update();

      return;
    }
  }

  if (isCollapsible()) {
    bool inside = collapseRect_.contains(e->pos());

    if (inside) {
      collapsePress_ = true;

      update();

      return;
    }
  }

  QWidget::mousePressEvent(e);
}
Exemple #16
0
void
CQGroupBox::
mouseMoveEvent(QMouseEvent *e)
{
  if (isCheckable()) {
    bool inside = checkRect_.contains(e->pos()) || titleRect_.contains(e->pos());

    bool oldCheckPress = checkPress_;

    if      (! checkPress_ && inside)
      checkPress_ = true;
    else if (  checkPress_ && ! inside)
      checkPress_ = false;

    if (checkPress_ != oldCheckPress)
      update();
  }

  if (isCollapsible()) {
    bool inside = collapseRect_.contains(e->pos());

    bool oldCollapsePress = collapsePress_;

    if      (! collapsePress_ && inside)
      collapsePress_ = true;
    else if (  collapsePress_ && ! inside)
      collapsePress_ = false;

    if (collapsePress_ != oldCollapsePress)
      update();
  }

  QWidget::mouseMoveEvent(e);
}
QSize QGroupBox::sizeHint() const
{
    QFontMetrics fm( font() );
    int tw, th;
    if ( isCheckable() ) {
#ifndef QT_NO_CHECKBOX
        tw = d->checkbox->sizeHint().width() + 2*fm.width( "xx" );
        th = d->checkbox->sizeHint().height() + fm.width( QChar(' ') );
#endif
    } else {
        tw = fm.width( title() ) + 2 * fm.width( "xx" );
        th = fm.height() + fm.width( QChar(' ') );
    }

    QSize s;
    if ( layout() ) {
        s = QFrame::sizeHint();
        return s.expandedTo( QSize( tw, 0 ) );
    } else {
        QRect r = childrenRect();
        QSize s( 100, 50 );
        s = s.expandedTo( QSize( tw, th ) );
        if ( r.isNull() )
            return s;

        return s.expandedTo( QSize( r.width() + 2 * r.x(), r.height()+ 2 * r.y() ) );
    }
}
Exemple #18
0
void Action::changedSlot()
{
    if (isCheckable() && isChecked() && !isEnabled())
        setChecked(false);

    emit changed(this);
}
Exemple #19
0
bool WMenuItem::isChecked() const
{
  if (isCheckable()) {
    WCheckBox *cb = dynamic_cast<WCheckBox *>(anchor()->widget(0));
    return cb->isChecked();
  } else
    return false;
}
Exemple #20
0
void FbTextAction::connectAction()
{
    if (QAction * act = action()) {
        connect(this, SIGNAL(triggered(bool)), act, SIGNAL(triggered(bool)));
        connect(act, SIGNAL(changed()), this, SLOT(updateAction()));
        if (isCheckable()) setChecked(act->isChecked());
        setEnabled(act->isEnabled());
    } else {
Exemple #21
0
QgsRectangle QgsExtentGroupBox::outputExtent() const
{
  if ( isCheckable() && !isChecked() )
    return QgsRectangle();

  return QgsRectangle( mXMinLineEdit->text().toDouble(), mYMinLineEdit->text().toDouble(),
                       mXMaxLineEdit->text().toDouble(), mYMaxLineEdit->text().toDouble() );
}
Exemple #22
0
void KPopupMenu::paintCell(QPainter *p, int row, int col)
{
    if (row != 0)
        QPopupMenu::paintCell(p, row, col);
    else if ( ( (row == 0) && (col == 1) && (isCheckable()) ) || 
		( (row == 0) && (col == 0) && (!isCheckable()) ) ) {
        int cellh = cellHeight(0);
        int cellw = cellWidth(0);
        QColorGroup cg = this->colorGroup();
        
        p->setPen(cg.light());
		p->drawText(6, 3, cellw, cellh-4, 
			DontClip|AlignVCenter|ShowPrefix|SingleLine, text(0));
        p->setPen(cg.text());
		p->drawText(5, 2, cellw, cellh-4, 
			DontClip|AlignVCenter|ShowPrefix|SingleLine, text(0));
    }
}
Exemple #23
0
void wxQtToolButton::mouseReleaseEvent( QMouseEvent *event )
{
    QToolButton::mouseReleaseEvent(event);
    if (event->button() == Qt::LeftButton) {
        wxToolBarTool *handler = GetHandler();
        wxToolBarBase *toolbar = handler->GetToolBar();
        toolbar->OnLeftClick( handler->GetId(), isCheckable() ? 1 : 0 );
    }
}
Exemple #24
0
void WPushButton::setChecked(bool checked)
{
  if (isCheckable()) {
    flags_.set(BIT_IS_CHECKED, checked);

    flags_.set(BIT_CHECKED_CHANGED, true);
    repaint();
  }
}
Exemple #25
0
void QgsExtentGroupBox::groupBoxClicked()
{
  if ( !isCheckable() )
    return;

  updateTitle();

  // output extent just went from null to something (or vice versa)
  emit extentChanged( outputExtent() );
}
void PixmapButton::mouseReleaseEvent( QMouseEvent * _me )
{
	AutomatableButton::mouseReleaseEvent( _me );

	if( !isCheckable() )
	{
		m_pressed = false;
		update();
	}
}
Exemple #27
0
void StelAction::trigger()
{
	if (isCheckable())
		toggle();
	else
	{
		//parameterless slot call
		slot.invoke(target);
		emit triggered();
	}
}
void PixmapButton::mousePressEvent( QMouseEvent * _me )
{
	// Show pressing graphics if this isn't checkable
	if( !isCheckable() )
	{
		m_pressed = true;
		update();
	}

	AutomatableButton::mousePressEvent( _me );
}
void QGroupBox::paintEvent( QPaintEvent *event )
{
    QPainter paint( this );

    if ( lenvisible && !isCheckable() ) {	// draw title
        QFontMetrics fm = paint.fontMetrics();
        int h = fm.height();
        int tw = fm.width( str, lenvisible ) + fm.width(QChar(' '));
        int x;
        int marg = bFlat ? 0 : 8;
        if ( align & AlignHCenter )		// center alignment
            x = frameRect().width()/2 - tw/2;
        else if ( align & AlignRight )	// right alignment
            x = frameRect().width() - tw - marg;
        else if ( align & AlignLeft )		 // left alignment
            x = marg;
        else { // auto align
            if( QApplication::reverseLayout() )
                x = frameRect().width() - tw - marg;
            else
                x = marg;
        }
        QRect r( x, 0, tw, h );
        int va = style().styleHint(QStyle::SH_GroupBox_TextLabelVerticalAlignment, this);
        if(va & AlignTop)
            r.moveBy(0, fm.descent());
        QColor pen( (QRgb) style().styleHint(QStyle::SH_GroupBox_TextLabelColor, this )  );
        if (!style().styleHint(QStyle::SH_UnderlineAccelerator, this))
            va |= NoAccel;
        style().drawItem( &paint, r, ShowPrefix | AlignHCenter | va, colorGroup(),
                          isEnabled(), 0, str, -1, ownPalette() ? 0 : &pen );
        paint.setClipRegion( event->region().subtract( r ) ); // clip everything but title
#ifndef QT_NO_CHECKBOX
    } else if ( d->checkbox ) {
        QRect cbClip = d->checkbox->geometry();
        QFontMetrics fm = paint.fontMetrics();
        cbClip.setX( cbClip.x() - fm.width(QChar(' ')) );
        cbClip.setWidth( cbClip.width() + fm.width(QChar(' ')) );
        paint.setClipRegion( event->region().subtract( cbClip ) );
#endif
    }
    if ( bFlat ) {
        QRect fr = frameRect();
        QPoint p1( fr.x(), fr.y() + 1 );
        QPoint p2( fr.x() + fr.width(), p1.y() );
        // ### This should probably be a style primitive.
        qDrawShadeLine( &paint, p1, p2, colorGroup(), TRUE,
                        lineWidth(), midLineWidth() );
    } else {
        drawFrame(&paint);
    }
    drawContents( &paint );			// draw the contents
}
Exemple #30
0
void QgsExtentGroupBox::setOutputExtent( const QgsRectangle &r, const QgsCoordinateReferenceSystem &srcCrs, ExtentState state )
{
  QgsRectangle extent;
  if ( mOutputCrs == srcCrs )
  {
    extent = r;
  }
  else
  {
    try
    {
      QgsCoordinateTransform ct( srcCrs, mOutputCrs, QgsProject::instance() );
      extent = ct.transformBoundingBox( r );
    }
    catch ( QgsCsException & )
    {
      // can't reproject
      extent = r;
    }
  }

  int decimals = 4;
  switch ( mOutputCrs.mapUnits() )
  {
    case QgsUnitTypes::DistanceDegrees:
    case QgsUnitTypes::DistanceUnknownUnit:
      decimals = 9;
      break;
    case QgsUnitTypes::DistanceMeters:
    case QgsUnitTypes::DistanceKilometers:
    case QgsUnitTypes::DistanceFeet:
    case QgsUnitTypes::DistanceNauticalMiles:
    case QgsUnitTypes::DistanceYards:
    case QgsUnitTypes::DistanceMiles:
    case QgsUnitTypes::DistanceCentimeters:
    case QgsUnitTypes::DistanceMillimeters:
      decimals = 4;
      break;
  }
  mXMinLineEdit->setText( QString::number( extent.xMinimum(), 'f', decimals ) );
  mXMaxLineEdit->setText( QString::number( extent.xMaximum(), 'f', decimals ) );
  mYMinLineEdit->setText( QString::number( extent.yMinimum(), 'f', decimals ) );
  mYMaxLineEdit->setText( QString::number( extent.yMaximum(), 'f', decimals ) );

  mExtentState = state;

  if ( isCheckable() && !isChecked() )
    setChecked( true );

  updateTitle();

  emit extentChanged( extent );
}