Warning, /rolisteam/rolisteam/src/binaries/mindmap/MindMap.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick
0002 import QtQuick.Window
0003 import QtQuick.Controls
0004 import QtQuick.Layouts
0005 import QtQuick.Dialogs
0006 import mindmap
0007 import Customization
0008 import utils
0009 import "qrc:/resources/qml"
0010 
0011 Pane {
0012     id: root
0013     visible: true
0014     width: 800
0015     height: 400
0016     property QtObject styleSheet: Theme.styleSheet("mindmap")
0017     property real viewScale: 1
0018     property int idx: 0
0019     property bool darkMode: false
0020     property alias addPackage: _buttonGrid.addPackage
0021     property QtObject ctrl: MindmapManager.ctrl
0022 
0023     onDarkModeChanged: Theme.nightMode = root.darkMode
0024 
0025     Component.onCompleted: {
0026         //MindmapManager.ctrl.url = "file:///home/renaud/application/mine/renaudg/rolisteam/src/tests/manual/mindmap/campaign/media/test.rmap"
0027         //MindmapManager.ctrl.loadFile();
0028     }
0029 
0030     MindMap {
0031         id: mindMap
0032         anchors.fill: parent
0033         ctrl: root.ctrl
0034         zoomLevel: root.ctrl.zoomLevel
0035         addSubLink: _buttonGrid.addArrow
0036         marginW: _minimized.width
0037         onOpenImage: (id)=>{
0038           imgSelector.uuid = id
0039           imgSelector.open()
0040         }
0041         onPressed:  (mouse)=> {
0042             if(root.addPackage)
0043                 root.ctrl.addPackage(Qt.point(mouse.x, mouse.y))
0044             else
0045                 mouse.accepted = false
0046         }
0047         onPositionChanged: (mouse)=>{
0048             if(root.addPackage)
0049                 root.ctrl.updatePackage(Qt.point(mouse.x, mouse.y))
0050             else
0051                 mouse.accepted = false
0052         }
0053         onReleased: {
0054             if(root.addPackage)
0055                 root.addPackage = false
0056             else
0057                 mouse.accepted = false
0058         }
0059     }
0060     MindMenu {
0061         id: menu
0062         ctrl: root.ctrl
0063     }
0064 
0065     FileDialog {
0066       id: imgSelector
0067       property string uuid
0068       fileMode: FileDialog.OpenFile
0069       nameFilters: [qsTr("Images (*.jpg *.png *.jpeg *.gif *.bmp)")]
0070       onAccepted: {
0071           root.ctrl.openImage(imgSelector.uuid, imgSelector.selectedFile)
0072       }
0073     }
0074 
0075     FileDialog {
0076       id: screenShotSelector
0077       property string uuid
0078       defaultSuffix: "png"
0079       fileMode: FileDialog.SaveFile
0080       nameFilters: [qsTr("Images (*.png)")]
0081       onAccepted: {
0082           mindMap.makeScreenShot(screenShotSelector.selectedFile)
0083       }
0084     }
0085 
0086 
0087      RowLayout{
0088         anchors.top: parent.top
0089         anchors.right: parent.right
0090         anchors.rightMargin: root.styleSheet.margin
0091         anchors.topMargin: root.styleSheet.margin
0092 
0093         IconButton {//undo
0094             source: root.styleSheet.undoIcon
0095             enabled: root.ctrl.canUndo
0096             onClicked: root.ctrl.undo()
0097         }
0098         IconButton {//redo
0099             source: root.styleSheet.redoIcon
0100             enabled: root.ctrl.canRedo
0101             onClicked: root.ctrl.redo()
0102         }
0103         IconButton {
0104             source: root.styleSheet.listIcon
0105             onClicked: drawer.open()
0106         }
0107     }
0108 
0109     ButtonGrid {
0110         id: _buttonGrid
0111         anchors.top: parent.top
0112         anchors.right: parent.right
0113         anchors.rightMargin: 14
0114         anchors.topMargin: 14
0115         onOpenDrawer: drawer.open()
0116         automaticSpacing: root.ctrl.spacing
0117         onAutomaticSpacingChanged: root.ctrl.spacing = _buttonGrid.automaticSpacing
0118         onExportScene: {
0119             screenShotSelector.open()
0120         }
0121     }
0122 
0123     SideMenu {
0124         id: drawer
0125         edge: Qt.RightEdge
0126         width: 0.4 * root.width
0127         height: root.height
0128         mediaCtrl: root.ctrl
0129         onDarkModeChanged: root.darkMode = darkMode
0130         onLinkVisibilityChanged: root.ctrl.linkLabelVisibility = linkVisibility
0131         onDefaultStyleChanged: root.ctrl.defaultStyleIndex = defaultStyle
0132     }
0133 
0134     Rectangle {
0135         anchors.fill: _minimized
0136         anchors.margins: 2
0137         border.width: 2
0138         border.color: root.styleSheet.borderColor
0139         color: root.styleSheet.colorMiniMap
0140         visible: _buttonGrid.showLittleMap
0141     }
0142 
0143     ShaderEffectSource {
0144         id: _minimized
0145         sourceItem: mindMap.innerItem
0146         anchors.bottom: _bottomControl.top
0147         anchors.right: parent.right
0148         live: true
0149         visible: _buttonGrid.showLittleMap
0150         MappingHelper {
0151             id: helper
0152         }
0153         property size computedSize: helper.mapSizeTo(
0154                                         Qt.size(_bottomControl.width,_bottomControl.width),
0155                                         Qt.size(mindMap.innerItem.width, mindMap.innerItem.height))
0156         height: _minimized.computedSize.height
0157         width: _minimized.computedSize.width
0158 
0159         Rectangle {
0160             border.width: 2
0161             border.color: "blue"
0162             color: "transparent"
0163             x: mindMap.visibleArea.xPosition * _minimized.width
0164             y: mindMap.visibleArea.yPosition * _minimized.height
0165             width: mindMap.visibleArea.widthRatio * _minimized.width
0166             height: mindMap.visibleArea.heightRatio * _minimized.height
0167 
0168         }
0169     }
0170     RowLayout {
0171         id: _bottomControl
0172         anchors.bottom: parent.bottom
0173         anchors.right: parent.right
0174         Slider {
0175             id: slider
0176             from: 0.1
0177             to: 3
0178             value: root.ctrl.zoomLevel
0179             onValueChanged: root.ctrl.zoomLevel = value
0180 
0181         }
0182         Button {
0183             text: "reset"
0184             onClicked: slider.value = 1.0
0185         }
0186     }
0187 
0188     MouseArea {
0189         anchors.fill:parent
0190         acceptedButtons:Qt.MiddleButton | Qt.RightButton
0191         propagateComposedEvents: true
0192         onClicked:(mouse)=>{
0193             menu.x = mouse.x
0194             menu.y = mouse.y
0195             menu.open()
0196         }
0197         onWheel: (wheel)=>{
0198             var step = (wheel.modifiers & Qt.ControlModifier) ? 0.1 : 0.01
0199             if(wheel.angleDelta.y>0)
0200             {
0201                 root.viewScale = Math.min(root.viewScale+step,2.0)
0202             }
0203             else
0204                 root.viewScale = Math.max(root.viewScale-step,0.2)
0205         }
0206     }
0207 }