Warning, /rolisteam/rolisteam/src/libraries/mindmap/resources/qml/Node.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 0002 import QtQuick.Controls 0003 import QtQuick.Layouts 0004 import Customization 0005 0006 Pane 0007 { 0008 id: root 0009 //Properties 0010 property QtObject style: Theme.styleSheet("Controls") 0011 property alias source: img.source 0012 property alias text: _textlbl.text 0013 property bool readWrite: false 0014 property bool isEditable: false 0015 property bool selected: currentNode.selected 0016 property int radius: root.style.radius 0017 property alias open: control.open 0018 property int expandButtonSize: root.style.expandedButtonSize 0019 property QtObject currentNode 0020 property QtObject nodeStyle 0021 property alias foldingBtnVisible: control.visible 0022 0023 property string ident: currentNode.id 0024 property bool isDragged: currentNode.isDragged 0025 property bool dropOver: false 0026 property alias buttonColor: control.foreground 0027 0028 x: currentNode.position.x 0029 y: currentNode.position.y 0030 0031 0032 0033 visible: currentNode.visible 0034 onWidthChanged: currentNode.width = width 0035 onHeightChanged: { 0036 currentNode.height = height 0037 } 0038 0039 onXChanged: { 0040 if(dragMouse.drag.active) 0041 currentNode.position=Qt.point(x, y) 0042 } 0043 onYChanged: { 0044 if(dragMouse.drag.active) 0045 currentNode.position=Qt.point(x, y) 0046 } 0047 Connections { 0048 target: currentNode 0049 function onPositionChanged(position) { 0050 x=position.x 0051 y=position.y 0052 } 0053 } 0054 0055 focusPolicy: Qt.MouseFocusReason | Qt.ShortcutFocusReason | Qt.OtherFocusReason 0056 0057 //Signals 0058 signal clicked(var mouse) 0059 signal selectStyle() 0060 signal reparenting(var id) 0061 signal addChild() 0062 signal addImage(var img, var data) 0063 signal addCharacter(var name, var source, var color) 0064 signal textEdited(var text) 0065 0066 Binding on Drag.active { 0067 value: dragMouse.drag.active 0068 delayed: true 0069 } 0070 Drag.keys: [ "rmindmap/reparenting","text/plain" ] 0071 Drag.supportedActions: Qt.MoveAction 0072 Drag.mimeData: { 0073 "text/plain": root.ident 0074 } 0075 Item { 0076 id: centralItem 0077 implicitWidth: lyt.implicitWidth 0078 implicitHeight: lyt.implicitHeight 0079 MouseArea { 0080 id: dragMouse 0081 anchors.fill: parent 0082 anchors.margins: -root.padding 0083 drag.target: root 0084 drag.axis: Drag.XAndYAxis 0085 drag.minimumX: 0 0086 drag.minimumY: 0 0087 preventStealing: true 0088 onPressed:(mouse)=>{ 0089 root.clicked(mouse) 0090 root.grabToImage(function(result) { 0091 if(mouse.modifiers & Qt.ControlModifier) 0092 { 0093 root.Drag.dragType = Drag.Automatic 0094 root.Drag.keys = [ "rmindmap/reparenting"] 0095 } 0096 else 0097 { 0098 root.Drag.dragType = Drag.Internal 0099 root.Drag.keys = [] 0100 } 0101 root.Drag.imageSource = result.url 0102 }) 0103 } 0104 0105 onDoubleClicked: { 0106 root.isEditable = true 0107 } 0108 drag.onActiveChanged: root.isDragged = drag.active 0109 } 0110 ColumnLayout { 0111 id: lyt 0112 anchors.fill: parent 0113 Image { 0114 id: img 0115 visible: source 0116 fillMode: Image.PreserveAspectFit 0117 sourceSize.height: root.style.imageSize 0118 sourceSize.width: root.style.imageSize 0119 Layout.alignment: Qt.AlignHCenter 0120 } 0121 0122 0123 TextInput{ 0124 id: _textlbl 0125 text: root.currentNode.text 0126 enabled: root.readWrite && root.isEditable 0127 color: root.nodeStyle.textColor 0128 Layout.alignment: Qt.AlignHCenter 0129 onEnabledChanged: focus = enabled 0130 focus: true 0131 onEditingFinished: { 0132 root.isEditable = false 0133 root.textEdited(text) 0134 } 0135 0136 } 0137 } 0138 0139 0140 0141 0142 0143 AbstractButton { 0144 id: control 0145 property bool open: !checked 0146 property color foreground: root.style.textColor 0147 checkable: true 0148 visible: currentNode.hasLink 0149 width: implicitWidth //root.style.childrenButtonSize 0150 height: implicitHeight //root.style.childrenButtonSize 0151 anchors.verticalCenter: dragMouse.bottom 0152 anchors.horizontalCenter: dragMouse.horizontalCenter 0153 topPadding: 0 0154 padding: 0 0155 contentItem: Text { 0156 text: control.checked ? "▲" : "▼" 0157 color: control.foreground 0158 } 0159 0160 background: Item { 0161 0162 } 0163 } 0164 AbstractButton { 0165 visible: root.readWrite 0166 width: 10 0167 opacity: 0.7 0168 height: dragMouse.height 0169 anchors.right: dragMouse.right 0170 anchors.verticalCenter: dragMouse.verticalCenter 0171 onClicked: { 0172 root.addChild() 0173 } 0174 contentItem: Item{} 0175 background: Rectangle { 0176 radius: root.radius 0177 color: "blue" 0178 } 0179 } 0180 0181 AbstractButton { 0182 id: style 0183 width: root.expandButtonSize 0184 height: root.expandButtonSize 0185 onClicked: selectStyle() 0186 anchors.verticalCenter: dragMouse.top 0187 anchors.horizontalCenter: dragMouse.right 0188 text: "▼" 0189 contentItem: Text { 0190 topPadding: 0 0191 padding: 0 0192 width: 2 0193 height: 2 0194 anchors.centerIn: parent 0195 verticalAlignment: Text.AlignVCenter 0196 horizontalAlignment: Text.AlignHCenter 0197 fontSizeMode: Text.Fit 0198 minimumPixelSize: 2 0199 color: "white" 0200 text: "▼" 0201 } 0202 0203 background: Rectangle { 0204 radius: root.expandButtonSize/2 0205 color: "blue" 0206 } 0207 } 0208 0209 DropArea { 0210 anchors.fill: dragMouse 0211 keys: [ "rmindmap/reparenting","text/plain","text/uri-list", "rolisteam/userlist-item", "image/png","image/jpg","image/jpeg","image/gif" ] 0212 onDropped: (drop)=>{ 0213 console.log("keys:"+drop.keys) 0214 var reparenting = false 0215 var hasUrl = false 0216 var character = false 0217 var hasPng = false 0218 var hasJpg = false 0219 var hasJpeg = false 0220 var hasGif = false 0221 for(var i=0; i< drop.keys.length; ++i) 0222 { 0223 if(drop.keys[i] === "text/plain") 0224 reparenting = true 0225 else if(drop.keys[i] === "rmindmap/reparenting") 0226 reparenting = true 0227 else if(drop.keys[i] === "text/uri-list") 0228 hasUrl = true 0229 else if(drop.keys[i] === "rolisteam/userlist-item") 0230 character= true 0231 else if(drop.keys[i] === "image/png") 0232 hasPng= true 0233 else if(drop.keys[i] === "image/jpg") 0234 hasJpg= true 0235 else if(drop.keys[i] === "image/jpeg") 0236 hasJpeg= true 0237 else if(drop.keys[i] === "image/gif") 0238 hasGif= true 0239 0240 } 0241 if(reparenting) 0242 { 0243 console.log("reparenting") 0244 root.reparenting(drop.text) 0245 } 0246 else if(hasUrl && !character) 0247 { 0248 console.log("Has url") 0249 var url = drop.urls[0] 0250 var urlstr = url.toString() 0251 console.log(urlstr) 0252 if(urlstr.endsWith(".png") || urlstr.endsWith(".jpg") || urlstr.endsWith(".gif")|| urlstr.endsWith(".jpeg^") || urlstr.startsWith("http")) 0253 { 0254 var text = hasPng ? "image/png" : hasJpg ? "image/jpg" : hasJpeg ? "image/jpeg" : "image/gif" 0255 root.addImage(url, drop.getDataAsArrayBuffer(text)) 0256 } 0257 } 0258 else if(character) 0259 { 0260 console.log("add character") 0261 root.addCharacter(drop.text, drop.urls[0], drop.colorData) 0262 } 0263 root.dropOver = false 0264 } 0265 onEntered: (drag)=>{ 0266 if(drag.source === root) 0267 drag.accepted = false 0268 0269 if(drag.source !== root) 0270 root.dropOver = true 0271 } 0272 onExited:root.dropOver = false 0273 } 0274 0275 } 0276 0277 0278 0279 background: Rectangle { 0280 radius: root.radius 0281 border.width: (root.dropOver || root.selected) ? 4 : 1 0282 border.color: root.dropOver ? root.style.overColor : root.selected ? root.style.highlightColor : root.style.textColor 0283 gradient: Gradient { 0284 GradientStop { position: 0.0; color: root.nodeStyle.colorOne } 0285 GradientStop { position: 1.0; color: root.nodeStyle.colorTwo } 0286 } 0287 } 0288 }