Warning, /graphics/washipad/src/ToolBar.qml is written in an unsupported language. File is not indexed.

0001 // This file is part of Washi Pad
0002 // SPDX-FileCopyrightText: 2018 Kevin Ottens <ervin@kde.org>
0003 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 
0005 import QtQuick 2.0
0006 import QtQuick.Window 2.0
0007 
0008 import WashiPad 1.0
0009 
0010 Row {
0011     id: root
0012     property bool isMouseSupportEnabled: false
0013     property point cursorPos
0014     property color currentColor: "black"
0015 
0016     signal saveRequested
0017 
0018     height: childrenRect.height
0019     opacity: cursorNearToolBar() ? 0 : 1
0020 
0021     Behavior on opacity {
0022         NumberAnimation { duration: 200; easing.type: Easing.InOutQuad }
0023     }
0024 
0025     function cursorNearToolBar() {
0026         var fivemm = 5 * Screen.pixelDensity
0027         var rect = Qt.rect(root.x - fivemm, root.y - fivemm,
0028                            root.width + 2 * fivemm, root.height + 2 * fivemm)
0029         return cursorPos.x > rect.x && cursorPos.x < (rect.x + rect.width)
0030             && cursorPos.y > rect.y && cursorPos.y < (rect.y + rect.height)
0031     }
0032 
0033     Repeater {
0034         model: ["black", "gray",
0035                 "#ee7700", "#1188cc",
0036                 "#11aa11", "#cc3377",
0037                 "#cc1111"]
0038         delegate: ColorButton {
0039             color: model.modelData
0040             active: root.currentColor === color
0041             onClicked: root.currentColor = color
0042         }
0043     }
0044 
0045     ToolButton {
0046         id: mouseToggler
0047 
0048         onClicked: root.isMouseSupportEnabled = !root.isMouseSupportEnabled
0049 
0050         Image {
0051             anchors.fill: parent
0052             source: root.isMouseSupportEnabled ? "qrc:/input-mouse.svg" : "qrc:/input-tablet.svg"
0053             fillMode: Image.PreserveAspectFit
0054             sourceSize: Qt.size(width, height)
0055         }
0056     }
0057 
0058     ToolButton {
0059         onClicked: root.saveRequested()
0060 
0061         Image {
0062             anchors.fill: parent
0063             source: "qrc:/document-save.svg"
0064             fillMode: Image.PreserveAspectFit
0065             sourceSize: Qt.size(width, height)
0066         }
0067     }
0068 
0069     ToolButton {
0070         color: "darkRed"
0071         onClicked: Qt.quit()
0072 
0073         Image {
0074             anchors.fill: parent
0075             source: "qrc:/window-close.svg"
0076             fillMode: Image.PreserveAspectFit
0077             sourceSize: Qt.size(width, height)
0078         }
0079     }
0080 }