File indexing completed on 2024-04-14 04:38:32

0001 /*
0002     This file is part of the Polkit-qt project
0003     SPDX-FileCopyrightText: 2009 Dario Freddi <drf@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef POLKITQT1_GUI_ACTIONBUTTONS_H
0009 #define POLKITQT1_GUI_ACTIONBUTTONS_H
0010 
0011 #include "polkitqt1-gui-actionbutton.h"
0012 
0013 namespace PolkitQt1
0014 {
0015 
0016 namespace Gui
0017 {
0018 
0019 class ActionButtonsPrivate;
0020 /**
0021  * \class ActionButtons polkitqt1-gui-actionbuttons.h ActionButtons
0022  * \author Dario Freddi <drf@kde.org>
0023  *
0024  * \brief Class used to hold and update a list of QAbstractButtons
0025  *
0026  * This class is a convenience wrapper around ActionButton that lets
0027  * you associate an undefined number of QAbstractButtons with a single
0028  * action. Every button will be updated accordingly upon action's properties
0029  * changes.
0030  *
0031  * \see ActionButton
0032  */
0033 class ActionButtons : public ActionButton
0034 {
0035     Q_OBJECT
0036     Q_DECLARE_PRIVATE(ActionButtons)
0037     Q_DISABLE_COPY(ActionButtons)
0038 
0039 public:
0040     /**
0041      * Constructs a new ActionButton. You need to pass this
0042      * constructor an existing list of QAbstractButtons, whose properties
0043      * will be modified according to the underlying Action
0044      * object. As ActionButtons inherits from Action, you can
0045      * define your buttons' behavior right through this wrapper.
0046      *
0047      * \see Action
0048      *
0049      * \param buttons the QAbstractButton to associate to this ActionButton
0050      * \param actionId the action Id to create the underlying Action
0051      * \param parent the parent object
0052      */
0053     explicit ActionButtons(const QList<QAbstractButton *> &buttons, const QString &actionId = QString(), QObject *parent = nullptr);
0054     ~ActionButtons() override;
0055 
0056     /**
0057      * Sets a list of buttons associated to the underlying action.
0058      *
0059      * \note If you are calling this function, you're probably
0060      *       changing the buttons list the action is referring to. If this
0061      *       is the case, please note that Polkit-Qt does not handle
0062      *       the previous buttons' memory, so you should take care of
0063      *       deleting them yourself (if needed). You can retrieve it by
0064      *       using buttons()
0065      *
0066      * \see buttons
0067      *
0068      * \param buttons the new buttons associated with the underlying action
0069      */
0070     void setButtons(const QList<QAbstractButton *> &buttons);
0071 
0072     /**
0073      * Returns the current buttons list
0074      *
0075      * \return the buttons currently associated with the underlying action
0076      */
0077     QList<QAbstractButton *> buttons() const;
0078 
0079     /**
0080      * Adds a button to the current button list. The button's properties
0081      * will be updated according to the action upon adding.
0082      *
0083      * \param button the button to add
0084      */
0085     void addButton(QAbstractButton *button);
0086 
0087     /**
0088      * Removes a button from the current list. Please note that Polkit-Qt
0089      * does not handle the removed button's memory, so you should take care of
0090      * deleting it yourself (if needed).
0091      *
0092      * \param button the button to remove
0093      */
0094     void removeButton(QAbstractButton *button);
0095 };
0096 
0097 }
0098 
0099 }
0100 
0101 #endif