NotificationIcon.qml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (c) 2019 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 2.3
  5. import UM 1.4 as UM
  6. //
  7. // A notification icon which is a circle with a number at the center, that can be used to indicate, for example, how
  8. // many new messages that are available.
  9. //
  10. Rectangle
  11. {
  12. id: notificationIcon
  13. color: UM.Theme.getColor("notification_icon")
  14. width: UM.Theme.getSize("notification_icon").width
  15. height: UM.Theme.getSize("notification_icon").height
  16. radius: (0.5 * width) | 0
  17. property alias labelText: notificationLabel.text
  18. property alias labelFont: notificationLabel.font
  19. Label
  20. {
  21. id: notificationLabel
  22. anchors.fill: parent
  23. color: UM.Theme.getColor("primary_text")
  24. horizontalAlignment: Text.AlignHCenter
  25. verticalAlignment: Text.AlignVCenter
  26. font: UM.Theme.getFont("default")
  27. renderType: Text.NativeRendering
  28. // This is a bit of a hack, but we don't really have enough room for 2 characters (eg 9+). The default font
  29. // does have a tad bit to much spacing. So instead of adding a whole new font, we just modify it a bit for this
  30. // specific instance.
  31. Component.onCompleted: font.letterSpacing = -1
  32. }
  33. }