2018-02-21 21:12:40 +01:00
|
|
|
#!/usr/bin/env python3
|
2016-06-03 10:16:00 +02:00
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
mkuidefaults.py
|
|
|
|
---------------------
|
|
|
|
Date : June 2013
|
|
|
|
Copyright : (C) 2013 by Juergen E. Fischer
|
|
|
|
Email : jef at norbit dot de
|
|
|
|
***************************************************************************
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
***************************************************************************
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = "Juergen E. Fischer"
|
|
|
|
__date__ = "June 2013"
|
|
|
|
__copyright__ = "(C) 2013, Juergen E. Fischer"
|
|
|
|
|
2018-02-18 13:14:32 +07:00
|
|
|
import struct
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from PyQt5.QtCore import QCoreApplication, QSettings
|
2016-03-21 10:23:43 +01:00
|
|
|
|
2013-06-19 23:04:31 +02:00
|
|
|
|
|
|
|
def chunks(l, n):
|
2017-03-04 19:41:23 +01:00
|
|
|
for i in range(0, len(l), n):
|
2016-03-21 10:23:43 +01:00
|
|
|
yield l[i : i + n]
|
2013-06-19 23:04:31 +02:00
|
|
|
|
2017-03-04 19:41:23 +01:00
|
|
|
|
2016-03-21 10:23:43 +01:00
|
|
|
QCoreApplication.setOrganizationName("QGIS")
|
|
|
|
QCoreApplication.setOrganizationDomain("qgis.org")
|
2016-10-04 15:44:50 +02:00
|
|
|
QCoreApplication.setApplicationName("QGIS3")
|
2013-06-19 23:04:31 +02:00
|
|
|
|
2018-02-18 13:14:32 +07:00
|
|
|
if len(sys.argv) == 1:
|
2018-02-21 21:12:40 +01:00
|
|
|
print('Usage: ./scripts/mkuidefaults.py "location_to_ini"')
|
2018-02-18 13:14:32 +07:00
|
|
|
sys.exit(1)
|
|
|
|
|
2024-01-21 20:53:17 +10:00
|
|
|
s = QSettings(sys.argv[1], QSettings.Format.IniFormat)
|
2013-06-19 23:04:31 +02:00
|
|
|
|
2017-05-29 19:18:44 +02:00
|
|
|
ba = bytes(s.value("/UI/geometry"))
|
2013-06-19 23:04:31 +02:00
|
|
|
|
2018-04-08 10:08:04 +02:00
|
|
|
with open("src/app/ui_defaults.h", "w") as f:
|
2013-06-19 23:04:31 +02:00
|
|
|
|
2018-04-08 10:08:04 +02:00
|
|
|
f.write(
|
|
|
|
"#ifndef UI_DEFAULTS_H\n#define UI_DEFAULTS_H\n"
|
|
|
|
+ "\nstatic const unsigned char defaultUIgeometry[] =\n{\n"
|
|
|
|
)
|
2013-07-10 23:16:42 +02:00
|
|
|
|
2017-05-29 19:18:44 +02:00
|
|
|
for chunk in chunks(ba, 16):
|
2018-02-21 21:12:40 +01:00
|
|
|
f.write(
|
|
|
|
" {},\n".format(
|
|
|
|
", ".join(map(hex, struct.unpack("B" * len(chunk), chunk)))
|
2024-11-29 14:26:30 +01:00
|
|
|
)
|
|
|
|
)
|
2013-07-10 23:16:42 +02:00
|
|
|
|
2018-04-08 10:08:04 +02:00
|
|
|
f.write("};\n\nstatic const unsigned char defaultUIstate[] =\n{\n")
|
|
|
|
|
|
|
|
ba = bytes(s.value("/UI/state"))
|
2013-07-10 23:16:42 +02:00
|
|
|
|
2017-05-29 19:18:44 +02:00
|
|
|
for chunk in chunks(ba, 16):
|
2018-02-21 21:12:40 +01:00
|
|
|
f.write(
|
|
|
|
" {},\n".format(
|
|
|
|
", ".join(map(hex, struct.unpack("B" * len(chunk), chunk)))
|
2024-11-29 14:26:30 +01:00
|
|
|
)
|
|
|
|
)
|
2013-06-19 23:04:31 +02:00
|
|
|
|
2018-04-08 10:08:04 +02:00
|
|
|
try:
|
|
|
|
ba = bytes(s.value("/app/LayoutDesigner/geometry"))
|
|
|
|
f.write(
|
|
|
|
"};\n\nstatic const unsigned char "
|
|
|
|
+ "defaultLayerDesignerUIgeometry[] =\n{\n"
|
|
|
|
)
|
|
|
|
|
|
|
|
for chunk in chunks(ba, 16):
|
|
|
|
f.write(
|
|
|
|
" {},\n".format(
|
|
|
|
", ".join(map(hex, struct.unpack("B" * len(chunk), chunk)))
|
2024-11-29 14:26:30 +01:00
|
|
|
)
|
|
|
|
)
|
2018-04-08 10:08:04 +02:00
|
|
|
except TypeError as ex:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
|
|
|
ba = bytes(s.value("/app/LayoutDesigner/state"))
|
|
|
|
f.write(
|
|
|
|
"};\n\nstatic const unsigned char " + "defaultLayerDesignerUIstate[] =\n{\n"
|
|
|
|
)
|
|
|
|
|
|
|
|
for chunk in chunks(ba, 16):
|
|
|
|
f.write(
|
|
|
|
" {},\n".format(
|
|
|
|
", ".join(map(hex, struct.unpack("B" * len(chunk), chunk)))
|
2024-11-29 14:26:30 +01:00
|
|
|
)
|
|
|
|
)
|
2018-04-08 10:08:04 +02:00
|
|
|
except TypeError as ex:
|
|
|
|
pass
|
|
|
|
|
|
|
|
f.write("};\n\n#endif // UI_DEFAULTS_H\n")
|