File indexing completed on 2024-05-19 03:59:01

0001 /*
0002     SPDX-FileCopyrightText: 2004 Aaron J. Seigo <aseigo@kde.org>
0003     SPDX-FileCopyrightText: 2021 Alexander Lohnau <alexander.lohnau@gmx.de>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 #ifndef KNEWSTUFFWIDGETSBUTTON_H
0009 #define KNEWSTUFFWIDGETSBUTTON_H
0010 
0011 #include <KNSCore/Entry>
0012 #include <QPushButton>
0013 #include <memory>
0014 
0015 #include "knewstuffwidgets_export.h"
0016 
0017 namespace KNSWidgets
0018 {
0019 class ButtonPrivate;
0020 /**
0021  * @class Button button.h <KNSWidgets/Button>
0022  *
0023  * QPushButton subclass that encapsulates the logic for showing the KNewStuff dialog.
0024  * If KNewStuff is disabled using KAuthorized, the button is hidden.
0025  * @see KAuthorized::GenericRestriction::GHNS
0026  *
0027  * @since 5.91
0028  */
0029 class KNEWSTUFFWIDGETS_EXPORT Button : public QPushButton
0030 {
0031     Q_OBJECT
0032 
0033 public:
0034     /**
0035      * Constructor used when the details of the KHotNewStuff
0036      * download is known when the button is created.
0037      *
0038      * @param text describing what is being downloaded.
0039      *        It should be a text beginning with "Download New ..." for consistency
0040      * @param configFile the name of the .knsrc file
0041      * @param parent the parent widget
0042      */
0043     explicit Button(const QString &text, const QString &configFile, QWidget *parent);
0044 
0045     /**
0046      * Constructor used when the code is generated from a .ui file
0047      * After the UI is set up, you must call setConfigFile(QString)
0048      */
0049     explicit Button(QWidget *parent);
0050 
0051     ~Button() override;
0052 
0053     /**
0054      * @note This should only be used when crating the button from a UI-file
0055      */
0056     void setConfigFile(const QString &configFile);
0057 
0058 Q_SIGNALS:
0059     /**
0060      * emitted when the dialog has been closed
0061      */
0062     void dialogFinished(const QList<KNSCore::Entry> &changedEntries);
0063 
0064 private:
0065     const std::unique_ptr<ButtonPrivate> d;
0066 };
0067 
0068 }
0069 
0070 #endif // KNEWSTUFFBUTTON_H