File indexing completed on 2024-05-05 17:19:09
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2022 S. MANKOWSKI stephane@mankowski.fr 0003 * SPDX-FileCopyrightText: 2022 G. DE BURE support@mankowski.fr 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 ***************************************************************************/ 0006 #ifndef SKGWIDGETSELECTOR_H 0007 #define SKGWIDGETSELECTOR_H 0008 /** @file 0009 * A widget selector. 0010 * 0011 * @author Stephane MANKOWSKI / Guillaume DE BURE 0012 */ 0013 0014 #include "skgbasegui_export.h" 0015 #include "ui_skgwidgetselector.h" 0016 0017 class QToolButton; 0018 0019 /** 0020 * This file is a color selector box with more features. 0021 */ 0022 class SKGBASEGUI_EXPORT SKGWidgetSelector : public QWidget 0023 { 0024 Q_OBJECT 0025 /** 0026 * The selected mode 0027 */ 0028 Q_PROPERTY(int selectedMode READ getSelectedMode WRITE setSelectedMode NOTIFY selectedModeChanged USER true) 0029 0030 /** 0031 * The default mode 0032 */ 0033 Q_PROPERTY(bool alwaysOneOpen READ getAlwaysOneOpen WRITE setAlwaysOneOpen NOTIFY alwaysOneOpenChanged USER true) 0034 0035 0036 public: 0037 /** 0038 * A list of QWidget* ==> SKGListQWidget 0039 */ 0040 using SKGListQWidget = QList<QWidget*>; 0041 0042 /** 0043 * Default Constructor 0044 * @param iParent the parent 0045 */ 0046 explicit SKGWidgetSelector(QWidget* iParent); 0047 0048 /** 0049 * Default Destructor 0050 */ 0051 ~SKGWidgetSelector() override; 0052 0053 /** 0054 * Add a button to the selector 0055 * @param iIcon the icon 0056 * @param iTitle the text 0057 * @param iToolTip the tooltip 0058 * @param iListOfShownWidgets the list of widget to display 0059 */ 0060 virtual void addButton(const QIcon& iIcon, const QString& iTitle, const QString& iToolTip, const SKGWidgetSelector::SKGListQWidget& iListOfShownWidgets); 0061 0062 /** 0063 * Add a button to the selector 0064 * @param iIcon the icon 0065 * @param iTitle the text 0066 * @param iToolTip the tooltip 0067 * @param iWidgets the widget to display 0068 */ 0069 virtual void addButton(const QIcon& iIcon, const QString& iTitle, const QString& iToolTip, QWidget* iWidgets); 0070 0071 /** 0072 * Get the current selected mode 0073 * @return the current selected mode 0074 */ 0075 virtual int getSelectedMode() const; 0076 0077 /** 0078 * Set the selected mode 0079 * @param iMode the selected mode 0080 */ 0081 virtual void setSelectedMode(int iMode); 0082 /** 0083 * Enable/disable a mode 0084 * @param iMode the mode 0085 * @param iEnabled the state 0086 */ 0087 virtual void setEnabledMode(int iMode, bool iEnabled); 0088 0089 /** 0090 * Get the "Always one open" mode 0091 * @return the mode 0092 */ 0093 virtual bool getAlwaysOneOpen() const; 0094 0095 /** 0096 * Set the "Always one open" mode. 0097 * @param iMode the mode 0098 */ 0099 virtual void setAlwaysOneOpen(bool iMode); 0100 0101 Q_SIGNALS: 0102 /** 0103 * Emitted when the selected mode changed 0104 * @param iMode the new selected mode 0105 */ 0106 void selectedModeChanged(int iMode); 0107 0108 /** 0109 * Emitted when the property is modified 0110 */ 0111 void alwaysOneOpenChanged(); 0112 0113 private Q_SLOTS: 0114 0115 void onButtonClicked(); 0116 0117 private: 0118 Ui::skgwidgetselector_base ui{}; 0119 0120 QList<QToolButton*> m_listButton; 0121 QList<SKGListQWidget> m_listWidgets; 0122 // QHash<QWidget*, QRect> m_originGeometries; 0123 // QHash<QWidget*, QRect> m_endGeometries; 0124 int m_currentMode; 0125 bool m_alwaysOneOpen; 0126 }; 0127 0128 #endif // SKGWIDGETSELECTOR_H