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 +
+ [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
- [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 \