-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkuidefaults.py
45 lines (27 loc) · 1.37 KB
/
mkuidefaults.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from PyQt4.QtCore import QCoreApplication, QSettings
def chunks(l, n):
for i in xrange(0, len(l), n):
yield l[i:i+n]
QCoreApplication.setOrganizationName( "QGIS" )
QCoreApplication.setOrganizationDomain( "qgis.org" )
QCoreApplication.setApplicationName( "QGIS2" )
s = QSettings()
ba = s.value("/UI/geometry").toByteArray()
f = open("src/app/ui_defaults.h", "w")
f.write( "#ifndef UI_DEFAULTS_H\n#define UI_DEFAULTS_H\n\nstatic const unsigned char defaultUIgeometry[] =\n{\n" )
for chunk in chunks(ba,16):
f.write( " %s,\n" % ", ".join( map( lambda x : "0x%02x" % ord(x), chunk ) ) )
f.write( "};\n\nstatic const unsigned char defaultUIstate[] =\n{\n" )
ba = s.value("/UI/state").toByteArray()
for chunk in chunks(ba,16):
f.write( " %s,\n" % ", ".join( map( lambda x : "0x%02x" % ord(x), chunk ) ) )
ba = s.value("/Composer/geometry").toByteArray()
f.write( "};\n\nstatic const unsigned char defaultComposerUIgeometry[] =\n{\n" )
for chunk in chunks(ba,16):
f.write( " %s,\n" % ", ".join( map( lambda x : "0x%02x" % ord(x), chunk ) ) )
f.write( "};\n\nstatic const unsigned char defaultComposerUIstate[] =\n{\n" )
ba = s.value("/ComposerUI/state").toByteArray()
for chunk in chunks(ba,16):
f.write( " %s,\n" % ", ".join( map( lambda x : "0x%02x" % ord(x), chunk ) ) )
f.write( "};\n\n#endif // UI_DEFAULTS_H\n" )
f.close()