icon.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is adapted from Qt Creator (replacing theme stuff by QColor)
7 **
8 ** Commercial License Usage
9 ** Licensees holding valid commercial Qt licenses may use this file in
10 ** accordance with the commercial license agreement provided with the
11 ** Software or, alternatively, in accordance with the terms contained in
12 ** a written agreement between you and The Qt Company. For licensing terms
13 ** and conditions see https://www.qt.io/terms-conditions. For further
14 ** information use the contact form at https://www.qt.io/contact-us.
15 **
16 ** GNU General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU
18 ** General Public License version 3 as published by the Free Software
19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
20 ** included in the packaging of this file. Please review the following
21 ** information to ensure the GNU General Public License requirements will
22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
23 **
24 ****************************************************************************/
25 
26 #pragma once
27 
28 #include <QPair>
29 #include <QVector>
30 
31 class QColor;
32 class QIcon;
33 class QPixmap;
34 class QString;
35 
36 namespace moveit_rviz_plugin {
37 namespace utils {
38 
39 using IconMaskAndColor = QPair<QString, QColor>;
40 
41 // Returns a recolored icon with shadow and custom disabled state for a
42 // series of grayscalemask|Theme::Color mask pairs
43 class Icon : public QVector<IconMaskAndColor>
44 {
45 public:
47  {
48  NONE = 0,
49  TINT = 1,
52 
55  };
56 
57  Q_DECLARE_FLAGS(IconStyleOptions, IconStyleOption)
58 
59  Icon();
60  Icon(std::initializer_list<IconMaskAndColor> args, IconStyleOptions style = TOOL_BAR_STYLE);
61  Icon(const QString& imageFileName);
62  Icon(const Icon& other) = default;
63 
64  QIcon icon() const;
65  // Same as icon() but without disabled state.
66  QPixmap pixmap() const;
67 
68  // Try to avoid it. it is just there for special API cases in Qt Creator
69  // where icons are still defined as filename.
70  QString imageFileName() const;
71 
72  // Combined icon pixmaps in Normal and Disabled states from several QIcons
73  static QIcon combinedIcon(const QList<QIcon>& icons);
74 
75 private:
76  IconStyleOptions m_style = NONE;
77 };
78 } // namespace utils
79 } // namespace moveit_rviz_plugin
80 
81 Q_DECLARE_OPERATORS_FOR_FLAGS(moveit_rviz_plugin::utils::Icon::IconStyleOptions)
moveit_rviz_plugin::utils::IconMaskAndColor
QPair< QString, QColor > IconMaskAndColor
Definition: icon.h:39
moveit_rviz_plugin::utils::Icon
Definition: icon.h:43
moveit_rviz_plugin::utils::Icon::combinedIcon
static QIcon combinedIcon(const QList< QIcon > &icons)
Definition: icon.cpp:242
moveit_rviz_plugin::utils::Icon::MENU_TINTED_STYLE
@ MENU_TINTED_STYLE
Definition: icon.h:54
moveit_rviz_plugin::utils::Icon::imageFileName
QString imageFileName() const
Definition: icon.cpp:238
moveit_rviz_plugin::utils::Icon::PUNCH_EDGES
@ PUNCH_EDGES
Definition: icon.h:51
moveit_rviz_plugin::utils::Icon::icon
QIcon icon() const
Definition: icon.cpp:206
moveit_rviz_plugin::utils::Icon::TOOL_BAR_STYLE
@ TOOL_BAR_STYLE
Definition: icon.h:53
moveit_rviz_plugin::utils::Icon::pixmap
QPixmap pixmap() const
Definition: icon.cpp:226
moveit_rviz_plugin::utils::Icon::NONE
@ NONE
Definition: icon.h:48
moveit_rviz_plugin::utils::Icon::Icon
Icon()
Definition: icon.cpp:197
moveit_rviz_plugin
uint8_t
uint8_t
moveit_rviz_plugin::utils::Icon::m_style
IconStyleOptions m_style
Definition: icon.h:76
moveit_rviz_plugin::utils::Icon::TINT
@ TINT
Definition: icon.h:49
args
moveit_rviz_plugin::utils::Icon::IconStyleOption
IconStyleOption
Definition: icon.h:46
moveit_rviz_plugin::utils::Icon::DROP_SHADOW
@ DROP_SHADOW
Definition: icon.h:50


visualization
Author(s): Robert Haschke
autogenerated on Thu Feb 27 2025 03:39:51