qt-material-widgets/components/qtmaterialdrawer_internal.h

80 lines
1.6 KiB
C
Raw Normal View History

2017-09-30 00:20:12 +00:00
#ifndef DRAWER_INTERNAL_H
#define DRAWER_INTERNAL_H
#include <QStateMachine>
#include "lib/qtmaterialoverlaywidget.h"
2017-09-30 00:20:12 +00:00
2022-02-17 02:22:22 +00:00
namespace md
{
class Drawer;
class DrawerWidget;
2017-09-30 00:20:12 +00:00
2022-02-17 02:22:22 +00:00
class DrawerStateMachine : public QStateMachine
2017-09-30 00:20:12 +00:00
{
Q_OBJECT
Q_PROPERTY(qreal opacity WRITE setOpacity READ opacity)
2017-09-30 00:20:12 +00:00
public:
2022-02-17 02:22:22 +00:00
explicit DrawerStateMachine(DrawerWidget *drawer,
Drawer *parent);
~DrawerStateMachine();
2017-09-30 00:20:12 +00:00
void setOpacity(qreal opacity);
inline qreal opacity() const;
bool isInClosedState() const;
2017-09-30 00:20:12 +00:00
void updatePropertyAssignments();
signals:
void signalOpen();
void signalClose();
2017-09-30 00:20:12 +00:00
private:
2022-02-17 02:22:22 +00:00
Q_DISABLE_COPY(DrawerStateMachine)
2017-09-30 00:20:12 +00:00
2022-02-17 02:22:22 +00:00
DrawerWidget *const m_drawer;
Drawer *const m_main;
QState *const m_openingState;
QState *const m_openedState;
QState *const m_closingState;
QState *const m_closedState;
qreal m_opacity;
2017-09-30 00:20:12 +00:00
};
2022-02-17 02:22:22 +00:00
inline qreal DrawerStateMachine::opacity() const
{
return m_opacity;
}
2022-02-17 02:22:22 +00:00
class DrawerWidget : public OverlayWidget
{
Q_OBJECT
Q_PROPERTY(int offset WRITE setOffset READ offset)
public:
2022-02-17 02:22:22 +00:00
explicit DrawerWidget(QWidget *parent = 0);
~DrawerWidget();
void setOffset(int offset);
inline int offset() const;
protected:
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
QRect overlayGeometry() const Q_DECL_OVERRIDE;
private:
int m_offset;
};
2022-02-17 02:22:22 +00:00
inline int DrawerWidget::offset() const
{
return m_offset;
}
2022-02-17 02:22:22 +00:00
}
2017-09-30 00:20:12 +00:00
#endif // DRAWER_INTERNAL_H