From c1c66f5b34aa6a4e721ab3e7fcd067777ba5fca7 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 6 Jun 2016 12:59:52 +0200 Subject: use QtQuick.Controls 2; use qml runtime; tooltip for details Also a Quit shortcut, and better zooming behavior, and some simplification. Change-Id: I6a14639c0c555692e862298815c719008a4e9668 Reviewed-by: Shawn Rutledge --- README | 4 +- imports/Diagrams/UmlSequence/Message.qml | 75 +++++++++------------- imports/Diagrams/UmlSequence/ObjectInstance.qml | 33 +++++----- .../Diagrams/UmlSequence/UmlSequenceDiagram.qml | 51 ++++++++------- uq | 2 +- 5 files changed, 79 insertions(+), 86 deletions(-) diff --git a/README b/README index 5d69ebe..1935945 100644 --- a/README +++ b/README @@ -11,8 +11,8 @@ https://codereview.qt-project.org/#change,43201 and there is an example patch for qtbase to trace touch events here https://codereview.qt-project.org/#change,65307 -It should work with Qt 5.2 or newer (due to some limited usage of -QtQuick.Controls). +It should work with Qt 5.7 or newer (due to some limited usage of +QtQuick.Controls 2). uq is a script which simply runs qml with your given (possibly generated) qml file containing the declarative UML diagram. It can diff --git a/imports/Diagrams/UmlSequence/Message.qml b/imports/Diagrams/UmlSequence/Message.qml index ddd45af..19d38cf 100644 --- a/imports/Diagrams/UmlSequence/Message.qml +++ b/imports/Diagrams/UmlSequence/Message.qml @@ -35,77 +35,64 @@ ** ****************************************************************************/ -import QtQuick 2.0 +import QtQuick 2.7 +import QtQuick.Controls 2.0 -Item { +MouseArea { id: root property ObjectInstance from: null property ObjectInstance to: null - property string method + property alias method: methodLabel.text + property string methodSignature property string params property string fromMethod + property string backtrace width: 100 - height: 60 + height: 30 + hoverEnabled: true + z: 1 property bool toSelf: from && from === to - property bool backwards: from.x > to.x + property bool backwards: from ? from.x > to.x : false + property real timestamp: 0 Rectangle { width: 150 - height: 26 + height: 20 radius: 5 visible: toSelf y: 4 x: -radius color: "transparent" - border.color: "black" + border.color: root.containsMouse ? "blue" : "black" + border.width: root.containsMouse ? 2 : 1 Rectangle { height: parent.height - width: parent.radius * 2 - border.color: "black" - } - Text { - id: methodLabelToSelf - font.bold: true - text: root.method - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.top - } - Text { - id: paramsLabelToSelf - text: root.params - font.pointSize: 7 - anchors.left: parent.left - anchors.leftMargin: 10 - anchors.top: parent.bottom + width: parent.radius } } + Text { + id: methodLabel + font.bold: true + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + } Rectangle { + id: line width: parent.width - height: 1 + height: (root.containsMouse ? 2 : 1) / root.parent.scale visible: !toSelf - color: "black" - y: parent.height / 2 - Text { - id: methodLabel - text: root.method - font.bold: true - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.top - } - Text { - id: paramsLabel - text: root.params - font.pointSize: 7 - anchors.left: parent.left - anchors.leftMargin: 10 - anchors.top: parent.bottom - } + color: root.containsMouse ? "blue" : "black" + anchors.top: methodLabel.bottom } Text { text: backwards || toSelf ? "<" : ">" - anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenter: line.verticalCenter x: backwards || toSelf ? 0 : parent.width - width } + ToolTip { + text: root.methodSignature + "\n" + root.backtrace + "\n\nparams:\n" + root.params + visible: root.containsMouse + } - anchors.left: backwards ? to.horizontalCenter : from.horizontalCenter + anchors.left: backwards ? to.horizontalCenter : from ? from.horizontalCenter : undefined anchors.right: backwards ? from.horizontalCenter : toSelf ? undefined : to.horizontalCenter } diff --git a/imports/Diagrams/UmlSequence/ObjectInstance.qml b/imports/Diagrams/UmlSequence/ObjectInstance.qml index ea5293d..b8dea17 100644 --- a/imports/Diagrams/UmlSequence/ObjectInstance.qml +++ b/imports/Diagrams/UmlSequence/ObjectInstance.qml @@ -43,6 +43,7 @@ Rectangle { width: implicitWidth height: 45 border.color: "black" + antialiasing: true property alias objectName: objectNameLabel.text property alias objectClass: objectClassLabel.text property string q @@ -82,23 +83,23 @@ Rectangle { height: parent.parent.height - parent.y - parent.height source: "../common/images/vdash5.png" fillMode: Image.TileVertically - Repeater { - model: parent.height / 1000 - Rectangle { - y: 500 + index * 1000 - z: 0 - anchors.horizontalCenter: dashline.horizontalCenter - rotation: -90 - width: rotatedLabel.width - height: rotatedLabel.height - opacity: 0.6 - Text { - id: rotatedLabel - color: "darkblue" - text: objectClassLabel.text - anchors.centerIn: parent + Repeater { + model: parent.height / 1000 + Rectangle { + y: 500 + index * 1000 + z: 0 + anchors.horizontalCenter: dashline.horizontalCenter + rotation: -90 + width: rotatedLabel.width + height: rotatedLabel.height + opacity: 0.6 + Text { + id: rotatedLabel + color: "darkblue" + text: objectClassLabel.text + anchors.centerIn: parent + } } } } - } } diff --git a/imports/Diagrams/UmlSequence/UmlSequenceDiagram.qml b/imports/Diagrams/UmlSequence/UmlSequenceDiagram.qml index 21def32..42c89f2 100644 --- a/imports/Diagrams/UmlSequence/UmlSequenceDiagram.qml +++ b/imports/Diagrams/UmlSequence/UmlSequenceDiagram.qml @@ -35,37 +35,43 @@ ** ****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Window 2.0 -import QtQuick.Controls 1.0 +import QtQuick 2.7 +import QtQuick.Controls 2.0 Item { id: root width: 1914 - height: 1180 + height: 1040 default property alias data: col.data focus: true - ScrollView { + Shortcut { + sequence: StandardKey.Quit + onActivated: Qt.quit() + } + Flickable { + id: flickable anchors.fill: parent - Flickable { - id: flickable - anchors.fill: parent - contentHeight: col.implicitHeight * col.scale - contentWidth: col.width * col.scale - Column { - id: col - property int rightmostX: 0 - width: rightmostX + 100 - transformOrigin: Item.TopLeft -// onScaleChanged: console.log("scale " + scale + " width " + width + " flickable contentwidth " + flickable.contentWidth) - } + contentHeight: col.implicitHeight * col.scale + contentWidth: col.width * col.scale + Column { + id: col + property int rightmostX: 0 + width: rightmostX + 100 + transformOrigin: Item.TopLeft + } + ScrollBar.vertical: ScrollBar { } + ScrollBar.horizontal: ScrollBar { } + } + MouseArea { + acceptedButtons: Qt.NoButton + anchors.fill: parent + onWheel: { + if (wheel.modifiers === Qt.ControlModifier) + col.scale *= (wheel.angleDelta.y > 0 ? 1.4142135623731 : 0.707106781186547) + else + wheel.accepted = false } } -// MouseArea { -// acceptedButtons: Qt.MiddleButton -// anchors.fill: parent -// onWheel: col.scale *= (wheel.angleDelta.y > 0 ? 1.4142135623731 : 0.707106781186547) -// } Keys.onPressed: { console.log("pressed " + event.key + " mods " + event.modifiers) if (event.modifiers === Qt.ControlModifier) { @@ -76,4 +82,3 @@ Item { } } } - diff --git a/uq b/uq index eba91cf..a0d8c5b 100755 --- a/uq +++ b/uq @@ -1,3 +1,3 @@ #!/bin/sh dir=`dirname $0` -qmlscene -I ${dir}/imports $1 +qml -I ${dir}/imports $1 -- cgit v1.2.3