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(); // }
void IdentityItem::hidePopups() { if ( hasPicture() ) { m_nameItem->hide(); } m_fanMenu->hide(); }
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(); } }
void ImageViewer::layoutImage() { if(hasPicture()) { calcScaleRatio(); calcTopLeft(); calcShift(); } updateCursor(); }
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(); } } }