예제 #1
0
void ImageViewer::myMouseMove(QMouseEvent * event)
{
    QPoint change = event->globalPos() - startPos;

    if(event->modifiers() == Qt::ControlModifier){
        emit siteChange(change);
    }else{
        //if widget smaller than widget, allow to move image.
        //! + SIZE_ADJUST
        if(hasPicture() && !(rect().size() + Config::SizeAdjusted - image.size()*scale).isValid()){
            shift += change;
            updateShift();


            QPoint delta = event->pos() - pressPos;
            if(justPressed){
                if (delta.x() > threshold || delta.x() < -threshold ||
                        delta.y() > threshold || delta.y() < -threshold) {
                    timeStamp = QTime::currentTime(); //start calculate
                    justPressed = false; ///
                    this->delta = QPoint(0, 0);
                    pressPos = event->pos();
                }
            }else{
                if (timeStamp.elapsed() > 100) {
                    timeStamp = QTime::currentTime();   //restart calculate
                    speed = delta - this->delta;    ///
                    this->delta = delta;
                }
            }
        }
    }

    startPos = event->globalPos();    //
}
예제 #2
0
void IdentityItem::hidePopups()
{
  if ( hasPicture() ) {
    m_nameItem->hide();
  }
  m_fanMenu->hide();
}
예제 #3
0
void ImageViewer::scrollContent(int deltaX, int deltaY)
{
    // if widget smaller than widget, allow to move image.
    if(hasPicture() && scaleLargeThanWidget()){
        shift.setX(shift.x() + deltaX);
        shift.setY(shift.y() + deltaY);
        updateShift();
    }
}
예제 #4
0
void ImageViewer::layoutImage()
{
    if(hasPicture()) {
        calcScaleRatio();
        calcTopLeft();
        calcShift();
    }

    updateCursor();
}
예제 #5
0
void ImageViewer::mousePressEvent ( QMouseEvent * event )
{
    if(event->button() & Qt::LeftButton){
        startPos = event->globalPos();
        if(hasPicture() && cursor().shape() == Qt::OpenHandCursor)
            setCursor(QCursor(Qt::ClosedHandCursor));

        justPressed = true;
        pressPos = event->pos();
        if(timer.isActive()){ // auto scroll
            speed = QPoint(0, 0);
            timer.stop();
        }
    }
}