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.

213 lines
12KB

  1. /*
  2. * Carla style
  3. * Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #include "carla_shared.hpp"
  18. #include "carla_style.hpp"
  19. #include "theme/CarlaStyle.hpp"
  20. #include <QtCore/QDir>
  21. #include <QtCore/QSettings>
  22. #include <QtWidgets/QApplication>
  23. // ------------------------------------------------------------------------------------------------------------
  24. CarlaApplication::CarlaApplication(int& argc, char* argv[], const QString& appName)
  25. : fApp(nullptr),
  26. fStyle(nullptr)
  27. {
  28. fApp = new QApplication(argc, argv, true);
  29. fApp->setApplicationName(appName);
  30. fApp->setApplicationVersion(VERSION);
  31. fApp->setOrganizationName("falkTX");
  32. if (appName.toLower() == "carla-control")
  33. fApp->setWindowIcon(QIcon(":/scalable/carla-control.svg"));
  34. else
  35. fApp->setWindowIcon(QIcon(":/scalable/carla.svg"));
  36. fPalSystem = fApp->palette();
  37. fPalBlack.setColor(QPalette::Disabled, QPalette::Window, QColor(14, 14, 14));
  38. fPalBlack.setColor(QPalette::Active, QPalette::Window, QColor(17, 17, 17));
  39. fPalBlack.setColor(QPalette::Inactive, QPalette::Window, QColor(17, 17, 17));
  40. fPalBlack.setColor(QPalette::Disabled, QPalette::WindowText, QColor(83, 83, 83));
  41. fPalBlack.setColor(QPalette::Active, QPalette::WindowText, QColor(240, 240, 240));
  42. fPalBlack.setColor(QPalette::Inactive, QPalette::WindowText, QColor(240, 240, 240));
  43. fPalBlack.setColor(QPalette::Disabled, QPalette::Base, QColor(6, 6, 6));
  44. fPalBlack.setColor(QPalette::Active, QPalette::Base, QColor(7, 7, 7));
  45. fPalBlack.setColor(QPalette::Inactive, QPalette::Base, QColor(7, 7, 7));
  46. fPalBlack.setColor(QPalette::Disabled, QPalette::AlternateBase, QColor(12, 12, 12));
  47. fPalBlack.setColor(QPalette::Active, QPalette::AlternateBase, QColor(14, 14, 14));
  48. fPalBlack.setColor(QPalette::Inactive, QPalette::AlternateBase, QColor(14, 14, 14));
  49. fPalBlack.setColor(QPalette::Disabled, QPalette::ToolTipBase, QColor(4, 4, 4));
  50. fPalBlack.setColor(QPalette::Active, QPalette::ToolTipBase, QColor(4, 4, 4));
  51. fPalBlack.setColor(QPalette::Inactive, QPalette::ToolTipBase, QColor(4, 4, 4));
  52. fPalBlack.setColor(QPalette::Disabled, QPalette::ToolTipText, QColor(230, 230, 230));
  53. fPalBlack.setColor(QPalette::Active, QPalette::ToolTipText, QColor(230, 230, 230));
  54. fPalBlack.setColor(QPalette::Inactive, QPalette::ToolTipText, QColor(230, 230, 230));
  55. fPalBlack.setColor(QPalette::Disabled, QPalette::Text, QColor(74, 74, 74));
  56. fPalBlack.setColor(QPalette::Active, QPalette::Text, QColor(230, 230, 230));
  57. fPalBlack.setColor(QPalette::Inactive, QPalette::Text, QColor(230, 230, 230));
  58. fPalBlack.setColor(QPalette::Disabled, QPalette::Button, QColor(24, 24, 24));
  59. fPalBlack.setColor(QPalette::Active, QPalette::Button, QColor(28, 28, 28));
  60. fPalBlack.setColor(QPalette::Inactive, QPalette::Button, QColor(28, 28, 28));
  61. fPalBlack.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(90, 90, 90));
  62. fPalBlack.setColor(QPalette::Active, QPalette::ButtonText, QColor(240, 240, 240));
  63. fPalBlack.setColor(QPalette::Inactive, QPalette::ButtonText, QColor(240, 240, 240));
  64. fPalBlack.setColor(QPalette::Disabled, QPalette::BrightText, QColor(255, 255, 255));
  65. fPalBlack.setColor(QPalette::Active, QPalette::BrightText, QColor(255, 255, 255));
  66. fPalBlack.setColor(QPalette::Inactive, QPalette::BrightText, QColor(255, 255, 255));
  67. fPalBlack.setColor(QPalette::Disabled, QPalette::Light, QColor(191, 191, 191));
  68. fPalBlack.setColor(QPalette::Active, QPalette::Light, QColor(191, 191, 191));
  69. fPalBlack.setColor(QPalette::Inactive, QPalette::Light, QColor(191, 191, 191));
  70. fPalBlack.setColor(QPalette::Disabled, QPalette::Midlight, QColor(155, 155, 155));
  71. fPalBlack.setColor(QPalette::Active, QPalette::Midlight, QColor(155, 155, 155));
  72. fPalBlack.setColor(QPalette::Inactive, QPalette::Midlight, QColor(155, 155, 155));
  73. fPalBlack.setColor(QPalette::Disabled, QPalette::Dark, QColor(129, 129, 129));
  74. fPalBlack.setColor(QPalette::Active, QPalette::Dark, QColor(129, 129, 129));
  75. fPalBlack.setColor(QPalette::Inactive, QPalette::Dark, QColor(129, 129, 129));
  76. fPalBlack.setColor(QPalette::Disabled, QPalette::Mid, QColor(94, 94, 94));
  77. fPalBlack.setColor(QPalette::Active, QPalette::Mid, QColor(94, 94, 94));
  78. fPalBlack.setColor(QPalette::Inactive, QPalette::Mid, QColor(94, 94, 94));
  79. fPalBlack.setColor(QPalette::Disabled, QPalette::Shadow, QColor(155, 155, 155));
  80. fPalBlack.setColor(QPalette::Active, QPalette::Shadow, QColor(155, 155, 155));
  81. fPalBlack.setColor(QPalette::Inactive, QPalette::Shadow, QColor(155, 155, 155));
  82. fPalBlack.setColor(QPalette::Disabled, QPalette::Highlight, QColor(14, 14, 14));
  83. fPalBlack.setColor(QPalette::Active, QPalette::Highlight, QColor(60, 60, 60));
  84. fPalBlack.setColor(QPalette::Inactive, QPalette::Highlight, QColor(34, 34, 34));
  85. fPalBlack.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(83, 83, 83));
  86. fPalBlack.setColor(QPalette::Active, QPalette::HighlightedText, QColor(255, 255, 255));
  87. fPalBlack.setColor(QPalette::Inactive, QPalette::HighlightedText, QColor(240, 240, 240));
  88. fPalBlack.setColor(QPalette::Disabled, QPalette::Link, QColor(34, 34, 74));
  89. fPalBlack.setColor(QPalette::Active, QPalette::Link, QColor(100, 100, 230));
  90. fPalBlack.setColor(QPalette::Inactive, QPalette::Link, QColor(100, 100, 230));
  91. fPalBlack.setColor(QPalette::Disabled, QPalette::LinkVisited, QColor(74, 34, 74));
  92. fPalBlack.setColor(QPalette::Active, QPalette::LinkVisited, QColor(230, 100, 230));
  93. fPalBlack.setColor(QPalette::Inactive, QPalette::LinkVisited, QColor(230, 100, 230));
  94. fPalBlue.setColor(QPalette::Disabled, QPalette::Window, QColor(32, 35, 39));
  95. fPalBlue.setColor(QPalette::Active, QPalette::Window, QColor(37, 40, 45));
  96. fPalBlue.setColor(QPalette::Inactive, QPalette::Window, QColor(37, 40, 45));
  97. fPalBlue.setColor(QPalette::Disabled, QPalette::WindowText, QColor(89, 95, 104));
  98. fPalBlue.setColor(QPalette::Active, QPalette::WindowText, QColor(223, 237, 255));
  99. fPalBlue.setColor(QPalette::Inactive, QPalette::WindowText, QColor(223, 237, 255));
  100. fPalBlue.setColor(QPalette::Disabled, QPalette::Base, QColor(48, 53, 60));
  101. fPalBlue.setColor(QPalette::Active, QPalette::Base, QColor(55, 61, 69));
  102. fPalBlue.setColor(QPalette::Inactive, QPalette::Base, QColor(55, 61, 69));
  103. fPalBlue.setColor(QPalette::Disabled, QPalette::AlternateBase, QColor(60, 64, 67));
  104. fPalBlue.setColor(QPalette::Active, QPalette::AlternateBase, QColor(69, 73, 77));
  105. fPalBlue.setColor(QPalette::Inactive, QPalette::AlternateBase, QColor(69, 73, 77));
  106. fPalBlue.setColor(QPalette::Disabled, QPalette::ToolTipBase, QColor(182, 193, 208));
  107. fPalBlue.setColor(QPalette::Active, QPalette::ToolTipBase, QColor(182, 193, 208));
  108. fPalBlue.setColor(QPalette::Inactive, QPalette::ToolTipBase, QColor(182, 193, 208));
  109. fPalBlue.setColor(QPalette::Disabled, QPalette::ToolTipText, QColor(42, 44, 48));
  110. fPalBlue.setColor(QPalette::Active, QPalette::ToolTipText, QColor(42, 44, 48));
  111. fPalBlue.setColor(QPalette::Inactive, QPalette::ToolTipText, QColor(42, 44, 48));
  112. fPalBlue.setColor(QPalette::Disabled, QPalette::Text, QColor(96, 103, 113));
  113. fPalBlue.setColor(QPalette::Active, QPalette::Text, QColor(210, 222, 240));
  114. fPalBlue.setColor(QPalette::Inactive, QPalette::Text, QColor(210, 222, 240));
  115. fPalBlue.setColor(QPalette::Disabled, QPalette::Button, QColor(51, 55, 62));
  116. fPalBlue.setColor(QPalette::Active, QPalette::Button, QColor(59, 63, 71));
  117. fPalBlue.setColor(QPalette::Inactive, QPalette::Button, QColor(59, 63, 71));
  118. fPalBlue.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(98, 104, 114));
  119. fPalBlue.setColor(QPalette::Active, QPalette::ButtonText, QColor(210, 222, 240));
  120. fPalBlue.setColor(QPalette::Inactive, QPalette::ButtonText, QColor(210, 222, 240));
  121. fPalBlue.setColor(QPalette::Disabled, QPalette::BrightText, QColor(255, 255, 255));
  122. fPalBlue.setColor(QPalette::Active, QPalette::BrightText, QColor(255, 255, 255));
  123. fPalBlue.setColor(QPalette::Inactive, QPalette::BrightText, QColor(255, 255, 255));
  124. fPalBlue.setColor(QPalette::Disabled, QPalette::Light, QColor(59, 64, 72));
  125. fPalBlue.setColor(QPalette::Active, QPalette::Light, QColor(63, 68, 76));
  126. fPalBlue.setColor(QPalette::Inactive, QPalette::Light, QColor(63, 68, 76));
  127. fPalBlue.setColor(QPalette::Disabled, QPalette::Midlight, QColor(48, 52, 59));
  128. fPalBlue.setColor(QPalette::Active, QPalette::Midlight, QColor(51, 56, 63));
  129. fPalBlue.setColor(QPalette::Inactive, QPalette::Midlight, QColor(51, 56, 63));
  130. fPalBlue.setColor(QPalette::Disabled, QPalette::Dark, QColor(18, 19, 22));
  131. fPalBlue.setColor(QPalette::Active, QPalette::Dark, QColor(20, 22, 25));
  132. fPalBlue.setColor(QPalette::Inactive, QPalette::Dark, QColor(20, 22, 25));
  133. fPalBlue.setColor(QPalette::Disabled, QPalette::Mid, QColor(28, 30, 34));
  134. fPalBlue.setColor(QPalette::Active, QPalette::Mid, QColor(32, 35, 39));
  135. fPalBlue.setColor(QPalette::Inactive, QPalette::Mid, QColor(32, 35, 39));
  136. fPalBlue.setColor(QPalette::Disabled, QPalette::Shadow, QColor(13, 14, 16));
  137. fPalBlue.setColor(QPalette::Active, QPalette::Shadow, QColor(15, 16, 18));
  138. fPalBlue.setColor(QPalette::Inactive, QPalette::Shadow, QColor(15, 16, 18));
  139. fPalBlue.setColor(QPalette::Disabled, QPalette::Highlight, QColor(32, 35, 39));
  140. fPalBlue.setColor(QPalette::Active, QPalette::Highlight, QColor(14, 14, 17));
  141. fPalBlue.setColor(QPalette::Inactive, QPalette::Highlight, QColor(27, 28, 33));
  142. fPalBlue.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(89, 95, 104));
  143. fPalBlue.setColor(QPalette::Active, QPalette::HighlightedText, QColor(217, 234, 253));
  144. fPalBlue.setColor(QPalette::Inactive, QPalette::HighlightedText, QColor(223, 237, 255));
  145. fPalBlue.setColor(QPalette::Disabled, QPalette::Link, QColor(79, 100, 118));
  146. fPalBlue.setColor(QPalette::Active, QPalette::Link, QColor(156, 212, 255));
  147. fPalBlue.setColor(QPalette::Inactive, QPalette::Link, QColor(156, 212, 255));
  148. fPalBlue.setColor(QPalette::Disabled, QPalette::LinkVisited, QColor(51, 74, 118));
  149. fPalBlue.setColor(QPalette::Active, QPalette::LinkVisited, QColor(64, 128, 255));
  150. fPalBlue.setColor(QPalette::Inactive, QPalette::LinkVisited, QColor(64, 128, 255));
  151. loadSettings();
  152. }
  153. CarlaApplication::~CarlaApplication()
  154. {
  155. CARLA_SAFE_ASSERT_RETURN(fApp != nullptr,);
  156. if (fStyle != nullptr)
  157. {
  158. //delete fStyle;
  159. fStyle = nullptr;
  160. }
  161. delete fApp;
  162. fApp = nullptr;
  163. }
  164. void CarlaApplication::loadSettings()
  165. {
  166. CARLA_SAFE_ASSERT_RETURN(fApp != nullptr,);
  167. QSettings settings;
  168. const bool useProTheme(settings.value("Main/UseProTheme", true).toBool());
  169. if (useProTheme)
  170. {
  171. //QFont font("DejaVu Sans [Book]", 8, QFont::Normal);
  172. //fApp->setFont(font);
  173. //QApplication::setFont(font);
  174. // TODO
  175. if (fStyle == nullptr)
  176. fStyle = new CarlaStyle();
  177. fApp->setStyle(fStyle);
  178. QApplication::setStyle(fStyle);
  179. const QString proThemeColor(settings.value("Main/ProThemeColor", "Black").toString().toLower());
  180. if (proThemeColor == "black")
  181. fApp->setPalette(fPalBlack);
  182. else if (proThemeColor == "blue")
  183. fApp->setPalette(fPalBlue);
  184. }
  185. carla_stdout("Using \"%s\" theme", fApp->style()->objectName().toUtf8().constData());
  186. }
  187. // ------------------------------------------------------------------------------------------------------------