2015-10-15 16:34:54 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-10-15 16:34:54 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:58:39 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2015-10-15 16:34:54 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2015-10-15 16:34:54 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2015-10-15 16:34:54 +02:00
|
|
|
|
|
|
|
|
#include "utils_global.h"
|
2015-11-23 16:41:54 +01:00
|
|
|
#include "theme/theme.h"
|
|
|
|
|
|
|
|
|
|
#include <QPair>
|
|
|
|
|
#include <QVector>
|
2015-10-15 16:34:54 +02:00
|
|
|
|
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QColor)
|
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QIcon)
|
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QPixmap)
|
2015-11-23 16:41:54 +01:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QString)
|
2015-10-15 16:34:54 +02:00
|
|
|
|
|
|
|
|
namespace Utils {
|
|
|
|
|
|
2015-11-23 16:41:54 +01:00
|
|
|
typedef QPair<QString, Theme::Color> IconMaskAndColor;
|
|
|
|
|
|
|
|
|
|
// Returns a recolored icon with shadow and custom disabled state for a
|
|
|
|
|
// series of grayscalemask|Theme::Color mask pairs
|
|
|
|
|
class QTCREATOR_UTILS_EXPORT Icon : public QVector<IconMaskAndColor>
|
2015-10-15 16:34:54 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2015-12-22 19:44:57 +01:00
|
|
|
enum IconStyleOption {
|
|
|
|
|
None = 0,
|
|
|
|
|
Tint = 1,
|
|
|
|
|
DropShadow = 2,
|
|
|
|
|
PunchEdges = 4,
|
|
|
|
|
|
2016-04-20 16:12:42 +02:00
|
|
|
ToolBarStyle = Tint | DropShadow | PunchEdges,
|
|
|
|
|
MenuTintedStyle = Tint | PunchEdges
|
2015-11-23 16:41:54 +01:00
|
|
|
};
|
|
|
|
|
|
2015-12-22 19:44:57 +01:00
|
|
|
Q_DECLARE_FLAGS(IconStyleOptions, IconStyleOption)
|
|
|
|
|
|
2015-11-23 16:41:54 +01:00
|
|
|
Icon();
|
2015-12-22 19:44:57 +01:00
|
|
|
Icon(std::initializer_list<IconMaskAndColor> args, IconStyleOptions style = ToolBarStyle);
|
2015-11-23 16:41:54 +01:00
|
|
|
Icon(const QString &imageFileName);
|
2015-11-11 19:26:58 +01:00
|
|
|
Icon(const Icon &other) = default;
|
2015-11-23 16:41:54 +01:00
|
|
|
|
|
|
|
|
QIcon icon() const;
|
|
|
|
|
// Same as icon() but without disabled state.
|
|
|
|
|
QPixmap pixmap() const;
|
|
|
|
|
|
|
|
|
|
// Try to avoid it. it is just there for special API cases in Qt Creator
|
|
|
|
|
// where icons are still defined as filename.
|
|
|
|
|
QString imageFileName() const;
|
|
|
|
|
|
2015-11-11 19:26:58 +01:00
|
|
|
// Returns either the classic or a themed icon depending on
|
|
|
|
|
// the current Theme::FlatModeIcons flag.
|
|
|
|
|
static QIcon sideBarIcon(const Icon &classic, const Icon &flat);
|
|
|
|
|
// Like sideBarIcon plus added action mode for the flat icon
|
|
|
|
|
static QIcon modeIcon(const Icon &classic, const Icon &flat, const Icon &flatActive);
|
|
|
|
|
|
2016-11-12 04:16:59 +01:00
|
|
|
// Combined icon pixmaps in Normal and Disabled states from several Icons
|
2015-11-11 19:26:58 +01:00
|
|
|
static QIcon combinedIcon(const QList<QIcon> &icons);
|
2016-11-12 04:16:59 +01:00
|
|
|
static QIcon combinedIcon(const QList<Icon> &icons);
|
2015-11-23 16:41:54 +01:00
|
|
|
|
|
|
|
|
private:
|
2015-12-22 19:44:57 +01:00
|
|
|
IconStyleOptions m_style = None;
|
2015-10-15 16:34:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Utils
|
|
|
|
|
|
2015-12-22 19:44:57 +01:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Utils::Icon::IconStyleOptions)
|