Skip to content
Permalink
Browse files

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
  • Loading branch information...
hacst committed Oct 26, 2014
1 parent 291ed48 commit 38807bef1a4dd62b1c8eca9f29d549216660ff65
Showing with 821 additions and 539 deletions.
  1. +49 −20 scripts/generate-ApplicationPalette-class.py
  2. +766 −516 src/mumble/ApplicationPalette.h
  3. +6 −3 src/mumble/ApplicationPaletteTemplate.h
@@ -16,16 +16,6 @@
"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 @@
}
"""

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 @@
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)
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)

0 comments on commit 38807be

Please sign in to comment.
You can’t perform that action at this time.