Warning, /rolisteam/rolisteam/src/libraries/charactersheet/qml/Rolisteam/DiceButton.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick
0002 import QtQuick.Controls
0003 import QtQuick.Templates as T
0004 
0005 T.AbstractButton {
0006     id:root
0007     property color color: "#ff0000"
0008     property color pressedColor: "#990000"
0009     property color backgroundColor
0010     property color textColor: text.color
0011     property alias hAlign: text.horizontalAlignment
0012     property alias wrapMode: text.wrapMode
0013     property string command: ""
0014     property alias vAlign: text.verticalAlignment
0015     property bool readOnly: false
0016     property bool hasAlias: true
0017     property string tooltip: ""
0018     down: mouseZone.pressed
0019 
0020     background: Rectangle {
0021         id: background
0022         opacity: enabled ? 1 : 0.3
0023         border.color: root.down ? root.pressedColor : root.textColor
0024         border.width: 1
0025         color: root.down ? root.color : root.backgroundColor
0026     }
0027 
0028     contentItem: Text {
0029         id: text
0030         font: root.font
0031         text: root.text
0032         opacity: enabled ? 1.0 : 0.3
0033         color: root.down ? root.pressedColor : root.textColor
0034         wrapMode: Text.WrapAnywhere
0035     }
0036 
0037     Drag.active: mouseZone.drag.active
0038     Drag.mimeData: {"text/label":root.text,
0039                     "text/command": root.command,
0040                     "text/hasAlias": root.hasAlias}
0041     Drag.dragType: Drag.Automatic
0042     Drag.supportedActions: Qt.CopyAction
0043 
0044     function computeSizeFont()
0045     {
0046             while((contentWidth>root.width)&&(font.pointSize>1)&&(root.width>0))
0047             {
0048                 font.pointSize-=1
0049             }
0050             while((contentWidth+2<width)&&(contentHeight+2<height))
0051             {
0052                 font.pointSize+=1
0053             }
0054     }
0055 
0056     MouseArea {
0057         id: mouseZone
0058         anchors.fill: parent
0059         ToolTip.visible: root.tooltip.length >0 && mouseZone.pressed
0060         ToolTip.text: root.tooltip
0061         onClicked: {
0062             root.clicked()
0063             if(root.checkable)
0064             {
0065                 console.log("checked")
0066                 root.checked = !root.checked
0067             }
0068         }
0069         enabled: !root.readOnly
0070         drag.target: parent
0071         onPressed: {
0072             parent.grabToImage(function(result) {
0073             parent.Drag.imageSource = result.url
0074         })
0075         }
0076     }
0077 }