示例#1
0
void
AnimationButton::mousePressEvent(QMouseEvent* e)
{
    if ( buttonDownIsLeft(e) ) {
        _dragPos = e->pos();
        _dragging = true;
    }
    QPushButton::mousePressEvent(e);
}
示例#2
0
void
ComboBox::mousePressEvent(QMouseEvent* e)
{
    if (buttonDownIsLeft(e) && !_readOnly) {
        _clicked = true;
        createMenu();
        update();
        QFrame::mousePressEvent(e);
    }
    _currentDelta = 0;
}
示例#3
0
void
AnimationButton::mouseMoveEvent(QMouseEvent* e)
{
    if (_dragging) {
        // If the left button isn't pressed anymore then return
        if ( !buttonDownIsLeft(e) ) {
            return;
        }
        // If the distance is too small then return
        if ( (e->pos() - _dragPos).manhattanLength() < QApplication::startDragDistance() ) {
            return;
        }

        // initiate Drag

        _knob->onCopyAnimationActionTriggered();
        QDrag* drag = new QDrag(this);
        QMimeData* mimeData = new QMimeData;
        mimeData->setData("Animation", "");
        drag->setMimeData(mimeData);

        QFontMetrics fmetrics = fontMetrics();
        QString textFirstLine( tr("Copying animation from:") );
        QString textSecondLine( _knob->getKnob()->getDescription().c_str() );
        QString textThirdLine( tr("Drag it to another animation button.") );
        int textWidth = std::max( std::max( fmetrics.width(textFirstLine), fmetrics.width(textSecondLine) ),fmetrics.width(textThirdLine) );
        QImage dragImg(textWidth,(fmetrics.height() + 5) * 3,QImage::Format_ARGB32);
        dragImg.fill( QColor(243,137,0) );
        QPainter p(&dragImg);
        p.drawText(QPointF(0,dragImg.height() - 2.5), textThirdLine);
        p.drawText(QPointF(0,dragImg.height() - fmetrics.height() - 5), textSecondLine);
        p.drawText(QPointF(0,dragImg.height() - fmetrics.height() * 2 - 10), textFirstLine);

        drag->setPixmap( QPixmap::fromImage(dragImg) );
        setDown(false);
        drag->exec();
    } else {
        QPushButton::mouseMoveEvent(e);
    }
}