File indexing completed on 2025-01-19 04:24:07
0001 /**************************************************************************************** 0002 * Copyright (c) 2010 Daniel Faust <hessijames@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef LABEL_OVERLAY_BUTTON_H 0018 #define LABEL_OVERLAY_BUTTON_H 0019 0020 #include <QGraphicsItem> 0021 #include <QPixmap> 0022 0023 class KIconEffect; 0024 class QGraphicsSceneHoverEvent; 0025 class QPainter; 0026 class QStyleOptionGraphicsItem; 0027 class QWidget; 0028 0029 class LabelOverlayButton : public QObject, public QGraphicsItem 0030 { 0031 Q_OBJECT 0032 Q_INTERFACES( QGraphicsItem ) 0033 Q_PROPERTY( qreal opacity READ opacity WRITE setOpacity ) 0034 0035 public: 0036 explicit LabelOverlayButton( QGraphicsItem *parent ); 0037 ~LabelOverlayButton() override; 0038 0039 void setPixmap( const QPixmap& pixmap ); 0040 QPixmap pixmap(); 0041 void setSize( int size ); 0042 int size(); 0043 void updateHoverStatus(); 0044 0045 QRectF boundingRect() const; 0046 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ); 0047 0048 protected: 0049 void hoverEnterEvent( QGraphicsSceneHoverEvent *event ) override; 0050 void hoverLeaveEvent( QGraphicsSceneHoverEvent *event ) override; 0051 0052 private: 0053 KIconEffect *m_iconEffect; 0054 QPixmap m_pixmap; 0055 QPixmap m_scaledPixmap; 0056 int m_size; 0057 0058 }; 0059 0060 #endif