Warning, /maui/mauikit/src/controls.5/Doodle.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick 2.13
0002 import QtQuick.Controls 2.13
0003 import QtQuick.Layouts 1.3
0004 
0005 import org.mauikit.controls 1.3 as Maui
0006 
0007 /*!
0008   \since org.mauikit.controls.labs 1.0
0009   \inqmlmodule org.mauikit.controls.labs
0010 */
0011 Maui.PopupPage
0012 {
0013     id: control
0014 
0015     Maui.Theme.backgroundColor: Qt.rgba(bgColor.r, bgColor.g, bgColor.b, 0.85)
0016     Maui.Theme.textColor:"#fefefe"
0017     //     deafultButtons: false
0018 
0019     maxHeight: img.height + footer.height + Maui.Style.toolBarHeight + Maui.Style.space.medium
0020     maxWidth: img.width
0021 
0022     /**
0023       *
0024       */
0025     property Item sourceItem : null
0026 
0027     /**
0028       *
0029       */
0030     readonly property color bgColor : "#333"
0031 
0032     /**
0033       *
0034       */
0035     property alias source : img.source
0036 
0037     /**
0038       *
0039       */
0040     property alias brushSize : _canvas.brushSize 
0041 
0042     /**
0043       *
0044       */
0045     property alias brushOpacity : _canvas.brushOpacity
0046 
0047     /**
0048       *
0049       */
0050     property alias brushShape : _canvas.brushShape //0 -Circular, 1 - rectangular.
0051 
0052     /**
0053       *
0054       */
0055     property alias maxBrushSize: _canvas.maxBrushSize
0056 
0057     /**
0058       *
0059       */
0060     property alias paintColor: _canvas.paintColor
0061 
0062 //    onRejected: control.close()
0063 
0064     onOpened:
0065     {
0066         if(control.visible)
0067         {
0068             if(control.sourceItem)
0069             {
0070                 control.sourceItem.grabToImage(function(result) {
0071                     img.source = result.url;
0072                 })
0073             }
0074         }else
0075         {
0076             _canvas.buffer.clear()
0077         }
0078     }
0079 
0080     onSourceItemChanged:
0081     {
0082         if(control.visible && control.opened)
0083         {
0084             if(control.sourceItem)
0085             {
0086                 control.sourceItem.grabToImage(function(result) { img.source = result.url })
0087             }
0088         }
0089     }
0090     footBar.visible: true
0091 
0092     footBar.rightContent: ToolButton
0093     {
0094         icon.name: "document-share"
0095         onClicked: {}
0096     }
0097 
0098     footBar.leftContent: Maui.ToolActions
0099     {
0100         expanded: true
0101         autoExclusive: true
0102         checkable: false
0103 
0104         Action
0105         {
0106             icon.name: "edit-undo"
0107         }
0108 
0109         Action
0110         {
0111             icon.name: "edit-redo"
0112         }
0113     }
0114 
0115     footBar.middleContent:[
0116 
0117         Maui.ToolActions
0118         {
0119             autoExclusive: true
0120             expanded: true
0121             display: ToolButton.TextBesideIcon
0122 
0123             Action
0124             {
0125                 icon.name: "draw-highlight"
0126                 text: i18nd("mauikit", "Highlighter")
0127                 onTriggered:
0128                 {
0129                     control.paintColor = "yellow"
0130                     control.brushShape = 1
0131                 }
0132             }
0133 
0134             Action
0135             {
0136                 icon.name: "draw-brush"
0137                 text: i18nd("mauikit", "Marker")
0138                 onTriggered:
0139                 {
0140                     control.paintColor = "blue"
0141                     control.brushShape = 0
0142                 }
0143             }
0144 
0145             Action
0146             {
0147                 icon.name: "draw-calligraphic"
0148                 text: i18nd("mauikit", "Highlighter")
0149                 onTriggered:
0150                 {
0151                     control.paintColor = "#333"
0152                     control.brushShape = 1
0153                 }
0154             }
0155 
0156             Action
0157             {
0158                 id: _eraserButton
0159                 text: i18nd("mauikit", "Eraser")
0160 
0161                 icon.name: "draw-eraser"
0162             }
0163         },
0164 
0165         Maui.ToolActions
0166         {
0167             expanded: true
0168             autoExclusive: false
0169             display: ToolButton.TextBesideIcon
0170 
0171             Action
0172             {
0173                 id: _colorsButton
0174                 text: i18nd("mauikit", "Color")
0175                 icon.name: "color-fill"
0176             }
0177 
0178             Action
0179             {
0180                 id: _opacityButton
0181                 text: i18nd("mauikit", "Opacity")
0182 
0183                 icon.name: "edit-opacity"
0184             }
0185 
0186             Action
0187             {
0188                 id: _sizeButton
0189                 text: i18nd("mauikit", "Size")
0190 
0191             }
0192         }
0193 
0194     ]
0195 
0196     page.footerColumn: [
0197         Maui.ToolBar
0198         {
0199             id: _sizeBar
0200             visible: _sizeButton.checked
0201             width: parent.width
0202             position: ToolBar.Footer
0203             leftContent: Label
0204             {
0205                 text: i18nd("mauikit", "Size")
0206                 color: Maui.Theme.textColor
0207             }
0208 
0209             rightContent: Label
0210             {
0211                 text: _sizeSlider.value
0212                 color: Maui.Theme.textColor
0213             }
0214 
0215             middleContent: Slider
0216             {
0217                 id: _sizeSlider
0218                 Layout.fillWidth: true
0219                 value: 20
0220                 from : 10
0221                 to : 100
0222                 stepSize: 10
0223             }
0224         },
0225 
0226         Maui.ToolBar
0227         {
0228             id: _opacityBar
0229             visible: _opacityButton.checked
0230             width: parent.width
0231             position: ToolBar.Footer
0232 
0233             leftContent: Label
0234             {
0235                 text: i18nd("mauikit", "Opacity")
0236                 color: Maui.Theme.textColor
0237             }
0238 
0239             middleContent: Slider
0240             {
0241                 id: _opacitySlider
0242                 Layout.fillWidth: true
0243                 value: 1
0244                 from: 0
0245                 to: 1
0246             }
0247 
0248             rightContent: Label
0249             {
0250                 text: _opacitySlider.value
0251                 color: Maui.Theme.textColor
0252             }
0253         },
0254 
0255         Maui.ToolBar
0256         {
0257             id: _colorsBar
0258             visible: _colorsButton.checked
0259             width: parent.width
0260             position: ToolBar.Footer
0261             middleContent: Row
0262             {
0263                 height: parent.height
0264                 spacing: 0
0265                 Repeater
0266                 {
0267                     model: ["yellow", "pink", "orange", "blue", "magenta", "black", "grey", "cian",
0268                         "#63b598", "#ce7d78", "#ea9e70", "#a48a9e", "#c6e1e8", "#648177" ,"#0d5ac1" ,
0269                         "#f205e6" ,"#1c0365" ,"#14a9ad" ,"#4ca2f9" ,"#a4e43f" ,"#d298e2" ,"#6119d0",
0270                         "#d2737d" ,"#c0a43c" ,"#f2510e" ,"#651be6" ,"#79806e" ,"#61da5e" ,"#cd2f00" ,
0271                         "#9348af" ,"#01ac53" ,"#c5a4fb" ,"#996635","#b11573" ,"#4bb473" ,"#75d89e" ,
0272                         "#2f3f94" ,"#2f7b99" ,"#da967d" ,"#34891f" ,"#b0d87b" ,"#ca4751" ,"#7e50a8" ,
0273                         "#c4d647" ,"#e0eeb8" ,"#11dec1" ,"#289812" ,"#566ca0" ,"#ffdbe1" ,"#2f1179" ,
0274                         "#935b6d" ,"#916988" ,"#513d98" ,"#aead3a", "#9e6d71", "#4b5bdc", "#0cd36d",
0275                         "#250662", "#cb5bea", "#228916", "#ac3e1b", "#df514a", "#539397", "#880977",
0276                         "#f697c1", "#ba96ce", "#679c9d", "#c6c42c", "#5d2c52", "#48b41b", "#e1cf3b",
0277                         "#5be4f0", "#57c4d8", "#a4d17a", "#225b8", "#be608b", "#96b00c", "#088baf",
0278                         "#f158bf", "#e145ba", "#ee91e3", "#05d371", "#5426e0", "#4834d0", "#802234",
0279                         "#6749e8", "#0971f0", "#8fb413", "#b2b4f0", "#c3c89d", "#c9a941", "#41d158",
0280                         "#409188", "#911e20", "#1350ce", "#10e5b1", "#fff4d7", "#cb2582", "#ce00be",
0281                         "#32d5d6", "#17232", "#608572", "#c79bc2", "#00f87c", "#77772a", "#6995ba",
0282                         "#fc6b57", "#f07815", "#8fd883", "#060e27", "#96e591", "#21d52e", "#d00043",
0283                         "#b47162", "#1ec227", "#4f0f6f", "#1d1d58", "#947002", "#bde052", "#e08c56",
0284                         "#28fcfd", "#bb09b", "#36486a", "#d02e29", "#1ae6db", "#3e464c", "#a84a8f",
0285                         "#911e7e", "#3f16d9", "#0f525f", "#ac7c0a", "#b4c086", "#c9d730", "#30cc49",
0286                         "#3d6751", "#fb4c03", "#640fc1", "#62c03e", "#d3493a", "#88aa0b", "#406df9",
0287                         "#615af0", "#4be47", "#2a3434", "#4a543f", "#79bca0", "#a8b8d4", "#00efd4",
0288                         "#7ad236", "#7260d8", "#1deaa7", "#06f43a", "#823c59", "#e3d94c", "#dc1c06",
0289                         "#f53b2a", "#b46238", "#2dfff6", "#a82b89", "#1a8011", "#436a9f", "#1a806a",
0290                         "#4cf09d", "#c188a2", "#67eb4b", "#b308d3", "#fc7e41", "#af3101", "#ff065",
0291                         "#71b1f4", "#a2f8a5", "#e23dd0", "#d3486d", "#00f7f9", "#474893", "#3cec35",
0292                         "#1c65cb", "#5d1d0c", "#2d7d2a", "#ff3420", "#5cdd87", "#a259a4", "#e4ac44",
0293                         "#1bede6", "#8798a4", "#d7790f", "#b2c24f", "#de73c2", "#d70a9c", "#25b67",
0294                         "#88e9b8", "#c2b0e2", "#86e98f", "#ae90e2", "#1a806b", "#436a9e", "#0ec0ff",
0295                         "#f812b3", "#b17fc9", "#8d6c2f", "#d3277a", "#2ca1ae", "#9685eb", "#8a96c6",
0296                         "#dba2e6", "#76fc1b", "#608fa4", "#20f6ba", "#07d7f6", "#dce77a", "#77ecca"]
0297 
0298                     MouseArea
0299                     {
0300                         height: parent.height
0301                         width: height
0302                         onClicked: control.paintColor = modelData
0303                         Rectangle
0304                         {
0305                             anchors.fill: parent
0306                             color: modelData
0307                             //                             radius: Maui.Style.radiusV
0308                             //                             border.color: Qt.darker(color)
0309                         }
0310                     }
0311 
0312                 }
0313             }
0314         }
0315     ]
0316 
0317     headBar.visible: false
0318     ScrollView
0319     {
0320         Layout.fillHeight: true
0321         Layout.fillWidth: true
0322 
0323         contentHeight: img.height
0324         contentWidth: img.width
0325 
0326         Image
0327         {
0328 
0329             id: img
0330             height: sourceSize.height
0331             width: sourceSize.width
0332             fillMode: Image.PreserveAspectFit
0333             autoTransform: true
0334             asynchronous: true
0335             anchors.centerIn: parent
0336 
0337 
0338             //     Label
0339             //     {
0340             //         color: "yellow"
0341             //         text: parent.height + "-" + parent.width + " / " + control.height + "-" + control.width + " / " + buffer.width + "-"+ buffer.height
0342             //     }
0343 
0344 
0345     }
0346     
0347     Maui.DoodleCanvas
0348     {
0349         id: _canvas
0350         anchors.fill: parent
0351         brushSize : _sizeSlider.value
0352         brushOpacity :_opacitySlider.value
0353     }
0354     }  
0355 }