|
1 #include "widgetcreator.h" |
|
2 #include <QDir> |
|
3 #include <QTextStream> |
|
4 #include <QCheckBox> |
|
5 |
|
6 WidgetCreator::WidgetCreator(MainWindow& aUi, QObject *parent ) : |
|
7 QObject(parent), iUi( aUi ) |
|
8 { |
|
9 generateFolders(); |
|
10 generateBuildFile(); |
|
11 generateHSPSManifest(); |
|
12 generateEmptyDat(); |
|
13 generateHSPSConf(); |
|
14 generateXml(); |
|
15 generateCss(); |
|
16 generateDat(); |
|
17 generateDtd(); |
|
18 generatePkg(); |
|
19 generateBur(); |
|
20 } |
|
21 |
|
22 |
|
23 |
|
24 QString WidgetCreator::widgetName() |
|
25 { |
|
26 return iUi.widgetName(); |
|
27 } |
|
28 |
|
29 QString WidgetCreator::widgetUid() |
|
30 { |
|
31 return iUi.widgetUid(); |
|
32 } |
|
33 |
|
34 QString WidgetCreator::widgetLayout() |
|
35 { |
|
36 return iUi.widgetLayout(); |
|
37 } |
|
38 |
|
39 void WidgetCreator::generateFolders() |
|
40 { |
|
41 QDir dir; |
|
42 dir.mkpath( widgetName() + "/widget"); |
|
43 dir.setPath( widgetName() + "/widget" ); |
|
44 dir.mkpath( "group" ); |
|
45 dir.mkpath( "hsps/00" ); |
|
46 dir.mkpath( "xuikon/00" ); |
|
47 dir.mkpath( "sis" ); |
|
48 } |
|
49 |
|
50 void WidgetCreator::generateBuildFile() |
|
51 { |
|
52 iUi.replaceData("data/" + widgetLayout() +"/group/bld.inf", widgetName() + "/widget/group/bld.inf", 1); |
|
53 } |
|
54 |
|
55 void WidgetCreator::generateHSPSManifest() |
|
56 { |
|
57 iUi.replaceData("data/" + widgetLayout() +"/hsps/00/manifest.dat", |
|
58 widgetName() + "/widget/hsps/00/manifest.dat"); |
|
59 } |
|
60 |
|
61 void WidgetCreator::generateHSPSConf() |
|
62 { |
|
63 iUi.replaceData( "data/" + widgetLayout() +"/hsps/00/widgetconfiguration.xml", |
|
64 widgetName() + "/widget/hsps/00/widgetconfiguration.xml" ); |
|
65 } |
|
66 |
|
67 void WidgetCreator::generateEmptyDat() |
|
68 { |
|
69 QDir dir; |
|
70 dir.setPath( widgetName() + "/widget/hsps/00"); |
|
71 QFile file(dir.filePath("empty.dat")); |
|
72 if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) |
|
73 return; |
|
74 } |
|
75 |
|
76 void WidgetCreator::generateXml() |
|
77 { |
|
78 if( iUi.rendererCheckBox().isChecked()) |
|
79 { |
|
80 iUi.replaceData( "data/" + widgetLayout() +"/xuikon/00/replacerenderer.xml", |
|
81 widgetName() + "/widget/xuikon/00/" + iUi.widgetName() + ".xml"); |
|
82 } |
|
83 else |
|
84 { |
|
85 iUi.replaceData( "data/" + widgetLayout() +"/xuikon/00/replace.xml", |
|
86 widgetName() + "/widget/xuikon/00/" + iUi.widgetName() + ".xml"); |
|
87 } |
|
88 |
|
89 } |
|
90 |
|
91 void WidgetCreator::generateCss() |
|
92 { |
|
93 if( iUi.rendererCheckBox().isChecked()) |
|
94 { |
|
95 iUi.replaceData( "data/" + widgetLayout() +"/xuikon/00/replacerenderer.css", |
|
96 widgetName() + "/widget/xuikon/00/" + iUi.widgetName() + ".css"); |
|
97 } |
|
98 else |
|
99 { |
|
100 iUi.replaceData( "data/" + widgetLayout() +"/xuikon/00/replace.css", |
|
101 widgetName() + "/widget/xuikon/00/" + iUi.widgetName() + ".css"); |
|
102 } |
|
103 } |
|
104 |
|
105 void WidgetCreator::generateDat() |
|
106 { |
|
107 iUi.replaceData("data/" + widgetLayout() +"/xuikon/00/replace.dat", |
|
108 widgetName() + "/widget/xuikon/00/" + widgetName() + "_" + iUi.widgetUidNoHex() + ".dat"); |
|
109 } |
|
110 |
|
111 void WidgetCreator::generateDtd() |
|
112 { |
|
113 QDir dir; |
|
114 dir.setPath( widgetName() + "/widget/xuikon/00"); |
|
115 QFile file(dir.filePath(widgetName()+".dtd")); |
|
116 if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) |
|
117 return; |
|
118 |
|
119 } |
|
120 |
|
121 void WidgetCreator::generatePkg() |
|
122 { |
|
123 iUi.replaceData("data/" + widgetLayout() +"/sis/replace.pkg", |
|
124 widgetName() + "/widget/sis/"+ widgetName() + ".pkg", 1); // 1 =no hex uid used |
|
125 } |
|
126 |
|
127 void WidgetCreator::generateBur() |
|
128 { |
|
129 QDir dir; |
|
130 dir.setPath( widgetName() + "/widget/sis"); |
|
131 QFile file(dir.filePath("backup_registration.xml")); |
|
132 if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) |
|
133 return; |
|
134 |
|
135 QTextStream out(&file); |
|
136 |
|
137 out << "<?xml version=\"1.0\" standalone=\"yes\"?>\n" |
|
138 << "<backup_registration>\n" |
|
139 << "<system_backup/>\n" |
|
140 << "<restore requires_reboot = \"no\"/>\n" |
|
141 << "</backup_registration>\n"; |
|
142 } |