2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-07-15 12:38:45 +02:00
|
|
|
#include "utils_global.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QStyle>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-10-01 16:38:08 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QPalette;
|
|
|
|
|
class QPainter;
|
|
|
|
|
class QRect;
|
2010-03-15 17:09:57 +01:00
|
|
|
// Note, this is exported but in a private header as qtopengl depends on it.
|
|
|
|
|
// We should consider adding this as a public helper function.
|
2010-03-16 12:08:17 +01:00
|
|
|
void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0);
|
|
|
|
|
QT_END_NAMESPACE
|
2010-03-15 17:09:57 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// Helper class holding all custom color values
|
|
|
|
|
|
2009-10-05 11:06:05 +02:00
|
|
|
namespace Utils {
|
2009-07-15 12:38:45 +02:00
|
|
|
class QTCREATOR_UTILS_EXPORT StyleHelper
|
2008-12-02 15:08:31 +01:00
|
|
|
{
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2010-05-27 16:07:52 +02:00
|
|
|
static const unsigned int DEFAULT_BASE_COLOR = 0x666666;
|
2013-03-22 14:14:21 +01:00
|
|
|
static const int progressFadeAnimationDuration = 600;
|
2010-05-27 16:07:52 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// Height of the project explorer navigation bar
|
|
|
|
|
static int navigationWidgetHeight() { return 24; }
|
|
|
|
|
static qreal sidebarFontSize();
|
|
|
|
|
static QPalette sidebarFontPalette(const QPalette &original);
|
|
|
|
|
|
|
|
|
|
// This is our color table, all colors derive from baseColor
|
2010-03-03 11:02:13 +01:00
|
|
|
static QColor requestedBaseColor() { return m_requestedBaseColor; }
|
2010-02-19 09:54:29 +01:00
|
|
|
static QColor baseColor(bool lightColored = false);
|
2023-01-30 17:25:10 +01:00
|
|
|
static QColor toolbarBaseColor(bool lightColored = false);
|
2010-02-19 09:54:29 +01:00
|
|
|
static QColor panelTextColor(bool lightColored = false);
|
|
|
|
|
static QColor highlightColor(bool lightColored = false);
|
|
|
|
|
static QColor shadowColor(bool lightColored = false);
|
|
|
|
|
static QColor borderColor(bool lightColored = false);
|
2016-07-19 18:24:25 +02:00
|
|
|
static QColor toolBarBorderColor();
|
2008-12-02 12:01:29 +01:00
|
|
|
static QColor buttonTextColor() { return QColor(0x4c4c4c); }
|
2009-06-05 13:59:10 +02:00
|
|
|
static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50);
|
2016-06-17 19:00:59 +02:00
|
|
|
static QColor alphaBlendedColors(const QColor &colorA, const QColor &colorB);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-18 11:41:58 +01:00
|
|
|
static QColor sidebarHighlight() { return QColor(255, 255, 255, 40); }
|
|
|
|
|
static QColor sidebarShadow() { return QColor(0, 0, 0, 40); }
|
|
|
|
|
|
2016-03-29 17:36:49 +02:00
|
|
|
static QColor toolBarDropShadowColor() { return QColor(0, 0, 0, 70); }
|
|
|
|
|
|
2014-06-06 16:06:32 +02:00
|
|
|
static QColor notTooBrightHighlightColor();
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// Sets the base color and makes sure all top level widgets are updated
|
|
|
|
|
static void setBaseColor(const QColor &color);
|
|
|
|
|
|
2010-02-17 17:09:00 +01:00
|
|
|
// Draws a shaded anti-aliased arrow
|
|
|
|
|
static void drawArrow(QStyle::PrimitiveElement element, QPainter *painter, const QStyleOption *option);
|
2023-01-20 14:06:19 +02:00
|
|
|
static void drawMinimalArrow(QStyle::PrimitiveElement element, QPainter *painter, const QStyleOption *option);
|
2010-02-17 17:09:00 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// Gradients used for panels
|
2010-02-19 09:54:29 +01:00
|
|
|
static void horizontalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false);
|
|
|
|
|
static void verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false);
|
2008-12-02 12:01:29 +01:00
|
|
|
static void menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect);
|
2009-01-26 15:27:04 +01:00
|
|
|
static bool usePixmapCache() { return true; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-11-11 19:26:58 +01:00
|
|
|
static QPixmap disabledSideBarIcon(const QPixmap &enabledicon);
|
2010-03-23 15:47:43 +01:00
|
|
|
static void drawIconWithShadow(const QIcon &icon, const QRect &rect, QPainter *p, QIcon::Mode iconMode,
|
2013-01-16 22:06:59 +01:00
|
|
|
int dipRadius = 3, const QColor &color = QColor(0, 0, 0, 130),
|
|
|
|
|
const QPoint &dipOffset = QPoint(1, -2));
|
2014-05-19 18:26:28 +03:00
|
|
|
static void drawCornerImage(const QImage &img, QPainter *painter, const QRect &rect,
|
2010-02-24 19:23:40 +01:00
|
|
|
int left = 0, int top = 0, int right = 0, int bottom = 0);
|
|
|
|
|
|
2010-08-02 17:02:53 +02:00
|
|
|
static void tintImage(QImage &img, const QColor &tintColor);
|
2013-03-22 14:06:42 +01:00
|
|
|
static QLinearGradient statusBarGradient(const QRect &statusBarRect);
|
2010-08-02 17:02:53 +02:00
|
|
|
|
2023-01-30 17:25:10 +01:00
|
|
|
static bool isQDSTheme();
|
|
|
|
|
|
2020-07-13 17:17:39 +02:00
|
|
|
class IconFontHelper
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
IconFontHelper(const QString &iconSymbol,
|
|
|
|
|
const QColor &color,
|
|
|
|
|
const QSize &size,
|
|
|
|
|
QIcon::Mode mode = QIcon::Normal,
|
|
|
|
|
QIcon::State state = QIcon::Off)
|
|
|
|
|
: m_iconSymbol(iconSymbol)
|
|
|
|
|
, m_color(color)
|
|
|
|
|
, m_size(size)
|
|
|
|
|
, m_mode(mode)
|
|
|
|
|
, m_state(state)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
QString iconSymbol() const { return m_iconSymbol; }
|
|
|
|
|
QColor color() const { return m_color; }
|
|
|
|
|
QSize size() const { return m_size; }
|
|
|
|
|
QIcon::Mode mode() const { return m_mode; }
|
|
|
|
|
QIcon::State state() const { return m_state; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QString m_iconSymbol;
|
|
|
|
|
QColor m_color;
|
|
|
|
|
QSize m_size;
|
|
|
|
|
QIcon::Mode m_mode;
|
|
|
|
|
QIcon::State m_state;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static QIcon getIconFromIconFont(const QString &fontName, const QList<IconFontHelper> ¶meters);
|
2020-04-20 09:34:38 +02:00
|
|
|
static QIcon getIconFromIconFont(const QString &fontName, const QString &iconSymbol, int fontSize, int iconSize, QColor color);
|
|
|
|
|
static QIcon getIconFromIconFont(const QString &fontName, const QString &iconSymbol, int fontSize, int iconSize);
|
2020-11-18 16:28:16 +01:00
|
|
|
static QIcon getCursorFromIconFont(const QString &fontname, const QString &cursorFill, const QString &cursorOutline,
|
|
|
|
|
int fontSize, int iconSize);
|
2020-04-07 19:17:33 +02:00
|
|
|
|
2014-07-24 15:24:58 +02:00
|
|
|
static QString dpiSpecificImageFile(const QString &fileName);
|
2015-10-15 16:34:54 +02:00
|
|
|
static QString imageFileWithResolution(const QString &fileName, int dpr);
|
|
|
|
|
static QList<int> availableImageResolutions(const QString &fileName);
|
2014-07-09 13:20:53 +02:00
|
|
|
|
2019-11-14 14:11:34 +01:00
|
|
|
static double luminance(const QColor &color);
|
2019-11-14 14:12:59 +01:00
|
|
|
static bool isReadableOn(const QColor &background, const QColor &foreground);
|
2023-01-20 11:20:53 +01:00
|
|
|
// returns a foreground color readable on background (desiredForeground if already readable or adaption fails)
|
|
|
|
|
static QColor ensureReadableOn(const QColor &background, const QColor &desiredForeground);
|
2019-11-14 14:12:59 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
|
|
|
|
static QColor m_baseColor;
|
2010-03-03 11:02:13 +01:00
|
|
|
static QColor m_requestedBaseColor;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2009-10-05 11:06:05 +02:00
|
|
|
} // namespace Utils
|