2020-11-16 18:01:03 +01:00
|
|
|
/****************************************************************************
|
|
|
|
** Modern Linbo GUI
|
|
|
|
** Copyright (C) 2020 Dorian Zedler <dorian@itsblue.de>
|
|
|
|
**
|
|
|
|
** This program is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU Affero General Public License as published
|
|
|
|
** by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** This program is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU Affero General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU Affero General Public License
|
|
|
|
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-11-16 00:31:28 +01:00
|
|
|
#ifndef QMODERNPUSHBUTTON_H
|
|
|
|
#define QMODERNPUSHBUTTON_H
|
|
|
|
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QSvgWidget>
|
|
|
|
#include <QGraphicsOpacityEffect>
|
|
|
|
#include <QResizeEvent>
|
|
|
|
#include <QPropertyAnimation>
|
|
|
|
#include <QString>
|
2020-11-19 14:39:32 +01:00
|
|
|
#include <QStringList>
|
2020-11-16 00:31:28 +01:00
|
|
|
#include <QDebug>
|
2020-11-19 14:39:32 +01:00
|
|
|
#include <QEventLoop>
|
|
|
|
|
|
|
|
#include "qmodernpushbuttonoverlay.h"
|
2020-11-16 00:31:28 +01:00
|
|
|
|
2020-11-16 18:01:03 +01:00
|
|
|
class QModernPushButton : public QAbstractButton
|
2020-11-16 00:31:28 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QModernPushButton(QString icon, QWidget* parent = nullptr);
|
|
|
|
|
2020-11-23 11:57:51 +01:00
|
|
|
void setVisibleAnimated(bool visible, bool asynchronos = true);
|
|
|
|
|
|
|
|
void setGeometryAnimated(const QRect& geometry);
|
2020-11-19 14:39:32 +01:00
|
|
|
|
2020-11-16 00:31:28 +01:00
|
|
|
protected:
|
|
|
|
void resizeEvent(QResizeEvent *event) override;
|
2020-11-16 18:01:03 +01:00
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
|
|
|
void keyReleaseEvent(QKeyEvent *e) override;
|
|
|
|
void enterEvent(QEvent *e) override;
|
|
|
|
void leaveEvent(QEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
2020-11-16 00:31:28 +01:00
|
|
|
|
|
|
|
private:
|
2020-11-23 11:57:51 +01:00
|
|
|
QPropertyAnimation* geometryAnimation;
|
2020-11-19 14:39:32 +01:00
|
|
|
QList<QModernPushButtonOverlay*> overlays;
|
2020-11-16 00:31:28 +01:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void handleToggled(bool checked);
|
2020-11-23 11:57:51 +01:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void checked();
|
2020-11-16 00:31:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QMODERNPUSHBUTTON_H
|