1
0

ThemeManager.qml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. pragma Singleton
  2. import QtQuick 2.15
  3. import Qt.labs.settings 1.0
  4. // Design tokens for the touch UI — "the table at night".
  5. // Night: warm basalt ground, bone text, one amber accent (the LED glow).
  6. // Day: warm sand ground instead of inverted gray. Same ember accent family.
  7. // Every color, size, and spacing in the QML goes through this singleton.
  8. QtObject {
  9. id: themeManager
  10. // Theme state - loaded from settings
  11. property bool darkMode: settings.darkMode
  12. // ---- Typography (bundled in fonts/, registered in main.py) ----
  13. // Static instances carry legacy family names, hence three families.
  14. readonly property string fontBody: "Outfit"
  15. readonly property string fontMedium: "Outfit Medium"
  16. readonly property string fontDisplay: "Outfit SemiBold"
  17. readonly property string fontIcon: "Material Icons Round"
  18. // Type scale — the panel is read at arm's length, so nothing under 12.
  19. readonly property int fontSizeCaption: 12 // eyebrows, meta, counts
  20. readonly property int fontSizeBody: 14 // controls, list rows
  21. readonly property int fontSizeTitle: 17 // page titles, card titles
  22. readonly property int fontSizeDisplay: 24 // the one big thing per page
  23. // ---- Layout ----
  24. readonly property int spaceXs: 4
  25. readonly property int spaceSm: 8
  26. readonly property int spaceMd: 12
  27. readonly property int spaceLg: 16
  28. readonly property int spaceXl: 24
  29. readonly property int radiusSm: 10
  30. readonly property int radiusMd: 14
  31. readonly property int radiusPill: 999 // circles/pills: the table's geometry
  32. readonly property int touchTarget: 48 // minimum hit size, fingertips + sand
  33. readonly property int controlHeight: 56 // primary transport controls
  34. readonly property int headerHeight: 60
  35. readonly property int navHeight: 64
  36. // ---- Surfaces ----
  37. property color backgroundColor: darkMode ? "#171310" : "#ece5d6" // basalt / dune
  38. property color surfaceColor: darkMode ? "#201b16" : "#f5f0e5"
  39. property color cardColor: darkMode ? "#2a241d" : "#e4dcca"
  40. property color pressedColor: darkMode ? "#332c24" : "#d9cfba"
  41. // ---- Text ----
  42. property color textPrimary: darkMode ? "#ece4d3" : "#332c22" // bone / ink
  43. property color textSecondary: darkMode ? "#a39885" : "#7c7161"
  44. property color textTertiary: darkMode ? "#6e6455" : "#a89d8a"
  45. // ---- Borders ----
  46. property color borderColor: darkMode ? "#362f26" : "#d6ccb7"
  47. property color borderLight: darkMode ? "#2b2620" : "#e0d8c6"
  48. // ---- Accent: ember (the LED ring's glow) ----
  49. property color accent: darkMode ? "#e2a860" : "#b0791f"
  50. property color accentPressed: darkMode ? "#c98f49" : "#8f6014"
  51. property color onAccent: darkMode ? "#241a0c" : "#fdf8ee"
  52. // Subtle amber-tinted fill for selected chips/rows
  53. property color accentSoft: darkMode ? "#3a2f1e" : "#eadfc2"
  54. // ---- Semantic ----
  55. property color ok: darkMode ? "#9db07f" : "#5f7a3f" // connected, running
  56. property color okSoft: darkMode ? "#28301f" : "#e2e6d2"
  57. property color danger: darkMode ? "#c65a33" : "#b0431d" // stop, delete, alarm
  58. property color dangerPressed: darkMode ? "#a84a28" : "#8f3517"
  59. // ---- Legacy aliases (older call sites; prefer the tokens above) ----
  60. property color accentBlue: accent
  61. property color accentBlueHover: accentPressed
  62. property color accentRed: danger
  63. property color accentRedHover: dangerPressed
  64. property color accentGray: textSecondary
  65. property color accentGrayHover: textPrimary
  66. property color accentGrayDisabled: textTertiary
  67. property color buttonBackground: cardColor
  68. property color buttonBackgroundHover: pressedColor
  69. property color buttonBorder: borderColor
  70. property color selectedBackground: accent
  71. property color selectedBorder: accentPressed
  72. // Placeholder / preview
  73. property color placeholderBackground: cardColor
  74. property color placeholderText: textTertiary
  75. // Previews carry their own dark circular dish (thr_preview.py) and sit
  76. // directly on the page surface — no boxed backdrop.
  77. property color previewBackground: backgroundColor
  78. property color shadowColor: darkMode ? "#000000" : "#00000020"
  79. // Navigation
  80. property color navBackground: surfaceColor
  81. property color navBorder: borderColor
  82. property color navIconActive: accent
  83. property color navIconInactive: textSecondary
  84. property color navTextActive: accent
  85. property color navTextInactive: textSecondary
  86. // Persistent settings
  87. property Settings settings: Settings {
  88. category: "Appearance"
  89. property bool darkMode: true // night is the default: this screen lives on furniture
  90. }
  91. onDarkModeChanged: {
  92. // Save preference
  93. settings.darkMode = darkMode
  94. }
  95. // Helper function to get contrast color
  96. function getContrastColor(baseColor) {
  97. return darkMode ? Qt.lighter(baseColor, 1.2) : Qt.darker(baseColor, 1.1)
  98. }
  99. }