File indexing completed on 2024-04-21 03:56:30

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2005 Olivier Goffart <ogoffart at kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #ifndef KNOTIFYCONFIGWIDGET_H
0009 #define KNOTIFYCONFIGWIDGET_H
0010 
0011 #include <QString>
0012 #include <QWidget>
0013 #include <knotifyconfig_export.h>
0014 
0015 #include <memory>
0016 
0017 class KNotifyConfigElement;
0018 class KNotifyConfigWidgetPrivate;
0019 /**
0020  * @class KNotifyConfigWidget knotifyconfigwidget.h <KNotifyConfigWidget>
0021  *
0022  * Configure the notification for a given application
0023  *
0024  * You probably will want to use the static function configure
0025  *
0026  * If you create the widget yourself, you must call setApplication before showing it
0027  *
0028  * @author Olivier Goffart <ogoffart @ kde.org>
0029  */
0030 class KNOTIFYCONFIG_EXPORT KNotifyConfigWidget : public QWidget
0031 {
0032     Q_OBJECT
0033 public:
0034     explicit KNotifyConfigWidget(QWidget *parent);
0035     ~KNotifyConfigWidget() override;
0036 
0037     /**
0038      * Show a dialog with the widget.
0039      * @param parent the parent widget of the dialog
0040      * @param appname the application name,  if null, it is autodetected
0041      * @return the widget itself    the topLevelWidget of it is probably a KDialog
0042      */
0043     static KNotifyConfigWidget *configure(QWidget *parent = nullptr, const QString &appname = QString());
0044 
0045     /**
0046      * Change the application
0047      *
0048      * @param appname name of the application.   if null QCoreApplication::instance()->applicationName() is used
0049      */
0050     void setApplication(const QString &appname = QString());
0051 
0052     /**
0053      * Select a given notification in the current list
0054      *
0055      * @param id The id of the notification
0056      * @since 5.18
0057      */
0058     void selectEvent(const QString &eventId);
0059 
0060 public Q_SLOTS:
0061     /**
0062      * save to the config file
0063      */
0064     void save();
0065 
0066     /*
0067      * Reset the UI to display the default values
0068      * @see KCModule::defaults
0069      * @since 5.15
0070      */
0071     void revertToDefaults();
0072 
0073     /*
0074      * Disable all sounds for the current application
0075      * @since 5.23
0076      */
0077     void disableAllSounds();
0078 
0079 Q_SIGNALS:
0080     /**
0081      * Indicate that the state of the modules contents has changed.
0082      * This signal is emitted whenever the state of the configuration changes.
0083      * @see KCModule::changed
0084      */
0085     void changed(bool state);
0086 
0087 private Q_SLOTS:
0088     KNOTIFYCONFIG_NO_EXPORT void slotEventSelected(KNotifyConfigElement *e);
0089     KNOTIFYCONFIG_NO_EXPORT void slotActionChanged();
0090 
0091 private:
0092     std::unique_ptr<KNotifyConfigWidgetPrivate> const d;
0093 };
0094 
0095 #endif