28int QResourceBuilder::iconStateFlags(
const DomResourceIcon *dpi)
32 if (dpi->hasElementNormalOff() && dpi->elementNormalOff()->text() !=
"."_L1)
34 if (dpi->hasElementNormalOn())
36 if (dpi->hasElementDisabledOff())
38 if (dpi->hasElementDisabledOn())
40 if (dpi->hasElementActiveOff())
42 if (dpi->hasElementActiveOn())
44 if (dpi->hasElementSelectedOff())
46 if (dpi->hasElementSelectedOn())
51QVariant QResourceBuilder::loadResource(
const QDir &workingDirectory,
const DomProperty *property)
const
53 switch (property->kind()) {
54 case DomProperty::Pixmap: {
55 const DomResourcePixmap *dpx = property->elementPixmap();
56 QPixmap pixmap(QFileInfo(workingDirectory, dpx->text()).absoluteFilePath());
57 return QVariant::fromValue(pixmap);
59 case DomProperty::IconSet: {
60 const DomResourceIcon *dpi = property->elementIconSet();
61 if (!dpi->attributeTheme().isEmpty()) {
62 const QString theme = dpi->attributeTheme();
63 const qsizetype themeEnum = theme.at(0).isUpper()
64 ? themeIconNames().indexOf(theme) : -1;
65 if (themeEnum != -1) {
66 const auto themeEnumE =
static_cast<QIcon::ThemeIcon>(themeEnum);
67 return QVariant::fromValue(QIcon::fromTheme(themeEnumE));
69 const bool known = QIcon::hasThemeIcon(theme);
71 qDebug(
"Theme %s known %d",
qPrintable(theme), known);
73 return QVariant::fromValue(QIcon::fromTheme(theme));
75 if (
const int flags = iconStateFlags(dpi)) {
77 if (flags & NormalOff)
78 icon.addFile(QFileInfo(workingDirectory, dpi->elementNormalOff()->text()).absoluteFilePath(), QSize(), QIcon::Normal, QIcon::Off);
80 icon.addFile(QFileInfo(workingDirectory, dpi->elementNormalOn()->text()).absoluteFilePath(), QSize(), QIcon::Normal, QIcon::On);
81 if (flags & DisabledOff)
82 icon.addFile(QFileInfo(workingDirectory, dpi->elementDisabledOff()->text()).absoluteFilePath(), QSize(), QIcon::Disabled, QIcon::Off);
83 if (flags & DisabledOn)
84 icon.addFile(QFileInfo(workingDirectory, dpi->elementDisabledOn()->text()).absoluteFilePath(), QSize(), QIcon::Disabled, QIcon::On);
85 if (flags & ActiveOff)
86 icon.addFile(QFileInfo(workingDirectory, dpi->elementActiveOff()->text()).absoluteFilePath(), QSize(), QIcon::Active, QIcon::Off);
88 icon.addFile(QFileInfo(workingDirectory, dpi->elementActiveOn()->text()).absoluteFilePath(), QSize(), QIcon::Active, QIcon::On);
89 if (flags & SelectedOff)
90 icon.addFile(QFileInfo(workingDirectory, dpi->elementSelectedOff()->text()).absoluteFilePath(), QSize(), QIcon::Selected, QIcon::Off);
91 if (flags & SelectedOn)
92 icon.addFile(QFileInfo(workingDirectory, dpi->elementSelectedOn()->text()).absoluteFilePath(), QSize(), QIcon::Selected, QIcon::On);
93 return QVariant::fromValue(icon);
96 const QIcon icon(QFileInfo(workingDirectory, dpi->text()).absoluteFilePath());
97 return QVariant::fromValue(icon);