Commit 8015de16 authored by Alberto Mardegan's avatar Alberto Mardegan
Browse files

QML: implement a view panning-only mode

parent 04ad25f1
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/icons">
<file alias="fullscreen">fullscreen.svg</file>
<file alias="move-view">move-view.svg</file>
<file alias="stop-move-view">stop-move-view.svg</file>
</qresource>
</RCC>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64"
height="64"
viewBox="0 0 16.933333 16.933334"
version="1.1"
id="svg8"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
sodipodi:docname="move-view.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="11.2"
inkscape:cx="9.9106717"
inkscape:cy="32.000441"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="true"
units="px"
inkscape:window-width="1871"
inkscape:window-height="1056"
inkscape:window-x="49"
inkscape:window-y="24"
inkscape:window-maximized="1"
inkscape:pagecheckerboard="true">
<inkscape:grid
type="xygrid"
id="grid4518"
empspacing="4" />
</sodipodi:namedview>
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-280.06665)">
<g
id="g856"
style="fill:#ffffff;fill-opacity:0;stroke:#000000;stroke-width:0.5291667;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
transform="matrix(0.73257485,0.16072987,-0.16072987,0.73257485,52.535106,78.068137)">
<path
sodipodi:nodetypes="cssc"
inkscape:connector-curvature="0"
id="path841"
d="m 2.1166667,290.64998 -2e-7,-5.34836 c 0,-1.05834 1.540167,-0.9638 1.5497024,0.0946 l 0.037798,4.19552"
style="fill:#ffffff;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path843"
d="m 4.2333333,288.53332 c 0.5291666,-0.52918 1.3229167,10e-6 1.3229167,1.05833"
style="fill:#ffffff;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
style="fill:#ffffff;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 5.8208333,288.53332 c 0.529166,-0.52918 1.3229167,10e-6 1.3229167,1.05833"
id="path845"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
sodipodi:nodetypes="cczc"
inkscape:connector-curvature="0"
id="path847"
d="m 7.4083326,288.53332 c 0.529167,-0.52918 1.3229174,10e-6 1.3229174,1.05833 v 3.175 c 0,1.05832 -0.2645834,1.05835 -0.7937504,2.11667"
style="fill:#ffffff;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
sodipodi:nodetypes="csc"
inkscape:connector-curvature="0"
id="path849"
d="m 1.5402529,289.97908 c -0.5291666,-1.05834 -2.10169957,-0.83114 -1.49300597,0.72758 l 1.01108637,2.58916 0.79375,1.05833 0.2645834,0.52917"
style="fill:#ffffff;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
<g
id="g5144"
transform="translate(-0.5291671,-3.3333334e-6)">
<path
sodipodi:nodetypes="cccccc"
inkscape:connector-curvature="0"
id="rect821"
d="M 7.4083333,288.53332 H 5.2916671 l 4e-7,-6.35 H 12.7 v 6.35 h -1.852083"
style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#040404;stroke-width:1.05833328;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke" />
<path
sodipodi:nodetypes="ccccc"
inkscape:connector-curvature="0"
id="path5137"
d="m 7.14375,288.00415 h 1.190625 l -0.2302815,1.05833 H 7.14375 Z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.21173805px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.21173805px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 10.847917,289.06248 H 9.8954167 l 0.2302813,-1.05833 h 0.722219 z"
id="path5139"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
</g>
<g
id="g5152">
<path
inkscape:connector-curvature="0"
id="path5146"
d="m 3.7041667,285.35832 -2.6458334,0"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.79374999;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
sodipodi:nodetypes="cc" />
<path
inkscape:connector-curvature="0"
id="path5148"
d="m 2.1166666,286.41665 -1.0583333,-1.05833 1.0583333,-1.05834"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
<g
id="g5158"
transform="matrix(-1,0,0,1,16.933333,-3.3333334e-6)">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.79374999;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 3.7041663,285.35832 H 1.0583333"
id="path5154"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 2.1166666,286.41665 -1.0583333,-1.05833 1.0583333,-1.05834"
id="path5156"
inkscape:connector-curvature="0" />
</g>
</g>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64"
height="64"
viewBox="0 0 16.933333 16.933334"
version="1.1"
id="svg8"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
sodipodi:docname="stop-move-view.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="11.2"
inkscape:cx="39.553529"
inkscape:cy="32.536155"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="true"
units="px"
inkscape:window-width="1871"
inkscape:window-height="1056"
inkscape:window-x="49"
inkscape:window-y="24"
inkscape:window-maximized="1"
inkscape:pagecheckerboard="true">
<inkscape:grid
type="xygrid"
id="grid4518"
empspacing="4" />
</sodipodi:namedview>
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-280.06665)">
<g
id="g856"
style="fill:#ffffff;fill-opacity:0;stroke:#000000;stroke-width:0.5291667;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
transform="matrix(0.73257485,0.16072987,-0.16072987,0.73257485,52.535106,78.068137)">
<path
sodipodi:nodetypes="cssc"
inkscape:connector-curvature="0"
id="path841"
d="m 2.1166667,290.64998 -2e-7,-5.34836 c 0,-1.05834 1.540167,-0.9638 1.5497024,0.0946 l 0.037798,4.19552"
style="fill:#ffffff;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path843"
d="m 4.2333333,288.53332 c 0.5291666,-0.52918 1.3229167,10e-6 1.3229167,1.05833"
style="fill:#ffffff;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
style="fill:#ffffff;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 5.8208333,288.53332 c 0.529166,-0.52918 1.3229167,10e-6 1.3229167,1.05833"
id="path845"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
sodipodi:nodetypes="cczc"
inkscape:connector-curvature="0"
id="path847"
d="m 7.4083326,288.53332 c 0.529167,-0.52918 1.3229174,10e-6 1.3229174,1.05833 v 3.175 c 0,1.05832 -0.2645834,1.05835 -0.7937504,2.11667"
style="fill:#ffffff;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
sodipodi:nodetypes="csc"
inkscape:connector-curvature="0"
id="path849"
d="m 1.5402529,289.97908 c -0.5291666,-1.05834 -2.10169957,-0.83114 -1.49300597,0.72758 l 1.01108637,2.58916 0.79375,1.05833 0.2645834,0.52917"
style="fill:#ffffff;fill-opacity:0;fill-rule:evenodd;stroke:#000000;stroke-width:0.5291667;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
<g
id="g5144"
transform="translate(-0.5291671,-3.3333334e-6)">
<path
sodipodi:nodetypes="cccccc"
inkscape:connector-curvature="0"
id="rect821"
d="M 7.4083333,288.53332 H 5.2916671 l 4e-7,-6.35 H 12.7 v 6.35 h -1.852083"
style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#040404;stroke-width:1.05833328;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke" />
<path
sodipodi:nodetypes="ccccc"
inkscape:connector-curvature="0"
id="path5137"
d="m 7.14375,288.00415 h 1.190625 l -0.2302815,1.05833 H 7.14375 Z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.21173805px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.21173805px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 10.847917,289.06248 H 9.8954167 l 0.2302813,-1.05833 h 0.722219 z"
id="path5139"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
</g>
<g
id="g5152">
<path
inkscape:connector-curvature="0"
id="path5146"
d="M 3.7041667,285.35832 H 1.0583333"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.79374999;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
sodipodi:nodetypes="cc" />
<path
inkscape:connector-curvature="0"
id="path5148"
d="m 2.1166666,286.41665 -1.0583333,-1.05833 1.0583333,-1.05834"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
<g
id="g5158"
transform="matrix(-1,0,0,1,16.933333,-3.3333334e-6)">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.79374999;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 3.7041663,285.35832 H 1.0583333"
id="path5154"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 2.1166666,286.41665 -1.0583333,-1.05833 1.0583333,-1.05834"
id="path5156"
inkscape:connector-curvature="0" />
</g>
<rect
style="fill:#ffffff;fill-opacity:0.37438426;fill-rule:evenodd;stroke:none;stroke-width:0.39699998;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke"
id="rect829"
width="16.933332"
height="16.933332"
x="0"
y="280.06665" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.5875;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
d="m 2.1166666,282.18332 12.6999994,12.7"
id="path831"
inkscape:connector-curvature="0" />
<use
x="0"
y="0"
xlink:href="#path831"
id="use833"
width="100%"
height="100%"
transform="matrix(-1,0,0,1,16.933333,0)" />
</g>
</svg>
......@@ -12,6 +12,12 @@ RowLayout {
Item { Layout.fillWidth: true }
OsdButton {
Layout.alignment : Qt.AlignRight
iconSource: "qrc:/icons/move-view"
onClicked: root.moveViewRequested()
}
OsdButton {
Layout.alignment : Qt.AlignRight
iconSource: "qrc:/icons/fullscreen"
......
......@@ -7,6 +7,7 @@ Page {
id: root
property alias vncClient: viewer.client
property bool moveViewMode: false
title: qsTr("VNC Client - Viewer")
......@@ -32,16 +33,89 @@ Page {
VncOutput {
id: viewer
anchors.fill: parent
enabled: !parent.pinch.active
enabled: !root.moveViewMode && !parent.pinch.active
}
}
Flickable {
id: flickable
property real __startCenterX: 0
property real __startCenterY: 0
property real __startContentX: 0
property real __startContentY: 0
anchors.fill: parent
contentWidth: viewer.remoteScreenSize.width * viewer.scale
contentHeight: viewer.remoteScreenSize.height * viewer.scale
bottomMargin: viewer.bottomMargin
leftMargin: viewer.leftMargin
rightMargin: viewer.rightMargin
topMargin: viewer.topMargin
enabled: root.moveViewMode
onContentXChanged: if (moving) updateView()
onContentYChanged: if (moving) updateView()
onMovementStarted: updateOffset()
onMovementEnded: updateContentPosition()
Connections {
target: viewer
enabled: !flickable.moving
onCenterChanged: flickable.updateContentPosition()
onScaleChanged: flickable.updateContentPosition()
}
function updateContentPosition() {
var topLeft = viewer.vncToItem(Qt.point(0, 0))
contentX = -topLeft.x
contentY = -topLeft.y
updateOffset()
}
function updateOffset() {
__startContentX = contentX
__startContentY = contentY
__startCenterX = viewer.center.x
__startCenterY = viewer.center.y
}
function updateView() {
var s = viewer.scale
var cx = (contentX - __startContentX) / s + __startCenterX
var cy = (contentY - __startContentY) / s + __startCenterY
viewer.center = Qt.point(cx, cy)
}
/* We keep this here for debugging
Rectangle {
color: "red"
opacity: 0.5
width: viewer.remoteScreenSize.width * viewer.scale
height: viewer.remoteScreenSize.height * viewer.scale
Rectangle {
width: parent.width / 2
height: parent.height / 2
color: "blue"
anchors.centerIn: parent
}
}
*/
}
OsdButton {
anchors { right: parent.right; bottom: parent.bottom }
visible: root.moveViewMode
iconSource: "qrc:/icons/stop-move-view"
onClicked: root.moveViewMode = false
}
Drawer {
width: root.width
edge: Qt.BottomEdge
OsdRow {
onToggleFullScreenRequested: root.toggleFullScreen()
onMoveViewRequested: root.enableMoveViewMode()
}
}
......@@ -54,4 +128,7 @@ Page {
}
}
function enableMoveViewMode() {
root.moveViewMode = true
}
}
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