blob: e5455fb7556c5ec396d1110a925b5ce79d144582 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
#include <QGraphicsWidget>
#include <QIcon>
QT_BEGIN_NAMESPACE
class QAction;
QT_END_NAMESPACE
namespace QmlDesigner {
class FormEditorToolButton : public QGraphicsWidget
{
Q_OBJECT
public:
explicit FormEditorToolButton(QAction *action, QGraphicsItem *parent = nullptr);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
QRectF boundingRect() const override;
signals:
void clicked();
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
private:
enum State {
Pressed,
Hovered,
Normal
};
State m_state = Normal;
QAction *m_action;
};
} //QmlDesigner
|