#JsExtensions Plugin This QtCreator plugin enables writing plugins using JavaScript/QML #Overview Plugin allows to easily write simple additions to QtCreator called JEP plugins (*.jep.js files). JEP plugin files are JavaScript files with most of the QtCreator API avaliable. You don't need to clone and build QtCreator to develop QtCreator plugins.
You can get a pre-compiled plugin for Linux(Ubuntu) and Windows here. Just unzip JsExtensions folder to the QtCreator plugins folder (you may need to change the version of dependency Core in JsExtensions.pluginspec file - valid range from 3.0.0 to 3.2.1).
Here are some screenshots of JEP plugin:
Video available here.
There are 5 JEP-Plugins available now. You can manage them via Tools->JsExtensions... menu in QtCreator:
- RelaxTracker is a green box with "Work" label on Mode panel. This is a QQuickView window which periodically flashes with a red box and a label "Break" - to remind user to have a break.
- ModePanelButtons places your favorite commands as buttons on Mode panel.
- Calculator QML based calculator widget from QtCreator examples, which can be shown in Navigation panel (see video).
- Jenkins shows status of buildson Jenkins server.
- Weather-box shows current weather conditions see.
#How to write JEP plugins At QtCreator startup JsExtensions plugin scans jep_plugins folder and subfolders for *.jep.js files. It tries to load each *.jep.js file, looks for "initialize" function inside and executes it. We can write minimal jep plugin like this:
function initialize() {
// write message to General Messages panel with flashing
messageManager.write("Jep plugin has started!", 512);
}
There are two optional functions extensionsInitialized() and aboutToShutdown() that will be called in JsExtensionsPlugin::extensionsInitialized and JsExtensionsPlugin::aboutToShutdown functions. Also there are four optional variables to manage JEP plugins:
- pluginDescription - short text description of the plugin (for example "var pluginDescription = "My very usefull plugin";")
- pluginPriority - numeric variable to change loading order (for example "var pluginPriority = 1;")
- pluginEnable - bool variable to abort plugin loading (for example "var pluginEnable = false;")
- pluginTrace - bool variable to trace all wrapper calls to log file (for example "var pluginTrace = true;")
In the global object of the JavaScript/QML environment were injected several objects to access QtCreator API:
- core - wraps Core::ICore
- messageManager - wraps Core::MessageManager
- actionManager - wraps Core::ActionManager
- modeManager - wraps Core::ModeManager
- jepAPI - collection of utility functions
In addition to singleton objects there are wrappers for some other classes:
- Core::ActionContainer
- Core::Command