File indexing completed on 2024-04-21 15:02:35

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 class KNotifyConfigElement;
0016 class KNotifyConfigWidgetPrivate;
0017 /**
0018  * @class KNotifyConfigWidget knotifyconfigwidget.h <KNotifyConfigWidget>
0019  *
0020  * Configure the notification for a given application / context
0021  *
0022  * You probably will want to use the static function configure
0023  *
0024  * If you create the widget yourself, you must call setApplication before showing it
0025  *
0026  * @author Olivier Goffart <ogoffart @ kde.org>
0027  */
0028 class KNOTIFYCONFIG_EXPORT KNotifyConfigWidget : public QWidget
0029 {
0030     Q_OBJECT
0031 public:
0032     explicit KNotifyConfigWidget(QWidget *parent);
0033     ~KNotifyConfigWidget() override;
0034 
0035     /**
0036      * Show a dialog with the widget.
0037      * @param parent the parent widget of the dialog
0038      * @param appname the application name,  if null, it is autodetected
0039      * @return the widget itself    the topLevelWidget of it is probably a KDialog
0040      */
0041     static KNotifyConfigWidget *configure(QWidget *parent = nullptr, const QString &appname = QString());
0042 
0043     /**
0044      * Change the application and the context
0045      *
0046      * @param appname name of the application.   if null QCoreApplication::instance()->applicationName() is used
0047      * @param context_name the name of the context, if null , avery context are considered
0048      * @param context_value the context value
0049      */
0050     void setApplication(const QString &appname = QString(), const QString &context_name = QString(), const QString &context_value = 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:
0088     KNotifyConfigWidgetPrivate *const d;
0089 private Q_SLOTS:
0090     KNOTIFYCONFIG_NO_EXPORT void slotEventSelected(KNotifyConfigElement *e);
0091     KNOTIFYCONFIG_NO_EXPORT void slotActionChanged();
0092 };
0093 
0094 #endif