File indexing completed on 2024-04-21 15:02:28
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 <QPushButton> 0012 #include <memory> 0013 0014 #include "KNSCore/EntryInternal" 0015 #include "knewstuffwidgets_export.h" 0016 0017 namespace KNSCore 0018 { 0019 using Entry = KNSCore::EntryInternal; 0020 } 0021 0022 namespace KNSWidgets 0023 { 0024 class ButtonPrivate; 0025 /** 0026 * @class Button button.h <KNSWidgets/Button> 0027 * 0028 * KHotNewStuff push button that makes using KHNS in an application 0029 * more convenient by encapsulating most of the details involved in 0030 * using KHotNewStuff in the button itself. 0031 * 0032 * @since 5.91 0033 */ 0034 class KNEWSTUFFWIDGETS_EXPORT Button : public QPushButton 0035 { 0036 Q_OBJECT 0037 0038 // This way the configFile can be set as a property with QtCreator. 0039 Q_PROPERTY(QString configFile WRITE setConfigFile READ configFile) 0040 0041 public: 0042 /** 0043 * Constructor used when the details of the KHotNewStuff 0044 * download is known when the button is created. 0045 * 0046 * @param text describing what is being downloaded. 0047 * It should be a text beginning with "Download New ..." for consistency 0048 * @param configFile the name of the .knsrc file 0049 * @param parent the parent widget 0050 */ 0051 Button(const QString &text, const QString &configFile, QWidget *parent); 0052 0053 /** 0054 * Constructor used when the details of the KHotNewStuff 0055 * download is not known in advance of the button being created. 0056 * 0057 * @param parent the parent widget 0058 * @note When this constructor is used, the @p configFile property has to be set 0059 */ 0060 explicit Button(QWidget *parent); 0061 0062 ~Button() override; 0063 0064 /** 0065 * set the name of the .knsrc file to use 0066 */ 0067 void setConfigFile(const QString &configFile); 0068 0069 Q_SIGNALS: 0070 /** 0071 * emitted when the Hot New Stuff dialog is about to be shown, usually 0072 * as a result of the user having click on the button 0073 */ 0074 void aboutToShowDialog(); 0075 0076 /** 0077 * emitted when the Hot New Stuff dialog has been closed 0078 */ 0079 void dialogFinished(const QList<KNSCore::Entry> &changedEntries); 0080 0081 private: 0082 QString configFile(); 0083 Q_SLOT void showDialog(); 0084 friend class ButtonPrivate; 0085 const std::unique_ptr<ButtonPrivate> d; 0086 }; 0087 0088 } 0089 0090 #endif // KNEWSTUFFBUTTON_H