File indexing completed on 2024-04-21 16:30:28

0001 // SPDX-FileCopyrightText: 2006 Pino Toscano <toscano.pino@tiscali.it>
0002 // SPDX-FileCopyrightText: 2020 Simon Persson <simon.persson@mykolab.com>
0003 //
0004 // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 
0006 #ifndef KBUTTONGROUP_H
0007 #define KBUTTONGROUP_H
0008 
0009 #include <QGroupBox>
0010 
0011 class QAbstractButton;
0012 
0013 /**
0014  * @deprecated since 5.0, use QGroupBox and QButtonGroup instead
0015  *
0016  * @short Group box with index of the selected button
0017  * KButtonGroup is a simple group box that can keep track of the current selected
0018  * button of the ones added to it.
0019  *
0020  * Use normally as you would with a QGroupBox.
0021  *
0022  * \image html kbuttongroup.png "KDE Button Group containing 3 KPushButtons"
0023  *
0024  * @author Pino Toscano <toscano.pino@tiscali.it>
0025  */
0026 class KButtonGroup : public QGroupBox
0027 {
0028     Q_OBJECT
0029 
0030     Q_PROPERTY(int current READ selected WRITE setSelected NOTIFY changed USER true)
0031 
0032 public:
0033     /**
0034      * Construct a new empty KGroupBox.
0035      */
0036     explicit KButtonGroup(QWidget *parent = nullptr);
0037 
0038     /**
0039      * Destroys the widget.
0040      */
0041     ~KButtonGroup() override;
0042 
0043     /**
0044      * Return the index of the selected QAbstractButton, among the QAbstractButton's
0045      * added to the widget.
0046      * @return the index of the selected button
0047      */
0048     int selected() const;
0049 
0050     /**
0051      * @return the index of @p button.
0052      * @since 4.3
0053      */
0054     int id(QAbstractButton *button) const;
0055 
0056 public Q_SLOTS:
0057     /**
0058      * Select the \p id -th button
0059      */
0060     void setSelected(int id);
0061 
0062 Q_SIGNALS:
0063     /**
0064      * The button with index \p id was clicked
0065      */
0066     void clicked(int id);
0067     /**
0068      * The button with index \p id was pressed
0069      */
0070     void pressed(int id);
0071     /**
0072      * The button with index \p id was released
0073      */
0074     void released(int id);
0075     /**
0076      * Emitted when anything (a click on a button, or calling setSelected())
0077      * change the id of the current selected. \p id is the index of the new
0078      * selected button.
0079      */
0080     void changed(int id);
0081 
0082 protected:
0083     /**
0084      * Reimplemented from QGroupBox.
0085      */
0086     void childEvent(QChildEvent *event) override;
0087 
0088 private:
0089     Q_PRIVATE_SLOT(d, void slotClicked(int id))
0090 
0091     class Private;
0092     friend class Private;
0093     Private *const d;
0094 };
0095 
0096 #endif
0097 
0098