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.

CarlaStyle.hpp 3.7KB

11 years ago
10 years ago
10 years ago
10 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Carla Style, based on Qt5 fusion style
  3. * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies)
  4. * Copyright (C) 2013-2019 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. #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
  25. # include <QtWidgets/QCommonStyle>
  26. #else
  27. # ifdef __clang__
  28. # pragma clang diagnostic push
  29. # pragma clang diagnostic ignored "-Wdeprecated-register"
  30. # endif
  31. # if defined(__GNUC__) && __GNUC__ >= 8
  32. # pragma GCC diagnostic push
  33. # pragma GCC diagnostic ignored "-Wclass-memaccess"
  34. # pragma GCC diagnostic ignored "-Wdeprecated-copy"
  35. # endif
  36. # include <QtGui/QCommonStyle>
  37. # if defined(__GNUC__) && __GNUC__ >= 8
  38. # pragma GCC diagnostic pop
  39. # endif
  40. # ifdef __clang__
  41. # pragma clang diagnostic pop
  42. # endif
  43. #endif
  44. class CarlaStylePrivate;
  45. class CarlaStyle : public QCommonStyle
  46. {
  47. #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) && defined(__clang_major__) && __clang_major__ >= 4
  48. # pragma clang diagnostic push
  49. # pragma clang diagnostic ignored "-Winconsistent-missing-override"
  50. #endif
  51. Q_OBJECT
  52. #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) && defined(__clang_major__) && __clang_major__ >= 4
  53. # pragma clang diagnostic pop
  54. #endif
  55. public:
  56. CarlaStyle();
  57. ~CarlaStyle() override;
  58. QPalette standardPalette() const override;
  59. void drawPrimitive(PrimitiveElement elem, const QStyleOption* option, QPainter* painter,
  60. const QWidget* widget = nullptr) const override;
  61. void drawControl(ControlElement ce, const QStyleOption* option, QPainter* painter, const QWidget* widget) const override;
  62. int pixelMetric(PixelMetric metric, const QStyleOption* option = nullptr, const QWidget* widget = nullptr) const override;
  63. void drawComplexControl(ComplexControl control, const QStyleOptionComplex* option, QPainter* painter,
  64. const QWidget* widget) const override;
  65. QRect subElementRect(SubElement r, const QStyleOption* opt, const QWidget* widget = nullptr) const override;
  66. QSize sizeFromContents(ContentsType type, const QStyleOption* option, const QSize& size, const QWidget* widget) const override;
  67. QRect subControlRect(ComplexControl cc, const QStyleOptionComplex* opt, SubControl sc, const QWidget* widget) const override;
  68. QPixmap standardPixmap(StandardPixmap sp, const QStyleOption* opt = nullptr, const QWidget* widget = nullptr) const override;
  69. int styleHint(StyleHint hint, const QStyleOption* option = nullptr, const QWidget* widget = nullptr,
  70. QStyleHintReturn* returnData = nullptr) const override;
  71. void drawItemText(QPainter *painter, const QRect& rect, int flags, const QPalette& pal, bool enabled, const QString& text,
  72. QPalette::ColorRole textRole = QPalette::NoRole) const override;
  73. void polish(QApplication* app) override;
  74. void polish(QPalette& pal) override;
  75. void polish(QWidget* widget) override;
  76. void unpolish(QApplication* app) override;
  77. void unpolish(QWidget* widget) override;
  78. private:
  79. CarlaStylePrivate* const d;
  80. friend class CarlaStylePrivate;
  81. CARLA_DECLARE_NON_COPY_CLASS(CarlaStyle);
  82. };
  83. #endif // CARLA_STYLE_HPP_INCLUDED