MenuButton.qml 1.5 KB

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