MenuButton.qml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import QtQuick 2.5
  2. import QtQuick.Controls 1.4
  3. //import Qt.labs.controls 1.0
  4. import QtQuick.Controls 2.0
  5. import QtQuick.Controls.Styles 1.3
  6. import QtGraphicalEffects 1.0
  7. import ApplicationLauncher 1.0
  8. Button {
  9. property double buttGreyed: 0.0 //Saturation -1.0 greyed ... 0.0 colored
  10. property int imgBorder: 20 // in percent of parent.height defaults to 20%
  11. property string menuQML // next UI to goto
  12. property string menuImage // Image name
  13. // property string menuText // Text to display in Button Box
  14. property alias menuText: menTXT.text
  15. signal itemClicked
  16. width: parent.width
  17. height: parent.height
  18. Image {
  19. id: idIMG
  20. anchors.centerIn: parent
  21. fillMode: Image.PreserveAspectFit
  22. source: menuImage
  23. sourceSize.height: parent.height - parent.width * (parent.imgBorder / 100.0)
  24. sourceSize.width: parent.width - parent.width * (parent.imgBorder / 100.0)
  25. Text {
  26. id: menTXT
  27. anchors.bottom: parent.bottom
  28. anchors.bottomMargin: 3
  29. x: 2
  30. width: parent.width - 2 * x
  31. color: "white"
  32. font.pixelSize: (parent.height * 0.21) / 2
  33. wrapMode: Text.WordWrap
  34. text: menuText
  35. }
  36. }
  37. HueSaturation {
  38. id: idSaturation
  39. anchors.fill: idIMG
  40. source: idIMG
  41. hue: 0.0
  42. saturation: buttGreyed
  43. lightness: 0.0
  44. }
  45. background: Rectangle {
  46. border.width: 0.0
  47. }
  48. onClicked: {
  49. sysinfo.beep();
  50. itemClicked();
  51. }
  52. }