diff --git a/Mainpage.dox b/Mainpage.dox new file mode 100644 --- /dev/null +++ b/Mainpage.dox @@ -0,0 +1,111 @@ +/** \mainpage KNotifications + +KNotifications is a cross-platform library for creating popup notifications. + +It currently supports Linux (and other Unix platforms that implement freedesktop.org notifications), Windows (8 or later), macOS and Android (version 5.0 or later). + +Please consult the KDE Human Interface Guidelines for when using Notifications is appropriate. + +KNotification is the main entry point for using KNotifications. + +\section file The global config file +In order to perform a notification, you need to create a description file, which contains +default parameters of the notification. It needs to be installed to knotifications5/appname.notifyrc +in a QStandardPaths::GenericDataLocation directory. +On Android, this path is qrc:/knotifications5/. + +The filename must either match QCoreApplication::applicationName or be specified as the +component name to the KNotification object. +@warning Notifications won't be visible otherwise. + +You can do this with the following CMake command: +install(FILES appname.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR})) + + This file contains mainly 3 parts +
    +
  1. \ref global "Global information"
  2. +
  3. \ref context "Context information"
  4. +
  5. \ref events "Definition of individual events"
  6. +
+ +\subsection global Global information +The global part looks like that +
+    [Global]
+    IconName=myicon
+    Comment=Friendly Name of app
+    Name=Name of app
+
+ The Comment field will be used in the system settings to describe the application. + The Name field is optional and may be used as the application name for popup, + if Name is not present, Comment is used instead + +\subsection context Context information + +This part consists of hints for the configuration widget +
+    [Context/group]
+    Name=Group name
+    Comment=The name of the group for contacts
+
+    [Context/folder]
+    Name=Group name
+ 
+ The second part of the groupname is the context identifier. + It should not contain special characters. + The Name field is the one the user will see (and which is translated) + +\subsection events Definition of Events + +The definition of the events forms the most important part of the config file +
+    [Event/newmail]
+    Name=New email
+    Comment=You have got a new email
+    Contexts=folder,group
+    Action=Sound|Popup
+
+    [Event/contactOnline]
+    Name=Contact goes online
+    Comment=One of your contact has been connected
+    Contexts=group
+    Sound=filetoplay.ogg
+    Action=None
+    Urgency=Low
+ 
+These are the default settings for each notifiable event. +Action is the string representing the action. Actions can be added to +KNotification as plugins, by deriving from KNotificationPlugin. +At the time of writing, the following actions are available: Taskbar, +Sound, Popup, Logfile, TTS, Execute. +Actions can be combined by separating them with '|'. + +Contexts is a comma separated list of possible context for this event. + +Urgency can be any of: Low, Normal, Critical. + +\section example Example of code + +This portion of code will fire the event for the "contactOnline" event + +@code + KNotification *notification = new KNotification("contactOnline"); + notification->setText(i18n("The contact %1 has gone online", contact->name()); + notification->setPixmap(contact->pixmap()); + notification->setActions({i18n("Open chat")}); + + const auto groups = contact->groups(); + for (const QString &group : groups) { + notification->addContext("group", group); + } + + connect(notification, QOverload::of(&KNotification::activated), contact, &Contact::slotOpenChat); + + notification->sendEvent(); +@endcode +*/ + +// DOXYGEN_SET_RECURSIVE = YES +// DOXYGEN_SET_EXCLUDE_PATTERNS += *_p.h */private/* */examples/* +// DOXYGEN_SET_PROJECT_NAME = KNotifications +// vim:ts=4:sw=4:expandtab:filetype=doxygen diff --git a/src/knotification.h b/src/knotification.h --- a/src/knotification.h +++ b/src/knotification.h @@ -34,160 +34,7 @@ /** * @class KNotification knotification.h KNotification * - * KNotification is used to notify the user of an event. - * - * \section Introduction - * - * There are two main kinds of notifications: - * - * @li Feedback events: - * For notifying the user that he/she just performed an operation, like maximizing a - * window. This allows us to play sounds when a dialog appears. - * This is an instant notification. It ends automatically after a small timeout. - * - * @li persistant notifications: - * Notify when the user received a new message, or when something else important happened - * the user has to know about. This notification has a start and a end. It begins when - * the event actually occurs, and finishes when the message is acknowledged or read. - * - * Example of a persistent notification in an instant messaging application: - * The application emits the notification when the message is actually received, and closes it only - * when the user has read the message (when the message window has received the focus) using the close() slot. - * Persistent notifications must have the Persistent flag. - * - * By default a notification will use the application name as title, but you - * can also provide a brief text in the title and a more precise description in - * the body text. This is especially useful for notifications coming from - * applications which should be considered "part of the system", like a battery - * monitor or a network connection manager. - * For example a battery indicator could use "Low Battery" as a title and "Only - * 12 minutes left." as a body text. - * - * In order to perform a notification, you need to create a description file, which contains - * default parameters of the notification, and use KNotification::event at the place in the - * application code where the notification occurs. - * The returned KNotification pointer may be used to connect signals or slots - * - * \section file The global config file - * Your application should install a file called knotifications5/appname.notifyrc - * in a QStandardPaths::GenericDataLocation directory. - * On Android, this path is qrc:/knotifications5/. - * - * The filename must either match QCoreApplication::applicationName or be specified as the - * component name to the KNotification object. - * @warning Notifications won't be visible otherwise. - * - * You can do this with the following CMake command: - * install(FILES appname.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR})) - * - * This file contains mainly 3 parts - *
  1. \ref global "Global information"
  2. - *
  3. \ref context "Context information"
  4. - *
  5. \ref events "Definition of individual events"
- * - * \subsection global Global information - * The global part looks like that - *
-           [Global]
-           IconName=Filename
-           Comment=Friendly Name of app
-           Name=Name of app
- * 
- * The icon filename is just the name, without extension, it's found with the KIconLoader. - * The Comment field will be used in KControl to describe the application. - * The Name field is optional and may be used as the application name for popup, - * if Name is not present, Comment is used instead - * - * \subsection context Context information - * - * This part consists of hints for the configuration widget - *
-           [Context/group]
-           Name=Group name
-           Comment=The name of the group for contacts
-
-           [Context/folder]
-           Name=Group name
- *  
- * The second part of the groupname is the context identifier. - * It should not contain special characters. - * The Name field is the one the user will see (and which is translated) - * - * \subsection events Definition of Events - * - * The definition of the events forms the most important part of the config file - *
-           [Event/newmail]
-           Name=New email
-           Comment=You have got a new email
-           Contexts=folder,group
-           Action=Sound|Popup
-
-           [Event/contactOnline]
-           Name=Contact goes online
-           Comment=One of your contact has been connected
-           Contexts=group
-           Sound=filetoplay.ogg
-           Action=None
-           Urgency=Low
- *  
- * These are the default settings for each notifiable event. - * Action is the string representing the action. Actions can be added to - * KNotification as plugins, by deriving from KNotificationPlugin. - * At the time of writing, the following actions are available: Taskbar, - * Sound, Popup, Logfile, TTS, Execute. - * Actions can be combined by separating them with '|'. - * - * Contexts is a comma separated list of possible context for this event. - * - * Urgency can be any of: Low, Normal, Critical. - * - * \section userfile The user's config file - * - * This is an implementation detail, and is described here for your information. - * - * In the config file, there are two parts: the event configuration, and the context information - * \subsection context Context information - * These are hints for the configuration dialog. They contain both the internal id of the context, and the user visible string. - *
-           [Context/group]
-           Values=1:Friends,2:Work,3:Family
- *  
- * \subsection event Events configuration - * This contains the configuration of events for the user. - * It contains the same fields as the description file. - * The key of groups is in the form - * Event/<EventName>/<ContextName>/<ContextValue> - *
-           [Event/contactOnline]
-           Action=Sound
-           Sound=/usr/share/sounds/super.ogg
-
-           [Event/contactOnline/group/1]
-           Action=Popup|Sound
- * 
- * - * \section example Example of code - * - * This portion of code will fire the event for the "contactOnline" event - * - * @code - KNotification *notification= new KNotification ( "contactOnline", widget ); - notification->setText( i18n("The contact %1 has gone online", contact->name() ); - notification->setPixmap( contact->pixmap() ); - notification->setActions( QStringList( i18n( "Open chat" ) ) ); - - const auto groups = contact->groups(); - for ( const QString &group : groups ) { - notification->addContext( "group" , group ) ; - } - - connect(notification, SIGNAL(activated(unsigned int )), contact , SLOT(slotOpenChat()) ); - - notification->sendEvent(); - * @endcode - * - * @author Olivier Goffart \ + * KNotification is the main class for creating notifications. */ class KNOTIFICATIONS_EXPORT KNotification : public QObject {