Skip to content

Commit

Permalink
New methods: pluginVersion() and pythonVersion()
Browse files Browse the repository at this point in the history
  • Loading branch information
thp committed Feb 6, 2014
1 parent da02a1c commit be1edb6
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ the QML UI thread:

Call a Python function. Returns the return value of the Python function.

The following functions allow access to the version of the running PyOtherSide
plugin and Python interpreter.

.. function:: pluginVersion() -> string

Get the version of the PyOtherSide plugin that is currently used.

.. versionadded:: 1.1.0

.. function:: pythonVersion() -> string

Get the version of the Python interpreter that is currently used.

.. versionadded:: 1.1.0

Python API
==========

Expand Down Expand Up @@ -664,6 +679,7 @@ Version 1.1.0 (2014-02-XX)
* Add support for Python-based image providers (see `Image Provider`_).
* Fix threading crashes and aborts due to assertions.
* :func:`addImportPath` will automatically strip a leading ``file://``.
* Added :func:`pluginVersion` and :func:`pythonVersion` for runtime version detection.

Version 1.0.0 (2013-08-08)
--------------------------
Expand Down
4 changes: 4 additions & 0 deletions examples/helloworld.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Rectangle {
id: python

Component.onCompleted: {
// Print version of plugin and Python interpreter
console.log('PyOtherSide version: ' + pluginVersion());
console.log('Python version: ' + pythonVersion());

// Asynchronous module importing
importModule('os', function() {
console.log('Python module "os" is now imported');
Expand Down
2 changes: 2 additions & 0 deletions pyotherside.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PROJECTNAME = pyotherside
VERSION = 1.1.0
12 changes: 12 additions & 0 deletions src/qpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,15 @@ QPython::imported(bool result, QJSValue *callback)
callback->call(args);
delete callback;
}

QString
QPython::pluginVersion()
{
return QString(PYOTHERSIDE_VERSION);
}

QString
QPython::pythonVersion()
{
return QString(PY_VERSION);
}
17 changes: 17 additions & 0 deletions src/qpython.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,23 @@ class QPython : public QObject {
Q_INVOKABLE QVariant
call_sync(QString func, QVariant args=QVariantList());


/**
* \brief Get the PyOtherSide version
*
* \result The running version of PyOtherSide
**/
Q_INVOKABLE QString
pluginVersion();

/**
* \brief Get the Python versino
*
* \result The running versino of Python
**/
Q_INVOKABLE QString
pythonVersion();

signals:
/**
* \brief Default event handler for \c pyotherside.send()
Expand Down
4 changes: 4 additions & 0 deletions src/src.pro
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
TARGET = pyothersideplugin

include(../pyotherside.pri)

DEFINES += PYOTHERSIDE_VERSION=\\\"$${VERSION}\\\"

PLUGIN_IMPORT_PATH = io/thp/pyotherside

TEMPLATE = lib
Expand Down
3 changes: 3 additions & 0 deletions tests/tests.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
QT += testlib qml
CONFIG -= app_bundle

include(../pyotherside.pri)
DEFINES += PYOTHERSIDE_VERSION=\\\"$${VERSION}\\\"

SOURCES += tests.cpp
HEADERS += tests.h

Expand Down

0 comments on commit be1edb6

Please sign in to comment.