File indexing completed on 2024-03-24 15:27:40

0001 /* This file is part of the KDE libraries
0002     Copyright (C) 1997 Mario Weilguni (mweilguni@sime.com)
0003     Copyright (C) 2006 Olivier Goffart <ogoffart@kde.org>
0004 
0005     This library is free software; you can redistribute it and/or
0006     modify it under the terms of the GNU Library General Public
0007     License as published by the Free Software Foundation; either
0008     version 2 of the License, or (at your option) any later version.
0009 
0010     This library is distributed in the hope that it will be useful,
0011     but WITHOUT ANY WARRANTY; without even the implied warranty of
0012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013     Library General Public License for more details.
0014 
0015     You should have received a copy of the GNU Library General Public License
0016     along with this library; see the file COPYING.LIB.  If not, write to
0017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018     Boston, MA 02110-1301, USA.
0019 */
0020 
0021 #ifndef KDIALOGBUTTONBOX_H
0022 #define KDIALOGBUTTONBOX_H
0023 
0024 #include <kdelibs4support_export.h>
0025 
0026 #include <QDialogButtonBox>
0027 
0028 class QPushButton;
0029 class KPushButton;
0030 class KGuiItem;
0031 
0032 class KDialogButtonBoxPrivate;
0033 /**
0034  * Container widget for buttons.
0035  *
0036  * An extension of QDialogButtonBox which allow the use of KGuiItem and
0037  * conveniance slot connection.
0038  *
0039  * \image html kdialogbuttonbox.png "Various KDE Dialog Button Boxes with different buttons"
0040  *
0041  * @author Mario Weilguni <mweilguni@sime.com>
0042  * @author Olivier Goffart <ogoffart@kde.org>
0043  **/
0044 
0045 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KDialogButtonBox : public QDialogButtonBox
0046 {
0047     Q_OBJECT
0048 
0049 public:
0050     /**
0051       * Create an empty container for buttons.
0052       *
0053       * If @p _orientation is @p Vertical, the buttons inserted with
0054       * addButton() are laid out from top to bottom, otherwise they
0055       * are laid out from left to right.
0056       */
0057     KDELIBS4SUPPORT_DEPRECATED explicit KDialogButtonBox(QWidget *parent, Qt::Orientation _orientation = Qt::Horizontal);
0058 
0059     /**
0060       * Free private data field
0061       */
0062     ~KDialogButtonBox() override;
0063 
0064     /**
0065       * Creates a push button with the given text, adds it to the button box for the specified role, and returns the corresponding push button.
0066       * If role is invalid, no button is created, and zero is returned.
0067       *
0068       * The clicked signal of the button is automatically connected to the slot
0069       *
0070       * @param text the text of the button to add.
0071       * @param role the button role
0072       * @param receiver An object to connect to.
0073       * @param slot A Qt slot to connect the 'clicked()' signal to.
0074       *
0075       * @return A pointer to the new button.
0076       */
0077     QPushButton *addButton(const QString &text, ButtonRole role, QObject *receiver, const char *slot);
0078 
0079     /**
0080       * Creates a push button with the given KUiItem, adds it to the button box for the specified role, and returns the corresponding push button.
0081       * If role is invalid, the button is created, but not added.
0082       *
0083       * The clicked signal of the button is automatically connected to the slot
0084       *
0085       * @param guiitem text and icon on the button
0086       * @param role the button role
0087       * @param receiver An object to connect to.
0088       * @param slot A Qt slot to connect the 'clicked()' signal to.
0089       *
0090       * @return A pointer to the new button.
0091       */
0092     KPushButton *addButton(const KGuiItem &guiitem, ButtonRole role, QObject *receiver = nullptr, const char *slot = nullptr);
0093 
0094     using QDialogButtonBox::addButton;
0095 
0096 private:
0097     KDialogButtonBoxPrivate *const d;
0098 };
0099 
0100 #endif
0101