summaryrefslogtreecommitdiffstats
path: root/tools/designer/src/lib/uilib
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2010-09-08 08:51:31 (GMT)
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2010-09-08 08:51:31 (GMT)
commit6bcdb38b5bdf8f0176db3f372d4b8c8b14ba459f (patch)
tree0705d016f6b5b5d506aff73d2c966b7b3682ff32 /tools/designer/src/lib/uilib
parent0901337e0c23910f265f0991b9fc6875efafedaf (diff)
downloadQt-6bcdb38b5bdf8f0176db3f372d4b8c8b14ba459f.zip
Qt-6bcdb38b5bdf8f0176db3f372d4b8c8b14ba459f.tar.gz
Qt-6bcdb38b5bdf8f0176db3f372d4b8c8b14ba459f.tar.bz2
Designer/uic: Start on support for QIcon::fromTheme().
Schemas: Add "theme" attribute to <iconset> element of the UI format. uic: Extend it to generate the code for icons with themes and/or resource paths, add auto-test for it. Designer: Add 'theme'-member to PropertySheetIconValue + convenience functions including subproperty mask handling and simplify the existing code. Add new class IconThemeEditor to be used in action editor dialog and property editor. Theme names can now be specified in the action editor dialog. Reviewed-by: Jarek Kobus <jaroslaw.kobus@nokia.com> Task-number: QTBUG-7777
Diffstat (limited to 'tools/designer/src/lib/uilib')
-rw-r--r--tools/designer/src/lib/uilib/resourcebuilder.cpp11
-rw-r--r--tools/designer/src/lib/uilib/ui4.cpp11
-rw-r--r--tools/designer/src/lib/uilib/ui4_p.h8
3 files changed, 30 insertions, 0 deletions
diff --git a/tools/designer/src/lib/uilib/resourcebuilder.cpp b/tools/designer/src/lib/uilib/resourcebuilder.cpp
index d19a09a..03e2a66 100644
--- a/tools/designer/src/lib/uilib/resourcebuilder.cpp
+++ b/tools/designer/src/lib/uilib/resourcebuilder.cpp
@@ -44,6 +44,7 @@
#include <QtCore/QVariant>
#include <QtCore/QFileInfo>
#include <QtCore/QDir>
+#include <QtCore/QDebug>
#include <QtGui/QPixmap>
#include <QtGui/QIcon>
@@ -53,6 +54,8 @@ QT_BEGIN_NAMESPACE
namespace QFormInternal {
#endif
+enum { themeDebug = 0 };
+
QResourceBuilder::QResourceBuilder()
{
@@ -95,6 +98,14 @@ QVariant QResourceBuilder::loadResource(const QDir &workingDirectory, const DomP
}
case DomProperty::IconSet: {
const DomResourceIcon *dpi = property->elementIconSet();
+ if (!dpi->attributeTheme().isEmpty()) {
+ const QString theme = dpi->attributeTheme();
+ const bool known = QIcon::hasThemeIcon(theme);
+ if (themeDebug)
+ qDebug("Theme %s known %d", qPrintable(theme), known);
+ if (known)
+ return qVariantFromValue(QIcon::fromTheme(dpi->attributeTheme()));
+ } // non-empty theme
if (const int flags = iconStateFlags(dpi)) { // new, post 4.4 format
QIcon icon;
if (flags & NormalOff)
diff --git a/tools/designer/src/lib/uilib/ui4.cpp b/tools/designer/src/lib/uilib/ui4.cpp
index c13bd59..98974e6 100644
--- a/tools/designer/src/lib/uilib/ui4.cpp
+++ b/tools/designer/src/lib/uilib/ui4.cpp
@@ -7745,6 +7745,7 @@ void DomResourceIcon::clear(bool clear_all)
if (clear_all) {
m_text = QLatin1String("");
+ m_has_attr_theme = false;
m_has_attr_resource = false;
}
@@ -7762,6 +7763,7 @@ void DomResourceIcon::clear(bool clear_all)
DomResourceIcon::DomResourceIcon()
{
m_children = 0;
+ m_has_attr_theme = false;
m_has_attr_resource = false;
m_text = QLatin1String("");
m_normalOff = 0;
@@ -7791,6 +7793,10 @@ void DomResourceIcon::read(QXmlStreamReader &reader)
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
QStringRef name = attribute.name();
+ if (name == QLatin1String("theme")) {
+ setAttributeTheme(attribute.value().toString());
+ continue;
+ }
if (name == QLatin1String("resource")) {
setAttributeResource(attribute.value().toString());
continue;
@@ -7869,6 +7875,8 @@ void DomResourceIcon::read(QXmlStreamReader &reader)
#ifdef QUILOADER_QDOM_READ
void DomResourceIcon::read(const QDomElement &node)
{
+ if (node.hasAttribute(QLatin1String("theme")))
+ setAttributeTheme(node.attribute(QLatin1String("theme")));
if (node.hasAttribute(QLatin1String("resource")))
setAttributeResource(node.attribute(QLatin1String("resource")));
@@ -7938,6 +7946,9 @@ void DomResourceIcon::write(QXmlStreamWriter &writer, const QString &tagName) co
{
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("resourceicon") : tagName.toLower());
+ if (hasAttributeTheme())
+ writer.writeAttribute(QLatin1String("theme"), attributeTheme());
+
if (hasAttributeResource())
writer.writeAttribute(QLatin1String("resource"), attributeResource());
diff --git a/tools/designer/src/lib/uilib/ui4_p.h b/tools/designer/src/lib/uilib/ui4_p.h
index 1f38f88..a464a89 100644
--- a/tools/designer/src/lib/uilib/ui4_p.h
+++ b/tools/designer/src/lib/uilib/ui4_p.h
@@ -2809,6 +2809,11 @@ public:
inline void setText(const QString &s) { m_text = s; }
// attribute accessors
+ inline bool hasAttributeTheme() const { return m_has_attr_theme; }
+ inline QString attributeTheme() const { return m_attr_theme; }
+ inline void setAttributeTheme(const QString& a) { m_attr_theme = a; m_has_attr_theme = true; }
+ inline void clearAttributeTheme() { m_has_attr_theme = false; }
+
inline bool hasAttributeResource() const { return m_has_attr_resource; }
inline QString attributeResource() const { return m_attr_resource; }
inline void setAttributeResource(const QString& a) { m_attr_resource = a; m_has_attr_resource = true; }
@@ -2868,6 +2873,9 @@ private:
void clear(bool clear_all = true);
// attribute data
+ QString m_attr_theme;
+ bool m_has_attr_theme;
+
QString m_attr_resource;
bool m_has_attr_resource;