From 4baa816d772567e01e603b3c650a6508fee6a366 Mon Sep 17 00:00:00 2001 From: Juraj Oravec Date: Fri, 24 May 2019 23:44:20 +0200 Subject: [PATCH] Tutorial4: Change the flow of the article Signed-off-by: Juraj Oravec --- articles/4. Adding entry to the extension menu.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/articles/4. Adding entry to the extension menu.md b/articles/4. Adding entry to the extension menu.md index 7516fc7..8db2f44 100644 --- a/articles/4. Adding entry to the extension menu.md +++ b/articles/4. Adding entry to the extension menu.md @@ -1,7 +1,14 @@ # 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`. +![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. 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_() ``` -![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) **Note:** Always create an instance of Action in `populateExtensionsMenu`. 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. - -[1]: https://doc.qt.io/qtforpython/PySide2/QtWidgets/QMessageBox.html