void Tab::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event)

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

    QBrush brush;
    brush.setStyle(Qt::SolidPattern);
    brush.setColor(backgroundColor());
    painter.setOpacity(1);
    painter.setBrush(brush);
    painter.setPen(Qt::NoPen);
    painter.drawRect(rect());

    paintHalo(&painter);

    QStylePainter style(this);

    if (!icon().isNull()) {
        style.translate(0, 12);
    }

    QStyleOptionButton option;
    initStyleOption(&option);
    option.features |= QStyleOptionButton::Flat;
    option.iconSize = QSize(-1, -1);  // Prevent icon from being drawn twice

    style.drawControl(QStyle::CE_PushButtonLabel, option);

    if (!icon().isNull()) {
        const QSize &size = iconSize();
        QRect iconRect(QPoint((width()-size.width())/2, 0), size);
        icon().paint(&painter, iconRect, Qt::AlignCenter, QIcon::Normal);
    }

    if (!_active) {
        QColor overlayColor = backgroundColor();
        overlayColor.setAlphaF(0.36);

        QBrush overlay;
        overlay.setStyle(Qt::SolidPattern);
        overlay.setColor(overlayColor);
        painter.fillRect(rect(), overlay);
    }

#ifdef DEBUG_LAYOUT
    QPainter debug(this);
    QPen pen;
    pen.setColor(Qt::red);
    pen.setWidth(2);
    debug.setPen(pen);
    debug.setBrush(Qt::NoBrush);
    debug.drawRect(rect());
#endif
}
Example #2
0
QIcon QgsPenStyleComboBox::iconForPen( Qt::PenStyle style )
{
  QPixmap pix( iconSize() );
  QPainter p;
  pix.fill( Qt::transparent );

  p.begin( &pix );
  QPen pen( style );
  pen.setWidth( 2 );
  p.setPen( pen );
  double mid = iconSize().height() / 2.0;
  p.drawLine( 0, mid, iconSize().width(), mid );
  p.end();

  return QIcon( pix );
}
Example #3
0
void QgsLegendLayer::refreshSymbology( const QString& key )
{
  QgsMapLayer* theMapLayer = QgsMapLayerRegistry::instance()->mapLayer( key );
  if ( !theMapLayer )
  {
    return;
  }

  if ( theMapLayer->type() == QgsMapLayer::VectorLayer ) // VECTOR
  {
    QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( theMapLayer );
    vectorLayerSymbologyV2( vlayer );
  }
  else if ( theMapLayer->type() == QgsMapLayer::RasterLayer ) // RASTER
  {
    QgsRasterLayer* rlayer = qobject_cast<QgsRasterLayer *>( theMapLayer );
    rasterLayerSymbology( rlayer ); // get and change symbology
  }
  else if ( theMapLayer->type() == QgsMapLayer::PluginLayer )
  {
    QgsPluginLayer* player = qobject_cast<QgsPluginLayer *>( theMapLayer );

    QSize iconSize( 16, 16 );
    SymbologyList itemList = player->legendSymbologyItems( iconSize );

    changeSymbologySettings( theMapLayer, itemList );
  }

  updateIcon();
}
Example #4
0
void MainWindow::setupFindToolBar()
{
  m_findToolBar->setObjectName("FindToolBar");
  m_findToolBar->setVisible(false);

  QLabel* findLabel = new QLabel("Find Text: ");
  m_findLineEdit = new QLineEdit();
  m_findLineEdit->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
  m_findLineEdit->setFocusPolicy(Qt::ClickFocus);
  connect(m_findLineEdit, SIGNAL(textChanged(const QString&)),
          this, SLOT(setFindText(const QString&)));

  //add a spacer
  QWidget* spacer = new QWidget();
  spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);

  //set the size of the buttons and the icon based on the height of the line edit
  QSize buttonSize(m_findLineEdit->sizeHint().height()-4, m_findLineEdit->sizeHint().height()-4);
  QSize iconSize(m_findLineEdit->sizeHint().height()-8, m_findLineEdit->sizeHint().height()-8);

  QPushButton* closeButton = new QPushButton(QIcon(QString("icons/stop.png")), "");
  closeButton->setToolTip("Close the find toolbar");
  closeButton->setFlat(true);
  closeButton->setFixedSize(buttonSize);
  closeButton->setIconSize(iconSize);
  closeButton->setFocusPolicy(Qt::ClickFocus);
  connect(closeButton, SIGNAL(released()), this, SLOT(closeFindToolBar()));

  m_findToolBar->addWidget(findLabel);
  m_findToolBar->addWidget(m_findLineEdit);
  m_findToolBar->addWidget(spacer);
  m_findToolBar->addWidget(closeButton);
}
Example #5
0
QSize
AnimatedBarWidget::sizeHint() const
{
    QSize size = QAbstractButton::sizeHint();
    size.setHeight( iconSize().height() + 8 );
    return size;
}
Example #6
0
void ElidingButton::elideText( const QSize &widgetSize )
{
    const int width = widgetSize.width();
    const int iconWidth = icon().isNull() ? 0 : iconSize().width();

    int left, top, right, bottom;
    getContentsMargins( &left, &top, &right, &bottom );
    int padding = left + right + 4;
    int textWidth = width - ( iconWidth + padding );

    QFontMetrics fm( font() );
    QString elidedText = fm.elidedText( m_fullText, Qt::ElideRight, textWidth );
    QPushButton::setText( elidedText );

    bool elided = ( elidedText != m_fullText );

    // If there is no tooltip set, then we set it to be the full text when elided,
    // and clear it if the button is no longer elided.
    const QString tip = toolTip();
    if( elided && tip.isEmpty() )
        setToolTip( m_fullText );
    else if( !elided && tip == m_fullText )
        setToolTip( QString() );

    if( elided )
        setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
    else
        setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed );

    if( m_isElided != elided )
    {
        m_isElided = elided;
        emit( sizePolicyChanged() );
    }
}
Example #7
0
   void MainWindow::creatbuttons()
   {
       textTop=new GcodeEdit(0);
       textBottom=new QPlainTextEdit(0);
       load=new QPushButton(QString::fromLocal8Bit("载入"),0);
       //count=new QPushButton(QObject::tr("count"),0);
       count=new QPushButton(QString::fromLocal8Bit("计数"),0);
       simulation=new QPushButton(QString::fromLocal8Bit("仿真"),0);
       send=new QPushButton(QString::fromLocal8Bit("发送"),0);
       finish=new QPushButton(QString::fromLocal8Bit("结束"),0);
       compiler=new QPushButton(QString::fromLocal8Bit("编译"),0);

       QSize iconSize(4,4);
       zoomInIcon = new QToolButton;
       zoomInIcon->setAutoRepeat(true);
       zoomInIcon->setAutoRepeatInterval(33);
       zoomInIcon->setAutoRepeatDelay(0);
       //zoomInIcon->setIcon(QPixmap("images//zoomin.png"));
       //zoomInIcon->setIconSize(QPixmap( "images//zoomin.png").size());
       zoomOutIcon = new QToolButton;
       zoomOutIcon->setAutoRepeat(true);
       zoomOutIcon->setAutoRepeatInterval(33);
       zoomOutIcon->setAutoRepeatDelay(0);
       // zoomOutIcon->setIcon(QPixmap(":/File/zoomout.png"));
       //zoomOutIcon->setIconSize(QPixmap("/File/zoomin.png").size());
       zoomSlider = new QSlider;
       zoomSlider->setMinimum(0);
       zoomSlider->setMaximum(500);
       zoomSlider->setValue(250);
       zoomSlider->setTickPosition(QSlider::TicksRight);

       // Zoom slider layout


       QVBoxLayout *zoomSliderLayout = new QVBoxLayout;
       zoomSliderLayout->addWidget(zoomInIcon);
       zoomSliderLayout->addWidget(zoomSlider);
       zoomSliderLayout->addWidget(zoomOutIcon);
       zoomwidget=new QWidget();
       zoomwidget->setLayout(zoomSliderLayout);
       //zoom in out

       selectGroup = new QGroupBox(0);
       //  selectGroup->setTitle(tr("select"));
       selectGroup->setTitle(QString::fromLocal8Bit("选择"));
       zhengjiaoType = new QRadioButton(selectGroup);
       zuijinType = new QRadioButton(selectGroup);
       zidingyiType= new QRadioButton(selectGroup);
       zhengjiaoType->setText(QString::fromLocal8Bit("正交"));
       zuijinType->setText(QString::fromLocal8Bit("最近点选择"));
       zidingyiType->setText(QString::fromLocal8Bit("自定义"));
       selectGroup->adjustSize();
       zhengjiaoType->setChecked(true);
       QVBoxLayout *vbox=new QVBoxLayout;
       vbox->addWidget(zhengjiaoType);
       vbox->addWidget(zuijinType);
       vbox->addWidget(zidingyiType);
       selectGroup->setLayout(vbox);

   }
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;
}
int QTabBar::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 8)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 8;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< Shape*>(_v) = shape(); break;
        case 1: *reinterpret_cast< int*>(_v) = currentIndex(); break;
        case 2: *reinterpret_cast< int*>(_v) = count(); break;
        case 3: *reinterpret_cast< bool*>(_v) = drawBase(); break;
        case 4: *reinterpret_cast< QSize*>(_v) = iconSize(); break;
        case 5: *reinterpret_cast< Qt::TextElideMode*>(_v) = elideMode(); break;
        case 6: *reinterpret_cast< bool*>(_v) = usesScrollButtons(); break;
        case 7: *reinterpret_cast< bool*>(_v) = tabsClosable(); break;
        case 8: *reinterpret_cast< SelectionBehavior*>(_v) = selectionBehaviorOnRemove(); break;
        case 9: *reinterpret_cast< bool*>(_v) = expanding(); break;
        case 10: *reinterpret_cast< bool*>(_v) = isMovable(); break;
        case 11: *reinterpret_cast< bool*>(_v) = documentMode(); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setShape(*reinterpret_cast< Shape*>(_v)); break;
        case 1: setCurrentIndex(*reinterpret_cast< int*>(_v)); break;
        case 3: setDrawBase(*reinterpret_cast< bool*>(_v)); break;
        case 4: setIconSize(*reinterpret_cast< QSize*>(_v)); break;
        case 5: setElideMode(*reinterpret_cast< Qt::TextElideMode*>(_v)); break;
        case 6: setUsesScrollButtons(*reinterpret_cast< bool*>(_v)); break;
        case 7: setTabsClosable(*reinterpret_cast< bool*>(_v)); break;
        case 8: setSelectionBehaviorOnRemove(*reinterpret_cast< SelectionBehavior*>(_v)); break;
        case 9: setExpanding(*reinterpret_cast< bool*>(_v)); break;
        case 10: setMovable(*reinterpret_cast< bool*>(_v)); break;
        case 11: setDocumentMode(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 12;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Example #10
0
void ResourceListWidget::startDrag(Qt::DropActions supportedActions)
{
    if (supportedActions == Qt::MoveAction)
        return;

    QListWidgetItem *item = currentItem();
    if (!item)
        return;

    const QString filePath = item->data(Qt::UserRole).toString();
    const QIcon icon = item->icon();

    QMimeData *mimeData = new QMimeData;
    const QtResourceView::ResourceType type = icon.isNull() ? QtResourceView::ResourceOther : QtResourceView::ResourceImage;
    mimeData->setText(QtResourceView::encodeMimeData(type , filePath));

    QDrag *drag = new QDrag(this);
    if (!icon.isNull()) {
        const QSize size = icon.actualSize(iconSize());
        drag->setPixmap(icon.pixmap(size));
        drag->setHotSpot(QPoint(size.width() / 2, size.height() / 2));
    }

    drag->setMimeData(mimeData);
    drag->exec(Qt::CopyAction);
}
void pDockWidgetTitleBar::updateStandardIcons()
{
    const QSize size( 16, 16 );
    QPixmap pixmap;
    QRect rect( QPoint(), iconSize() );
    
    QTransform transform;
    transform.rotate( 90 );
    
    pixmap = style()->standardIcon( QStyle::SP_ToolBarHorizontalExtensionButton, 0, widgetForAction( aOrientation ) ).pixmap( size );
    rect.moveCenter( pixmap.rect().center() );
    pixmap = pixmap.copy( rect );
    pixmap = pixmap.transformed( transform, Qt::SmoothTransformation );
    aOrientation->setIcon( pixmap );
    
    pixmap = style()->standardIcon( QStyle::SP_TitleBarNormalButton, 0, widgetForAction( aFloat ) ).pixmap( size );
    rect.moveCenter( pixmap.rect().center() );
    pixmap = pixmap.copy( rect );
    aFloat->setIcon( pixmap );
    
    pixmap = style()->standardIcon( QStyle::SP_TitleBarCloseButton, 0, widgetForAction( aClose ) ).pixmap( size );
    rect.moveCenter( pixmap.rect().center() );
    pixmap = pixmap.copy( rect );
    aClose->setIcon( pixmap );
}
Example #12
0
void RListWidget::mouseMoveEvent(QMouseEvent* e) {
    if (e->x()-iconOffset < iconSize().width()) {
    } else {
        e->ignore();
        QListWidget::mouseMoveEvent(e);
    }
}
Example #13
0
QModelIndex FolderViewListView::indexAt(const QPoint& point) const {
  QModelIndex index = QListView::indexAt(point);
  // NOTE: QListView has a severe design flaw here. It does hit-testing based on the 
  // total bound rect of the item. The width of an item is determined by max(icon_width, text_width).
  // So if the text label is much wider than the icon, when you click outside the icon but
  // the point is still within the outer bound rect, the item is still selected.
  // This results in very poor usability. Let's do precise hit-testing here.
  // An item is hit only when the point is in the icon or text label.
  // If the point is in the bound rectangle but outside the icon or text, it should not be selected.
  if(viewMode() == QListView::IconMode && index.isValid()) {
    // FIXME: this hack only improves the usability partially. We still need more precise sizeHint handling.
    // FolderItemDelegate* delegate = static_cast<FolderItemDelegate*>(itemDelegateForColumn(FolderModel::ColumnFileName));
    // Q_ASSERT(delegate != NULL);
    // We use the grid size - (2, 2) as the size of the bounding rectangle of the whole item.
    // The width of the text label hence is gridSize.width - 2, and the width and height of the icon is from iconSize().
    QRect visRect = visualRect(index); // visibal area on the screen
    QSize itemSize = gridSize();
    itemSize.setWidth(itemSize.width() - 2);
    itemSize.setHeight(itemSize.height() - 2);
    QSize _iconSize = iconSize();
    int textHeight = itemSize.height() - _iconSize.height();
    if(point.y() < visRect.bottom() - textHeight) {
      // the point is in the icon area, not over the text label
      int iconXMargin = (itemSize.width() - _iconSize.width()) / 2;
      if(point.x() < (visRect.left() + iconXMargin) || point.x() > (visRect.right() - iconXMargin))
	return QModelIndex();
    }
    // qDebug() << "visualRect: " << visRect << "point:" << point;
  }
  return index;
}
Example #14
0
    void paint(QPainter * painter,
            const QStyleOptionGraphicsItem * option, QWidget * widget)
    {
        Q_UNUSED(option);
        Q_UNUSED(widget);

        // BasicWidget::paint(painter, option, widget);
        if (iconInSvg().isValid()) {
            QRectF iconRect = QRectF(QPointF(), iconSize());
            QSizeF sizeDiff = size() - iconRect.size();

            iconRect.setTopLeft(QPointF(sizeDiff.width() / 2, sizeDiff.height() / 2));
            if (animate) {
                iconInSvg().paint(painter,
                    iconRect.left(),
                    iconRect.top(),
                    "frame" + QString::number(frame));
            } else {
                iconInSvg().paint(painter,
                    iconRect.left(),
                    iconRect.top(),
                    "frame" + QString::number(
                        (frame > 0) ? frameCount : 0
                    ));

            }
        }
    }
Example #15
0
/*!
    Initialize \a option with the values from this QPushButton. 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 QPushButton::initStyleOption(QStyleOptionButton *option) const
{
    if (!option)
        return;

    Q_D(const QPushButton);
    option->initFrom(this);
    option->features = QStyleOptionButton::None;
    if (d->flat)
        option->features |= QStyleOptionButton::Flat;
#ifndef QT_NO_MENU
    if (d->menu)
        option->features |= QStyleOptionButton::HasMenu;
#endif
    if (autoDefault())
        option->features |= QStyleOptionButton::AutoDefaultButton;
    if (d->defaultButton)
        option->features |= QStyleOptionButton::DefaultButton;
    if (d->down || d->menuOpen)
        option->state |= QStyle::State_Sunken;
    if (d->checked)
        option->state |= QStyle::State_On;
    if (!d->flat && !d->down)
        option->state |= QStyle::State_Raised;
    option->text = d->text;
    option->icon = d->icon;
    option->iconSize = iconSize();
}
QSize Tab::sizeHint() const
{
    if (icon().isNull()) {
        return FlatButton::sizeHint();
    } else {
        return QSize(40, iconSize().height() + 46);
    }
}
Example #17
0
void RListWidget::mousePressEvent(QMouseEvent* e) {
    if (e->x()-iconOffset < iconSize().width()) {
        itemPressed = itemAt(e->pos());
    } else {
        e->ignore();
        QListWidget::mousePressEvent(e);
    }
}
Example #18
0
/*! \reimp */
int QCommandLinkButton::heightForWidth(int width) const
{
    Q_D(const QCommandLinkButton);
    int heightWithoutDescription = d->descriptionOffset() + d->bottomMargin();
    // find the width available for the description area
    return qMax(heightWithoutDescription + d->descriptionHeight(width),
                iconSize().height() + d->topMargin() + d->bottomMargin());
}
Example #19
0
void PlaybaKFadingButton::paintEvent(QPaintEvent* ev)
{
    //KPushButton::paintEvent(ev);
    QPainter p(this);
    qreal frame = (qreal)timeLine->currentFrame()/1000.;
    //p.setOpacity(frame);
    //p.drawPixmap(0, 0, width(), height(), QPixmap("/home/gil/glow.png"));

    p.setOpacity(1);
    icon().paint(&p, width()/2 - iconSize().width()/2, height()/2 - iconSize().height()/2, iconSize().width(), iconSize().height());
    //KIcon(mOverIcon).pixmap(iconSize().width(), iconSize().height()

    p.setOpacity(frame);
    //p.drawPixmap(0, 0, width(), height(), QPixmap(mOverIcon));
    p.drawPixmap(0, 0, width(), height(), QPixmap("/home/gil/Projectos/play.png"));
    //p.drawLine(0, 0, 20, 20);
}
QVariant QgsSymbolV2LegendNode::data( int role ) const
{
  if ( role == Qt::DisplayRole )
  {
    return mLabel;
  }
  else if ( role == Qt::EditRole )
  {
    return mUserLabel.isEmpty() ? mItem.label() : mUserLabel;
  }
  else if ( role == Qt::DecorationRole )
  {
    QSize iconSize( 16, 16 ); // TODO: configurable
    const int indentSize = 20;
    if ( mPixmap.isNull() )
    {
      QPixmap pix;
      if ( mItem.symbol() )
        pix = QgsSymbolLayerV2Utils::symbolPreviewPixmap( mItem.symbol(), iconSize );
      else
      {
        pix = QPixmap( iconSize );
        pix.fill( Qt::transparent );
      }

      if ( mItem.level() == 0 )
        mPixmap = pix;
      else
      {
        // ident the symbol icon to make it look like a tree structure
        QPixmap pix2( pix.width() + mItem.level() * indentSize, pix.height() );
        pix2.fill( Qt::transparent );
        QPainter p( &pix2 );
        p.drawPixmap( mItem.level() * indentSize, 0, pix );
        p.end();
        mPixmap = pix2;
      }
    }
    return mPixmap;
  }
  else if ( role == Qt::CheckStateRole )
  {
    if ( !mItem.isCheckable() )
      return QVariant();

    QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( mLayerNode->layer() );
    if ( !vlayer || !vlayer->rendererV2() )
      return QVariant();

    return vlayer->rendererV2()->legendSymbolItemChecked( mItem.ruleKey() ) ? Qt::Checked : Qt::Unchecked;
  }
  else if ( role == RuleKeyRole )
  {
    return mItem.ruleKey();
  }

  return QVariant();
}
Example #21
0
void
CQDividedAreaTitle::
paintEvent(QPaintEvent *)
{
  QPainter painter(this);

  painter.fillRect(rect(), QBrush(bg_));

  int x = 2;
  int h = height();

  int iw = 0;

  if (! icon_.isNull()) {
    iw = iconSize().width() + 2;

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

    x += iw;
  }

  int bw = collapseButton_->width();

  if (title_.length()) {
    QFontMetrics fm(font());

    QString title = fm.elidedText(title_, Qt::ElideRight, width() - iw - bw - 6);

    // if just an ellipsis keep first letter
    if (title.length() == 0 || title.utf16()[0] == 8230)
      title = title_[0] + "..";

    painter.drawText(x, (h - fm.height())/2 + fm.ascent(), title);
  }

  QRect buttonRect(collapseButton_->x() - 2, 0, bw + 4, height());

  painter.fillRect(buttonRect, QBrush(bg_));

  QColor c = widget_->palette().window().color().darker(200);

  painter.setPen(c);

  painter.drawLine(0, height() - 1, width() - 1, height() - 1);
}
Example #22
0
void QPictureButton::PaintIcon()
{
    if (!icon().isNull()) {
        QPainter painter(this);
        painter.setRenderHint(QPainter::Antialiasing);
        QRect PainterRect = painter.window();

        int Top  = (PainterRect.height() - iconSize().height()) / 2;
        int Left = (PainterRect.width()  - iconSize().width())  / 2;

        switch (m_IconPosition) {
        case PositionTop:
            Top = m_IconSpace;
            break;
        case PositionBottom:
            Top = PainterRect.height() - iconSize().height() - m_IconSpace;
            break;
        case PositionLeft:
            Left = m_IconSpace;
            break;
        case PositionRight:
            Left = PainterRect.width() - iconSize().width() - m_IconSpace;
            break;
        }

        QPixmap Pixmap = icon().pixmap(iconSize());
        QRect PixmapRect(Left, Top, iconSize().width(), iconSize().height());

        painter.drawPixmap(PixmapRect, Pixmap);
    }
}
Example #23
0
void
AccountsToolButton::paintEvent( QPaintEvent* event )
{
    QToolButton::paintEvent( event );

    QPainter painter( this );
    painter.initFrom( this );

    if ( m_proxy->rowCount() == 0 )
    {
        QRect pixmapRect( QPoint( width() / 2 - iconSize().width() / 2,
                                  height() / 2 - iconSize().height() / 2 ),
                          iconSize() );
        painter.drawPixmap( pixmapRect, m_defaultPixmap );
    }
    else
    {
        for ( int i = 0; i < m_factoryPixmaps.count(); ++i )
        {
            int diff = height() - iconSize().height();
            int pixmapRectX = diff / 2
                            + i * ( iconSize().width() + diff );
            QRect pixmapRect( QPoint( pixmapRectX, height() / 2 - iconSize().height() / 2 ),
                              iconSize() );
            painter.drawPixmap( pixmapRect, m_factoryPixmaps.at( i ) );
        }
    }

    painter.end();
}
Example #24
0
/*!
    \reimp
 */
QSize QCommandLinkButton::minimumSizeHint() const
{
    Q_D(const QCommandLinkButton);
    QSize size = sizeHint();
    int minimumHeight = qMax(d->descriptionOffset() + d->bottomMargin(),
                             iconSize().height() + d->topMargin());
    size.setHeight(minimumHeight);
    return size;
}
void KexiLinkButton::updateIcon(const KIcon &icon)
{
    if (!d->usesForegroundColor)
        return;
    QColor c(palette().color(foregroundRole()));
    QPixmap pixmap(icon.pixmap(iconSize()));
    KexiUtils::replaceColors(&pixmap, c);
    KPushButton::setIcon(KIcon(pixmap));
}
void SettingsDialog::updateColorButton(QPushButton* button,
                                       const QColor& color) {
  QPixmap pixmap(68, 20);
  pixmap.fill(color);
  QIcon icon(pixmap);
  QSize iconSize(pixmap.width(), pixmap.height());
  button->setIconSize(iconSize);
  button->setIcon(icon);
}
void BracketStackList::slotThumbnail(const KUrl& url, const QPixmap& pix)
{
    QTreeWidgetItemIterator it(this);
    while (*it)
    {
        BracketStackItem* item = static_cast<BracketStackItem*>(*it);
        if (item->url() == url)
        {
            if (pix.isNull())
                item->setThumbnail(SmallIcon("image-x-generic", iconSize().width(), KIconLoader::DisabledState));
            else
                item->setThumbnail(pix.scaled(iconSize().width(), iconSize().height(), Qt::KeepAspectRatio));

            return;
        }
        ++it;
    }
}
Example #28
0
void Widget::CreateButton()
{
    ButtonLayout = new QHBoxLayout;

    QSize iconSize(40,40);//设置图标大小
    StartButton = new QToolButton;
    StartButton->setIcon(QPixmap(":/image/3.png"));
    StartButton->setAutoRaise(true);//鼠标放在按钮上面才显示按钮阴影框
    StartButton->setIconSize(iconSize);
    connect(StartButton,SIGNAL(clicked()),this,SLOT(StartMusic()));

    StopButton = new QToolButton;
    StopButton->setIcon(QPixmap(":/image/2.png"));
    StopButton->setVisible(false);//隐藏按钮
    StopButton->setAutoRaise(true);
    StopButton->setIconSize(iconSize);
    connect(StopButton,SIGNAL(clicked()),this,SLOT(StopMusic()));

    NextButton = new QToolButton;
    NextButton->setIcon(QPixmap(":/image/1.png"));
    NextButton->setAutoRaise(true);
    NextButton->setIconSize(iconSize);
    connect(NextButton,SIGNAL(clicked()),this,SLOT(NextMusic()));

    LastButton = new QToolButton;
    LastButton->setIcon(QPixmap(":/image/4.png"));
    LastButton->setAutoRaise(true);
    LastButton->setIconSize(iconSize);
    connect(LastButton,SIGNAL(clicked()),this,SLOT(LastMusic()));

    OpenButton = new QToolButton;
    OpenButton->setIcon(QPixmap(":/image/6.png"));
    OpenButton->setAutoRaise(true);
    OpenButton->setIconSize(iconSize);
    connect(OpenButton,SIGNAL(clicked()),this,SLOT(OpenFile()));

    ButtonLayout->addWidget(LastButton,0,0);
    ButtonLayout->addWidget(StartButton,1,0);
    ButtonLayout->addWidget(StopButton,1,0);
    ButtonLayout->addWidget(NextButton,2,0);
    ButtonLayout->addWidget(OpenButton,3,0);

    LabelLayout = new QHBoxLayout;

    timeLabel= new QLabel;//显示播放时间
    timeLabel->setText("00:00");
    TotaltimeLabel= new QLabel;//显示歌曲时间长度
    TotaltimeLabel->setText("00:00");

    TitleLabel= new QLabel;//显示歌曲名字
    TitleLabel->setText(tr("Music Title"));

    LabelLayout->addWidget(timeLabel);
    LabelLayout->addStretch();//中间空开
    LabelLayout->addWidget(TotaltimeLabel);
}
Example #29
0
int QToolBar::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 13)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 13;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = isMovable(); break;
        case 1: *reinterpret_cast< Qt::ToolBarAreas*>(_v) = allowedAreas(); break;
        case 2: *reinterpret_cast< Qt::Orientation*>(_v) = orientation(); break;
        case 3: *reinterpret_cast< QSize*>(_v) = iconSize(); break;
        case 4: *reinterpret_cast< Qt::ToolButtonStyle*>(_v) = toolButtonStyle(); break;
        case 5: *reinterpret_cast< bool*>(_v) = isFloating(); break;
        case 6: *reinterpret_cast< bool*>(_v) = isFloatable(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setMovable(*reinterpret_cast< bool*>(_v)); break;
        case 1: setAllowedAreas(*reinterpret_cast< Qt::ToolBarAreas*>(_v)); break;
        case 2: setOrientation(*reinterpret_cast< Qt::Orientation*>(_v)); break;
        case 3: setIconSize(*reinterpret_cast< QSize*>(_v)); break;
        case 4: setToolButtonStyle(*reinterpret_cast< Qt::ToolButtonStyle*>(_v)); break;
        case 6: setFloatable(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        bool *_b = reinterpret_cast<bool*>(_a[0]);
        switch (_id) {
        case 0: *_b = (qobject_cast<QMainWindow*>(parentWidget())!=0); break;
        case 1: *_b = (qobject_cast<QMainWindow*>(parentWidget())!=0); break;
        case 2: *_b = (qobject_cast<QMainWindow*>(parentWidget())==0); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Example #30
0
void ToolButton::paintEvent(QPaintEvent *) {
  QPainter p(this);
  p.setRenderHint(QPainter::Antialiasing);
  p.setPen(Qt::black);
  p.setBrush(_flashBackground != Qt::lightGray
      ? _flashBackground
      : _mousePressPoint.isNull()
        ? (_mouseCurrentlyOver ? Qt::darkGray : Qt::lightGray)
        : Qt::white);
  p.drawRoundedRect(rect(), 20, 20, Qt::RelativeSize);
  if (_tool) {
    p.drawPixmap(2, 2, _tool->icon()
                 .pixmap(iconSize(), _currentlyTriggerable
                         ? QIcon::Normal : QIcon::Disabled));
  }
  if (!_keyLabel.isNull()) {
    QPainterPath pp;
    QFont font = this->font();
    //QFont font("Sans");
    //font.setPointSize(10);
    pp.addText(QPointF(0, 0), font, _keyLabel);
    pp.translate(width()-2-pp.boundingRect().width()-pp.boundingRect().x(),
                 height()-2-pp.boundingRect().height()-pp.boundingRect().y());
    p.setRenderHint(QPainter::Antialiasing);
    // LATER parametrize outline and main letter colors
    p.setBrush(Qt::white);
    p.setPen(Qt::white);
    p.drawPath(pp);
    p.setBrush(Qt::darkBlue);
    p.setPen(Qt::transparent);
    p.drawPath(pp);
  }
  // LATER use icon rather than text as target indicator
  QString targetIndicator("?");
  switch (_targetType) {
  case TargetManager::PrimaryTarget:
    targetIndicator = QString();
    break;
  case TargetManager::PreviousPrimaryTarget:
    targetIndicator = "p";
    break;
  case TargetManager::MouseOverTarget:
    targetIndicator = "o";
    break;
  }
  if (!targetIndicator.isEmpty()) {
    QFont font = this->font();
    //font.setPointSize(10);
    p.setFont(font);
    p.setPen(Qt::black);
    QFontMetrics fm(font);
    p.drawText(QRectF(2, height()-2-fm.height(), width()-4, fm.maxWidth()),
               Qt::AlignLeft, targetIndicator);
  }
  p.end();
}