File indexing completed on 2024-04-21 05:50:04

0001 /*
0002     SPDX-FileCopyrightText: 2012-2013 Evan Teran <evan.teran@gmail.com>
0003     SPDX-FileCopyrightText: 2006 Michel Marti <mma@objectxp.com>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #pragma once
0009 
0010 #include <QAbstractButton>
0011 
0012 class BitButton : public QAbstractButton
0013 {
0014     Q_OBJECT
0015 
0016 public:
0017     explicit BitButton(QWidget *parent = nullptr);
0018     Q_REQUIRED_RESULT bool isOn() const;
0019     void setOn(bool value);
0020     void setRenderSize(const QSize &size);
0021     QSize renderSize() const;
0022 
0023 protected:
0024     void paintEvent(QPaintEvent *event) override;
0025 
0026 private:
0027     void enterEvent(QEnterEvent *event) override;
0028     void focusInEvent(QFocusEvent *event) override;   
0029     void focusOutEvent(QFocusEvent *event) override;
0030     void leaveEvent(QEvent *event) override;
0031     bool on_ = false;
0032     bool over_ = false;
0033     QSize renderSize_;
0034 };
0035