diff options
author | Stefan Hacker <dd0t@users.sourceforge.net> | 2014-10-26 19:38:28 +0300 |
---|---|---|
committer | Stefan Hacker <dd0t@users.sourceforge.net> | 2014-10-26 19:44:09 +0300 |
commit | 38807bef1a4dd62b1c8eca9f29d549216660ff65 (patch) | |
tree | 2d9976fd691d0f4cfd0b4068d7c4c9de10ed905e /scripts | |
parent | 291ed489d93a0501de20df0505c40723d5e1b70d (diff) |
Integrate some feedback to ApplicationPalette
* Changed naming scheme from "qproperty-<group>_<role>"
to "qproperty-<role>_<group>".
* Introduced "qproperty-<group>" to set all roles of the
group to the same brush
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/generate-ApplicationPalette-class.py | 69 |
1 files changed, 49 insertions, 20 deletions
diff --git a/scripts/generate-ApplicationPalette-class.py b/scripts/generate-ApplicationPalette-class.py index c48321458..a6749055b 100644 --- a/scripts/generate-ApplicationPalette-class.py +++ b/scripts/generate-ApplicationPalette-class.py @@ -16,16 +16,6 @@ color_role = [ "WindowText", "Button", "Light", "Midlight", "Dark", "Mid", "AlternateBase", "ToolTipBase", "ToolTipText"] - - -template = open(template_source, "r").read() - -variables = {"warning": "// Auto-generated from %s . Do not edit manually." % template_source, - "properties": "", - "getterssetters": "", - "paletteupdates": "", - "variables": ""} - property_template = """ Q_PROPERTY(QBrush %(prop)s READ get_%(prop)s WRITE set_%(prop)s) """ @@ -42,6 +32,21 @@ gettersetter_template = """ } """ +role_multigettersetter_template = """ + QBrush get_%(role)s() { + qWarning("get_%(role)s called. This shouldn't happen. Cannot return meaningful value."); + return QBrush(); + } + + void set_%(role)s(const QBrush& brush) { +%(setters)s + } +""" + +role_multisetter_template=""" setProperty("%(prop)s", brush); +""" + + paletteupdate_template =""" if (m_%(prop)s) { palette.setBrush(QPalette::%(group)s, QPalette::%(role)s, *m_%(prop)s); @@ -51,18 +56,42 @@ paletteupdate_template =""" variable_template = """ boost::optional<QBrush> m_%(prop)s; """ +def rolename(role): + return role.lower() -for group in color_group: - for role in color_role: +def groupname(group): + return group.lower() - vars = {"prop" : group.lower() + "_" + role.lower(), - "group" : group, - "role" : role} +def propname(role, group): + return rolename(role) + "_" + groupname(group) - variables["properties"] += property_template % vars - variables["getterssetters"] += gettersetter_template % vars - variables["paletteupdates"] += paletteupdate_template % vars - variables["variables"] += variable_template % vars +if __name__ == "__main__": + template = open(template_source, "r").read() + variables = {"warning": "// Auto-generated from %s . Do not edit manually." % template_source, + "properties": "", + "getterssetters": "", + "paletteupdates": "", + "variables": ""} -open(target, "w").write(template % variables)
\ No newline at end of file + for role in color_role: + # Add a property that sets all color groups to the same QBrush using + # the setters of the single group properties. + variables["properties"] += property_template % {"prop" : rolename(role)} + role_multisetters = "".join([role_multisetter_template % {"prop": propname(role, group)} for group in color_group]) + variables["getterssetters"] += role_multigettersetter_template % {"role" : rolename(role), + "setters": role_multisetters} + + # Add separate group properties + for group in color_group: + vars = {"prop" : propname(role, group), + "group" : group, + "role" : role} + + variables["properties"] += property_template % vars + variables["getterssetters"] += gettersetter_template % vars + variables["paletteupdates"] += paletteupdate_template % vars + variables["variables"] += variable_template % vars + + + open(target, "w").write(template % variables)
\ No newline at end of file |