aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md14
-rw-r--r--examples/examples.pro4
-rw-r--r--examples/macroexpander.py (renamed from examples/macroexpander/__init__.py)0
-rw-r--r--plugins/pythonextensions/pythonextensionsplugin.cpp13
4 files changed, 20 insertions, 11 deletions
diff --git a/README.md b/README.md
index 58f2ee5..709dbc8 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,10 @@
# Python Extensions for Qt Creator
This plugin for Qt Creator makes it possible to extend the Qt Creator by
-writing Python extensions. These extensions are simply Python packages,
-so they are directories containing a `__init__.py` and any other Python
-files necessary. They can be shared as zip archives, installed and managed
+writing Python extensions. These extensions are simply Python modules or
+packages, so they are either single Python files or directories containing a
+`__init__.py` and any other Python files necessary.
+They can be shared as zip archives, installed and managed
through the included extension manager (which is a Python extension itself) and
thus allow the Qt Creator to be easily extended with custom functionality.
@@ -129,9 +130,10 @@ The following process allows the plugin to work:
2. When Qt Creator is executed, the C++ plugin searches the standard
Qt Creator plugin directories for a directory named `python`, the
first directory found is the Python extension directory.
- Each python package in this directory represents it's own Python extension.
- Each package is loaded with `import`, which executes the initialization
- code in its `__init__.py`.
+ Each python module and package in this directory represents it's own Python
+ extension. Each extension is loaded with `import`, which executes the
+ module's initialization code (for extensions in the form of Python packages
+ that is the code in `__init__.py`).
3. Now all Python extensions have registered their actions / menus / etc.,
which can be triggered from the Qt Creator interface.
diff --git a/examples/examples.pro b/examples/examples.pro
index 57b1764..34b5843 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -7,7 +7,6 @@ include(../plugins/pythonextensions/qtcreator.pri)
include($$IDE_SOURCE_TREE/qtcreator.pri)
inst_examples.files = \
- macroexpander \
projects \
requirerequests \
smallmenu \
@@ -18,7 +17,8 @@ inst_examples.CONFIG += no_default_install directory
INSTALLS += inst_examples
inst_examplefiles.files = \
- examples_common.py
+ examples_common.py \
+ macroexpander.py
inst_examplefiles.path = $$IDE_PLUGIN_PATH/python
inst_examplefiles.CONFIG += no_default_install
diff --git a/examples/macroexpander/__init__.py b/examples/macroexpander.py
index 20e10a3..20e10a3 100644
--- a/examples/macroexpander/__init__.py
+++ b/examples/macroexpander.py
diff --git a/plugins/pythonextensions/pythonextensionsplugin.cpp b/plugins/pythonextensions/pythonextensionsplugin.cpp
index b3730b4..893819c 100644
--- a/plugins/pythonextensions/pythonextensionsplugin.cpp
+++ b/plugins/pythonextensions/pythonextensionsplugin.cpp
@@ -141,9 +141,16 @@ static QVector<Extension> getExtensionList(const QDir &directory)
QStringList entries = directory.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
entries.removeAll("site-packages");
entries.removeAll("__pycache__");
- return Utils::transform<QVector>(entries, [](const QString &entry) {
- return Extension({entry, false});
- });
+ const QVector<Extension> packageExtensions
+ = Utils::transform<QVector>(entries, [](const QString &entry) {
+ return Extension({entry, false});
+ });
+ const QStringList fileEntries = directory.entryList({"*.py"}, QDir::Files);
+ const QVector<Extension> fileExtensions
+ = Utils::transform<QVector>(fileEntries, [](const QString &entry) {
+ return Extension({entry.left(entry.size() - 3), false});
+ });
+ return packageExtensions + fileExtensions;
}
QVector<Extension> PythonExtensionsPlugin::extensionList()