File indexing completed on 2024-10-06 04:25:59
0001 /* 0002 SPDX-FileCopyrightText: 1998-2007 Sebastian Trueg <trueg@k3b.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef FLATBUTTON_H 0007 #define FLATBUTTON_H 0008 0009 #include <QColor> 0010 #include <QAbstractButton> 0011 0012 class QEvent; 0013 class QMouseEvent; 0014 class QAction; 0015 class QPaintEvent; 0016 0017 /** 0018 @author Sebastian Trueg 0019 */ 0020 namespace K3b { 0021 class FlatButton : public QAbstractButton 0022 { 0023 Q_OBJECT 0024 0025 public: 0026 explicit FlatButton( QWidget* parent = 0 ); 0027 explicit FlatButton( const QString& text, QWidget* parent = 0 ); 0028 explicit FlatButton( QAction* action, QWidget* parent = 0 ); 0029 0030 ~FlatButton() override; 0031 0032 QSize sizeHint() const override; 0033 0034 public Q_SLOTS: 0035 void setColors( const QColor& fore, const QColor& back ); 0036 0037 private Q_SLOTS: 0038 void slotThemeChanged(); 0039 0040 private: 0041 void init(); 0042 bool event( QEvent* event ) override; 0043 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 0044 void enterEvent( QEvent* event ) override; 0045 #else 0046 void enterEvent( QEnterEvent* event ) override; 0047 #endif 0048 void leaveEvent( QEvent* event ) override; 0049 void paintEvent( QPaintEvent* event ) override; 0050 void setHover( bool ); 0051 0052 QColor m_backColor; 0053 QColor m_foreColor; 0054 0055 bool m_hover; 0056 }; 0057 } 0058 0059 #endif