diff options
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/bootstrap/bootstrap.pri | 4 | ||||
-rw-r--r-- | src/tools/bootstrap/bootstrap.pro | 20 | ||||
-rw-r--r-- | src/tools/uic/cpp/cppwriteinitialization.cpp | 94 | ||||
-rw-r--r-- | src/tools/uic/cpp/cppwriteinitialization.h | 1 | ||||
-rw-r--r-- | src/tools/uic/ui4.cpp | 22 | ||||
-rw-r--r-- | src/tools/uic/ui4.h | 16 | ||||
-rw-r--r-- | src/tools/uic3/converter.cpp | 2 | ||||
-rw-r--r-- | src/tools/uic3/domtool.cpp | 14 | ||||
-rw-r--r-- | src/tools/uic3/domtool.h | 2 |
9 files changed, 138 insertions, 37 deletions
diff --git a/src/tools/bootstrap/bootstrap.pri b/src/tools/bootstrap/bootstrap.pri index 1aa8121..f48c8c1 100644 --- a/src/tools/bootstrap/bootstrap.pri +++ b/src/tools/bootstrap/bootstrap.pri @@ -22,7 +22,9 @@ DEFINES += \ QT_NO_TEXTSTREAM \ QT_NO_THREAD \ QT_NO_UNICODETABLES \ - QT_NO_USING_NAMESPACE + QT_NO_USING_NAMESPACE \ + QT_NO_DEPRECATED + win32:DEFINES += QT_NODLL INCLUDEPATH += $$QT_BUILD_TREE/include \ diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index ba844ea..9e5845c 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -25,7 +25,9 @@ DEFINES += \ QT_NO_TEXTSTREAM \ QT_NO_THREAD \ QT_NO_UNICODETABLES \ - QT_NO_USING_NAMESPACE + QT_NO_USING_NAMESPACE \ + QT_NO_DEPRECATED + win32:DEFINES += QT_NODLL INCLUDEPATH += $$QT_BUILD_TREE/include \ @@ -57,6 +59,8 @@ SOURCES += \ ../../corelib/io/qdiriterator.cpp \ ../../corelib/io/qfile.cpp \ ../../corelib/io/qfileinfo.cpp \ + ../../corelib/io/qfilesystementry.cpp \ + ../../corelib/io/qfilesystemengine.cpp \ ../../corelib/io/qfsfileengine.cpp \ ../../corelib/io/qfsfileengine_iterator.cpp \ ../../corelib/io/qiodevice.cpp \ @@ -65,6 +69,7 @@ SOURCES += \ ../../corelib/io/qurl.cpp \ ../../corelib/kernel/qmetatype.cpp \ ../../corelib/kernel/qvariant.cpp \ + ../../corelib/kernel/qsystemerror.cpp \ ../../corelib/tools/qbitarray.cpp \ ../../corelib/tools/qbytearray.cpp \ ../../corelib/tools/qbytearraymatcher.cpp \ @@ -79,19 +84,22 @@ SOURCES += \ ../../corelib/tools/qvector.cpp \ ../../corelib/tools/qvsnprintf.cpp \ ../../corelib/xml/qxmlutils.cpp \ - ../../corelib/xml/qxmlstream.cpp \ + ../../corelib/xml/qxmlstream.cpp \ ../../xml/dom/qdom.cpp \ ../../xml/sax/qxml.cpp -unix:SOURCES += ../../corelib/io/qfsfileengine_unix.cpp \ - ../../corelib/io/qfsfileengine_iterator_unix.cpp +unix:SOURCES += ../../corelib/io/qfilesystemengine_unix.cpp \ + ../../corelib/io/qfilesystemiterator_unix.cpp \ + ../../corelib/io/qfsfileengine_unix.cpp -win32:SOURCES += ../../corelib/io/qfsfileengine_win.cpp \ - ../../corelib/io/qfsfileengine_iterator_win.cpp \ +win32:SOURCES += ../../corelib/io/qfilesystemengine_win.cpp \ + ../../corelib/io/qfilesystemiterator_win.cpp \ + ../../corelib/io/qfsfileengine_win.cpp \ ../../corelib/plugin/qsystemlibrary.cpp \ macx: { QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 #enables weak linking for 10.4 (exported) + SOURCES += ../../corelib/io/qfilesystemengine_mac.cpp SOURCES += ../../corelib/kernel/qcore_mac.cpp LIBS += -framework CoreServices } diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 8f63054..37d012c 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -139,13 +139,17 @@ namespace { << indent << "QWidgetList childWidgets;\n"; } - static inline bool isIconFormat44(const DomResourceIcon *i) { + static inline bool iconHasStatePixmaps(const DomResourceIcon *i) { return i->hasElementNormalOff() || i->hasElementNormalOn() || i->hasElementDisabledOff() || i->hasElementDisabledOn() || i->hasElementActiveOff() || i->hasElementActiveOn() || i->hasElementSelectedOff() || i->hasElementSelectedOn(); } + static inline bool isIconFormat44(const DomResourceIcon *i) { + return iconHasStatePixmaps(i) || !i->attributeTheme().isEmpty(); + } + // Check on properties. Filter out empty legacy pixmap/icon properties // as Designer pre 4.4 used to remove missing resource references. // This can no longer be handled by the code as we have 'setIcon(QIcon())' as well as 'QIcon icon' @@ -258,6 +262,9 @@ IconHandle::IconHandle(const DomResourceIcon *domIcon) : int IconHandle::compare(const IconHandle &rhs) const { + if (const int comp = m_domIcon->attributeTheme().compare(rhs.m_domIcon->attributeTheme())) + return comp; + const QString normalOff = m_domIcon->hasElementNormalOff() ? m_domIcon->elementNormalOff()->text() : QString(); const QString rhsNormalOff = rhs.m_domIcon->hasElementNormalOff() ? rhs.m_domIcon->elementNormalOff()->text() : QString(); if (const int comp = normalOff.compare(rhsNormalOff)) @@ -478,7 +485,8 @@ WriteInitialization::WriteInitialization(Uic *uic, bool activateScripts) : m_delayedOut(&m_delayedInitialization, QIODevice::WriteOnly), m_refreshOut(&m_refreshInitialization, QIODevice::WriteOnly), m_actionOut(&m_delayedActionInitialization, QIODevice::WriteOnly), - m_activateScripts(activateScripts), m_layoutWidget(false) + m_activateScripts(activateScripts), m_layoutWidget(false), + m_firstThemeIcon(true) { } @@ -1088,6 +1096,8 @@ void WriteInitialization::acceptLayoutItem(DomLayoutItem *node) const int colSpan = node->hasAttributeColSpan() ? node->attributeColSpan() : 1; addArgs = QString::fromLatin1("%1, %2, %3, %4, %5").arg(itemName).arg(row).arg(col).arg(rowSpan).arg(colSpan); + if (!node->attributeAlignment().isEmpty()) + addArgs += QLatin1String(", ") + node->attributeAlignment(); } else { if (layout->attributeClass() == QLatin1String("QFormLayout")) { methodPrefix = QLatin1String("set"); @@ -1097,6 +1107,8 @@ void WriteInitialization::acceptLayoutItem(DomLayoutItem *node) addArgs = QString::fromLatin1("%1, %2, %3").arg(row).arg(role).arg(itemName); } else { addArgs = itemName; + if (layout->attributeClass().contains(QLatin1String("Box")) && !node->attributeAlignment().isEmpty()) + addArgs += QLatin1String(", 0, ") + node->attributeAlignment(); } } @@ -1670,6 +1682,30 @@ QString WriteInitialization::writeFontProperties(const DomFont *f) return fontName; } +// Post 4.4 write resource icon +static void writeResourceIcon(QTextStream &output, + const QString &iconName, + const QString &indent, + const DomResourceIcon *i) +{ + if (i->hasElementNormalOff()) + output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), indent) << "), QSize(), QIcon::Normal, QIcon::Off);\n"; + if (i->hasElementNormalOn()) + output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOn()->text(), indent) << "), QSize(), QIcon::Normal, QIcon::On);\n"; + if (i->hasElementDisabledOff()) + output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementDisabledOff()->text(), indent) << "), QSize(), QIcon::Disabled, QIcon::Off);\n"; + if (i->hasElementDisabledOn()) + output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementDisabledOn()->text(), indent) << "), QSize(), QIcon::Disabled, QIcon::On);\n"; + if (i->hasElementActiveOff()) + output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementActiveOff()->text(), indent) << "), QSize(), QIcon::Active, QIcon::Off);\n"; + if (i->hasElementActiveOn()) + output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementActiveOn()->text(), indent) << "), QSize(), QIcon::Active, QIcon::On);\n"; + if (i->hasElementSelectedOff()) + output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementSelectedOff()->text(), indent) << "), QSize(), QIcon::Selected, QIcon::Off);\n"; + if (i->hasElementSelectedOn()) + output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementSelectedOn()->text(), indent) << "), QSize(), QIcon::Selected, QIcon::On);\n"; +} + QString WriteInitialization::writeIconProperties(const DomResourceIcon *i) { // check cache @@ -1683,25 +1719,41 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i) const QString iconName = m_driver->unique(QLatin1String("icon")); m_iconPropertiesNameMap.insert(IconHandle(i), iconName); if (isIconFormat44(i)) { - const QString pixmap = QLatin1String("QPixmap"); - m_output << m_indent << "QIcon " << iconName << ";\n"; - if (i->hasElementNormalOff()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Normal, QIcon::Off);\n"; - if (i->hasElementNormalOn()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOn()->text(), m_dindent) << "), QSize(), QIcon::Normal, QIcon::On);\n"; - if (i->hasElementDisabledOff()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementDisabledOff()->text(), m_dindent) << "), QSize(), QIcon::Disabled, QIcon::Off);\n"; - if (i->hasElementDisabledOn()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementDisabledOn()->text(), m_dindent) << "), QSize(), QIcon::Disabled, QIcon::On);\n"; - if (i->hasElementActiveOff()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementActiveOff()->text(), m_dindent) << "), QSize(), QIcon::Active, QIcon::Off);\n"; - if (i->hasElementActiveOn()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementActiveOn()->text(), m_dindent) << "), QSize(), QIcon::Active, QIcon::On);\n"; - if (i->hasElementSelectedOff()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementSelectedOff()->text(), m_dindent) << "), QSize(), QIcon::Selected, QIcon::Off);\n"; - if (i->hasElementSelectedOn()) - m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementSelectedOn()->text(), m_dindent) << "), QSize(), QIcon::Selected, QIcon::On);\n"; - } else { // pre-4.4 legacy + if (i->attributeTheme().isEmpty()) { + // No theme: Write resource icon as is + m_output << m_indent << "QIcon " << iconName << ";\n"; + writeResourceIcon(m_output, iconName, m_indent, i); + } else { + // Theme: Generate code to check the theme and default to resource + const QString themeIconName = fixString(i->attributeTheme(), QString()); + if (iconHasStatePixmaps(i)) { + // Theme + default state pixmaps: + // Generate code to check the theme and default to state pixmaps + m_output << m_indent << "QIcon " << iconName << ";\n"; + const char themeNameStringVariableC[] = "iconThemeName"; + // Store theme name in a variable + m_output << m_indent; + if (m_firstThemeIcon) { // Declare variable string + m_output << "QString "; + m_firstThemeIcon = false; + } + m_output << themeNameStringVariableC << " = QString::fromUtf8(" + << themeIconName << ");\n"; + m_output << m_indent << "if (QIcon::hasThemeIcon(" + << themeNameStringVariableC + << ")) {\n" + << m_dindent << iconName << " = QIcon::fromTheme(" << themeNameStringVariableC << ");\n" + << m_indent << "} else {\n"; + writeResourceIcon(m_output, iconName, m_dindent, i); + m_output << m_indent << "}\n"; + } else { + // Theme, but no state pixmaps: Construct from theme directly. + m_output << m_indent << "QIcon " << iconName + << "(QIcon::fromTheme(QString::fromUtf8(" + << themeIconName << ")));\n"; + } // Theme, but not state + } // >= 4.4 + } else { // pre-4.4 legacy m_output << m_indent << "const QIcon " << iconName << " = " << pixCall(QLatin1String("QIcon"), i->text())<< ";\n"; } return iconName; diff --git a/src/tools/uic/cpp/cppwriteinitialization.h b/src/tools/uic/cpp/cppwriteinitialization.h index 667ec96..302fbe4 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.h +++ b/src/tools/uic/cpp/cppwriteinitialization.h @@ -363,6 +363,7 @@ private: const bool m_activateScripts; bool m_layoutWidget; + bool m_firstThemeIcon; }; } // namespace CPP diff --git a/src/tools/uic/ui4.cpp b/src/tools/uic/ui4.cpp index 52bc8e3..94d931b 100644 --- a/src/tools/uic/ui4.cpp +++ b/src/tools/uic/ui4.cpp @@ -3673,6 +3673,7 @@ void DomLayoutItem::clear(bool clear_all) m_attr_rowSpan = 0; m_has_attr_colSpan = false; m_attr_colSpan = 0; + m_has_attr_alignment = false; } m_kind = Unknown; @@ -3694,6 +3695,7 @@ DomLayoutItem::DomLayoutItem() m_attr_rowSpan = 0; m_has_attr_colSpan = false; m_attr_colSpan = 0; + m_has_attr_alignment = false; m_widget = 0; m_layout = 0; m_spacer = 0; @@ -3727,6 +3729,10 @@ void DomLayoutItem::read(QXmlStreamReader &reader) setAttributeColSpan(attribute.value().toString().toInt()); continue; } + if (name == QLatin1String("alignment")) { + setAttributeAlignment(attribute.value().toString()); + continue; + } reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString()); } @@ -3779,6 +3785,8 @@ void DomLayoutItem::read(const QDomElement &node) setAttributeRowSpan(node.attribute(QLatin1String("rowspan")).toInt()); if (node.hasAttribute(QLatin1String("colspan"))) setAttributeColSpan(node.attribute(QLatin1String("colspan")).toInt()); + if (node.hasAttribute(QLatin1String("alignment"))) + setAttributeAlignment(node.attribute(QLatin1String("alignment"))); for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { if (!n.isElement()) @@ -3828,6 +3836,9 @@ void DomLayoutItem::write(QXmlStreamWriter &writer, const QString &tagName) cons if (hasAttributeColSpan()) writer.writeAttribute(QLatin1String("colspan"), QString::number(attributeColSpan())); + if (hasAttributeAlignment()) + writer.writeAttribute(QLatin1String("alignment"), attributeAlignment()); + switch (kind()) { case Widget: { DomWidget* v = elementWidget(); @@ -7745,6 +7756,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 +7774,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 +7804,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 +7886,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 +7957,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/src/tools/uic/ui4.h b/src/tools/uic/ui4.h index 2e09c67..6caf515 100644 --- a/src/tools/uic/ui4.h +++ b/src/tools/uic/ui4.h @@ -1427,6 +1427,11 @@ public: inline void setAttributeColSpan(int a) { m_attr_colSpan = a; m_has_attr_colSpan = true; } inline void clearAttributeColSpan() { m_has_attr_colSpan = false; } + inline bool hasAttributeAlignment() const { return m_has_attr_alignment; } + inline QString attributeAlignment() const { return m_attr_alignment; } + inline void setAttributeAlignment(const QString& a) { m_attr_alignment = a; m_has_attr_alignment = true; } + inline void clearAttributeAlignment() { m_has_attr_alignment = false; } + // child element accessors enum Kind { Unknown = 0, Widget, Layout, Spacer }; inline Kind kind() const { return m_kind; } @@ -1460,6 +1465,9 @@ private: int m_attr_colSpan; bool m_has_attr_colSpan; + QString m_attr_alignment; + bool m_has_attr_alignment; + // child element data Kind m_kind; DomWidget* m_widget; @@ -2809,6 +2817,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 +2881,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; diff --git a/src/tools/uic3/converter.cpp b/src/tools/uic3/converter.cpp index 657198e..cc0992f 100644 --- a/src/tools/uic3/converter.cpp +++ b/src/tools/uic3/converter.cpp @@ -864,7 +864,7 @@ DomLayoutItem *Ui3Reader::createLayoutItem(const QDomElement &e) Variant var; var.createSize(0, 0); - QVariant def = qVariantFromValue(var); + QVariant def = QVariant::fromValue(var); Size size = asVariant(DomTool::readProperty(e, QLatin1String("sizeHint"), def)).size; QString sizeType = QLatin1String("QSizePolicy::") + DomTool::readProperty(e, QLatin1String("sizeType"), QLatin1String("Expanding")).toString(); diff --git a/src/tools/uic3/domtool.cpp b/src/tools/uic3/domtool.cpp index 920e7d4..d6fc296 100644 --- a/src/tools/uic3/domtool.cpp +++ b/src/tools/uic3/domtool.cpp @@ -169,7 +169,7 @@ QVariant DomTool::elementToVariant(const QDomElement& e, const QVariant& defValu n3 = n3.nextSibling().toElement(); } var.createRect(x, y, w, h); - qVariantSetValue(v, var); + v.setValue(var); } else if (e.tagName() == QLatin1String("point")) { QDomElement n3 = e.firstChild().toElement(); int x = 0, y = 0; @@ -181,7 +181,7 @@ QVariant DomTool::elementToVariant(const QDomElement& e, const QVariant& defValu n3 = n3.nextSibling().toElement(); } var.createPoint(x,y); - qVariantSetValue(v, var); + v.setValue(var); } else if (e.tagName() == QLatin1String("size")) { QDomElement n3 = e.firstChild().toElement(); int w = 0, h = 0; @@ -193,10 +193,10 @@ QVariant DomTool::elementToVariant(const QDomElement& e, const QVariant& defValu n3 = n3.nextSibling().toElement(); } var.createSize(w, h); - qVariantSetValue(v, var); + v.setValue(var); } else if (e.tagName() == QLatin1String("color")) { var.color = readColor(e); - qVariantSetValue(v, var); + v.setValue(var); } else if (e.tagName() == QLatin1String("font")) { QDomElement n3 = e.firstChild().toElement(); Font f; @@ -217,7 +217,7 @@ QVariant DomTool::elementToVariant(const QDomElement& e, const QVariant& defValu n3 = n3.nextSibling().toElement(); } var.font = f; - qVariantSetValue(v, var); + v.setValue(var); } else if (e.tagName() == QLatin1String("string")) { v = QVariant(e.firstChild().toText().data()); QDomElement n = e; @@ -258,10 +258,10 @@ QVariant DomTool::elementToVariant(const QDomElement& e, const QVariant& defValu var.sizePolicy.verstretch = n3.firstChild().toText().data().toInt(); n3 = n3.nextSibling().toElement(); } - qVariantSetValue(v, var); + v.setValue(var); } else if (e.tagName() == QLatin1String("cursor")) { var.createCursor(e.firstChild().toText().data().toInt()); - qVariantSetValue(v, var); + v.setValue(var); } else if (e.tagName() == QLatin1String("stringlist")) { QStringList lst; QDomElement n; diff --git a/src/tools/uic3/domtool.h b/src/tools/uic3/domtool.h index a0ba54f..c724e52 100644 --- a/src/tools/uic3/domtool.h +++ b/src/tools/uic3/domtool.h @@ -266,7 +266,7 @@ QT_BEGIN_NAMESPACE inline Variant asVariant(const QVariant &v) { Variant var; - var = qVariantValue<Variant>(v); + var = qvariant_cast<Variant>(v); return var; } |