Add config template (WIP)
Signed-off-by: Juraj Oravec <sgd.orava@gmail.com>
This commit is contained in:
parent
2b661f17cb
commit
99e2411e01
@ -6,4 +6,5 @@ Falkon Python plugin templates for KDevelop.
|
||||
|
||||
- **plugin**: python plugin project template
|
||||
- **button**: toolbar button file template
|
||||
- **sidebar**: sidebar template file template
|
||||
- **sidebar**: sidebar file template
|
||||
- **config**: pythos - PySide2 config class template (in progress)
|
||||
|
62
config/config.py
Normal file
62
config/config.py
Normal file
@ -0,0 +1,62 @@
|
||||
{% load kdev_filters %}
|
||||
{% block license_header %}
|
||||
{% if license %}
|
||||
{{ license|lines_prepend:"# " }}
|
||||
{% endif %}
|
||||
{% endblock license_header %}
|
||||
|
||||
|
||||
from PySide2.QtCore import QObject, Signal
|
||||
|
||||
|
||||
class {{ name }}{% if base_classes %}({% for inh in base_classes %}{{ inh.baseType }}{% if not forloop.last %}, {% endif %}{% endfor %}){% endif %}:
|
||||
{% for member in members %}
|
||||
{{ member.name }}Changed = Signal({{ member.type }})
|
||||
{% endfor %}
|
||||
|
||||
|
||||
def __init__(self{% for member in members %}, {{ member.name }}=None{% endfor %}):
|
||||
{% for inh in base_classes %}
|
||||
{{ inh.baseType }}.__init__(self)
|
||||
{% endfor %}
|
||||
|
||||
|
||||
{% for member in members %}
|
||||
self._{{ member.name }} = {{ member.name }}
|
||||
{% empty %}
|
||||
pass
|
||||
{% endfor %}
|
||||
|
||||
|
||||
{% for method in methods %}
|
||||
|
||||
{% if method.isStatic %}
|
||||
@staticmethod
|
||||
def {{ method.name }}({% include "arguments_names.txt" %}):
|
||||
{% else %}{% if method.arguments %}
|
||||
def {{ method.name }}(self{% for arg in method.arguments %}, {{ arg.name }}{% endfor %}):
|
||||
{% else %}
|
||||
def {{ method.name }}(self):
|
||||
{% endif %}{% endif %}
|
||||
pass
|
||||
|
||||
{% endfor %}
|
||||
|
||||
|
||||
{% for member in members %}
|
||||
|
||||
@property
|
||||
def {{ member.name }}(self):
|
||||
return self._{{ member.name }}
|
||||
|
||||
@{{ member.name }}.setter
|
||||
def {{ member.name }}(self, {{ member.name }}):
|
||||
if not {{ member.name }}:
|
||||
return
|
||||
if self._{{ member.name }} == {{ member.name }}:
|
||||
return
|
||||
|
||||
self._{{ member.name }} = {{ member.name }}
|
||||
self.{{ member.name }}Changed.emit({{ member.name }})
|
||||
|
||||
{% endfor %}
|
14
config/pyside2-config.desktop
Normal file
14
config/pyside2-config.desktop
Normal file
@ -0,0 +1,14 @@
|
||||
[General]
|
||||
Name=PySide2 Config
|
||||
Comment=Config class for PySide2
|
||||
Category=Python/PySide2
|
||||
Language=Python
|
||||
Type=Class
|
||||
Files=Implementation
|
||||
BaseClasses=QObject
|
||||
# OptionsFile=options.kcfg
|
||||
|
||||
[Implementation]
|
||||
Name=Implementation
|
||||
File=config.py
|
||||
OutputFile={{ name }}.py
|
Loading…
Reference in New Issue
Block a user