27int QResourceBuilder::iconStateFlags(
const DomResourceIcon *dpi)
31 if (dpi->hasElementNormalOff() && dpi->elementNormalOff()->text() !=
"."_L1)
33 if (dpi->hasElementNormalOn())
35 if (dpi->hasElementDisabledOff())
37 if (dpi->hasElementDisabledOn())
39 if (dpi->hasElementActiveOff())
41 if (dpi->hasElementActiveOn())
43 if (dpi->hasElementSelectedOff())
45 if (dpi->hasElementSelectedOn())
50QVariant QResourceBuilder::loadResource(
const QDir &workingDirectory,
const DomProperty *property)
const
52 switch (property->kind()) {
53 case DomProperty::Pixmap: {
54 const DomResourcePixmap *dpx = property->elementPixmap();
55 QPixmap pixmap(QFileInfo(workingDirectory, dpx->text()).absoluteFilePath());
56 return QVariant::fromValue(pixmap);
58 case DomProperty::IconSet: {
59 const DomResourceIcon *dpi = property->elementIconSet();
60 if (!dpi->attributeTheme().isEmpty()) {
61 const QString theme = dpi->attributeTheme();
62 const qsizetype themeEnum = theme.at(0).isUpper()
63 ? themeIconNames().indexOf(theme) : -1;
64 if (themeEnum != -1) {
65 const auto themeEnumE =
static_cast<QIcon::ThemeIcon>(themeEnum);
66 return QVariant::fromValue(QIcon::fromTheme(themeEnumE));
68 const bool known = QIcon::hasThemeIcon(theme);
70 qDebug(
"Theme %s known %d",
qPrintable(theme), known);
72 return QVariant::fromValue(QIcon::fromTheme(theme));
74 if (
const int flags = iconStateFlags(dpi)) {
76 if (flags & NormalOff)
77 icon.addFile(QFileInfo(workingDirectory, dpi->elementNormalOff()->text()).absoluteFilePath(), QSize(), QIcon::Normal, QIcon::Off);
79 icon.addFile(QFileInfo(workingDirectory, dpi->elementNormalOn()->text()).absoluteFilePath(), QSize(), QIcon::Normal, QIcon::On);
80 if (flags & DisabledOff)
81 icon.addFile(QFileInfo(workingDirectory, dpi->elementDisabledOff()->text()).absoluteFilePath(), QSize(), QIcon::Disabled, QIcon::Off);
82 if (flags & DisabledOn)
83 icon.addFile(QFileInfo(workingDirectory, dpi->elementDisabledOn()->text()).absoluteFilePath(), QSize(), QIcon::Disabled, QIcon::On);
84 if (flags & ActiveOff)
85 icon.addFile(QFileInfo(workingDirectory, dpi->elementActiveOff()->text()).absoluteFilePath(), QSize(), QIcon::Active, QIcon::Off);
87 icon.addFile(QFileInfo(workingDirectory, dpi->elementActiveOn()->text()).absoluteFilePath(), QSize(), QIcon::Active, QIcon::On);
88 if (flags & SelectedOff)
89 icon.addFile(QFileInfo(workingDirectory, dpi->elementSelectedOff()->text()).absoluteFilePath(), QSize(), QIcon::Selected, QIcon::Off);
90 if (flags & SelectedOn)
91 icon.addFile(QFileInfo(workingDirectory, dpi->elementSelectedOn()->text()).absoluteFilePath(), QSize(), QIcon::Selected, QIcon::On);
92 return QVariant::fromValue(icon);
94 const QIcon icon(QFileInfo(workingDirectory, dpi->text()).absoluteFilePath());
95 return QVariant::fromValue(icon);