StatusPoint.qml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (C) 2015 Malte Veerman <maldela@halloarsch.de>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. *
  18. */
  19. import QtQuick 2.4
  20. import QtQuick.Controls 1.2
  21. Rectangle {
  22. id: root
  23. property QtObject fan
  24. property Item canvas: parent
  25. property real unscaledTemp: fan.temp ? fan.temp.value : minTemp
  26. property real unscaledPwm: fan.pwm
  27. property var locale: Qt.locale()
  28. readonly property real centerX: x + width / 2
  29. readonly property real centerY: y + height / 2
  30. property int size: 10
  31. width: size
  32. height: size
  33. radius: size / 2
  34. x: canvas.scaleX(unscaledTemp) - width/2
  35. y: canvas.scaleY(unscaledPwm) - height/2
  36. color: "black"
  37. Behavior on unscaledTemp {
  38. SpringAnimation {
  39. epsilon: 0.1
  40. spring: 1.0
  41. damping: 0.4
  42. }
  43. }
  44. Behavior on unscaledPwm {
  45. SpringAnimation {
  46. epsilon: 0.1
  47. spring: 1.0
  48. damping: 0.4
  49. }
  50. }
  51. MouseArea {
  52. id: pwmMouse
  53. anchors.fill: parent
  54. hoverEnabled: root.enabled ? true : false
  55. }
  56. Rectangle {
  57. id: tooltip
  58. x: parent.width
  59. y: - height
  60. width: Math.max(pwm.width, rpm.width)
  61. height: pwm.height + rpm.height
  62. radius: 4
  63. color: Qt.rgba(parent.color.r, parent.color.g, parent.color.b, 0.5)
  64. visible: root.enabled && pwmMouse.containsMouse
  65. Column {
  66. Label {
  67. id: pwm
  68. font.pixelSize: root.height * 1.5
  69. text: Number(Math.round(canvas.scalePwm(root.centerY)) / 2.55).toLocaleString(locale, 'f', 1) + '%'
  70. }
  71. Label {
  72. id: rpm
  73. font.pixelSize: root.height * 1.5
  74. text: fan.rpm + i18n("rpm")
  75. }
  76. }
  77. }
  78. }