1

Add QML example for notifications

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
Juraj Oravec 2022-03-29 01:37:11 +02:00
parent d35b5a76af
commit 7f13bf1388
Signed by: SGOrava
GPG Key ID: 13660A3F1D9F093B
5 changed files with 92 additions and 0 deletions

View File

@ -4,3 +4,4 @@
2. [Basic Extension](articles/2.Basic_extension.md) - [Extension](extensions/qml_tutorial_2/)
3. [Adding a button to the toolbar](articles/3.Adding_a_button_to_the_toolbar.md) - [Extension](extensions/qml_tutorial_3/)
4. [Adding an entry to the web context menu](articles/4.Adding_entry_to_the_web_context_menu.md) - [Extension](extensions/qml_tutorial_4/)
5. [Using notifications](articles/4.Using_notificcations.md) - [Extension](extensions/qml_tutorial_5/)

View File

@ -0,0 +1,40 @@
# Falkon QML Tutorial - 5. Using notifications
Hello, in this chapter I will show you how to use Falkon notifications.
## Create notification
```qml
Falkon.Notifications.create({
heading: i18n('Hello QML'),
message: i18n('First qml plugin action works :-)'),
icon: 'extensions.svg'
})
```
## Arguments
### heading
Notification header
### message
The body of the notification
### icon
Either system icon or file provided by extension.
## Example
The example code will add a button to main toolbar and statusbar. When
user clicks on the button a notification will show up.
![Notification](../images/tutorial5/notification.png)
Keep in mind that the form and shape of my notifications can be
different from yours.
### Code
The code for this example can be found at
[extensions/qml_tutorial_5](../extensions/qml_tutorial_5)

View File

@ -0,0 +1,40 @@
import org.kde.falkon 1.0 as Falkon
import QtQuick 2.3
Falkon.PluginInterface {
init: function(state, settingsPath){
console.log(i18n('"Tutorial5" plugin loaded'))
}
testPlugin: function() {
return true
}
unload: function() {
console.log(i18n('"Tutorial5" plugin unloaded'))
}
function buttonClicked() {
Falkon.Notifications.create({
heading: i18n('QML Tutorial 5'),
message: i18n('Some message text body.'),
icon: 'falkon'
})
}
Falkon.BrowserAction {
name: 'QML Tutorial 3'
identity: 'qml-tutorial-3-id'
title: i18n('Qml Tutorial 3')
toolTip: i18n('My little button')
icon: 'falkon'
location: Falkon.BrowserAction.NavigationToolBar | Falkon.BrowserAction.StatusBar
onClicked: buttonClicked()
popup: Rectangle {
width: 100;
height: 100;
}
}
}

View File

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Tutorial5 QML
Comment=Example QML extension with button and notifications
Icon=
Type=Service
X-Falkon-Type=Extension/Qml
X-Falkon-Author=Juraj Oravec
X-Falkon-Email=jurajoravec@mailo.com
X-Falkon-Version=1.0.0
X-Falkon-Settings=false

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB