File indexing completed on 2024-05-12 04:57:49

0001 /**************************************************************************
0002 **
0003 ** This file is part of Qt Creator
0004 **
0005 ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
0006 **
0007 ** Contact: Nokia Corporation (qt-info@nokia.com)
0008 **
0009 ** Commercial Usage
0010 **
0011 ** Licensees holding valid Qt Commercial licenses may use this file in
0012 ** accordance with the Qt Commercial License Agreement provided with the
0013 ** Software or, alternatively, in accordance with the terms contained in
0014 ** a written agreement between you and Nokia.
0015 **
0016 ** GNU Lesser General Public License Usage
0017 **
0018 ** Alternatively, this file may be used under the terms of the GNU Lesser
0019 ** General Public License version 2.1 as published by the Free Software
0020 ** Foundation and appearing in the file LICENSE.LGPL included in the
0021 ** packaging of this file.  Please review the following information to
0022 ** ensure the GNU Lesser General Public License version 2.1 requirements
0023 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
0024 **
0025 ** If you are unsure which license is appropriate for your use, please
0026 ** contact the sales department at http://qt.nokia.com/contact.
0027 **
0028 **************************************************************************/
0029 
0030 #ifndef STYLEHELPER_H
0031 #define STYLEHELPER_H
0032 
0033 #include "qzcommon.h"
0034 
0035 #include <QColor>
0036 #include <QStyle>
0037 
0038 QT_BEGIN_NAMESPACE
0039 class QPalette;
0040 class QPainter;
0041 class QRect;
0042 // Note, this is exported but in a private header as qtopengl depends on it.
0043 // We should consider adding this as a public helper function.
0044 void qt_blurImage(QPainter* p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0);
0045 QT_END_NAMESPACE
0046 
0047 // Helper class holding all custom color values
0048 
0049 namespace Utils
0050 {
0051 class StyleHelper
0052 {
0053 public:
0054     static const unsigned int DEFAULT_BASE_COLOR = 0x666666;
0055 
0056     // Height of the project explorer navigation bar
0057     static qreal sidebarFontSize();
0058 
0059     // This is our color table, all colors derive from baseColor
0060     static QColor requestedBaseColor() { return m_requestedBaseColor; }
0061     static QColor baseColor(bool lightColored = false);
0062     static QColor panelTextColor(bool lightColored = false);
0063     static QColor highlightColor(bool lightColored = false);
0064     static QColor shadowColor(bool lightColored = false);
0065     static QColor borderColor(bool lightColored = false);
0066 
0067     static QColor sidebarHighlight() { return {255, 255, 255, 40}; }
0068     static QColor sidebarShadow() { return {0, 0, 0, 40}; }
0069 
0070     // Sets the base color and makes sure all top level widgets are updated
0071     static void setBaseColor(const QColor &color);
0072 
0073     // Gradients used for panels
0074     static void verticalGradient(QPainter* painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false);
0075     static bool usePixmapCache() { return true; }
0076 
0077     static void drawIconWithShadow(const QIcon &icon, const QRect &rect, QPainter* p, QIcon::Mode iconMode,
0078                                    int radius = 3, const QColor &color = QColor(0, 0, 0, 130),
0079                                    const QPoint &offset = QPoint(1, -2));
0080 
0081 private:
0082     static QColor m_baseColor;
0083     static QColor m_requestedBaseColor;
0084 };
0085 
0086 } // namespace Utils
0087 
0088 using Utils::StyleHelper;
0089 #endif // STYLEHELPER_H