2019-06-28 21:39:07 +02:00
|
|
|
{% load kdev_filters %}
|
|
|
|
{% block license_header %}
|
|
|
|
{% if license %}
|
|
|
|
{{ license|lines_prepend:"# " }}
|
|
|
|
{% endif %}
|
|
|
|
{% endblock license_header %}
|
|
|
|
|
|
|
|
|
2019-06-29 20:29:15 +02:00
|
|
|
{% if include_load_save %}
|
|
|
|
import os
|
|
|
|
{% endif %}
|
|
|
|
from PySide2.QtCore import QObject, Signal{% if include_load_save %}, QSettings{% endif %}
|
2019-06-28 21:39:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
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 %}
|
|
|
|
|
|
|
|
|
2019-06-29 20:29:15 +02:00
|
|
|
{% if include_load_save %}
|
|
|
|
configLoaded = Signal()
|
|
|
|
configSaved = Signal()
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
|
2019-06-28 21:39:07 +02:00
|
|
|
def __init__(self{% for member in members %}, {{ member.name }}=None{% endfor %}):
|
|
|
|
{% for inh in base_classes %}
|
2019-06-29 20:29:15 +02:00
|
|
|
{{ inh.baseType }}.__init__()
|
2019-06-28 21:39:07 +02:00
|
|
|
{% 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 %}
|
|
|
|
|
|
|
|
|
2019-06-29 20:29:15 +02:00
|
|
|
{% if include_load_save %}
|
|
|
|
|
|
|
|
def load(self):
|
|
|
|
if not self.{% if settings_filepath_variable %}{{settings_filepath_variable}}{% else %}settingsFile{% endif %}:
|
|
|
|
return
|
|
|
|
if os.path.exists(self.{% if settings_filepath_variable %}{{settings_filepath_variable}}{% else %}settingsFile{% endif %}):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
settings = QSettings(self.{% if settings_filepath_variable %}{{settings_filepath_variable}}{% else %}settingsFile{% endif %}, QSettings.IniFormat)
|
|
|
|
|
|
|
|
|
|
|
|
settings.beginGroup("{% if settings_group_name %}{{ settings_group_name }}{% else %}{{ name }}{% endif %}")
|
|
|
|
{% for member in members %}
|
2019-07-01 20:52:51 +02:00
|
|
|
self.{{ member.name }} = {% if member.type == "bool" %}self._{% endif %}{{ member.type }}(settings.value("{{ member.name }}", self.{{ member.name }}))
|
2019-06-29 20:29:15 +02:00
|
|
|
{% endfor %}
|
|
|
|
settings.endGroup()
|
|
|
|
|
|
|
|
|
|
|
|
self.configLoaded.emit()
|
|
|
|
|
|
|
|
|
|
|
|
def save(self):
|
|
|
|
if not self.{% if settings_filepath_variable %}{{settings_filepath_variable}}{% else %}settingsFile{% endif %}:
|
|
|
|
return
|
|
|
|
if os.path.exists(self.{% if settings_filepath_variable %}{{settings_filepath_variable}}{% else %}settingsFile{% endif %}):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
settings = QSettings(self.{% if settings_filepath_variable %}{{settings_filepath_variable}}{% else %}settingsFile{% endif %}, QSettings.IniFormat)
|
|
|
|
|
|
|
|
|
|
|
|
settings.beginGroup("{% if settings_group_name %}{{ settings_group_name }}{% else %}{{ name }}{% endif %}")
|
|
|
|
{% for member in members %}
|
|
|
|
settings.setValue("{{ member.name }}", self.{{ member.name }})
|
|
|
|
{% endfor %}
|
|
|
|
settings.endGroup()
|
|
|
|
|
|
|
|
|
|
|
|
settings.sync()
|
|
|
|
|
|
|
|
|
|
|
|
self.configSaved.emit()
|
|
|
|
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
|
2019-06-28 21:39:07 +02:00
|
|
|
{% for member in members %}
|
|
|
|
|
|
|
|
@property
|
|
|
|
def {{ member.name }}(self):
|
|
|
|
return self._{{ member.name }}
|
|
|
|
|
2019-06-29 20:29:15 +02:00
|
|
|
|
2019-06-28 21:39:07 +02:00
|
|
|
@{{ member.name }}.setter
|
|
|
|
def {{ member.name }}(self, {{ member.name }}):
|
|
|
|
if not {{ member.name }}:
|
|
|
|
return
|
|
|
|
if self._{{ member.name }} == {{ member.name }}:
|
|
|
|
return
|
|
|
|
|
2019-06-28 23:16:15 +02:00
|
|
|
|
2019-06-28 21:39:07 +02:00
|
|
|
self._{{ member.name }} = {{ member.name }}
|
|
|
|
self.{{ member.name }}Changed.emit({{ member.name }})
|
|
|
|
|
|
|
|
{% endfor %}
|
2019-07-01 20:52:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
{% if include_load_save %}
|
|
|
|
|
|
|
|
def _bool(self, value):
|
|
|
|
return value == "true"
|
|
|
|
|
|
|
|
{% endif %}
|