| 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 ACTIONPANELSCHEME_H |
| 10 |
#define ACTIONPANELSCHEME_H |
| 11 |
|
| 12 |
#include "qsint_global.h" |
| 13 |
|
| 14 |
#include <QApplication> |
| 15 |
#include <QImage> |
| 16 |
#include <QPainter> |
| 17 |
#include <QPalette> |
| 18 |
#include <QPixmap> |
| 19 |
#include <QSize> |
| 20 |
#include <QString> |
| 21 |
#include <QStyle> |
| 22 |
#include <QFontMetrics> |
| 23 |
|
| 24 |
namespace QSint |
| 25 |
{ |
| 26 |
/** |
| 27 |
* @brief Provides a color scheme and layout parameters for ActionPanel and ActionGroup widgets. |
| 28 |
* |
| 29 |
* ActionPanels group related actions, and ActionGroups organize actions within a panel. |
| 30 |
* This class defines the visual appearance and behavior (e.g., folding animation) of these components. |
| 31 |
*/ |
| 32 |
class QSINT_EXPORT ActionPanelScheme |
| 33 |
{ |
| 34 |
public: |
| 35 |
/** |
| 36 |
* @brief Animation effect used when expanding or collapsing an ActionGroup's contents. |
| 37 |
*/ |
| 38 |
enum FoldEffect |
| 39 |
{ |
| 40 |
NoFolding, ///< No folding animation. |
| 41 |
ShrunkFolding, ///< Contents shrink to a point during folding. |
| 42 |
SlideFolding ///< Contents slide in and out during folding. |
| 43 |
}; |
| 44 |
|
| 45 |
/** |
| 46 |
* @brief Constructs a default ActionPanelScheme. |
| 47 |
*/ |
| 48 |
ActionPanelScheme(); |
| 49 |
|
| 50 |
/** |
| 51 |
* @brief Returns a pointer to the default ActionPanelScheme object. |
| 52 |
* Derived classes can override this to provide a custom default scheme. |
| 53 |
* @return A pointer to the default ActionPanelScheme. |
| 54 |
*/ |
| 55 |
static ActionPanelScheme* defaultScheme(); |
| 56 |
|
| 57 |
/** |
| 58 |
* @brief Height of the header area in pixels. |
| 59 |
*/ |
| 60 |
int headerSize; |
| 61 |
|
| 62 |
/** |
| 63 |
* @brief Image of the folding button when the group is expanded. |
| 64 |
*/ |
| 65 |
QPixmap headerButtonFold; |
| 66 |
/** |
| 67 |
* @brief Image of the folding button when the group is expanded and the mouse is over it. |
| 68 |
*/ |
| 69 |
QPixmap headerButtonFoldOver; |
| 70 |
/** |
| 71 |
* @brief Image of the folding button when the group is collapsed. |
| 72 |
*/ |
| 73 |
QPixmap headerButtonUnfold; |
| 74 |
/** |
| 75 |
* @brief Image of the folding button when the group is collapsed and the mouse is over it. |
| 76 |
*/ |
| 77 |
QPixmap headerButtonUnfoldOver; |
| 78 |
|
| 79 |
/** |
| 80 |
* @brief Size of the header button. |
| 81 |
*/ |
| 82 |
QSize headerButtonSize; |
| 83 |
|
| 84 |
/** |
| 85 |
* @brief Number of steps in the expanding/collapsing animation (default: 20). |
| 86 |
*/ |
| 87 |
int groupFoldSteps; |
| 88 |
|
| 89 |
/** |
| 90 |
* @brief Delay in milliseconds between animation steps (default: 15). |
| 91 |
*/ |
| 92 |
int groupFoldDelay; |
| 93 |
|
| 94 |
/** |
| 95 |
* @brief Folding effect used during expanding/collapsing. |
| 96 |
*/ |
| 97 |
FoldEffect groupFoldEffect; |
| 98 |
|
| 99 |
/** |
| 100 |
* @brief Whether the group's opacity changes slowly during folding. |
| 101 |
*/ |
| 102 |
bool groupFoldThaw; |
| 103 |
|
| 104 |
/** |
| 105 |
* @brief CSS style for ActionPanel/ActionGroup elements. |
| 106 |
*/ |
| 107 |
QString actionStyle; |
| 108 |
|
| 109 |
/** |
| 110 |
* @brief Clears the custom action style, resetting to a minimal style. |
| 111 |
*/ |
| 112 |
void clearActionStyle(); |
| 113 |
|
| 114 |
/** |
| 115 |
* @brief Restores the original action style. |
| 116 |
*/ |
| 117 |
void restoreActionStyle(); |
| 118 |
|
| 119 |
protected: |
| 120 |
/** |
| 121 |
* @brief Draws a fold/unfold icon. |
| 122 |
* @param p The palette to use for coloring the icon. |
| 123 |
* @param fold `true` for fold icon, `false` for unfold icon. |
| 124 |
* @param hover `true` for hover effect, `false` otherwise. |
| 125 |
* @return The icon as a QPixmap. |
| 126 |
*/ |
| 127 |
QPixmap drawFoldIcon(const QPalette& p, bool fold, bool hover) const; |
| 128 |
|
| 129 |
private: |
| 130 |
/** |
| 131 |
* @brief Stores the built-in icons for restoration. |
| 132 |
*/ |
| 133 |
QPixmap builtinFold; |
| 134 |
QPixmap builtinFoldOver; |
| 135 |
QPixmap builtinUnfold; |
| 136 |
QPixmap builtinUnfoldOver; |
| 137 |
}; |
| 138 |
|
| 139 |
} // namespace QSint |
| 140 |
|
| 141 |
#endif // ACTIONPANELSCHEME_H |