| 1 | /************************************************************************** |
| 2 | ** |
| 3 | ** This file is part of Qt Creator |
| 4 | ** |
| 5 | ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
| 6 | ** |
| 7 | ** Contact: Nokia Corporation ([email protected]) |
| 8 | ** |
| 9 | ** Commercial Usage |
| 10 | ** |
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in |
| 12 | ** accordance with the Qt Commercial License Agreement provided with the |
| 13 | ** Software or, alternatively, in accordance with the terms contained in |
| 14 | ** a written agreement between you and Nokia. |
| 15 | ** |
| 16 | ** GNU Lesser General Public License Usage |
| 17 | ** |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 2.1 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| 24 | ** |
| 25 | ** If you are unsure which license is appropriate for your use, please |
| 26 | ** contact the sales department at http://qt.nokia.com/contact. |
| 27 | ** |
| 28 | **************************************************************************/ |
| 29 | |
| 30 | #ifndef STYLEHELPER_H |
| 31 | #define STYLEHELPER_H |
| 32 | |
| 33 | #include <QtGui/QColor> |
| 34 | #include <QStyle> |
| 35 | |
| 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 |
| 44 | |
| 45 | // Helper class holding all custom color values |
| 46 | |
| 47 | namespace Utils { |
| 48 | class StyleHelper |
| 49 | { |
| 50 | public: |
| 51 | static const unsigned int DEFAULT_BASE_COLOR = 0x666666; |
| 52 | |
| 53 | // Height of the project explorer navigation bar |
| 54 | static qreal sidebarFontSize(); |
| 55 | |
| 56 | // This is our color table, all colors derive from baseColor |
| 57 | static QColor requestedBaseColor() { return m_requestedBaseColor; } |
| 58 | static QColor baseColor(bool lightColored = false); |
| 59 | static QColor panelTextColor(bool lightColored = false); |
| 60 | static QColor highlightColor(bool lightColored = false); |
| 61 | static QColor shadowColor(bool lightColored = false); |
| 62 | static QColor borderColor(bool lightColored = false); |
| 63 | |
| 64 | static QColor sidebarHighlight() { return QColor(255, 255, 255, 40); } |
| 65 | static QColor sidebarShadow() { return QColor(0, 0, 0, 40); } |
| 66 | |
| 67 | // Sets the base color and makes sure all top level widgets are updated |
| 68 | static void setBaseColor(const QColor &color); |
| 69 | |
| 70 | // Gradients used for panels |
| 71 | static void verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false); |
| 72 | static bool usePixmapCache() { return true; } |
| 73 | |
| 74 | static void drawIconWithShadow(const QIcon &icon, const QRect &rect, QPainter *p, QIcon::Mode iconMode, |
| 75 | int radius = 3, const QColor &color = QColor(0, 0, 0, 130), |
| 76 | const QPoint &offset = QPoint(1, -2)); |
| 77 | |
| 78 | private: |
| 79 | static QColor m_baseColor; |
| 80 | static QColor m_requestedBaseColor; |
| 81 | }; |
| 82 | |
| 83 | } // namespace Utils |
| 84 | |
| 85 | using Utils::StyleHelper; |
| 86 | #endif // STYLEHELPER_H |