Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

257 lines
15KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla style
  4. # Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com>
  5. #
  6. # This program is free software you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation either version 2 of the License, or
  9. # any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # For a full copy of the GNU General Public License see the GPL.txt file
  17. # ------------------------------------------------------------------------------------------------------------
  18. # Imports (Config)
  19. from carla_config import *
  20. # ------------------------------------------------------------------------------------------------------------
  21. # Imports (Global)
  22. if config_UseQt5:
  23. from PyQt5.QtCore import QSettings
  24. from PyQt5.QtGui import QColor, QFont, QPalette
  25. from PyQt5.QtWidgets import QApplication
  26. else:
  27. from PyQt4.QtCore import QSettings
  28. from PyQt4.QtGui import QApplication, QColor, QFont, QPalette
  29. # ------------------------------------------------------------------------------------------------------------
  30. # Imports (Custom)
  31. from carla_shared import *
  32. # ------------------------------------------------------------------------------------------------------------
  33. class CarlaApplication(object):
  34. def __init__(self, appName = "Carla2", libPrefix = None):
  35. object.__init__(self)
  36. # try to find styles dir
  37. stylesDir = ""
  38. CWDl = CWD.lower()
  39. if libPrefix is not None:
  40. stylesDir = os.path.join(libPrefix, "lib", "carla")
  41. elif CWDl.endswith("resources"):
  42. if CWDl.endswith("native-plugins%sresources" % os.sep):
  43. stylesDir = os.path.abspath(os.path.join(CWD, "..", "..", "..", "..", "bin"))
  44. elif "carla-native.lv2" in sys.argv[0]:
  45. stylesDir = os.path.abspath(os.path.join(CWD, "..", "..", "..", "lib", "lv2", "carla-native.lv2"))
  46. else:
  47. stylesDir = os.path.abspath(os.path.join(CWD, "..", "..", "..", "lib", "carla"))
  48. elif CWDl.endswith("source"):
  49. stylesDir = os.path.abspath(os.path.join(CWD, "..", "bin"))
  50. if stylesDir:
  51. QApplication.addLibraryPath(stylesDir)
  52. elif not config_UseQt5:
  53. self._createApp(appName)
  54. return
  55. # base settings
  56. settings = QSettings("falkTX", appName)
  57. useProTheme = settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, True, type=bool)
  58. if not useProTheme:
  59. self._createApp(appName)
  60. return
  61. if config_UseQt5:
  62. # set initial Qt stuff
  63. customFont = QFont("DejaVu Sans [Book]")
  64. customFont.setBold(False)
  65. customFont.setItalic(False)
  66. customFont.setOverline(False)
  67. customFont.setKerning(True)
  68. customFont.setHintingPreference(QFont.PreferFullHinting)
  69. customFont.setPixelSize(12)
  70. customFont.setWeight(QFont.Normal)
  71. QApplication.setDesktopSettingsAware(False)
  72. QApplication.setFont(customFont)
  73. # set style
  74. QApplication.setStyle("carla" if stylesDir else "fusion")
  75. # create app
  76. self._createApp(appName)
  77. if config_UseQt5:
  78. self.fApp.setFont(customFont)
  79. self.fApp.setStyle("carla" if stylesDir else "fusion")
  80. # set palette
  81. proThemeColor = settings.value(CARLA_KEY_MAIN_PRO_THEME_COLOR, "Black", type=str).lower()
  82. if proThemeColor == "black":
  83. self.fPalBlack = QPalette()
  84. self.fPalBlack.setColor(QPalette.Disabled, QPalette.Window, QColor(14, 14, 14))
  85. self.fPalBlack.setColor(QPalette.Active, QPalette.Window, QColor(17, 17, 17))
  86. self.fPalBlack.setColor(QPalette.Inactive, QPalette.Window, QColor(17, 17, 17))
  87. self.fPalBlack.setColor(QPalette.Disabled, QPalette.WindowText, QColor(83, 83, 83))
  88. self.fPalBlack.setColor(QPalette.Active, QPalette.WindowText, QColor(240, 240, 240))
  89. self.fPalBlack.setColor(QPalette.Inactive, QPalette.WindowText, QColor(240, 240, 240))
  90. self.fPalBlack.setColor(QPalette.Disabled, QPalette.Base, QColor(6, 6, 6))
  91. self.fPalBlack.setColor(QPalette.Active, QPalette.Base, QColor(7, 7, 7))
  92. self.fPalBlack.setColor(QPalette.Inactive, QPalette.Base, QColor(7, 7, 7))
  93. self.fPalBlack.setColor(QPalette.Disabled, QPalette.AlternateBase, QColor(12, 12, 12))
  94. self.fPalBlack.setColor(QPalette.Active, QPalette.AlternateBase, QColor(14, 14, 14))
  95. self.fPalBlack.setColor(QPalette.Inactive, QPalette.AlternateBase, QColor(14, 14, 14))
  96. self.fPalBlack.setColor(QPalette.Disabled, QPalette.ToolTipBase, QColor(4, 4, 4))
  97. self.fPalBlack.setColor(QPalette.Active, QPalette.ToolTipBase, QColor(4, 4, 4))
  98. self.fPalBlack.setColor(QPalette.Inactive, QPalette.ToolTipBase, QColor(4, 4, 4))
  99. self.fPalBlack.setColor(QPalette.Disabled, QPalette.ToolTipText, QColor(230, 230, 230))
  100. self.fPalBlack.setColor(QPalette.Active, QPalette.ToolTipText, QColor(230, 230, 230))
  101. self.fPalBlack.setColor(QPalette.Inactive, QPalette.ToolTipText, QColor(230, 230, 230))
  102. self.fPalBlack.setColor(QPalette.Disabled, QPalette.Text, QColor(74, 74, 74))
  103. self.fPalBlack.setColor(QPalette.Active, QPalette.Text, QColor(230, 230, 230))
  104. self.fPalBlack.setColor(QPalette.Inactive, QPalette.Text, QColor(230, 230, 230))
  105. self.fPalBlack.setColor(QPalette.Disabled, QPalette.Button, QColor(24, 24, 24))
  106. self.fPalBlack.setColor(QPalette.Active, QPalette.Button, QColor(28, 28, 28))
  107. self.fPalBlack.setColor(QPalette.Inactive, QPalette.Button, QColor(28, 28, 28))
  108. self.fPalBlack.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(90, 90, 90))
  109. self.fPalBlack.setColor(QPalette.Active, QPalette.ButtonText, QColor(240, 240, 240))
  110. self.fPalBlack.setColor(QPalette.Inactive, QPalette.ButtonText, QColor(240, 240, 240))
  111. self.fPalBlack.setColor(QPalette.Disabled, QPalette.BrightText, QColor(255, 255, 255))
  112. self.fPalBlack.setColor(QPalette.Active, QPalette.BrightText, QColor(255, 255, 255))
  113. self.fPalBlack.setColor(QPalette.Inactive, QPalette.BrightText, QColor(255, 255, 255))
  114. self.fPalBlack.setColor(QPalette.Disabled, QPalette.Light, QColor(191, 191, 191))
  115. self.fPalBlack.setColor(QPalette.Active, QPalette.Light, QColor(191, 191, 191))
  116. self.fPalBlack.setColor(QPalette.Inactive, QPalette.Light, QColor(191, 191, 191))
  117. self.fPalBlack.setColor(QPalette.Disabled, QPalette.Midlight, QColor(155, 155, 155))
  118. self.fPalBlack.setColor(QPalette.Active, QPalette.Midlight, QColor(155, 155, 155))
  119. self.fPalBlack.setColor(QPalette.Inactive, QPalette.Midlight, QColor(155, 155, 155))
  120. self.fPalBlack.setColor(QPalette.Disabled, QPalette.Dark, QColor(129, 129, 129))
  121. self.fPalBlack.setColor(QPalette.Active, QPalette.Dark, QColor(129, 129, 129))
  122. self.fPalBlack.setColor(QPalette.Inactive, QPalette.Dark, QColor(129, 129, 129))
  123. self.fPalBlack.setColor(QPalette.Disabled, QPalette.Mid, QColor(94, 94, 94))
  124. self.fPalBlack.setColor(QPalette.Active, QPalette.Mid, QColor(94, 94, 94))
  125. self.fPalBlack.setColor(QPalette.Inactive, QPalette.Mid, QColor(94, 94, 94))
  126. self.fPalBlack.setColor(QPalette.Disabled, QPalette.Shadow, QColor(155, 155, 155))
  127. self.fPalBlack.setColor(QPalette.Active, QPalette.Shadow, QColor(155, 155, 155))
  128. self.fPalBlack.setColor(QPalette.Inactive, QPalette.Shadow, QColor(155, 155, 155))
  129. self.fPalBlack.setColor(QPalette.Disabled, QPalette.Highlight, QColor(14, 14, 14))
  130. self.fPalBlack.setColor(QPalette.Active, QPalette.Highlight, QColor(60, 60, 60))
  131. self.fPalBlack.setColor(QPalette.Inactive, QPalette.Highlight, QColor(34, 34, 34))
  132. self.fPalBlack.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(83, 83, 83))
  133. self.fPalBlack.setColor(QPalette.Active, QPalette.HighlightedText, QColor(255, 255, 255))
  134. self.fPalBlack.setColor(QPalette.Inactive, QPalette.HighlightedText, QColor(240, 240, 240))
  135. self.fPalBlack.setColor(QPalette.Disabled, QPalette.Link, QColor(34, 34, 74))
  136. self.fPalBlack.setColor(QPalette.Active, QPalette.Link, QColor(100, 100, 230))
  137. self.fPalBlack.setColor(QPalette.Inactive, QPalette.Link, QColor(100, 100, 230))
  138. self.fPalBlack.setColor(QPalette.Disabled, QPalette.LinkVisited, QColor(74, 34, 74))
  139. self.fPalBlack.setColor(QPalette.Active, QPalette.LinkVisited, QColor(230, 100, 230))
  140. self.fPalBlack.setColor(QPalette.Inactive, QPalette.LinkVisited, QColor(230, 100, 230))
  141. self.fApp.setPalette(self.fPalBlack)
  142. elif proThemeColor == "blue":
  143. self.fPalBlue = QPalette()
  144. self.fPalBlue.setColor(QPalette.Disabled, QPalette.Window, QColor(32, 35, 39))
  145. self.fPalBlue.setColor(QPalette.Active, QPalette.Window, QColor(37, 40, 45))
  146. self.fPalBlue.setColor(QPalette.Inactive, QPalette.Window, QColor(37, 40, 45))
  147. self.fPalBlue.setColor(QPalette.Disabled, QPalette.WindowText, QColor(89, 95, 104))
  148. self.fPalBlue.setColor(QPalette.Active, QPalette.WindowText, QColor(223, 237, 255))
  149. self.fPalBlue.setColor(QPalette.Inactive, QPalette.WindowText, QColor(223, 237, 255))
  150. self.fPalBlue.setColor(QPalette.Disabled, QPalette.Base, QColor(48, 53, 60))
  151. self.fPalBlue.setColor(QPalette.Active, QPalette.Base, QColor(55, 61, 69))
  152. self.fPalBlue.setColor(QPalette.Inactive, QPalette.Base, QColor(55, 61, 69))
  153. self.fPalBlue.setColor(QPalette.Disabled, QPalette.AlternateBase, QColor(60, 64, 67))
  154. self.fPalBlue.setColor(QPalette.Active, QPalette.AlternateBase, QColor(69, 73, 77))
  155. self.fPalBlue.setColor(QPalette.Inactive, QPalette.AlternateBase, QColor(69, 73, 77))
  156. self.fPalBlue.setColor(QPalette.Disabled, QPalette.ToolTipBase, QColor(182, 193, 208))
  157. self.fPalBlue.setColor(QPalette.Active, QPalette.ToolTipBase, QColor(182, 193, 208))
  158. self.fPalBlue.setColor(QPalette.Inactive, QPalette.ToolTipBase, QColor(182, 193, 208))
  159. self.fPalBlue.setColor(QPalette.Disabled, QPalette.ToolTipText, QColor(42, 44, 48))
  160. self.fPalBlue.setColor(QPalette.Active, QPalette.ToolTipText, QColor(42, 44, 48))
  161. self.fPalBlue.setColor(QPalette.Inactive, QPalette.ToolTipText, QColor(42, 44, 48))
  162. self.fPalBlue.setColor(QPalette.Disabled, QPalette.Text, QColor(96, 103, 113))
  163. self.fPalBlue.setColor(QPalette.Active, QPalette.Text, QColor(210, 222, 240))
  164. self.fPalBlue.setColor(QPalette.Inactive, QPalette.Text, QColor(210, 222, 240))
  165. self.fPalBlue.setColor(QPalette.Disabled, QPalette.Button, QColor(51, 55, 62))
  166. self.fPalBlue.setColor(QPalette.Active, QPalette.Button, QColor(59, 63, 71))
  167. self.fPalBlue.setColor(QPalette.Inactive, QPalette.Button, QColor(59, 63, 71))
  168. self.fPalBlue.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(98, 104, 114))
  169. self.fPalBlue.setColor(QPalette.Active, QPalette.ButtonText, QColor(210, 222, 240))
  170. self.fPalBlue.setColor(QPalette.Inactive, QPalette.ButtonText, QColor(210, 222, 240))
  171. self.fPalBlue.setColor(QPalette.Disabled, QPalette.BrightText, QColor(255, 255, 255))
  172. self.fPalBlue.setColor(QPalette.Active, QPalette.BrightText, QColor(255, 255, 255))
  173. self.fPalBlue.setColor(QPalette.Inactive, QPalette.BrightText, QColor(255, 255, 255))
  174. self.fPalBlue.setColor(QPalette.Disabled, QPalette.Light, QColor(59, 64, 72))
  175. self.fPalBlue.setColor(QPalette.Active, QPalette.Light, QColor(63, 68, 76))
  176. self.fPalBlue.setColor(QPalette.Inactive, QPalette.Light, QColor(63, 68, 76))
  177. self.fPalBlue.setColor(QPalette.Disabled, QPalette.Midlight, QColor(48, 52, 59))
  178. self.fPalBlue.setColor(QPalette.Active, QPalette.Midlight, QColor(51, 56, 63))
  179. self.fPalBlue.setColor(QPalette.Inactive, QPalette.Midlight, QColor(51, 56, 63))
  180. self.fPalBlue.setColor(QPalette.Disabled, QPalette.Dark, QColor(18, 19, 22))
  181. self.fPalBlue.setColor(QPalette.Active, QPalette.Dark, QColor(20, 22, 25))
  182. self.fPalBlue.setColor(QPalette.Inactive, QPalette.Dark, QColor(20, 22, 25))
  183. self.fPalBlue.setColor(QPalette.Disabled, QPalette.Mid, QColor(28, 30, 34))
  184. self.fPalBlue.setColor(QPalette.Active, QPalette.Mid, QColor(32, 35, 39))
  185. self.fPalBlue.setColor(QPalette.Inactive, QPalette.Mid, QColor(32, 35, 39))
  186. self.fPalBlue.setColor(QPalette.Disabled, QPalette.Shadow, QColor(13, 14, 16))
  187. self.fPalBlue.setColor(QPalette.Active, QPalette.Shadow, QColor(15, 16, 18))
  188. self.fPalBlue.setColor(QPalette.Inactive, QPalette.Shadow, QColor(15, 16, 18))
  189. self.fPalBlue.setColor(QPalette.Disabled, QPalette.Highlight, QColor(32, 35, 39))
  190. self.fPalBlue.setColor(QPalette.Active, QPalette.Highlight, QColor(14, 14, 17))
  191. self.fPalBlue.setColor(QPalette.Inactive, QPalette.Highlight, QColor(27, 28, 33))
  192. self.fPalBlue.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(89, 95, 104))
  193. self.fPalBlue.setColor(QPalette.Active, QPalette.HighlightedText, QColor(217, 234, 253))
  194. self.fPalBlue.setColor(QPalette.Inactive, QPalette.HighlightedText, QColor(223, 237, 255))
  195. self.fPalBlue.setColor(QPalette.Disabled, QPalette.Link, QColor(79, 100, 118))
  196. self.fPalBlue.setColor(QPalette.Active, QPalette.Link, QColor(156, 212, 255))
  197. self.fPalBlue.setColor(QPalette.Inactive, QPalette.Link, QColor(156, 212, 255))
  198. self.fPalBlue.setColor(QPalette.Disabled, QPalette.LinkVisited, QColor(51, 74, 118))
  199. self.fPalBlue.setColor(QPalette.Active, QPalette.LinkVisited, QColor(64, 128, 255))
  200. self.fPalBlue.setColor(QPalette.Inactive, QPalette.LinkVisited, QColor(64, 128, 255))
  201. self.fApp.setPalette(self.fPalBlue)
  202. print("Using \"%s\" theme" % self.fApp.style().objectName())
  203. def _createApp(self, appName):
  204. self.fApp = QApplication(sys.argv)
  205. self.fApp.setApplicationName(appName)
  206. self.fApp.setApplicationVersion(VERSION)
  207. self.fApp.setOrganizationName("falkTX")
  208. if appName.lower() == "carla-control":
  209. self.fApp.setWindowIcon(QIcon(":/scalable/carla-control.svg"))
  210. else:
  211. self.fApp.setWindowIcon(QIcon(":/scalable/carla.svg"))
  212. def arguments(self):
  213. return self.fApp.arguments()
  214. def exec_(self):
  215. return self.fApp.exec_()
  216. def exit_exec(self):
  217. return sys.exit(self.fApp.exec_())
  218. def getApp(self):
  219. return self.fApp
  220. def quit(self):
  221. self.fApp.quit()