swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame] | 1 | import QtQuick 2.0 |
| 2 | import QtQuick.Layouts 1.12 |
| 3 | import QtQuick.Controls 2.0 |
| 4 | |
| 5 | RowLayout { |
| 6 | id: root |
| 7 | |
| 8 | property string name: "Hello.refnb" |
| 9 | property alias containsMouse: mouseArea.containsMouse |
| 10 | signal clicked() |
swissChili | a44bf72 | 2022-04-16 18:41:54 -0700 | [diff] [blame] | 11 | signal removeClicked() |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame] | 12 | |
| 13 | Image { |
| 14 | id: nbIcon |
| 15 | width: 100 |
| 16 | height: 100 |
| 17 | source: "qrc:///icons/document.svg" |
| 18 | fillMode: Image.PreserveAspectFit |
| 19 | } |
| 20 | |
| 21 | Label { |
| 22 | text: name |
| 23 | Layout.fillWidth: true |
| 24 | |
| 25 | MouseArea { |
| 26 | id: mouseArea |
| 27 | |
| 28 | anchors.fill: parent |
| 29 | hoverEnabled: true |
| 30 | |
swissChili | a44bf72 | 2022-04-16 18:41:54 -0700 | [diff] [blame] | 31 | acceptedButtons: Qt.LeftButton | Qt.RightButton |
| 32 | |
| 33 | onClicked: { |
| 34 | if (mouse.button == Qt.LeftButton) |
| 35 | root.clicked(); |
| 36 | else if (mouse.button == Qt.RightButton) |
| 37 | contextMenu.popup(); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | Menu { |
| 42 | id: contextMenu |
| 43 | |
| 44 | MenuItem { |
| 45 | text: qsTr("Remove") |
| 46 | |
| 47 | onClicked: root.removeClicked() |
| 48 | } |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame] | 49 | } |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | /*##^## |
| 54 | Designer { |
| 55 | D{i:0;autoSize:true;height:24;width:300} |
| 56 | } |
| 57 | ##^##*/ |