Loading...
Searching...
No Matches
QGraphicsTextButton.hpp
1#pragma once
2#include <score/graphics/TextItem.hpp>
3#include <score/graphics/widgets/Constants.hpp>
4#include <score/widgets/MimeData.hpp>
5
6#include <QGraphicsItem>
7#include <QObject>
8
9#include <score_lib_base_export.h>
10
11#include <verdigris>
12namespace score
13{
14class SCORE_LIB_BASE_EXPORT QGraphicsTextButton final
15 : public QObject
16 , public QGraphicsItem
17{
18 W_OBJECT(QGraphicsTextButton)
19 SCORE_GRAPHICS_ITEM_TYPE(220)
20
21 bool m_pressed{};
22
23public:
24 QGraphicsTextButton(QString text, QGraphicsItem* parent);
25
26 void pressed() E_SIGNAL(SCORE_LIB_BASE_EXPORT, pressed);
27 void dropped(QString filename) E_SIGNAL(SCORE_LIB_BASE_EXPORT, dropped, filename);
28 void dropUnhandled(const QMimeData* mime)
29 E_SIGNAL(SCORE_LIB_BASE_EXPORT, dropUnhandled, mime);
30 void bang();
31
32 const QString& text() const noexcept { return m_string; }
33 void setText(const QString& s)
34 {
35 m_string = std::move(s);
36 updateBounds();
37 }
38 QRectF boundingRect() const override;
39
40private:
41 void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
42 void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
43 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
44
45 void dragEnterEvent(QGraphicsSceneDragDropEvent* event) override;
46 void dragMoveEvent(QGraphicsSceneDragDropEvent* event) override;
47 void dragLeaveEvent(QGraphicsSceneDragDropEvent* event) override;
48 void dropEvent(QGraphicsSceneDragDropEvent* event) override;
49
50 void updateBounds();
51 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
52 final override;
53 QRectF m_rect;
54 QString m_string;
55};
56}
Definition QGraphicsTextButton.hpp:17
Base toolkit upon which the software is built.
Definition Application.cpp:97