File indexing completed on 2024-03-24 15:36:49

0001 /*
0002     This file is part of KNewStuff2.
0003     SPDX-FileCopyrightText: 2004 Aaron J. Seigo <aseigo@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 #ifndef KNEWSTUFF3BUTTON_H
0009 #define KNEWSTUFF3BUTTON_H
0010 
0011 #include <QPushButton>
0012 
0013 #include "entry.h"
0014 #include "knewstuff_export.h"
0015 
0016 #if KNEWSTUFF_ENABLE_DEPRECATED_SINCE(5, 91)
0017 
0018 #include <memory>
0019 
0020 namespace KNS3
0021 {
0022 class ButtonPrivate;
0023 /**
0024  * KHotNewStuff push button that makes using KHNS in an application
0025  * more convenient by encapsulating most of the details involved in
0026  * using KHotNewStuff in the button itself.
0027  *
0028  * @since 4.4
0029  * @deprecated Since 5.91, use KNSWidgets::Button instead
0030  */
0031 class KNEWSTUFF_EXPORT Button : public QPushButton
0032 {
0033     Q_OBJECT
0034 
0035 public:
0036     /**
0037      * Constructor used when the details of the KHotNewStuff
0038      * download is known when the button is created.
0039      *
0040      * @param text describing what is being downloaded.
0041      *        It should be a text beginning with "Download New ..." for consistency
0042      * @param configFile the name of the .knsrc file
0043      * @param parent the parent widget
0044      */
0045     KNEWSTUFF_DEPRECATED_VERSION(5, 91, "use KNSWidgets::Button instead")
0046     Button(const QString &text, const QString &configFile, QWidget *parent);
0047 
0048     /**
0049      * Constructor used when the details of the KHotNewStuff
0050      * download is not known in advance of the button being created.
0051      *
0052      * @param parent the parent widget
0053      */
0054     KNEWSTUFF_DEPRECATED_VERSION(5, 91, "use KNSWidgets::Button instead")
0055     explicit Button(QWidget *parent);
0056 
0057     ~Button() override;
0058 
0059     /**
0060      * set the name of the .knsrc file to use
0061      */
0062     void setConfigFile(const QString &configFile);
0063 
0064 #if KNEWSTUFF_ENABLE_DEPRECATED_SINCE(5, 76)
0065     /**
0066      * Set the text that should appear on the button.
0067      * @deprecated Since 5.0, use setText(const QString&) instead
0068      */
0069     KNEWSTUFF_DEPRECATED_VERSION_BELATED(5, 76, 5, 0, "Use setText(const QString&) instead")
0070     void setButtonText(const QString &text);
0071 #endif
0072 
0073 Q_SIGNALS:
0074     /**
0075      * emitted when the Hot New Stuff dialog is about to be shown, usually
0076      * as a result of the user having click on the button
0077      */
0078     void aboutToShowDialog();
0079 
0080     /**
0081      * emitted when the Hot New Stuff dialog has been closed
0082      */
0083     void dialogFinished(const KNS3::Entry::List &changedEntries);
0084 
0085 protected Q_SLOTS:
0086     void showDialog();
0087 
0088 private:
0089     void init();
0090 
0091     const std::unique_ptr<ButtonPrivate> d;
0092 };
0093 
0094 }
0095 
0096 #endif
0097 #endif // KNEWSTUFFBUTTON_H