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.

94 lines
3.5KB

  1. /*
  2. * Carla Style, based on Qt5 fusion style
  3. * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies)
  4. * Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation.
  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 Lesser General Public License for more details.
  14. *
  15. * For a full copy of the license see the doc/LGPL.txt file
  16. */
  17. #ifndef CARLA_STYLE_HPP_INCLUDED
  18. #define CARLA_STYLE_HPP_INCLUDED
  19. #include "CarlaDefines.h"
  20. #undef noexcept
  21. #undef override
  22. #undef final
  23. #include <QtCore/Qt>
  24. #ifdef CARLA_OS_MAC
  25. # undef Q_COMPILER_UNICODE_STRINGS
  26. # undef Q_DECL_CONSTEXPR
  27. # undef Q_DECL_NOEXCEPT_EXPR
  28. # define Q_DECL_CONSTEXPR
  29. # define Q_DECL_NOEXCEPT_EXPR(x)
  30. #endif
  31. #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
  32. # include <QtWidgets/QCommonStyle>
  33. #else
  34. # ifdef __clang__
  35. # pragma clang diagnostic push
  36. # pragma clang diagnostic ignored "-Wdeprecated-register"
  37. # endif
  38. # include <QtGui/QCommonStyle>
  39. # ifdef __clang__
  40. # pragma clang diagnostic pop
  41. # endif
  42. #endif
  43. class CarlaStylePrivate;
  44. class CarlaStyle : public QCommonStyle
  45. {
  46. #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) && defined(__clang_major__) && __clang_major__ >= 4
  47. # pragma clang diagnostic push
  48. # pragma clang diagnostic ignored "-Winconsistent-missing-override"
  49. #endif
  50. Q_OBJECT
  51. #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) && defined(__clang_major__) && __clang_major__ >= 4
  52. # pragma clang diagnostic pop
  53. #endif
  54. public:
  55. CarlaStyle();
  56. ~CarlaStyle() override;
  57. QPalette standardPalette() const override;
  58. void drawPrimitive(PrimitiveElement elem, const QStyleOption* option, QPainter* painter,
  59. const QWidget* widget = nullptr) const override;
  60. void drawControl(ControlElement ce, const QStyleOption* option, QPainter* painter, const QWidget* widget) const override;
  61. int pixelMetric(PixelMetric metric, const QStyleOption* option = nullptr, const QWidget* widget = nullptr) const override;
  62. void drawComplexControl(ComplexControl control, const QStyleOptionComplex* option, QPainter* painter,
  63. const QWidget* widget) const override;
  64. QRect subElementRect(SubElement r, const QStyleOption* opt, const QWidget* widget = nullptr) const override;
  65. QSize sizeFromContents(ContentsType type, const QStyleOption* option, const QSize& size, const QWidget* widget) const override;
  66. QRect subControlRect(ComplexControl cc, const QStyleOptionComplex* opt, SubControl sc, const QWidget* widget) const override;
  67. int styleHint(StyleHint hint, const QStyleOption* option = nullptr, const QWidget* widget = nullptr,
  68. QStyleHintReturn* returnData = nullptr) const override;
  69. void drawItemText(QPainter *painter, const QRect& rect, int flags, const QPalette& pal, bool enabled, const QString& text,
  70. QPalette::ColorRole textRole = QPalette::NoRole) const override;
  71. void polish(QApplication* app) override;
  72. void polish(QPalette& pal) override;
  73. void polish(QWidget* widget) override;
  74. void unpolish(QApplication* app) override;
  75. void unpolish(QWidget* widget) override;
  76. private:
  77. CarlaStylePrivate* const d;
  78. friend class CarlaStylePrivate;
  79. CARLA_DECLARE_NON_COPY_CLASS(CarlaStyle);
  80. };
  81. #endif // CARLA_STYLE_HPP_INCLUDED