1

Tutorial4: Change the flow of the article

Signed-off-by: Juraj Oravec <sgd.orava@gmail.com>
This commit is contained in:
Juraj Oravec 2019-05-24 23:44:20 +02:00
parent 0d6c8dda8e
commit 4baa816d77
No known key found for this signature in database
GPG Key ID: 63ACB65056BC8D07

View File

@ -1,7 +1,14 @@
# Falkon Python Tutorial - 4. Adding entry to the extension menu # Falkon Python Tutorial - 4. Adding entry to the extension menu
Hello, in this chapter I will show you how to add an entry to the extension menu.
The extension menu is located at `Tools`: `Extensions`. The extension menu is located at `Tools`: `Extensions`.
![Extension menu](../images/Tutorial4/ExtensionMenu.png)
In this example extension you will see popup [message box](https://doc.qt.io/qtforpython/PySide2/QtWidgets/QMessageBox.html) with 'Tutorial 4 - Message from extension menu' after you click on the menu entry.
![Extension menu](../images/Tutorial4/MessageBox.png)
To add an entry to extension menu the `populateExtensionsMenu(self, menu)` method has to be implemented in plugin class. To add an entry to extension menu the `populateExtensionsMenu(self, menu)` method has to be implemented in plugin class.
The reason can be found in the [source code](https://github.com/KDE/falkon/blob/master/src/lib/plugins/plugininterface.h) The reason can be found in the [source code](https://github.com/KDE/falkon/blob/master/src/lib/plugins/plugininterface.h)
@ -23,16 +30,8 @@ The parameter menu is the menu into which the new entry / action will be added.
msgBox.exec_() msgBox.exec_()
``` ```
![Extension menu](../images/Tutorial4/ExtensionMenu.png)
![Extension menu](../images/Tutorial4/MessageBox.png)
In this example the action will show messagebox[1] with 'Tutorial 4 - Message from extension menu'.
The full code can be found at [extensions/Tutorial4](../extensions/Tutorial4) The full code can be found at [extensions/Tutorial4](../extensions/Tutorial4)
**Note:** Always create an instance of Action in `populateExtensionsMenu`. **Note:** Always create an instance of Action in `populateExtensionsMenu`.
It will be deleted / destroyed when the menu is hidden. It will be deleted / destroyed when the menu is hidden.
Do **not** try to add keyboard shortcut to the action used to construct the menu, it will not work properly. Do **not** try to add keyboard shortcut to the action used to construct the menu, it will not work properly.
[1]: https://doc.qt.io/qtforpython/PySide2/QtWidgets/QMessageBox.html