Ejemplo n.º 1
0
    void mousePressEvent(QMouseEvent *e) {
        if(e->button() == LeftButton) {
            if(labeltype == Des)
                return;

            QDragObject *drobj = 0;

            if(pixmap()) { // 如果有圖片
                // 產生QDragObject
                drobj = new QImageDrag(pixmap()->convertToImage(), this);

                QPixmap pm;
                // 產生縮圖
                pm.convertFromImage(
                   pixmap()->convertToImage().smoothScale(25, 25));
                // 拖曳時的顯示圖形與游標位移
                drobj->setPixmap(pm, QPoint(-14, -20));
            }
            else if(text()) { // 如果有文字
                drobj = new QTextDrag(text(), this);
                drobj->setPixmap(QPixmap("text.gif"), QPoint(-25, -15));
            }

            // ?#125;始拖放動作
            if(drobj)
                drobj->dragCopy();
        }
    }   
Ejemplo n.º 2
0
void KSnapshot::slotDragSnapshot()
{
    QDragObject *drobj = new QImageDrag(snapshot.convertToImage(), this);
    Q_CHECK_PTR(drobj);
    drobj->setPixmap(mainWidget->preview());
    drobj->dragCopy();
}
Ejemplo n.º 3
0
QDragObject *KNCollectionView::dragObject()
{
    KFolderTreeItem *item = static_cast<KFolderTreeItem *>
                            (itemAt(viewport()->mapFromGlobal(QCursor::pos())));
    if(item && item->protocol() == KFolderTreeItem::Local && item->type() == KFolderTreeItem::Other)
    {
        QDragObject *d = new QStoredDrag("x-knode-drag/folder", viewport());
        d->setPixmap(SmallIcon("folder"));
        return d;
    }
    return 0;
}
Ejemplo n.º 4
0
void DropSite::mousePressEvent( QMouseEvent * /*e*/ )
{
    QDragObject *d;
    if ( pixmap() ) {
	d = new QImageDrag( pixmap()->convertToImage(), this );
	QPixmap pm;
	pm.convertFromImage(pixmap()->convertToImage().smoothScale(
	   pixmap()->width()/3,pixmap()->height()/3));
	d->setPixmap(pm,QPoint(-5,-7));
    } else {
	d = new QTextDrag( text(), this );
    }
    d->dragCopy();
}
Ejemplo n.º 5
0
QDragObject* KonqSidebarTree::dragObject()
{
    KonqSidebarTreeItem* item = static_cast<KonqSidebarTreeItem *>( selectedItem() );
    if ( !item )
        return 0;

    QDragObject* drag = item->dragObject( viewport(), false );
    if ( !drag )
        return 0;

    const QPixmap *pix = item->pixmap(0);
    if ( pix && drag->pixmap().isNull() )
        drag->setPixmap( *pix );

    return drag;
}
Ejemplo n.º 6
0
void Summary::mouseMoveEvent(QMouseEvent *event)
{
    if((event->state() & LeftButton) &&
            (event->pos() - mDragStartPoint).manhattanLength() > 4)
    {

        QDragObject *drag = new QTextDrag("", this, "SummaryWidgetDrag");

        QPixmap pm = QPixmap::grabWidget(this);
        if(pm.width() > 300)
            pm = pm.convertToImage().smoothScale(300, 300, QImage::ScaleMin);

        QPainter painter;
        painter.begin(&pm);
        painter.setPen(Qt::gray);
        painter.drawRect(0, 0, pm.width(), pm.height());
        painter.end();
        drag->setPixmap(pm);
        drag->dragMove();
    }
    else
        QWidget::mouseMoveEvent(event);
}