Warning, /graphics/pikasso/src/contents/ui/main.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick 2.1
0002 import org.kde.kirigami 2.4 as Kirigami
0003 import QtQuick.Controls 2.0 as Controls
0004 import QtQuick.Layouts 1.14
0005 import org.kde.drawingarea 1.0
0006 import Qt.labs.platform 1.1
0007 
0008 Kirigami.ApplicationWindow {
0009     id: root
0010 
0011     title: i18n("Draw")
0012 
0013     contextDrawer: Kirigami.ContextDrawer {
0014         id: contextDrawer
0015     }
0016 
0017     pageStack.initialPage: mainPageComponent
0018     pageStack.interactive: false // we need to own the drag interaction
0019 
0020     Component {
0021         id: mainPageComponent
0022 
0023         Kirigami.Page {
0024             title: i18n("Draw")
0025             padding: 0
0026 
0027             DrawingArea {
0028                 id: drawingarea
0029                 anchors.fill: parent
0030                 antialiasing: true
0031                 layer.enabled: true
0032                 layer.samples: 4
0033             }
0034 
0035             ColorDialog {
0036                 id: colorDialog
0037                 currentColor: drawingarea.penColor
0038                 onAccepted: drawingarea.penColor = color
0039             }
0040 
0041             FileDialog {
0042                 id: fileDialog
0043                 fileMode: FileDialog.SaveFile
0044                 onAccepted: {
0045                     drawingarea.saveSvg(fileDialog.file)
0046                 }
0047             }
0048 
0049             actions {
0050                 contextualActions: [
0051                     Kirigami.Action {
0052                         text: i18n("Undo")
0053                         icon.name: "edit-undo"
0054                         enabled: drawingarea.canUndo
0055                         onTriggered: drawingarea.undo()
0056                     },
0057                     Kirigami.Action {
0058                         icon.name: "draw-brush"
0059                         checkable: true
0060                         checked: drawingarea.tool == DrawingArea.Drawing
0061                         onTriggered: drawingarea.tool = DrawingArea.Drawing
0062                     },
0063                     Kirigami.Action {
0064                         icon.name: "draw-rectangle"
0065                         checkable: true
0066                         checked: drawingarea.tool == DrawingArea.Rectangle
0067                         onTriggered: drawingarea.tool = DrawingArea.Rectangle
0068                     },
0069                     Kirigami.Action {
0070                         icon.name: "draw-ellipse"
0071                         checkable: true
0072                         checked: drawingarea.tool == DrawingArea.Circle
0073                         onTriggered: drawingarea.tool = DrawingArea.Circle
0074                     },
0075                     Kirigami.Action {
0076                         text: i18n("Color")
0077                         icon.name: "color-management"
0078                         onTriggered: colorDialog.open()
0079                     },
0080                     Kirigami.Action {
0081                         id: widthAction
0082                         text: i18n("Width")
0083                         enabled: drawingarea.tool == DrawingArea.Drawing
0084                         property int width: 4
0085                         displayComponent: RowLayout {
0086                             Controls.Label {
0087                                 text: widthAction.text
0088                             }
0089                             Controls.SpinBox {
0090                                 from: 1
0091                                 enabled: widthAction.enabled
0092                                 to: 100
0093                                 value: widthAction.width
0094                                 onValueChanged: {
0095                                     drawingarea.penWidth = value
0096                                     widthAction.width = value
0097                                 }
0098                             }
0099                         }
0100                     },
0101                     Kirigami.Action {
0102                         text: i18n("Save as")
0103                         icon.name: "document-save-as"
0104                         onTriggered: fileDialog.open()
0105                     }
0106                 ]
0107             }
0108         }
0109     }
0110 }