File indexing completed on 2023-05-30 10:40:29
0001 /* 0002 SPDX-License-Identifier: GPL-2.0-or-later 0003 SPDX-FileCopyrightText: 2012 Martin Kuettler <martin.kuettler@gmail.com> 0004 */ 0005 0006 #ifndef WORKSHEETTOOLBUTTON_H 0007 #define WORKSHEETTOOLBUTTON_H 0008 0009 #include <QGraphicsObject> 0010 #include <QPixmap> 0011 0012 #include <QIcon> 0013 0014 class WorksheetToolButton : public QGraphicsObject 0015 { 0016 Q_OBJECT 0017 public: 0018 explicit WorksheetToolButton(QGraphicsItem* parent); 0019 ~WorksheetToolButton() override = default; 0020 0021 void setIcon(const QIcon& icon); 0022 0023 qreal width(); 0024 qreal height(); 0025 QRectF boundingRect() const override; 0026 void setIconScale(qreal scale); 0027 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, 0028 QWidget* widget = nullptr) override; 0029 0030 Q_SIGNALS: 0031 void clicked(); 0032 void pressed(); 0033 0034 protected: 0035 void mousePressEvent(QGraphicsSceneMouseEvent* event) override; 0036 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override; 0037 0038 private: 0039 QSize m_size; 0040 QPixmap m_pixmap; 0041 QIcon m_icon; 0042 qreal m_scale; 0043 }; 0044 0045 #endif //WORKSHEETTOOLBUTTON_H