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.

carla_style.cpp 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. // ------------------------------------------------------------------------------------------------------------
  23. CarlaApplication::CarlaApplication(int& argc, char* argv[], const QString& appName)
  24. : fApp(nullptr),
  25. fStyle(nullptr)
  26. {
  27. fApp = new QApplication(argc, argv, true);
  28. fApp->setApplicationName(appName);
  29. fApp->setApplicationVersion(VERSION);
  30. fApp->setOrganizationName("falkTX");
  31. if (appName.toLower() == "carla-control")
  32. fApp->setWindowIcon(QIcon(":/scalable/carla-control.svg"));
  33. else
  34. fApp->setWindowIcon(QIcon(":/scalable/carla.svg"));
  35. fPalSystem = fApp->palette();
  36. fPalBlack.setColor(QPalette::Disabled, QPalette::Window, QColor(14, 14, 14));
  37. fPalBlack.setColor(QPalette::Active, QPalette::Window, QColor(17, 17, 17));
  38. fPalBlack.setColor(QPalette::Inactive, QPalette::Window, QColor(17, 17, 17));
  39. fPalBlack.setColor(QPalette::Disabled, QPalette::WindowText, QColor(83, 83, 83));
  40. fPalBlack.setColor(QPalette::Active, QPalette::WindowText, QColor(240, 240, 240));
  41. fPalBlack.setColor(QPalette::Inactive, QPalette::WindowText, QColor(240, 240, 240));
  42. fPalBlack.setColor(QPalette::Disabled, QPalette::Base, QColor(6, 6, 6));
  43. fPalBlack.setColor(QPalette::Active, QPalette::Base, QColor(7, 7, 7));
  44. fPalBlack.setColor(QPalette::Inactive, QPalette::Base, QColor(7, 7, 7));
  45. fPalBlack.setColor(QPalette::Disabled, QPalette::AlternateBase, QColor(12, 12, 12));
  46. fPalBlack.setColor(QPalette::Active, QPalette::AlternateBase, QColor(14, 14, 14));
  47. fPalBlack.setColor(QPalette::Inactive, QPalette::AlternateBase, QColor(14, 14, 14));
  48. fPalBlack.setColor(QPalette::Disabled, QPalette::ToolTipBase, QColor(4, 4, 4));
  49. fPalBlack.setColor(QPalette::Active, QPalette::ToolTipBase, QColor(4, 4, 4));
  50. fPalBlack.setColor(QPalette::Inactive, QPalette::ToolTipBase, QColor(4, 4, 4));
  51. fPalBlack.setColor(QPalette::Disabled, QPalette::ToolTipText, QColor(230, 230, 230));
  52. fPalBlack.setColor(QPalette::Active, QPalette::ToolTipText, QColor(230, 230, 230));
  53. fPalBlack.setColor(QPalette::Inactive, QPalette::ToolTipText, QColor(230, 230, 230));
  54. fPalBlack.setColor(QPalette::Disabled, QPalette::Text, QColor(74, 74, 74));
  55. fPalBlack.setColor(QPalette::Active, QPalette::Text, QColor(230, 230, 230));
  56. fPalBlack.setColor(QPalette::Inactive, QPalette::Text, QColor(230, 230, 230));
  57. fPalBlack.setColor(QPalette::Disabled, QPalette::Button, QColor(24, 24, 24));
  58. fPalBlack.setColor(QPalette::Active, QPalette::Button, QColor(28, 28, 28));
  59. fPalBlack.setColor(QPalette::Inactive, QPalette::Button, QColor(28, 28, 28));
  60. fPalBlack.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(90, 90, 90));
  61. fPalBlack.setColor(QPalette::Active, QPalette::ButtonText, QColor(240, 240, 240));
  62. fPalBlack.setColor(QPalette::Inactive, QPalette::ButtonText, QColor(240, 240, 240));
  63. fPalBlack.setColor(QPalette::Disabled, QPalette::BrightText, QColor(255, 255, 255));
  64. fPalBlack.setColor(QPalette::Active, QPalette::BrightText, QColor(255, 255, 255));
  65. fPalBlack.setColor(QPalette::Inactive, QPalette::BrightText, QColor(255, 255, 255));
  66. fPalBlack.setColor(QPalette::Disabled, QPalette::Light, QColor(191, 191, 191));
  67. fPalBlack.setColor(QPalette::Active, QPalette::Light, QColor(191, 191, 191));
  68. fPalBlack.setColor(QPalette::Inactive, QPalette::Light, QColor(191, 191, 191));
  69. fPalBlack.setColor(QPalette::Disabled, QPalette::Midlight, QColor(155, 155, 155));
  70. fPalBlack.setColor(QPalette::Active, QPalette::Midlight, QColor(155, 155, 155));
  71. fPalBlack.setColor(QPalette::Inactive, QPalette::Midlight, QColor(155, 155, 155));
  72. fPalBlack.setColor(QPalette::Disabled, QPalette::Dark, QColor(129, 129, 129));
  73. fPalBlack.setColor(QPalette::Active, QPalette::Dark, QColor(129, 129, 129));
  74. fPalBlack.setColor(QPalette::Inactive, QPalette::Dark, QColor(129, 129, 129));
  75. fPalBlack.setColor(QPalette::Disabled, QPalette::Mid, QColor(94, 94, 94));
  76. fPalBlack.setColor(QPalette::Active, QPalette::Mid, QColor(94, 94, 94));
  77. fPalBlack.setColor(QPalette::Inactive, QPalette::Mid, QColor(94, 94, 94));
  78. fPalBlack.setColor(QPalette::Disabled, QPalette::Shadow, QColor(155, 155, 155));
  79. fPalBlack.setColor(QPalette::Active, QPalette::Shadow, QColor(155, 155, 155));
  80. fPalBlack.setColor(QPalette::Inactive, QPalette::Shadow, QColor(155, 155, 155));
  81. fPalBlack.setColor(QPalette::Disabled, QPalette::Highlight, QColor(14, 14, 14));
  82. fPalBlack.setColor(QPalette::Active, QPalette::Highlight, QColor(60, 60, 60));
  83. fPalBlack.setColor(QPalette::Inactive, QPalette::Highlight, QColor(34, 34, 34));
  84. fPalBlack.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(83, 83, 83));
  85. fPalBlack.setColor(QPalette::Active, QPalette::HighlightedText, QColor(255, 255, 255));
  86. fPalBlack.setColor(QPalette::Inactive, QPalette::HighlightedText, QColor(240, 240, 240));
  87. fPalBlack.setColor(QPalette::Disabled, QPalette::Link, QColor(34, 34, 74));
  88. fPalBlack.setColor(QPalette::Active, QPalette::Link, QColor(100, 100, 230));
  89. fPalBlack.setColor(QPalette::Inactive, QPalette::Link, QColor(100, 100, 230));
  90. fPalBlack.setColor(QPalette::Disabled, QPalette::LinkVisited, QColor(74, 34, 74));
  91. fPalBlack.setColor(QPalette::Active, QPalette::LinkVisited, QColor(230, 100, 230));
  92. fPalBlack.setColor(QPalette::Inactive, QPalette::LinkVisited, QColor(230, 100, 230));
  93. fPalBlue.setColor(QPalette::Disabled, QPalette::Window, QColor(32, 35, 39));
  94. fPalBlue.setColor(QPalette::Active, QPalette::Window, QColor(37, 40, 45));
  95. fPalBlue.setColor(QPalette::Inactive, QPalette::Window, QColor(37, 40, 45));
  96. fPalBlue.setColor(QPalette::Disabled, QPalette::WindowText, QColor(89, 95, 104));
  97. fPalBlue.setColor(QPalette::Active, QPalette::WindowText, QColor(223, 237, 255));
  98. fPalBlue.setColor(QPalette::Inactive, QPalette::WindowText, QColor(223, 237, 255));
  99. fPalBlue.setColor(QPalette::Disabled, QPalette::Base, QColor(48, 53, 60));
  100. fPalBlue.setColor(QPalette::Active, QPalette::Base, QColor(55, 61, 69));
  101. fPalBlue.setColor(QPalette::Inactive, QPalette::Base, QColor(55, 61, 69));
  102. fPalBlue.setColor(QPalette::Disabled, QPalette::AlternateBase, QColor(60, 64, 67));
  103. fPalBlue.setColor(QPalette::Active, QPalette::AlternateBase, QColor(69, 73, 77));
  104. fPalBlue.setColor(QPalette::Inactive, QPalette::AlternateBase, QColor(69, 73, 77));
  105. fPalBlue.setColor(QPalette::Disabled, QPalette::ToolTipBase, QColor(182, 193, 208));
  106. fPalBlue.setColor(QPalette::Active, QPalette::ToolTipBase, QColor(182, 193, 208));
  107. fPalBlue.setColor(QPalette::Inactive, QPalette::ToolTipBase, QColor(182, 193, 208));
  108. fPalBlue.setColor(QPalette::Disabled, QPalette::ToolTipText, QColor(42, 44, 48));
  109. fPalBlue.setColor(QPalette::Active, QPalette::ToolTipText, QColor(42, 44, 48));
  110. fPalBlue.setColor(QPalette::Inactive, QPalette::ToolTipText, QColor(42, 44, 48));
  111. fPalBlue.setColor(QPalette::Disabled, QPalette::Text, QColor(96, 103, 113));
  112. fPalBlue.setColor(QPalette::Active, QPalette::Text, QColor(210, 222, 240));
  113. fPalBlue.setColor(QPalette::Inactive, QPalette::Text, QColor(210, 222, 240));
  114. fPalBlue.setColor(QPalette::Disabled, QPalette::Button, QColor(51, 55, 62));
  115. fPalBlue.setColor(QPalette::Active, QPalette::Button, QColor(59, 63, 71));
  116. fPalBlue.setColor(QPalette::Inactive, QPalette::Button, QColor(59, 63, 71));
  117. fPalBlue.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(98, 104, 114));
  118. fPalBlue.setColor(QPalette::Active, QPalette::ButtonText, QColor(210, 222, 240));
  119. fPalBlue.setColor(QPalette::Inactive, QPalette::ButtonText, QColor(210, 222, 240));
  120. fPalBlue.setColor(QPalette::Disabled, QPalette::BrightText, QColor(255, 255, 255));
  121. fPalBlue.setColor(QPalette::Active, QPalette::BrightText, QColor(255, 255, 255));
  122. fPalBlue.setColor(QPalette::Inactive, QPalette::BrightText, QColor(255, 255, 255));
  123. fPalBlue.setColor(QPalette::Disabled, QPalette::Light, QColor(59, 64, 72));
  124. fPalBlue.setColor(QPalette::Active, QPalette::Light, QColor(63, 68, 76));
  125. fPalBlue.setColor(QPalette::Inactive, QPalette::Light, QColor(63, 68, 76));
  126. fPalBlue.setColor(QPalette::Disabled, QPalette::Midlight, QColor(48, 52, 59));
  127. fPalBlue.setColor(QPalette::Active, QPalette::Midlight, QColor(51, 56, 63));
  128. fPalBlue.setColor(QPalette::Inactive, QPalette::Midlight, QColor(51, 56, 63));
  129. fPalBlue.setColor(QPalette::Disabled, QPalette::Dark, QColor(18, 19, 22));
  130. fPalBlue.setColor(QPalette::Active, QPalette::Dark, QColor(20, 22, 25));
  131. fPalBlue.setColor(QPalette::Inactive, QPalette::Dark, QColor(20, 22, 25));
  132. fPalBlue.setColor(QPalette::Disabled, QPalette::Mid, QColor(28, 30, 34));
  133. fPalBlue.setColor(QPalette::Active, QPalette::Mid, QColor(32, 35, 39));
  134. fPalBlue.setColor(QPalette::Inactive, QPalette::Mid, QColor(32, 35, 39));
  135. fPalBlue.setColor(QPalette::Disabled, QPalette::Shadow, QColor(13, 14, 16));
  136. fPalBlue.setColor(QPalette::Active, QPalette::Shadow, QColor(15, 16, 18));
  137. fPalBlue.setColor(QPalette::Inactive, QPalette::Shadow, QColor(15, 16, 18));
  138. fPalBlue.setColor(QPalette::Disabled, QPalette::Highlight, QColor(32, 35, 39));
  139. fPalBlue.setColor(QPalette::Active, QPalette::Highlight, QColor(14, 14, 17));
  140. fPalBlue.setColor(QPalette::Inactive, QPalette::Highlight, QColor(27, 28, 33));
  141. fPalBlue.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(89, 95, 104));
  142. fPalBlue.setColor(QPalette::Active, QPalette::HighlightedText, QColor(217, 234, 253));
  143. fPalBlue.setColor(QPalette::Inactive, QPalette::HighlightedText, QColor(223, 237, 255));
  144. fPalBlue.setColor(QPalette::Disabled, QPalette::Link, QColor(79, 100, 118));
  145. fPalBlue.setColor(QPalette::Active, QPalette::Link, QColor(156, 212, 255));
  146. fPalBlue.setColor(QPalette::Inactive, QPalette::Link, QColor(156, 212, 255));
  147. fPalBlue.setColor(QPalette::Disabled, QPalette::LinkVisited, QColor(51, 74, 118));
  148. fPalBlue.setColor(QPalette::Active, QPalette::LinkVisited, QColor(64, 128, 255));
  149. fPalBlue.setColor(QPalette::Inactive, QPalette::LinkVisited, QColor(64, 128, 255));
  150. loadSettings();
  151. }
  152. CarlaApplication::~CarlaApplication()
  153. {
  154. CARLA_SAFE_ASSERT_RETURN(fApp != nullptr,);
  155. if (fStyle != nullptr)
  156. {
  157. //delete fStyle;
  158. fStyle = nullptr;
  159. }
  160. delete fApp;
  161. fApp = nullptr;
  162. }
  163. void CarlaApplication::loadSettings()
  164. {
  165. CARLA_SAFE_ASSERT_RETURN(fApp != nullptr,);
  166. QSettings settings;
  167. const bool useProTheme(settings.value("Main/UseProTheme", true).toBool());
  168. if (useProTheme)
  169. {
  170. //QFont font("DejaVu Sans [Book]", 8, QFont::Normal);
  171. //fApp->setFont(font);
  172. //QApplication::setFont(font);
  173. // TODO
  174. if (fStyle == nullptr)
  175. fStyle = new CarlaStyle();
  176. fApp->setStyle(fStyle);
  177. QApplication::setStyle(fStyle);
  178. const QString proThemeColor(settings.value("Main/ProThemeColor", "Black").toString().toLower());
  179. if (proThemeColor == "black")
  180. fApp->setPalette(fPalBlack);
  181. else if (proThemeColor == "blue")
  182. fApp->setPalette(fPalBlue);
  183. }
  184. carla_stdout("Using \"%s\" theme", fApp->style()->objectName().toUtf8().constData());
  185. }
  186. // ------------------------------------------------------------------------------------------------------------