void PlaylistItemDelegate::createPlayIcon() {
    playIcon = QPixmap(THUMB_WIDTH, THUMB_HEIGHT);
    playIcon.fill(Qt::transparent);

    QPixmap tempPixmap(THUMB_WIDTH, THUMB_HEIGHT);
    tempPixmap.fill(Qt::transparent);
    QPainter painter(&tempPixmap);
    painter.setRenderHints(QPainter::Antialiasing, true);

    const int hPadding = PADDING*6;
    const int vPadding = PADDING*2;

    QPolygon polygon;
    polygon << QPoint(hPadding, vPadding)
            << QPoint(THUMB_WIDTH-hPadding, THUMB_HEIGHT/2)
            << QPoint(hPadding, THUMB_HEIGHT-vPadding);
    painter.setBrush(Qt::white);
    QPen pen;
    pen.setColor(Qt::white);
    pen.setWidth(PADDING);
    pen.setJoinStyle(Qt::RoundJoin);
    pen.setCapStyle(Qt::RoundCap);
    painter.setPen(pen);
    painter.drawPolygon(polygon);
    painter.end();

    QPainter painter2(&playIcon);
    painter2.setOpacity(.75);
    painter2.drawPixmap(0, 0, tempPixmap);
}
void PlaylistItemDelegate::createPlayIcon() {
    qreal maxRatio = 2.0;
    playIcon = QPixmap(thumbWidth * maxRatio, thumbHeight * maxRatio);
    playIcon.setDevicePixelRatio(maxRatio);
    playIcon.fill(Qt::transparent);

    QPixmap tempPixmap(thumbWidth * maxRatio, thumbHeight * maxRatio);
    tempPixmap.setDevicePixelRatio(maxRatio);
    tempPixmap.fill(Qt::transparent);
    QPainter painter(&tempPixmap);
    painter.setRenderHints(QPainter::Antialiasing, true);

    const int hPadding = padding * 6;
    const int vPadding = padding * 2;

    QPolygon polygon;
    polygon << QPoint(hPadding, vPadding) << QPoint(thumbWidth - hPadding, thumbHeight / 2)
            << QPoint(hPadding, thumbHeight - vPadding);
    painter.setBrush(Qt::white);
    QPen pen;
    pen.setColor(Qt::white);
    pen.setWidth(padding);
    pen.setJoinStyle(Qt::RoundJoin);
    pen.setCapStyle(Qt::RoundCap);
    painter.setPen(pen);
    painter.drawPolygon(polygon);
    painter.end();

    QPainter painter2(&playIcon);
    painter2.setOpacity(.75);
    painter2.drawPixmap(0, 0, tempPixmap);
}
Example #3
0
//---------------------------------------------mouseMoveEvent
void QtIOWidget::mouseMoveEvent(QMouseEvent* pEvent)
{
  QByteArray aItemData;
  QDataStream aDataStream(&aItemData, QIODevice::WriteOnly);

  QtIOWidget* pThis = this;
  aDataStream.writeRawData(reinterpret_cast<char*>(&pThis), sizeof(pThis));

  QMimeData* pMimeData = new QMimeData;
  pMimeData->setData(getDragDropFormat(), aItemData);

  QPixmap tempPixmap(width(), height());
  QPainter painter;
  painter.begin(&tempPixmap);
  painter.fillRect(rect(), QColor(127, 127, 127, 127));
  painter.end();

  QDrag* pDrag = new QDrag(this);
  pDrag->setMimeData(pMimeData);
  pDrag->setPixmap(tempPixmap);
  pDrag->setHotSpot(pEvent->pos());

  if (pDrag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction) == Qt::MoveAction)
  {
    return; 
  }
}
Example #4
0
void PlayerSelectorItem::selectionChanged(bool selectionState)
{
    m_playerName->setEnabled(selectionState);
    m_playerAuthor->setEnabled(selectionState);
    
    if(selectionState == true)
    {
        m_playerPreviewPixmapAlphaChannel->fill(QColor(255, 255, 255, 255));
    }
    else
    {
        m_playerPreviewPixmapAlphaChannel->fill(QColor(64, 64, 64, 255));
    }
    QPixmap tempPixmap(*m_playerPreviewPixmap);
    tempPixmap.setAlphaChannel(*m_playerPreviewPixmapAlphaChannel);
    m_playerPreviewPixmapLabel->setPixmap(tempPixmap);
    
    m_moveLeft->setEnabled(selectionState);
    m_moveUp->setEnabled(selectionState);
    m_moveRight->setEnabled(selectionState);
    m_moveDown->setEnabled(selectionState);
    m_dropBomb->setEnabled(selectionState);
    
    m_labelMoveLeft->setEnabled(selectionState);
    m_labelMoveUp->setEnabled(selectionState);
    m_labelMoveRight->setEnabled(selectionState);
    m_labelMoveDown->setEnabled(selectionState);
    m_labelDropBomb->setEnabled(selectionState);
}
Example #5
0
void PlayerSelectorItem::setPlayerPreviewPixmap(const QPixmap& pixmap)
{
    delete m_playerPreviewPixmap;
    m_playerPreviewPixmap = new QPixmap(pixmap);
    
    QPixmap tempPixmap(*m_playerPreviewPixmap);
    tempPixmap.setAlphaChannel(*m_playerPreviewPixmapAlphaChannel);
    m_playerPreviewPixmapLabel->setPixmap(tempPixmap);
}
Example #6
0
void tSunMoonDialog::ProcessMoonPixmap( QPixmap& moonPixmap )
{
    if( m_MoonData.Phase < 0.99 )
    {
        QRect r = moonPixmap.rect();

        qreal diameter = r.width() * 0.744;
        QRectF rF( r.center().x() - 0.5 - diameter / 2,
            r.center().y() + 1 - diameter / 2,
            diameter, diameter );

        QPainterPath darkMoonPath;
        if( m_MoonData.Phase > 0.01 )
        {
            QPainterPath halfMoonPath;
            halfMoonPath.moveTo( rF.left() + rF.width() / 2, rF.top() + rF.height() );

            qreal sweep = 180;
            if( m_MoonData.Waxing )
            {
                sweep *= -1;
            }
            halfMoonPath.arcTo( rF.left(), rF.top(), diameter, diameter, 90, sweep );
            halfMoonPath.lineTo( rF.left() + rF.width() / 2, rF.top() );

            QPainterPath cresentMoonPath;
            cresentMoonPath.addEllipse( rF.center(), diameter * cos( m_MoonData.Phase * M_PI ) / 2, diameter / 2 );

            if( m_MoonData.Phase < 0.5 )
            {
                darkMoonPath = halfMoonPath.united( cresentMoonPath );
            }
            else
            {
                darkMoonPath = halfMoonPath.subtracted( cresentMoonPath );
            }
        }
        else
        {
            darkMoonPath.addEllipse( rF.center(), diameter / 2, diameter / 2 );
        }

        QPainter painter( &moonPixmap );
        painter.setRenderHint( QPainter::Antialiasing );
        painter.setPen( Qt::NoPen );
        QColor c( 0, 0, 0, 170 );
        painter.setBrush( QBrush( c ) );
        painter.drawPath( darkMoonPath );
        painter.end();
    }

    // invert the image if in northern hemisphere
    if( m_Position.Y() >= 0 )
    {
        QPixmap tempPixmap( moonPixmap );
        moonPixmap.fill( QColor( 0, 0, 0, 0 ) );
        QPainter painter( &moonPixmap );
        painter.rotate( 180 );
        painter.drawPixmap( QPoint( -moonPixmap.width(), -moonPixmap.height() ), tempPixmap );
        painter.end();
    }

}