| 1 |
// SPDX-License-Identifier: LGPL-3.0-only |
| 2 |
/*************************************************************************** |
| 3 |
* * |
| 4 |
* Copyright: https://code.google.com/p/qsint/ * |
| 5 |
* License: LGPL * |
| 6 |
* * |
| 7 |
***************************************************************************/ |
| 8 |
|
| 9 |
#ifndef ACTIONPANEL_H |
| 10 |
#define ACTIONPANEL_H |
| 11 |
|
| 12 |
#include <QFrame> |
| 13 |
#include <QSpacerItem> |
| 14 |
#include "qsint_global.h" |
| 15 |
|
| 16 |
|
| 17 |
namespace QSint |
| 18 |
{ |
| 19 |
class ActionPanelScheme; |
| 20 |
class ActionGroup; |
| 21 |
|
| 22 |
/** |
| 23 |
* @brief Provides a panel of actions, similar to Windows XP task panels. |
| 24 |
* |
| 25 |
* An ActionPanel contains ActionGroups, which in turn contain actions (represented by ActionLabels). |
| 26 |
*/ |
| 27 |
class QSINT_EXPORT ActionPanel : public QFrame |
| 28 |
{ |
| 29 |
using BaseClass = QFrame; |
| 30 |
|
| 31 |
Q_OBJECT |
| 32 |
|
| 33 |
public: |
| 34 |
/** |
| 35 |
* @brief Constructs an ActionPanel. |
| 36 |
* @param parent The parent widget. |
| 37 |
*/ |
| 38 |
explicit ActionPanel(QWidget *parent = nullptr); |
| 39 |
|
| 40 |
/** |
| 41 |
* @brief Adds a widget to the ActionPanel. |
| 42 |
* @param w The widget to add. |
| 43 |
*/ |
| 44 |
void addWidget(QWidget *w); |
| 45 |
|
| 46 |
/** |
| 47 |
* @brief Removes a widget from the ActionPanel. |
| 48 |
* @param w The widget to remove. |
| 49 |
*/ |
| 50 |
void removeWidget(QWidget *w); |
| 51 |
|
| 52 |
/** |
| 53 |
* @brief Adds a spacer to bottom of the ActionPanel. |
| 54 |
* @param s The width of the spacer.. |
| 55 |
*/ |
| 56 |
void addStretch(int s = 0); |
| 57 |
|
| 58 |
/** |
| 59 |
* @brief Removes the spacer from the ActionPanel (if one was added). |
| 60 |
*/ |
| 61 |
void removeStretch(); |
| 62 |
|
| 63 |
/** |
| 64 |
* @brief Creates and adds an empty ActionGroup (without a header) to the panel. |
| 65 |
* @return The newly created ActionGroup. |
| 66 |
*/ |
| 67 |
ActionGroup* createGroup(); |
| 68 |
|
| 69 |
/** |
| 70 |
* @brief Creates and adds an ActionGroup (with a header) to the panel. |
| 71 |
* @param title The title of the group's header. |
| 72 |
* @param expandable If `true` (default), the group can be expanded/collapsed. |
| 73 |
* @return The newly created ActionGroup. |
| 74 |
*/ |
| 75 |
ActionGroup* createGroup(const QString &title, bool expandable = true); |
| 76 |
|
| 77 |
/** |
| 78 |
* @brief Creates and adds an ActionGroup (with a header) to the panel. |
| 79 |
* @param icon The icon for the group's header. |
| 80 |
* @param title The title of the group's header. |
| 81 |
* @param expandable If `true` (default), the group can be expanded/collapsed. |
| 82 |
* @return The newly created ActionGroup. |
| 83 |
*/ |
| 84 |
ActionGroup* createGroup(const QPixmap &icon, const QString &title, bool expandable = true); |
| 85 |
|
| 86 |
/** |
| 87 |
* @brief Sets the color scheme for the panel and its child groups. |
| 88 |
* @param scheme The new scheme to use. Defaults to `ActionPanelScheme::defaultScheme()` |
| 89 |
* if not set. |
| 90 |
*/ |
| 91 |
void setScheme(ActionPanelScheme *scheme); |
| 92 |
|
| 93 |
/** |
| 94 |
* @brief Returns the recommended minimum size for the panel. |
| 95 |
* @return The minimum size hint. |
| 96 |
*/ |
| 97 |
QSize minimumSizeHint() const override; |
| 98 |
|
| 99 |
protected: |
| 100 |
/** @brief The color scheme used by the panel. */ |
| 101 |
ActionPanelScheme *myScheme; |
| 102 |
|
| 103 |
/** @brief The spacer used for bottom spacing. */ |
| 104 |
QSpacerItem *mySpacer; |
| 105 |
}; |
| 106 |
|
| 107 |
} // namespace |
| 108 |
|
| 109 |
#endif // ACTIONPANEL_H |