176{
177 QString dontShow = "imperial";
178 if ( QLocale().measurementSystem() == QLocale::ImperialSystem) {
179 dontShow = "metric";
180 }
181
184 for (QStringList::ConstIterator it = dirs.constBegin(); it != dirs.constEnd(); ++it) {
187 continue;
188 QStringList files =
d.entryList(QDir::Files | QDir::Readable, QDir::Name);
189 for (int i = 0; i < files.count(); ++i) {
190 QString filePath = *it + files[i];
191
192 QString icon;
193 QString text;
194 QString description;
195 QString hidden_str;
196 QString fileName;
197 bool hidden = false;
199 QString templatePath;
200 QString measureSystem;
201
202
203 if (KDesktopFile::isDesktopFile(filePath)) {
204 KConfig _config(filePath, KConfig::SimpleConfig);
206 KConfigGroup config(&_config, "Desktop Entry");
207 if (config.readEntry("Type") == "Link") {
208 text = config.readEntry("Name");
209 fileName = filePath;
210 description = config.readEntry("Comment");
211
212 icon = config.readEntry("Icon");
213 if (icon[0] != '/' &&
214 QFile::exists(*it + icon))
215 icon = *it + icon;
216
217 hidden = config.readEntry("X-KDE-Hidden", false);
219 measureSystem = config.readEntry("X-KDE-MeasureSystem").toLower();
220
221
222 if (measureSystem == dontShow)
223 continue;
224
225
226 templatePath = config.readPathEntry("URL", QString());
227
228 if (templatePath[0] != '/') {
229 if (templatePath.left(6) == "file:/")
230 templatePath = templatePath.right(templatePath.length() - 6);
231
232
233 templatePath = *it + templatePath;
234
235 }
236 } else
237 continue;
238 }
239
240 else if (files[i].right(4) != ".png")
241
242 continue;
243 else {
244
245 icon = filePath;
246 QFileInfo fi(filePath);
247 text = fi.completeBaseName();
248 templatePath = filePath;
249
250 }
252 measureSystem, hidden);
253 group->
add(t,
false,
false);
254
255
258 }
259 }
260 }
261}
bool add(KisTemplate *t, bool force=false, bool touch=true)
KisTemplate * defaultTemplate() const