21 #ifndef WORKSPACEEXPOSEWIDGET_H 22 #define WORKSPACEEXPOSEWIDGET_H 24 #include <QGraphicsObject> 25 #include <QGraphicsView> 27 #include <tulip/tulipconf.h> 29 class QAbstractAnimation;
34 class PreviewItem :
public QGraphicsObject {
37 static QPixmap *_closeButtonPixmap;
38 static QRect _closePixmapRect;
41 WorkspacePanel *_panel;
43 bool _closeButtonHovered;
45 int textHeight()
const;
48 explicit PreviewItem(
const QPixmap &pixmap, WorkspacePanel *panel,
49 QGraphicsItem *parent =
nullptr);
50 QRectF boundingRect()
const override;
51 void paint(QPainter *,
const QStyleOptionGraphicsItem *, QWidget *)
override;
52 WorkspacePanel *panel()
const;
53 bool shouldClose(
const QPointF &);
56 void hoverEnterEvent(QGraphicsSceneHoverEvent *)
override;
57 void hoverLeaveEvent(QGraphicsSceneHoverEvent *)
override;
58 void hoverMoveEvent(QGraphicsSceneHoverEvent *)
override;
59 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *)
override;
64 class TLP_QT_SCOPE WorkspaceExposeWidget :
public QGraphicsView {
67 QAbstractAnimation *_positionAnimation;
68 QList<PreviewItem *> _items;
69 PreviewItem *_selectedItem;
70 QGraphicsRectItem *_placeholderItem;
71 bool _switchToSingleMode;
73 int _currentPanelIndex;
75 void updatePositions(
bool resetScenePos =
true);
76 static const int MARGIN;
81 static QSize previewSize();
83 explicit WorkspaceExposeWidget(QWidget *parent =
nullptr);
84 ~WorkspaceExposeWidget()
override;
85 int currentPanelIndex()
const;
86 QVector<WorkspacePanel *> panels()
const;
88 bool isSwitchToSingleMode()
const;
91 void setData(
const QVector<WorkspacePanel *> &panels,
int currentPanelIndex);
94 void exposeFinished();
97 void resizeEvent(QResizeEvent *event)
override;
98 bool eventFilter(QObject *, QEvent *)
override;
99 bool event(QEvent *)
override;
102 void updatePositionsAnimationFinished();
103 void resetSceneRect();
108 #endif // WORKSPACEEXPOSEWIDGET_H