Commit a238fdab authored by Alberto Mardegan's avatar Alberto Mardegan
Browse files

VncOutput: add a new requestedScale property

This makes the behaviour more clear, and avoids unnecessary emissions of
the scaleChanged signal.
parent a42ee9ee
......@@ -25,7 +25,7 @@ Page {
requestedScale
var diffY = (pinch.center.y - pinch.startCenter.y) /
requestedScale
viewer.scale = requestedScale
viewer.requestedScale = requestedScale
viewer.center = Qt.point(initialCenter.x - diffX, initialCenter.y - diffY)
}
......
......@@ -53,6 +53,7 @@ private:
QRectF m_paintedRect;
QTransform m_itemToVnc;
QTransform m_vncToItem;
qreal m_requestedScale;
qreal m_scale;
QPointF m_center;
VncOutput *q_ptr;
......@@ -62,6 +63,7 @@ private:
VncOutputPrivate::VncOutputPrivate(VncOutput *q):
m_client(nullptr),
m_requestedScale(0.0),
m_scale(0.0),
q_ptr(q)
{
......@@ -71,12 +73,6 @@ VncOutputPrivate::~VncOutputPrivate()
{
}
void VncOutputPrivate::setScale(qreal scale)
{
m_scale = scale;
updateMapping();
}
void VncOutputPrivate::setCenter(const QPointF &center)
{
m_center = center;
......@@ -87,6 +83,8 @@ void VncOutputPrivate::updateMapping()
{
Q_Q(VncOutput);
qreal oldScale = m_scale;
qreal w = q->width();
qreal h = q->height();
......@@ -94,7 +92,7 @@ void VncOutputPrivate::updateMapping()
Scaler::InputData in {
m_vncSize,
QSizeF(w, h),
m_scale,
m_requestedScale,
m_center,
};
......@@ -116,7 +114,9 @@ void VncOutputPrivate::updateMapping()
m_vncToItem = m_itemToVnc.inverted();
Q_EMIT q->scaleChanged();
if (m_scale != oldScale) {
Q_EMIT q->scaleChanged();
}
Q_EMIT q->centerChanged();
}
......@@ -166,13 +166,21 @@ VncClient *VncOutput::client() const
return d->m_client;
}
void VncOutput::setScale(qreal scale)
void VncOutput::setRequestedScale(qreal scale)
{
Q_D(VncOutput);
d->setScale(scale);
d->m_requestedScale = scale;
Q_EMIT requestedScaleChanged();
d->updateMapping();
update();
}
qreal VncOutput::requestedScale() const
{
Q_D(const VncOutput);
return d->m_requestedScale;
}
qreal VncOutput::scale() const
{
Q_D(const VncOutput);
......
......@@ -32,7 +32,9 @@ class VncOutput: public QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY(VncClient *client READ client WRITE setClient NOTIFY clientChanged)
Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
Q_PROPERTY(qreal requestedScale READ requestedScale WRITE setRequestedScale
NOTIFY requestedScaleChanged)
Q_PROPERTY(qreal scale READ scale NOTIFY scaleChanged)
Q_PROPERTY(QPointF center READ center WRITE setCenter NOTIFY centerChanged)
public:
......@@ -42,7 +44,9 @@ public:
void setClient(VncClient *client);
VncClient *client() const;
void setScale(qreal scale);
void setRequestedScale(qreal scale);
qreal requestedScale() const;
qreal scale() const;
void setCenter(const QPointF &center);
......@@ -52,6 +56,7 @@ public:
Q_SIGNALS:
void clientChanged();
void requestedScaleChanged();
void scaleChanged();
void centerChanged();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment