File indexing completed on 2024-04-21 03:42:02

0001 /*
0002     This file is part of Kiten, a KDE Japanese Reference Tool
0003     SPDX-FileCopyrightText: 2006 Joseph Kerian <jkerian@gmail.com>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef RADICALBUTTON_H
0009 #define RADICALBUTTON_H
0010 
0011 #include <QPushButton>
0012 #include <QString>
0013 
0014 class QMouseEvent;
0015 
0016 class RadicalButton : public QPushButton
0017 {
0018     Q_OBJECT
0019 
0020 public:
0021     RadicalButton(const QString &text, QWidget *parent);
0022     ~RadicalButton() override = default;
0023     /**
0024      * Overriding QPushButton's event for mousewheel events on a disabled button
0025      */
0026     bool event(QEvent *event) override;
0027     QSize minimumSizeHint() const override;
0028     QSize sizeHint() const override;
0029 
0030     typedef enum {
0031         Normal, /**< Normal button */
0032         Selected, /**< This button has been selected (checked) */
0033         NotAppropriate, /**< Due to other selected buttons: disabled */
0034         Related, /**< Display only this radical and related ones: italics? */
0035         Hidden /**< Not related (to above), so hide() */
0036     } ButtonStatus;
0037 
0038 Q_SIGNALS:
0039     void userClicked(const QString &text, RadicalButton::ButtonStatus status);
0040 
0041 public Q_SLOTS:
0042     void mousePressEvent(QMouseEvent *e) override;
0043     void mouseReleaseEvent(QMouseEvent *e) override;
0044     void resetButton();
0045     void setStatus(RadicalButton::ButtonStatus newStatus);
0046 
0047 private:
0048     ButtonStatus m_status;
0049 };
0050 
0051 #endif