1 | /* |
2 | SPDX-FileCopyrightText: 2004 Aaron J. Seigo <aseigo@kde.org> |
3 | SPDX-FileCopyrightText: 2021 Alexander Lohnau <alexander.lohnau@gmx.de> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.1-or-later |
6 | */ |
7 | |
8 | #ifndef KNEWSTUFFWIDGETSBUTTON_H |
9 | #define KNEWSTUFFWIDGETSBUTTON_H |
10 | |
11 | #include <KNSCore/Entry> |
12 | #include <QPushButton> |
13 | #include <memory> |
14 | |
15 | #include "knewstuffwidgets_export.h" |
16 | |
17 | namespace KNSWidgets |
18 | { |
19 | class ButtonPrivate; |
20 | /** |
21 | * @class Button button.h <KNSWidgets/Button> |
22 | * |
23 | * QPushButton subclass that encapsulates the logic for showing the KNewStuff dialog. |
24 | * If KNewStuff is disabled using KAuthorized, the button is hidden. |
25 | * @see KAuthorized::GenericRestriction::GHNS |
26 | * |
27 | * @since 5.91 |
28 | */ |
29 | class KNEWSTUFFWIDGETS_EXPORT Button : public QPushButton |
30 | { |
31 | Q_OBJECT |
32 | |
33 | public: |
34 | /** |
35 | * Constructor used when the details of the KHotNewStuff |
36 | * download is known when the button is created. |
37 | * |
38 | * @param text describing what is being downloaded. |
39 | * It should be a text beginning with "Download New ..." for consistency |
40 | * @param configFile the name of the .knsrc file |
41 | * @param parent the parent widget |
42 | */ |
43 | explicit Button(const QString &text, const QString &configFile, QWidget *parent); |
44 | |
45 | /** |
46 | * Constructor used when the code is generated from a .ui file |
47 | * After the UI is set up, you must call setConfigFile(QString) |
48 | */ |
49 | explicit Button(QWidget *parent); |
50 | |
51 | ~Button() override; |
52 | |
53 | /** |
54 | * @note This should only be used when crating the button from a UI-file |
55 | */ |
56 | void setConfigFile(const QString &configFile); |
57 | |
58 | Q_SIGNALS: |
59 | /** |
60 | * emitted when the dialog has been closed |
61 | */ |
62 | void dialogFinished(const QList<KNSCore::Entry> &changedEntries); |
63 | |
64 | private: |
65 | const std::unique_ptr<ButtonPrivate> d; |
66 | }; |
67 | |
68 | } |
69 | |
70 | #endif // KNEWSTUFFBUTTON_H |
71 | |