Warning, file /office/skrooge/skgbasegui/skgmenuitem.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2023 N. KRUPENKO krnekit@gmail.com 0003 * SPDX-License-Identifier: GPL-3.0-or-later 0004 ***************************************************************************/ 0005 #ifndef SKGMENUITEM_H 0006 #define SKGMENUITEM_H 0007 /** @file 0008 * This file is a widget that could be used in QWidgetAction and looks like a menu item. 0009 * 0010 * @author Nikita KRUPENKO 0011 */ 0012 #include <qicon.h> 0013 #include <qwidget.h> 0014 0015 #include "skgbasegui_export.h" 0016 0017 class QStyleOptionMenuItem; 0018 0019 /** 0020 * A widget that could be used in QWidgetAction and looks like a menu item 0021 */ 0022 class SKGBASEGUI_EXPORT SKGMenuitem : public QWidget 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 /** 0028 * Default Constructor 0029 * @param iParent the parent widget 0030 */ 0031 explicit SKGMenuitem(QWidget* iParent = nullptr); 0032 0033 /** 0034 * Default Destructor 0035 */ 0036 ~SKGMenuitem() override; 0037 0038 /** 0039 * Get menu item text 0040 * @return menu item text. 0041 */ 0042 QString getText() const; 0043 0044 /** 0045 * Set menu item text 0046 * @param iText menu item text 0047 */ 0048 void setText(const QString& iText); 0049 0050 /** 0051 * Get menu item icon 0052 * @return menu item icon. 0053 */ 0054 QIcon getIcon() const; 0055 0056 /** 0057 * Set menu item icon 0058 * @param iIcon menu item icon 0059 */ 0060 void setIcon(const QIcon& iIcon); 0061 0062 /** 0063 * Get menu item color 0064 * @return menu item color. 0065 */ 0066 QColor getColor() const; 0067 0068 /** 0069 * Set menu item color 0070 * @param iColor menu item color 0071 */ 0072 void setColor(const QColor& iColor); 0073 0074 /** 0075 * Get menu item text bold state 0076 * @return menu item text bold state. 0077 */ 0078 bool getIsBold() const; 0079 0080 /** 0081 * Set menu item text bold state 0082 * @param iBold menu item text bold state 0083 */ 0084 void setIsBold(bool isBold); 0085 0086 /** 0087 * Get recommended minimum size for the widget 0088 * @return recommended minimum size 0089 */ 0090 QSize minimumSizeHint() const override; 0091 0092 Q_SIGNALS: 0093 /** 0094 * This signal is launched when the menu item text is modified 0095 */ 0096 void textChanged(const QString& text) const; 0097 0098 /** 0099 * This signal is launched when the menu item icon is modified 0100 */ 0101 void iconChanged(const QIcon& icon) const; 0102 0103 /** 0104 * This signal is launched when the menu item color is modified 0105 */ 0106 void colorChanged(const QColor& color) const; 0107 0108 /** 0109 * This signal is launched when the menu item text bold state is modified 0110 */ 0111 void isBoldChanged(bool isBold) const; 0112 0113 protected: 0114 /** 0115 * Paint event handler 0116 * @param event object 0117 */ 0118 void paintEvent(QPaintEvent* event) override; 0119 0120 private: 0121 /** 0122 * Set up the style option 0123 * @param option style option 0124 */ 0125 void initStyleOption(QStyleOptionMenuItem* option) const; 0126 0127 QString m_text; 0128 QIcon m_icon; 0129 QColor m_color; 0130 bool m_isBold = false; 0131 }; 0132 0133 #endif // SKGMENUITEM_H