Cleanup
[carla.git] / source / theme / CarlaStyle.hpp
blob4c0ae3d138d8e43047ab8121b5f3c840dfdfad40
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>
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.
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.
15 * For a full copy of the license see the doc/LGPL.txt file
18 #ifndef CARLA_STYLE_HPP_INCLUDED
19 #define CARLA_STYLE_HPP_INCLUDED
21 #include "CarlaDefines.h"
22 #undef noexcept
23 #undef override
24 #undef final
26 #include <QtCore/Qt>
28 #if defined(__GNUC__) && __GNUC__ >= 8
29 # pragma GCC diagnostic push
30 # pragma GCC diagnostic ignored "-Wdeprecated-copy"
31 #endif
33 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
34 # include <QtWidgets/QCommonStyle>
35 #else
36 # ifdef __clang__
37 # pragma clang diagnostic push
38 # pragma clang diagnostic ignored "-Wdeprecated-register"
39 # endif
40 # if defined(__GNUC__) && __GNUC__ >= 8
41 # pragma GCC diagnostic ignored "-Wclass-memaccess"
42 # endif
43 # include <QtGui/QCommonStyle>
44 # ifdef __clang__
45 # pragma clang diagnostic pop
46 # endif
47 #endif
49 #if defined(__GNUC__) && __GNUC__ >= 8
50 # pragma GCC diagnostic pop
51 #endif
53 class CarlaStylePrivate;
55 class CarlaStyle : public QCommonStyle
57 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) && defined(__clang_major__) && __clang_major__ >= 4
58 # pragma clang diagnostic push
59 # pragma clang diagnostic ignored "-Winconsistent-missing-override"
60 #endif
61 Q_OBJECT
62 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) && defined(__clang_major__) && __clang_major__ >= 4
63 # pragma clang diagnostic pop
64 #endif
66 public:
67 CarlaStyle();
68 ~CarlaStyle() override;
70 QPalette standardPalette() const override;
71 void drawPrimitive(PrimitiveElement elem, const QStyleOption* option, QPainter* painter,
72 const QWidget* widget = nullptr) const override;
73 void drawControl(ControlElement ce, const QStyleOption* option, QPainter* painter, const QWidget* widget) const override;
74 int pixelMetric(PixelMetric metric, const QStyleOption* option = nullptr, const QWidget* widget = nullptr) const override;
75 void drawComplexControl(ComplexControl control, const QStyleOptionComplex* option, QPainter* painter,
76 const QWidget* widget) const override;
77 QRect subElementRect(SubElement r, const QStyleOption* opt, const QWidget* widget = nullptr) const override;
78 QSize sizeFromContents(ContentsType type, const QStyleOption* option, const QSize& size, const QWidget* widget) const override;
79 QRect subControlRect(ComplexControl cc, const QStyleOptionComplex* opt, SubControl sc, const QWidget* widget) const override;
80 QPixmap standardPixmap(StandardPixmap sp, const QStyleOption* opt = nullptr, const QWidget* widget = nullptr) const override;
81 int styleHint(StyleHint hint, const QStyleOption* option = nullptr, const QWidget* widget = nullptr,
82 QStyleHintReturn* returnData = nullptr) const override;
83 void drawItemText(QPainter *painter, const QRect& rect, int flags, const QPalette& pal, bool enabled, const QString& text,
84 QPalette::ColorRole textRole = QPalette::NoRole) const override;
85 void polish(QApplication* app) override;
86 void polish(QPalette& pal) override;
87 void polish(QWidget* widget) override;
88 void unpolish(QApplication* app) override;
89 void unpolish(QWidget* widget) override;
91 private:
92 CarlaStylePrivate* const d;
93 friend class CarlaStylePrivate;
95 CARLA_DECLARE_NON_COPYABLE(CarlaStyle);
98 #endif // CARLA_STYLE_HPP_INCLUDED