LP-311 Remove basic/advanced stabilization tab auto-switch (autotune/txpid lock issues)
[librepilot.git] / ground / gcs / src / libs / utils / stylehelper.h
bloba493a9f0b2b79033f839f14cb3b066cfaf691cf7
1 /**
2 ******************************************************************************
4 * @file stylehelper.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
7 * @brief
8 * @see The GNU Public License (GPL) Version 3
9 * @defgroup
10 * @{
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef STYLEHELPER_H
30 #define STYLEHELPER_H
32 #include "utils_global.h"
34 #include <QStyle>
36 QT_BEGIN_NAMESPACE
37 class QPalette;
38 class QPainter;
39 class QRect;
40 // Note, this is exported but in a private header as qtopengl depends on it.
41 // We should consider adding this as a public helper function.
42 void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0);
43 QT_END_NAMESPACE
45 // Helper class holding all custom color values
47 namespace Utils {
48 class QTCREATOR_UTILS_EXPORT StyleHelper {
49 public:
50 static const unsigned int DEFAULT_BASE_COLOR = 0x666666;
51 static const int progressFadeAnimationDuration = 600;
53 // Height of the project explorer navigation bar
54 static int navigationWidgetHeight()
56 return 24;
58 static qreal sidebarFontSize();
59 static QPalette sidebarFontPalette(const QPalette &original);
61 // This is our color table, all colors derive from baseColor
62 static QColor requestedBaseColor()
64 return m_requestedBaseColor;
66 static QColor baseColor(bool lightColored = false);
67 static QColor panelTextColor(bool lightColored = false);
68 static QColor highlightColor(bool lightColored = false);
69 static QColor shadowColor(bool lightColored = false);
70 static QColor borderColor(bool lightColored = false);
71 static QColor buttonTextColor()
73 return QColor(0x4c4c4c);
75 static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50);
77 static QColor sidebarHighlight()
79 return QColor(255, 255, 255, 40);
81 static QColor sidebarShadow()
83 return QColor(0, 0, 0, 40);
86 // Sets the base color and makes sure all top level widgets are updated
87 static void setBaseColor(const QColor &color);
89 // Draws a shaded anti-aliased arrow
90 static void drawArrow(QStyle::PrimitiveElement element, QPainter *painter, const QStyleOption *option);
92 // Gradients used for panels
93 static void horizontalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false);
94 static void verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false);
95 static void menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect);
96 static bool usePixmapCache()
98 return true;
101 static void drawIconWithShadow(const QIcon &icon, const QRect &rect, QPainter *p, QIcon::Mode iconMode,
102 int dipRadius = 3, const QColor &color = QColor(0, 0, 0, 130),
103 const QPoint &dipOffset = QPoint(1, -2));
104 static void drawCornerImage(const QImage &img, QPainter *painter, QRect rect,
105 int left = 0, int top = 0, int right = 0, int bottom = 0);
107 static void tintImage(QImage &img, const QColor &tintColor);
108 static QLinearGradient statusBarGradient(const QRect &statusBarRect);
110 private:
111 static QColor m_baseColor;
112 static QColor m_requestedBaseColor;
114 } // namespace Utils
115 #endif // STYLEHELPER_H