1 /***************************************************************************
2 **                                                                        **
3 **  Polyphone, a soundfont editor                                         **
4 **  Copyright (C) 2013-2020 Davy Triponney                                **
5 **                                                                        **
6 **  This program is free software: you can redistribute it and/or modify  **
7 **  it under the terms of the GNU General Public License as published by  **
8 **  the Free Software Foundation, either version 3 of the License, or     **
9 **  (at your option) any later version.                                   **
10 **                                                                        **
11 **  This program is distributed in the hope that it will be useful,       **
12 **  but WITHOUT ANY WARRANTY; without even the implied warranty of        **
13 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          **
14 **  GNU General Public License for more details.                          **
15 **                                                                        **
16 **  You should have received a copy of the GNU General Public License     **
17 **  along with this program. If not, see http://www.gnu.org/licenses/.    **
18 **                                                                        **
19 ****************************************************************************
20 **           Author: Davy Triponney                                       **
21 **  Website/Contact: https://www.polyphone-soundfonts.com                 **
22 **             Date: 01.01.2013                                           **
23 ***************************************************************************/
24 
25 #ifndef STYLEDACTION_H
26 #define STYLEDACTION_H
27 
28 #include <QToolButton>
29 
30 class StyledAction : public QToolButton
31 {
32     Q_OBJECT
33 
34 public:
35     StyledAction(QString label, QString iconName, QWidget *parent);
36     void disable(bool isDisabled);
37     void setData(int data);
38     int getData();
39 
40 signals:
41     void clicked();
42 
43 protected:
44     void leaveEvent(QEvent * event) override;
45     void enterEvent(QEvent * event) override;
46     QPixmap _icon;
47     QPixmap _iconHover;
48     QPixmap _iconDisabled;
49 
50 private slots:
51     void onToggled(bool isChecked);
52     void onClicked(bool isClicked);
53 
54 private:
55     bool _isDisabled;
56     static const QSize ICON_SIZE;
57     QColor _checkedBackgroundColor;
58     int _data;
59 };
60 
61 #endif // STYLEDACTION_H
62