emit viewportRectChanged() in a better way
This commit is contained in:
parent
5d35de4e84
commit
0ae1def918
|
@ -19,6 +19,9 @@ GraphicsView::GraphicsView(QWidget *parent)
|
||||||
"border-radius: 3px;");
|
"border-radius: 3px;");
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
setCheckerboardEnabled(false);
|
setCheckerboardEnabled(false);
|
||||||
|
|
||||||
|
connect(horizontalScrollBar(), &QScrollBar::valueChanged, this, &GraphicsView::viewportRectChanged);
|
||||||
|
connect(verticalScrollBar(), &QScrollBar::valueChanged, this, &GraphicsView::viewportRectChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsView::showFromUrlList(const QList<QUrl> &urlList)
|
void GraphicsView::showFromUrlList(const QList<QUrl> &urlList)
|
||||||
|
@ -243,17 +246,6 @@ void GraphicsView::dropEvent(QDropEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsView::paintEvent(QPaintEvent *event)
|
|
||||||
{
|
|
||||||
// A little dirty hack way to get the viewport "pan" event
|
|
||||||
// but still doesn't works well with gif which scaled up bigger than the window.
|
|
||||||
if (event->rect() == this->rect() && !isThingSmallerThanWindowWith(transform())) {
|
|
||||||
emit viewportRectChanged();
|
|
||||||
// qDebug() << "paintEvent" << event << QObject::sender();
|
|
||||||
}
|
|
||||||
return QGraphicsView::paintEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GraphicsView::isThingSmallerThanWindowWith(const QTransform &transform) const
|
bool GraphicsView::isThingSmallerThanWindowWith(const QTransform &transform) const
|
||||||
{
|
{
|
||||||
return rect().size().expandedTo(transform.mapRect(sceneRect()).size().toSize())
|
return rect().size().expandedTo(transform.mapRect(sceneRect()).size().toSize())
|
||||||
|
|
|
@ -49,8 +49,6 @@ private:
|
||||||
void dragMoveEvent(QDragMoveEvent *event) override;
|
void dragMoveEvent(QDragMoveEvent *event) override;
|
||||||
void dropEvent(QDropEvent *event) override;
|
void dropEvent(QDropEvent *event) override;
|
||||||
|
|
||||||
void paintEvent(QPaintEvent *event) override;
|
|
||||||
|
|
||||||
bool isThingSmallerThanWindowWith(const QTransform &transform) const;
|
bool isThingSmallerThanWindowWith(const QTransform &transform) const;
|
||||||
bool shouldIgnoreMousePressMoveEvent(const QMouseEvent *event) const;
|
bool shouldIgnoreMousePressMoveEvent(const QMouseEvent *event) const;
|
||||||
void setCheckerboardEnabled(bool enabled);
|
void setCheckerboardEnabled(bool enabled);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user