Maki
Formally verfied low-code orchestration
Loading...
Searching...
No Matches
section.h
1#pragma once
2
3#include <QToolButton>
4#include <QVBoxLayout>
5#include <QWidget>
6#include <oclero/qlementine/Common.hpp>
7
8#include "collapsible_area.h"
9
10class ClickableIcon;
11class QPropertyAnimation;
12
16class SectionWidget : public QWidget
17{
18 Q_OBJECT
19
20public:
26 SectionWidget(QWidget* parent = nullptr);
27
34 void addItem(QWidget* container, const QString& title);
35
43 void addItem(QWidget* container, const QString& title, oclero::qlementine::TextRole role);
44
50 void setExpanded(bool expanded);
51
57 bool isExpanded() const;
58
64 void setDuration(int duration);
65
71 QWidget* content() const;
72
78 void updateContentHeight(int height);
79
80private:
81 ClickableIcon* mToggleButton = nullptr;
82 QWidget* mContent = nullptr;
84 bool mExpanded = true;
85 std::optional<int> mDuration = std::nullopt;
86 QPropertyAnimation* mAnimation = nullptr;
87
95 inline int getAnimationDuration(int target, int current) const;
96
102 void toggled(bool checked);
103};
A clickable icon widget that can be checked or unchecked.
Definition clickable_icon.h:10
A widget that can be collapsed or expanded vertically.
Definition collapsible_area.h:58
void toggled(bool checked)
Slot called when the toggle button is toggled.
Definition section.cpp:118
void setExpanded(bool expanded)
Sets whether the section is expanded or collapsed.
Definition section.cpp:99
QWidget * mContent
Pointer to the toggle button for expanding/collapsing.
Definition section.h:82
int getAnimationDuration(int target, int current) const
Pointer to the property animation.
Definition section.cpp:158
void setDuration(int duration)
Sets the duration of the animation for expanding and collapsing.
Definition section.cpp:110
CollapsibleAreaHeight * mContentArea
Pointer to the content widget.
Definition section.h:83
bool isExpanded() const
Returns whether the section is currently expanded.
Definition section.cpp:105
bool mExpanded
Pointer to the collapsible area.
Definition section.h:84
QPropertyAnimation * mAnimation
Duration of the animation for expanding and collapsing.
Definition section.h:86
void addItem(QWidget *container, const QString &title)
Adds an item to the section with a title.
Definition section.cpp:31
QWidget * content() const
Returns the content widget of the section.
Definition section.cpp:153
void updateContentHeight(int height)
Updates the height of the content area.
Definition section.cpp:89
SectionWidget(QWidget *parent=nullptr)
Constructs a new SectionWidget.
Definition section.cpp:15
std::optional< int > mDuration
Current state of the section (expanded or collapsed).
Definition section.h:85