parley
Classes | |
class | Container |
class | Document |
class | Expression |
class | Identifier |
class | Lesson |
class | Parley |
class | Text |
class | Translation |
Functions | |
QList< KEduVocLesson * > | flattenLessons (KEduVocLesson *rootLesson) |
Detailed Description
Contains all the classes exposed to Kross scripts.
Main entry point is the Scripting::Parley class which allows us to access all the other Scripting classes (see code below).
Class Hierarchy:
- Parley
- Document
- Lesson (inherits Container)
- Expression (known as Entry in functions)
- Translation (inherits Text)
- Expression (known as Entry in functions)
- Lesson (inherits Container)
- Identifier
- Document
How to create a new Parley script (full example)
Each Parley script must be accompanied by a .desktop file, both put in the plugins folder in parley data directory (usually in /usr/share/apps/parley/plugins/). In this example the desktop file is "example.desktop" and the script file is "example.py".
The desktop file provides information about the script's functionality, author and specifies the script file that implements it. This information will appear in the Scripts Manager (Scripts->Script Manager in main menu) and the user will be able to enable/disable the script. If the script is enabled then it'll be loaded every time Parley starts up.
Content of example.desktop (/usr/share/apps/parley/plugins/example.desktop)
The script file will contain the functions (script functionality) and some code for creating an action for the Scripts menu. In the example below, the functions are moveSelectedToNewLesson() and markAsKnown() and they are called by the two actions that are added to the scripts menu (action1 and action2).
When the script file is loaded all the global code (outside of any function) is executed. This way we can register the Scripts menu actions and connect them with script functions (see example below for how to do this).
Another way to have a function called is by connecting it to a Parley signal (see Parley::translateWord() and the example in Detailed Description of the Parley class).
Content of example.py (/usr/share/apps/parley/plugins/example.py)
After creating the Script action and being able to call a function you can start adding your own code, using the documentation provided for the scripting classes and by seeing other examples.
For debugging use the standard output and observed it in the terminal.
Function Documentation
QList<KEduVocLesson*> Scripting::flattenLessons | ( | KEduVocLesson * | rootLesson | ) |
Definition at line 46 of file lesson.cpp.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:06 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.