diff options
author | axis <qt-info@nokia.com> | 2009-04-24 11:34:15 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-04-24 11:34:15 (GMT) |
commit | 8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76 (patch) | |
tree | a17e1a767a89542ab59907462206d7dcf2e504b2 /tools/activeqt | |
download | Qt-8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76.zip Qt-8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76.tar.gz Qt-8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76.tar.bz2 |
Long live Qt for S60!
Diffstat (limited to 'tools/activeqt')
30 files changed, 5291 insertions, 0 deletions
diff --git a/tools/activeqt/activeqt.pro b/tools/activeqt/activeqt.pro new file mode 100644 index 0000000..a0e7de3 --- /dev/null +++ b/tools/activeqt/activeqt.pro @@ -0,0 +1,11 @@ +TEMPLATE = subdirs + +CONFIG += ordered + +contains(QT_EDITION, OpenSource|Console) { + message("You are not licensed to use ActiveQt.") +} else { + SUBDIRS = dumpdoc \ + dumpcpp \ + testcon +} diff --git a/tools/activeqt/dumpcpp/dumpcpp.pro b/tools/activeqt/dumpcpp/dumpcpp.pro new file mode 100644 index 0000000..09a339b --- /dev/null +++ b/tools/activeqt/dumpcpp/dumpcpp.pro @@ -0,0 +1,6 @@ +TEMPLATE = app + +CONFIG += console qaxcontainer +DESTDIR = ../../../bin + +SOURCES += main.cpp diff --git a/tools/activeqt/dumpcpp/main.cpp b/tools/activeqt/dumpcpp/main.cpp new file mode 100644 index 0000000..05f1f19 --- /dev/null +++ b/tools/activeqt/dumpcpp/main.cpp @@ -0,0 +1,1502 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QAxObject> +#include <QFile> +#include <QMetaObject> +#include <QMetaEnum> +#include <QTextStream> +#include <QSettings> +#include <QStringList> +#include <QUuid> +#include <QWidget> +#include <qt_windows.h> +#include <ocidl.h> + +QT_BEGIN_NAMESPACE + +static ITypeInfo *currentTypeInfo = 0; + +enum ObjectCategory +{ + DefaultObject = 0x00, + SubObject = 0x001, + ActiveX = 0x002, + NoMetaObject = 0x004, + NoImplementation = 0x008, + NoDeclaration = 0x010, + NoInlines = 0x020, + OnlyInlines = 0x040, + DoNothing = 0x080, + Licensed = 0x100, + TypeLibID = 0x101 +}; + +// this comes from moc/qmetaobject.cpp +enum ProperyFlags { + Invalid = 0x00000000, + Readable = 0x00000001, + Writable = 0x00000002, + Resetable = 0x00000004, + EnumOrFlag = 0x00000008, + StdCppSet = 0x00000100, + Override = 0x00000200, + Designable = 0x00001000, + ResolveDesignable = 0x00002000, + Scriptable = 0x00004000, + ResolveScriptable = 0x00008000, + Stored = 0x00010000, + ResolveStored = 0x00020000, + Editable = 0x00040000, + ResolveEditable = 0x00080000 +}; + +enum MemberFlags { + AccessPrivate = 0x00, + AccessProtected = 0x01, + AccessPublic = 0x02, + MemberMethod = 0x00, + MemberSignal = 0x04, + MemberSlot = 0x08, + MemberCompatibility = 0x10, + MemberCloned = 0x20, + MemberScriptable = 0x40, +}; + +extern QMetaObject *qax_readEnumInfo(ITypeLib *typeLib, const QMetaObject *parentObject); +extern QMetaObject *qax_readClassInfo(ITypeLib *typeLib, ITypeInfo *typeInfo, const QMetaObject *parentObject); +extern QMetaObject *qax_readInterfaceInfo(ITypeLib *typeLib, ITypeInfo *typeInfo, const QMetaObject *parentObject); +extern QList<QByteArray> qax_qualified_usertypes; +extern QString qax_docuFromName(ITypeInfo *typeInfo, const QString &name); +extern bool qax_dispatchEqualsIDispatch; + +QByteArray nameSpace; +QMap<QByteArray, QByteArray> namespaceForType; + +void writeEnums(QTextStream &out, const QMetaObject *mo) +{ + // enums + for (int ienum = mo->enumeratorOffset(); ienum < mo->enumeratorCount(); ++ienum) { + QMetaEnum metaEnum = mo->enumerator(ienum); + out << " enum " << metaEnum.name() << " {" << endl; + for (int k = 0; k < metaEnum.keyCount(); ++k) { + QByteArray key(metaEnum.key(k)); + out << " " << key.leftJustified(24) << "= " << metaEnum.value(k); + if (k < metaEnum.keyCount() - 1) + out << ","; + out << endl; + } + out << " };" << endl; + out << endl; + } +} + +void writeHeader(QTextStream &out, const QByteArray &nameSpace) +{ + out << "#ifndef QAX_DUMPCPP_" << nameSpace.toUpper() << "_H" << endl; + out << "#define QAX_DUMPCPP_" << nameSpace.toUpper() << "_H" << endl; + out << endl; + out << "// Define this symbol to __declspec(dllexport) or __declspec(dllimport)" << endl; + out << "#ifndef " << nameSpace.toUpper() << "_EXPORT" << endl; + out << "#define " << nameSpace.toUpper() << "_EXPORT" << endl; + out << "#endif" << endl; + out << endl; + out << "#include <qaxobject.h>" << endl; + out << "#include <qaxwidget.h>" << endl; + out << "#include <qdatetime.h>" << endl; + out << "#include <qpixmap.h>" << endl; + out << endl; + out << "struct IDispatch;" << endl; + out << endl; +} + +void generateNameSpace(QTextStream &out, const QMetaObject *mo, const QByteArray &nameSpace) +{ + out << "namespace " << nameSpace << " {" << endl; + out << endl; + writeEnums(out, mo); + + // don't close on purpose +} + +static QByteArray joinParameterNames(const QList<QByteArray> ¶meterNames) +{ + QByteArray slotParameters; + for (int p = 0; p < parameterNames.count(); ++p) { + slotParameters += parameterNames.at(p); + if (p < parameterNames.count() - 1) + slotParameters += ','; + } + + return slotParameters; +} + +QByteArray constRefify(const QByteArray &type) +{ + QByteArray ctype(type); + if (type == "QString" || type == "QPixmap" + || type == "QVariant" || type == "QDateTime" + || type == "QColor" || type == "QFont" + || type == "QByteArray" || type == "QValueList<QVariant>" + || type == "QStringList") + ctype = "const " + ctype + "&"; + + return ctype; +} + +void generateClassDecl(QTextStream &out, const QString &controlID, const QMetaObject *mo, const QByteArray &className, const QByteArray &nameSpace, ObjectCategory category) +{ + QList<QByteArray> functions; + + QByteArray indent; + if (!(category & OnlyInlines)) + indent = " "; + + if (!(category & OnlyInlines)) { + // constructors + out << "class " << nameSpace.toUpper() << "_EXPORT " << className << " : public "; + if (category & ActiveX) + out << "QAxWidget"; + else + out << "QAxObject"; + out << endl; + + out << "{" << endl; + out << "public:" << endl; + out << " " << className << "("; + if (category & Licensed) + out << "const QString &licenseKey = QString(), "; + if (category & ActiveX) + out << "QWidget *parent = 0, Qt::WindowFlags f"; + else if (category & SubObject) + out << "IDispatch *subobject = 0, QAxObject *parent"; + else + out << "QObject *parent"; + out << " = 0)" << endl; + out << " : "; + if (category & ActiveX) + out << "QAxWidget(parent, f"; + else if (category & SubObject) + out << "QAxObject((IUnknown*)subobject, parent"; + else + out << "QAxObject(parent"; + out << ")" << endl; + out << " {" << endl; + if (category & SubObject) + out << " internalRelease();" << endl; + else if (category & Licensed) { + out << " if (licenseKey.isEmpty())" << endl; + out << " setControl(\"" << controlID << "\");" << endl; + out << " else" << endl; + out << " setControl(\"" << controlID << ":\" + licenseKey);" << endl; + } else { + out << " setControl(\"" << controlID << "\");" << endl; + } + out << " }" << endl; + out << endl; + + for (int ci = mo->classInfoOffset(); ci < mo->classInfoCount(); ++ci) { + QMetaClassInfo info = mo->classInfo(ci); + QByteArray iface_name = info.name(); + if (iface_name.startsWith("Event ")) + continue; + + QByteArray iface_class = info.value(); + + out << " " << className << "(" << iface_class << " *iface)" << endl; + + if (category & ActiveX) + out << " : QAxWidget()" << endl; + else + out << " : QAxObject()" << endl; + out << " {" << endl; + out << " initializeFrom(iface);" << endl; + out << " delete iface;" << endl; + out << " }" << endl; + out << endl; + } + } + + functions << className; + + // enums + if (nameSpace.isEmpty() && !(category & OnlyInlines)) { + for (int ienum = mo->enumeratorOffset(); ienum < mo->enumeratorCount(); ++ienum) { + QMetaEnum metaEnum = mo->enumerator(ienum); + out << " enum " << metaEnum.name() << " {" << endl; + for (int k = 0; k < metaEnum.keyCount(); ++k) { + QByteArray key(metaEnum.key(k)); + out << " " << key.leftJustified(24) << "= " << metaEnum.value(k); + if (k < metaEnum.keyCount() - 1) + out << ","; + out << endl; + } + out << " };" << endl; + out << endl; + } + } + // QAxBase public virtual functions. + QList<QByteArray> axBase_vfuncs; + axBase_vfuncs.append("metaObject"); + axBase_vfuncs.append("qObject"); + axBase_vfuncs.append("className"); + axBase_vfuncs.append("propertyWritable"); + axBase_vfuncs.append("setPropertyWritable"); + + // properties + for (int iprop = mo->propertyOffset(); iprop < mo->propertyCount(); ++iprop) { + QMetaProperty property = mo->property(iprop); + if (!property.isReadable()) + continue; + + QByteArray propertyName(property.name()); + if (propertyName == "control" || propertyName == className) + continue; + + if (!(category & OnlyInlines)) { + out << indent << "/*" << endl << indent << "Property " << propertyName << endl; + QString documentation = qax_docuFromName(currentTypeInfo, QString::fromLatin1(propertyName.constData())); + if (!documentation.isEmpty()) { + out << endl; + out << indent << documentation << endl; + } + out << indent << "*/" << endl; + } + + // Check whether the new function conflicts with any of QAxBase public virtual functions. + // If so, prepend the function name with '<classname>_'. Since all internal metaobject magic + // remains the same, we have to use the original name when used with QObject::connect or QMetaObject + QByteArray propertyFunctionName(propertyName); + if (axBase_vfuncs.contains(propertyFunctionName)) { + propertyFunctionName = className + "_" + propertyName; + qWarning("property conflits with QAXBase: %s changed to %s", propertyName.constData(), propertyFunctionName.constData()); + } + + QByteArray propertyType(property.typeName()); + QByteArray castType(propertyType); + + QByteArray simplePropType = propertyType; + simplePropType.replace('*', ""); + + out << indent << "inline "; + bool foreignNamespace = true; + if (!propertyType.contains("::") && + (qax_qualified_usertypes.contains(simplePropType) || qax_qualified_usertypes.contains("enum "+ simplePropType)) + ) { + propertyType = nameSpace + "::" + propertyType; + foreignNamespace = false; + } + + out << propertyType << " "; + + if (category & OnlyInlines) + out << className << "::"; + out << propertyFunctionName << "() const"; + + if (!(category & NoInlines)) { + out << endl << indent << "{" << endl; + if (qax_qualified_usertypes.contains(simplePropType)) { + out << indent << " " << propertyType << " qax_pointer = 0;" << endl; + out << indent << " qRegisterMetaType(\"" << property.typeName() << "\", &qax_pointer);" << endl; + if (foreignNamespace) + out << "#ifdef QAX_DUMPCPP_" << propertyType.left(propertyType.indexOf("::")).toUpper() << "_H" << endl; + out << indent << " qRegisterMetaType(\"" << simplePropType << "\", qax_pointer);" << endl; + if (foreignNamespace) + out << "#endif" << endl; + } + out << indent << " QVariant qax_result = property(\"" << propertyName << "\");" << endl; + if (propertyType.length() && propertyType.at(propertyType.length()-1) == '*') + out << indent << " if (!qax_result.constData()) return 0;" << endl; + out << indent << " Q_ASSERT(qax_result.isValid());" << endl; + if (qax_qualified_usertypes.contains(simplePropType)) { + simplePropType = propertyType; + simplePropType.replace('*', ""); + if (foreignNamespace) + out << "#ifdef QAX_DUMPCPP_" << propertyType.left(propertyType.indexOf("::")).toUpper() << "_H" << endl; + out << indent << " return *(" << propertyType << "*)qax_result.constData();" << endl; + if (foreignNamespace) { + out << "#else" << endl; + out << indent << " return 0; // foreign namespace not included" << endl; + out << "#endif" << endl; + } + + } else { + out << indent << " return *(" << propertyType << "*)qax_result.constData();" << endl; + } + out << indent << "}" << endl; + } else { + out << "; //Returns the value of " << propertyName << endl; + } + + functions << propertyName; + + if (property.isWritable()) { + QByteArray setter(propertyName); + QChar firstChar = QLatin1Char(setter.at(0)); + if (isupper(setter.at(0))) { + setter = "Set" + setter; + } else { + setter[0] = toupper(setter[0]); + setter = "set" + setter; + } + + out << indent << "inline " << "void "; + if (category & OnlyInlines) + out << className << "::"; + out << setter << "(" << constRefify(propertyType) << " value)"; + + if (!(category & NoInlines)) { + if (propertyType.endsWith('*')) { + out << "{" << endl; + out << " int typeId = qRegisterMetaType(\"" << propertyType << "\", &value);" << endl; + out << " setProperty(\"" << propertyName << "\", QVariant(typeId, &value));" << endl; + out << "}" << endl; + } else { + out << "{ setProperty(\"" << propertyName << "\", QVariant(value)); }" << endl; + } + } else { + out << "; //Sets the value of the " << propertyName << " property" << endl; + } + + functions << setter; + } + + out << endl; + } + + // slots - but not property setters + int defaultArguments = 0; + for (int islot = mo->methodOffset(); islot < mo->methodCount(); ++islot) { + const QMetaMethod slot(mo->method(islot)); + if (slot.methodType() != QMetaMethod::Slot) + continue; + +#if 0 + // makes not sense really to respect default arguments... + if (slot.attributes() & Cloned) { + ++defaultArguments; + continue; + } +#endif + + QByteArray slotSignature(slot.signature()); + QByteArray slotName = slotSignature.left(slotSignature.indexOf('(')); + if (functions.contains(slotName)) + continue; + + if (!(category & OnlyInlines)) { + out << indent << "/*" << endl << indent << "Method " << slotName << endl; + QString documentation = qax_docuFromName(currentTypeInfo, QString::fromLatin1(slotName.constData())); + if (!documentation.isEmpty()) { + out << endl; + out << indent << documentation << endl; + } + out << indent << "*/" << endl; + } + + QByteArray slotParameters(joinParameterNames(slot.parameterNames())); + QByteArray slotTag(slot.tag()); + QByteArray slotType(slot.typeName()); + + QByteArray simpleSlotType = slotType; + simpleSlotType.replace('*', ""); + if (!slotType.contains("::") && qax_qualified_usertypes.contains(simpleSlotType)) + slotType = nameSpace + "::" + slotType; + + + QByteArray slotNamedSignature; + if (slotSignature.endsWith("()")) { // no parameters - no names + slotNamedSignature = slotSignature; + } else { + slotNamedSignature = slotSignature.left(slotSignature.indexOf('(') + 1); + QByteArray slotSignatureTruncated(slotSignature.mid(slotNamedSignature.length())); + slotSignatureTruncated.truncate(slotSignatureTruncated.length() - 1); + + QList<QByteArray> signatureSplit = slotSignatureTruncated.split(','); + QList<QByteArray> parameterSplit; + if (slotParameters.isEmpty()) { // generate parameter names + for (int i = 0; i < signatureSplit.count(); ++i) + parameterSplit << QByteArray("p") + QByteArray::number(i); + } else { + parameterSplit = slotParameters.split(','); + } + + for (int i = 0; i < signatureSplit.count(); ++i) { + QByteArray parameterType = signatureSplit.at(i); + if (!parameterType.contains("::") && namespaceForType.contains(parameterType)) + parameterType = namespaceForType.value(parameterType) + "::" + parameterType; + + slotNamedSignature += constRefify(parameterType); + slotNamedSignature += " "; + slotNamedSignature += parameterSplit.at(i); + if (defaultArguments >= signatureSplit.count() - i) { + slotNamedSignature += " = "; + slotNamedSignature += parameterType + "()"; + } + if (i + 1 < signatureSplit.count()) + slotNamedSignature += ", "; + } + slotNamedSignature += ')'; + } + + out << indent << "inline "; + + if (!slotTag.isEmpty()) + out << slotTag << " "; + if (slotType.isEmpty()) + out << "void "; + else + out << slotType << " "; + if (category & OnlyInlines) + out << className << "::"; + + // Update function name in case of conflicts with QAxBase public virtual functions. + int parnIdx = slotNamedSignature.indexOf('('); + QByteArray slotOriginalName = slotNamedSignature.left(parnIdx); + if (axBase_vfuncs.contains(slotOriginalName)) { + QByteArray newSignature = className + "_" + slotOriginalName; + newSignature += slotNamedSignature.mid(parnIdx); + qWarning("function name conflits with QAXBase %s changed to %s", slotNamedSignature.constData(), newSignature.constData()); + slotNamedSignature = newSignature; + } + + out << slotNamedSignature; + + if (category & NoInlines) { + out << ";" << endl; + } else { + out << endl; + out << indent << "{" << endl; + + if (!slotType.isEmpty()) { + out << indent << " " << slotType << " qax_result"; + if (slotType.endsWith('*')) + out << " = 0"; + out << ";" << endl; + if (qax_qualified_usertypes.contains(simpleSlotType)) { + out << indent << " qRegisterMetaType(\"" << simpleSlotType << "*\", &qax_result);" << endl; + bool foreignNamespace = simpleSlotType.contains("::"); + if (foreignNamespace) + out << "#ifdef QAX_DUMPCPP_" << simpleSlotType.left(simpleSlotType.indexOf(':')).toUpper() << "_H" << endl; + out << indent << " qRegisterMetaType(\"" << simpleSlotType << "\", qax_result);" << endl; + if (foreignNamespace) + out << "#endif" << endl; + } + } + out << indent << " void *_a[] = {"; + if (!slotType.isEmpty()) + out << "(void*)&qax_result"; + else + out << "0"; + if (!slotParameters.isEmpty()) { + out << ", (void*)&"; + out << slotParameters.replace(",", ", (void*)&"); + } + out << "};" << endl; + + out << indent << " qt_metacall(QMetaObject::InvokeMetaMethod, " << islot << ", _a);" << endl; + if (!slotType.isEmpty()) + out << indent << " return qax_result;" << endl; + out << indent << "}" << endl; + } + + out << endl; + defaultArguments = 0; + } + + if (!(category & OnlyInlines)) { + if (!(category & NoMetaObject)) { + out << "// meta object functions" << endl; + out << " static const QMetaObject staticMetaObject;" << endl; + out << " virtual const QMetaObject *metaObject() const { return &staticMetaObject; }" << endl; + out << " virtual void *qt_metacast(const char *);" << endl; + } + + out << "};" << endl; + } +} + +#define addString(string, stringData) \ + out << stringDataLength << ", "; \ + stringData += string; \ + stringDataLength += qstrlen(string); \ + stringData += "\\0"; \ + lineLength += qstrlen(string) + 1; \ + if (lineLength > 200) { stringData += "\"\n \""; lineLength = 0; } \ + ++stringDataLength; + +void generateClassImpl(QTextStream &out, const QMetaObject *mo, const QByteArray &className, const QByteArray &nameSpace, ObjectCategory category) +{ + QByteArray qualifiedClassName; + if (!nameSpace.isEmpty()) + qualifiedClassName = nameSpace + "::"; + qualifiedClassName += className; + + QByteArray stringData(qualifiedClassName); + int stringDataLength = stringData.length(); + stringData += "\\0\"\n"; + ++stringDataLength; + int lineLength = 0; + + int classInfoCount = mo->classInfoCount() - mo->classInfoOffset(); + int enumCount = mo->enumeratorCount() - mo->enumeratorOffset(); + int methodCount = mo->methodCount() - mo->methodOffset(); + int propertyCount = mo->propertyCount() - mo->propertyOffset(); + int enumStart = 10; + + out << "static const uint qt_meta_data_" << qualifiedClassName.replace(':', '_') << "[] = {" << endl; + out << endl; + out << " // content:" << endl; + out << " 1, // revision" << endl; + out << " 0, // classname" << endl; + out << " " << classInfoCount << ", " << (classInfoCount ? enumStart : 0) << ", // classinfo" << endl; + enumStart += classInfoCount * 2; + out << " " << methodCount << ", " << (methodCount ? enumStart : 0) << ", // methods" << endl; + enumStart += methodCount * 5; + out << " " << propertyCount << ", " << (propertyCount ? enumStart : 0) << ", // properties" << endl; + enumStart += propertyCount * 3; + out << " " << enumCount << ", " << (enumCount ? enumStart : 0) + << ", // enums/sets" << endl; + out << endl; + + if (classInfoCount) { + out << " // classinfo: key, value" << endl; + stringData += " \""; + for (int i = 0; i < classInfoCount; ++i) { + QMetaClassInfo classInfo = mo->classInfo(i + mo->classInfoOffset()); + out << " "; + addString(classInfo.name(), stringData); + addString(classInfo.value(), stringData); + out << endl; + } + stringData += "\"\n"; + out << endl; + } + if (methodCount) { + out << " // signals: signature, parameters, type, tag, flags" << endl; + stringData += " \""; + for (int i = 0; i < methodCount; ++i) { + const QMetaMethod signal(mo->method(i + mo->methodOffset())); + if (signal.methodType() != QMetaMethod::Signal) + continue; + out << " "; + addString(signal.signature(), stringData); + addString(joinParameterNames(signal.parameterNames()), stringData); + addString(signal.typeName(), stringData); + addString(signal.tag(), stringData); + out << (AccessProtected | signal.attributes() | MemberSignal) << "," << endl; + } + stringData += "\"\n"; + out << endl; + + out << " // slots: signature, parameters, type, tag, flags" << endl; + stringData += " \""; + for (int i = 0; i < methodCount; ++i) { + const QMetaMethod slot(mo->method(i + mo->methodOffset())); + if (slot.methodType() != QMetaMethod::Slot) + continue; + out << " "; + addString(slot.signature(), stringData); + addString(joinParameterNames(slot.parameterNames()), stringData); + addString(slot.typeName(), stringData); + addString(slot.tag(), stringData); + out << (0x01 | slot.attributes() | MemberSlot) << "," << endl; + } + stringData += "\"\n"; + out << endl; + } + if (propertyCount) { + out << " // properties: name, type, flags" << endl; + stringData += " \""; + for (int i = 0; i < propertyCount; ++i) { + QMetaProperty property = mo->property(i + mo->propertyOffset()); + out << " "; + addString(property.name(), stringData); + addString(property.typeName(), stringData); + + uint flags = 0; + uint vartype = property.type(); + if (vartype != QVariant::Invalid && vartype != QVariant::UserType) + flags = vartype << 24; + else if (QByteArray(property.typeName()) == "QVariant") + flags |= 0xff << 24; + + if (property.isReadable()) + flags |= Readable; + if (property.isWritable()) + flags |= Writable; + if (property.isEnumType()) + flags |= EnumOrFlag; + if (property.isDesignable()) + flags |= Designable; + if (property.isScriptable()) + flags |= Scriptable; + if (property.isStored()) + flags |= Stored; + if (property.isEditable()) + flags |= Editable; + + out << "0x" << QString::number(flags, 16).rightJustified(8, '0') << ", \t\t // " << property.typeName() << " " << property.name(); + out << endl; + } + stringData += "\"\n"; + out << endl; + } + + QByteArray enumStringData; + if (enumCount) { + out << " // enums: name, flags, count, data" << endl; + enumStringData += " \""; + enumStart += enumCount * 4; + for (int i = 0; i < enumCount; ++i) { + QMetaEnum enumerator = mo->enumerator(i + mo->enumeratorOffset()); + out << " "; + addString(enumerator.name(), enumStringData); + out << (enumerator.isFlag() ? "0x1" : "0x0") << ", " << enumerator.keyCount() << ", " << enumStart << ", " << endl; + enumStart += enumerator.keyCount() * 2; + } + enumStringData += "\"\n"; + out << endl; + + out << " // enum data: key, value" << endl; + for (int i = 0; i < enumCount; ++i) { + enumStringData += " \""; + QMetaEnum enumerator = mo->enumerator(i + mo->enumeratorOffset()); + for (int j = 0; j < enumerator.keyCount(); ++j) { + out << " "; + addString(enumerator.key(j), enumStringData); + if (nameSpace.isEmpty()) + out << className << "::"; + else + out << nameSpace << "::"; + out << enumerator.key(j) << "," << endl; + } + enumStringData += "\"\n"; + } + out << endl; + } + out << " 0 // eod" << endl; + out << "};" << endl; + out << endl; + + QByteArray stringGenerator; + + if (!nameSpace.isEmpty()) { + static bool firstStringData = true; + if (firstStringData) { // print enums only once + firstStringData = false; + if (!enumStringData.isEmpty()) { + // Maximum string length supported is 64K + int maxStringLength = 65535; + if (enumStringData.size() < maxStringLength) { + out << "static const char qt_meta_enumstringdata_" << nameSpace << "[] = {" << endl; + out << enumStringData << endl; + out << "};" << endl; + out << endl; + } else { + // split the string into fragments of 64k + int fragments = (enumStringData.size() / maxStringLength); + fragments += (enumStringData.size() % maxStringLength) ? 1 : 0; + int i, index; + // define the fragments (qt_meta_enumstringdata_<nameSpace>fragment#) + for (i = 0 , index = 0; i < fragments; i++, index += maxStringLength) { + out << "static const char qt_meta_enumstringdata_" << nameSpace << "fragment"<< QString::number(i) << "[] = {" << endl; + QByteArray fragment = enumStringData.mid(index, maxStringLength); + if (!(fragment[0] == ' ' || fragment[0] == '\n' || fragment[0] == '\"')) + out << "\""; + out << fragment; + int endIx = fragment.size() - 1; + if (!(fragment[endIx] == ' ' || fragment[endIx] == '\n' || fragment[endIx] == '\"' || fragment[endIx] == '\0')) + out << "\"" << endl; + else + out << endl; + out << "};" << endl; + } + // original array definition, size will be the combined size of the arrays defined above + out << "static char qt_meta_enumstringdata_" << nameSpace << "[" << endl; + for (i = 0; i < fragments; i++, index += maxStringLength) { + out << " "; + if (i) + out << "+ "; + out << "sizeof(qt_meta_enumstringdata_" << nameSpace << "fragment"<< QString::number(i) <<")" << endl; + } + out << "] = {0};" << endl << endl; + // this class will initializes the original array in constructor + out << "class qt_meta_enumstringdata_" << nameSpace << "_init " << endl <<"{" <<endl; + out << "public:"<<endl; + out << " qt_meta_enumstringdata_" << nameSpace << "_init() " << endl <<" {" <<endl; + out << " int index = 0;" << endl; + for (i = 0; i < fragments; i++, index += maxStringLength) { + out << " memcpy(qt_meta_enumstringdata_" << nameSpace << " + index, " <<"qt_meta_enumstringdata_" << nameSpace << "fragment"<< QString::number(i); + out << ", sizeof(qt_meta_enumstringdata_" << nameSpace << "fragment"<< QString::number(i) <<") - 1);" << endl; + out << " index += sizeof(qt_meta_enumstringdata_" << nameSpace << "fragment"<< QString::number(i) <<") - 1;" << endl; + } + out << " }" << endl << "};" << endl; + // a global variable of the class + out << "static qt_meta_enumstringdata_" << nameSpace << "_init qt_meta_enumstringdata_" << nameSpace << "_init_instance;" << endl << endl; + } + } + } + stringGenerator = "qt_meta_stringdata_" + qualifiedClassName.replace(':','_') + "()"; + out << "static const char *" << stringGenerator << " {" << endl; + QList<QByteArray> splitStrings; + + // workaround for compilers that can't handle string literals longer than 64k + int splitCount = 0; + do { + int lastNewline = stringData.lastIndexOf('\n', 64000); + QByteArray splitString = stringData.left(lastNewline); + + splitStrings << splitString; + out << " static const char stringdata" << splitCount << "[] = {" << endl; + out << " \"" << splitString << endl; + out << " };" << endl; + stringData = stringData.mid(lastNewline + 1); + if (stringData.startsWith(" \"")) + stringData = stringData.mid(5); + ++splitCount; + } while (!stringData.isEmpty()); + + out << " static char data["; + for (int i = 0; i < splitCount; ++i) { + out << "sizeof(stringdata" << i << ") + "; + } + if (!enumStringData.isEmpty()) { + out << "sizeof(qt_meta_enumstringdata_" << nameSpace << ")"; + } else { + out << "0"; + } + out << "];" << endl; + out << " if (!data[0]) {" << endl; + out << " int index = 0;" << endl; + + int dataIndex = 0; + for (int i = 0; i < splitCount; ++i) { + out << " memcpy(data + index"; + out << ", stringdata" << i << ", sizeof(stringdata" << i << ") - 1);" << endl; + out << " index += sizeof(stringdata" << i << ") - 1;" << endl; + dataIndex += splitStrings.at(i).length(); + } + if (!enumStringData.isEmpty()) { + out << " memcpy(data + index, qt_meta_enumstringdata_" << nameSpace << ", sizeof(qt_meta_enumstringdata_" << nameSpace << "));" << endl; + } + out << " }" << endl; + out << endl; + out << " return data;" << endl; + out << "};" << endl; + out << endl; + } else { + stringData += enumStringData; + stringGenerator = "qt_meta_stringdata_" + qualifiedClassName.replace(':','_'); + out << "static const char qt_meta_stringdata_" << stringGenerator << "[] = {" << endl; + out << " \"" << stringData << endl; + out << "};" << endl; + out << endl; + } + + out << "const QMetaObject " << className << "::staticMetaObject = {" << endl; + if (category & ActiveX) + out << "{ &QWidget::staticMetaObject," << endl; + else + out << "{ &QObject::staticMetaObject," << endl; + out << stringGenerator << "," << endl; + out << "qt_meta_data_" << qualifiedClassName.replace(':','_') << " }" << endl; + out << "};" << endl; + out << endl; + + out << "void *" << className << "::qt_metacast(const char *_clname)" << endl; + out << "{" << endl; + out << " if (!_clname) return 0;" << endl; + out << " if (!strcmp(_clname, " << stringGenerator << "))" << endl; + out << " return static_cast<void*>(const_cast<" << className << "*>(this));" << endl; + if (category & ActiveX) + out << " return QAxWidget::qt_metacast(_clname);" << endl; + else + out << " return QAxObject::qt_metacast(_clname);" << endl; + out << "}" << endl; +} + +bool generateClass(QAxObject *object, const QByteArray &className, const QByteArray &nameSpace, const QByteArray &outname, ObjectCategory category) +{ + IOleControl *control = 0; + object->queryInterface(IID_IOleControl, (void**)&control); + if (control) { + category = ActiveX; + control->Release(); + } + + const QMetaObject *mo = object->metaObject(); + + if (!nameSpace.isEmpty() && !(category & NoDeclaration)) { + QFile outfile(QString::fromLatin1(nameSpace.toLower().constData()) + QLatin1String(".h")); + if (!outfile.open(QIODevice::WriteOnly | QIODevice::Text)) { + qWarning("dumpcpp: Could not open output file '%s'", qPrintable(outfile.fileName())); + return false; + } + QTextStream out(&outfile); + + out << "/****************************************************************************" << endl; + out << "**" << endl; + out << "** Namespace " << nameSpace << " generated by dumpcpp" << endl; + out << "**" << endl; + out << "****************************************************************************/" << endl; + out << endl; + + writeHeader(out, nameSpace); + generateNameSpace(out, mo, nameSpace); + + // close namespace file + out << "};" << endl; + out << endl; + + out << "#endif" << endl; + out << endl; + } + + if (!(category & NoDeclaration)) { + QFile outfile(QString::fromLatin1(outname.constData()) + QLatin1String(".h")); + if (!outfile.open(QIODevice::WriteOnly | QIODevice::Text)) { + qWarning("dumpcpp: Could not open output file '%s'", qPrintable(outfile.fileName())); + return false; + } + QTextStream out(&outfile); + + out << "/****************************************************************************" << endl; + out << "**" << endl; + out << "** Class declaration generated by dumpcpp" << endl; + out << "**" << endl; + out << "****************************************************************************/" << endl; + out << endl; + + out << "#include <qdatetime.h>" << endl; + if (category & ActiveX) + out << "#include <qaxwidget.h>" << endl; + else + out << "#include <qaxobject.h>" << endl; + out << endl; + + out << "struct IDispatch;" << endl, + out << endl; + + if (!nameSpace.isEmpty()) { + out << "#include \"" << nameSpace.toLower() << ".h\"" << endl; + out << endl; + out << "namespace " << nameSpace << " {" << endl; + } + + generateClassDecl(out, object->control(), mo, className, nameSpace, category); + + if (!nameSpace.isEmpty()) { + out << endl; + out << "};" << endl; + } + } + + if (!(category & (NoMetaObject|NoImplementation))) { + QFile outfile(QString::fromLatin1(outname.constData()) + QLatin1String(".cpp")); + if (!outfile.open(QIODevice::WriteOnly | QIODevice::Text)) { + qWarning("dumpcpp: Could not open output file '%s'", qPrintable(outfile.fileName())); + return false; + } + QTextStream out(&outfile); + + out << "#include <qmetaobject.h>" << endl; + out << "#include \"" << outname << ".h\"" << endl; + out << endl; + + if (!nameSpace.isEmpty()) { + out << "using namespace " << nameSpace << ";" << endl; + out << endl; + } + + generateClassImpl(out, mo, className, nameSpace, category); + } + + return true; +} + +bool generateTypeLibrary(const QByteArray &typeLib, const QByteArray &outname, ObjectCategory category) +{ + QString typeLibFile(QString::fromLatin1(typeLib.constData())); + typeLibFile = typeLibFile.replace(QLatin1Char('/'), QLatin1Char('\\')); + QString cppFile(QString::fromLatin1(outname.constData())); + + ITypeLib *typelib; + LoadTypeLibEx(reinterpret_cast<const wchar_t *>(typeLibFile.utf16()), REGKIND_NONE, &typelib); + if (!typelib) { + qWarning("dumpcpp: loading '%s' as a type library failed", qPrintable(typeLibFile)); + return false; + } + + QString libName; + BSTR nameString; + typelib->GetDocumentation(-1, &nameString, 0, 0, 0); + libName = QString::fromUtf16((const ushort *)nameString); + SysFreeString(nameString); + if (!nameSpace.isEmpty()) + libName = QString(nameSpace); + + QString libVersion(QLatin1String("1.0")); + + TLIBATTR *tlibattr = 0; + typelib->GetLibAttr(&tlibattr); + if (tlibattr) { + libVersion = QString::fromLatin1("%1.%2").arg(tlibattr->wMajorVerNum).arg(tlibattr->wMinorVerNum); + typelib->ReleaseTLibAttr(tlibattr); + } + + if (cppFile.isEmpty()) + cppFile = libName.toLower(); + + if (cppFile.isEmpty()) { + qWarning("dumpcpp: no output filename provided, and cannot deduce output filename"); + return false; + } + + QMetaObject *namespaceObject = qax_readEnumInfo(typelib, 0); + + QFile implFile(cppFile + QLatin1String(".cpp")); + QTextStream implOut(&implFile); + if (!(category & (NoMetaObject|NoImplementation))) { + if (!implFile.open(QIODevice::WriteOnly | QIODevice::Text)) { + qWarning("dumpcpp: Could not open output file '%s'", qPrintable(implFile.fileName())); + return false; + } + + implOut << "/****************************************************************************" << endl; + implOut << "**" << endl; + implOut << "** Metadata for " << libName << " generated by dumpcpp from type library" << endl; + implOut << "** " << typeLibFile << endl; + implOut << "**" << endl; + implOut << "****************************************************************************/" << endl; + implOut << endl; + + implOut << "#define QAX_DUMPCPP_" << libName.toUpper() << "_NOINLINES" << endl; + + implOut << "#include \"" << cppFile << ".h\"" << endl; + implOut << endl; + implOut << "using namespace " << libName << ";" << endl; + implOut << endl; + } + + QFile declFile(cppFile + QLatin1String(".h")); + QTextStream declOut(&declFile); + QByteArray classes; + QTextStream classesOut(&classes, QIODevice::WriteOnly); + QByteArray inlines; + QTextStream inlinesOut(&inlines, QIODevice::WriteOnly); + + QMap<QByteArray, QList<QByteArray> > namespaces; + + if(!(category & NoDeclaration)) { + if (!declFile.open(QIODevice::WriteOnly | QIODevice::Text)) { + qWarning("dumpcpp: Could not open output file '%s'", qPrintable(declFile.fileName())); + return false; + } + + declOut << "/****************************************************************************" << endl; + declOut << "**" << endl; + declOut << "** Namespace " << libName << " generated by dumpcpp from type library" << endl; + declOut << "** " << typeLibFile << endl; + declOut << "**" << endl; + declOut << "****************************************************************************/" << endl; + declOut << endl; + + writeHeader(declOut, libName.toLatin1()); + + UINT typeCount = typelib->GetTypeInfoCount(); + if (declFile.isOpen()) { + declOut << endl; + declOut << "// Referenced namespace" << endl; + for (UINT index = 0; index < typeCount; ++index) { + ITypeInfo *typeinfo = 0; + typelib->GetTypeInfo(index, &typeinfo); + if (!typeinfo) + continue; + + TYPEATTR *typeattr; + typeinfo->GetTypeAttr(&typeattr); + if (!typeattr) { + typeinfo->Release(); + continue; + } + + TYPEKIND typekind; + typelib->GetTypeInfoType(index, &typekind); + + QMetaObject *metaObject = 0; + + // trigger meta object to collect references to other type libraries + switch (typekind) { + case TKIND_COCLASS: + if (category & ActiveX) + metaObject = qax_readClassInfo(typelib, typeinfo, &QWidget::staticMetaObject); + else + metaObject = qax_readClassInfo(typelib, typeinfo, &QObject::staticMetaObject); + break; + case TKIND_DISPATCH: + if (category & ActiveX) + metaObject = qax_readInterfaceInfo(typelib, typeinfo, &QWidget::staticMetaObject); + else + metaObject = qax_readInterfaceInfo(typelib, typeinfo, &QObject::staticMetaObject); + break; + case TKIND_RECORD: + case TKIND_ENUM: + case TKIND_INTERFACE: // only for forward declarations + { + QByteArray className; + BSTR bstr; + if (S_OK != typeinfo->GetDocumentation(-1, &bstr, 0, 0, 0)) + break; + className = QString::fromUtf16((const ushort *)bstr).toLatin1(); + SysFreeString(bstr); + switch (typekind) { + case TKIND_RECORD: + className = "struct " + className; + break; + case TKIND_ENUM: + className = "enum " + className; + break; + default: + break; + } + namespaces[libName.toLatin1()].append(className); + if (!qax_qualified_usertypes.contains(className)) + qax_qualified_usertypes << className; + } + break; + default: + break; + } + + delete metaObject; + typeinfo->ReleaseTypeAttr(typeattr); + typeinfo->Release(); + } + + for (int i = 0; i < qax_qualified_usertypes.count(); ++i) { + QByteArray refType = qax_qualified_usertypes.at(i); + QByteArray refTypeLib; + if (refType.contains("::")) { + refTypeLib = refType; + refType = refType.mid(refType.lastIndexOf("::") + 2); + if (refTypeLib.contains(' ')) { + refType = refTypeLib.left(refTypeLib.indexOf(' ')) + ' ' + refType; + } + refTypeLib = refTypeLib.left(refTypeLib.indexOf("::")); + refTypeLib = refTypeLib.mid(refTypeLib.lastIndexOf(' ') + 1); + namespaces[refTypeLib].append(refType); + } else { + namespaces[libName.toLatin1()].append(refType); + } + } + + QList<QByteArray> keys = namespaces.keys(); + for (int n = 0; n < keys.count(); ++n) { + QByteArray nspace = keys.at(n); + if (QString::fromLatin1(nspace.constData()) != libName) { + declOut << "namespace " << nspace << " {" << endl; + QList<QByteArray> classList = namespaces.value(nspace); + for (int c = 0; c < classList.count(); ++c) { + QByteArray className = classList.at(c); + if (className.contains(' ')) { + declOut << " " << className << ";" << endl; + namespaceForType.insert(className.mid(className.indexOf(' ') + 1), nspace); + } else { + declOut << " class " << className << ";" << endl; + namespaceForType.insert(className, nspace); + namespaceForType.insert(className + "*", nspace); + } + } + declOut << "}" << endl << endl; + } + } + + declOut << endl; + } + generateNameSpace(declOut, namespaceObject, libName.toLatin1()); + + QList<QByteArray> classList = namespaces.value(libName.toLatin1()); + if (classList.count()) + declOut << "// forward declarations" << endl; + for (int c = 0; c < classList.count(); ++c) { + QByteArray className = classList.at(c); + if (className.contains(' ')) { + declOut << " " << className << ";" << endl; + namespaceForType.insert(className.mid(className.indexOf(' ') + 1), libName.toLatin1()); + } else { + declOut << " class " << className << ";" << endl; + namespaceForType.insert(className, libName.toLatin1()); + namespaceForType.insert(className + "*", libName.toLatin1()); + } + } + + declOut << endl; + } + + QList<QByteArray> subtypes; + + UINT typeCount = typelib->GetTypeInfoCount(); + for (UINT index = 0; index < typeCount; ++index) { + ITypeInfo *typeinfo = 0; + typelib->GetTypeInfo(index, &typeinfo); + if (!typeinfo) + continue; + + TYPEATTR *typeattr; + typeinfo->GetTypeAttr(&typeattr); + if (!typeattr) { + typeinfo->Release(); + continue; + } + + TYPEKIND typekind; + typelib->GetTypeInfoType(index, &typekind); + + uint object_category = category; + if (!(typeattr->wTypeFlags & TYPEFLAG_FCANCREATE)) + object_category |= SubObject; + else if (typeattr->wTypeFlags & TYPEFLAG_FCONTROL) + object_category |= ActiveX; + + QMetaObject *metaObject = 0; + QUuid guid(typeattr->guid); + + if (!(object_category & ActiveX)) { + QSettings settings(QLatin1String("HKEY_LOCAL_MACHINE\\Software\\Classes\\CLSID\\") + guid.toString(), QSettings::NativeFormat); + if (settings.childGroups().contains(QLatin1String("Control"))) { + object_category |= ActiveX; + object_category &= ~SubObject; + } + } + + switch (typekind) { + case TKIND_COCLASS: + if (object_category & ActiveX) + metaObject = qax_readClassInfo(typelib, typeinfo, &QWidget::staticMetaObject); + else + metaObject = qax_readClassInfo(typelib, typeinfo, &QObject::staticMetaObject); + break; + case TKIND_DISPATCH: + if (object_category & ActiveX) + metaObject = qax_readInterfaceInfo(typelib, typeinfo, &QWidget::staticMetaObject); + else + metaObject = qax_readInterfaceInfo(typelib, typeinfo, &QObject::staticMetaObject); + break; + case TKIND_INTERFACE: // only stub + { + QByteArray className; + BSTR bstr; + if (S_OK != typeinfo->GetDocumentation(-1, &bstr, 0, 0, 0)) + break; + className = QString::fromUtf16((const ushort *)bstr).toLatin1(); + SysFreeString(bstr); + + declOut << "// stub for vtable-only interface" << endl; + declOut << "class " << className << " : public QAxObject {};" << endl << endl; + } + break; + default: + break; + } + + if (metaObject) { + currentTypeInfo = typeinfo; + QByteArray className(metaObject->className()); + if (!(typeattr->wTypeFlags & TYPEFLAG_FDUAL) + && (metaObject->propertyCount() - metaObject->propertyOffset()) == 1 + && className.contains("Events")) { + declOut << "// skipping event interface " << className << endl << endl; + } else { + if (declFile.isOpen()) { + if (typeattr->wTypeFlags & TYPEFLAG_FLICENSED) + object_category |= Licensed; + if (typekind == TKIND_COCLASS) { // write those later... + generateClassDecl(classesOut, guid.toString(), metaObject, className, libName.toLatin1(), (ObjectCategory)(object_category|NoInlines)); + classesOut << endl; + } else { + generateClassDecl(declOut, guid.toString(), metaObject, className, libName.toLatin1(), (ObjectCategory)(object_category|NoInlines)); + declOut << endl; + } + subtypes << className; + generateClassDecl(inlinesOut, guid.toString(), metaObject, className, libName.toLatin1(), (ObjectCategory)(object_category|OnlyInlines)); + inlinesOut << endl; + } + if (implFile.isOpen()) { + generateClassImpl(implOut, metaObject, className, libName.toLatin1(), (ObjectCategory)object_category); + implOut << endl; + } + } + currentTypeInfo = 0; + } + + delete metaObject; + + typeinfo->ReleaseTypeAttr(typeattr); + typeinfo->Release(); + } + + delete namespaceObject; + + classesOut.flush(); + inlinesOut.flush(); + + if (declFile.isOpen()) { + if (classes.size()) { + declOut << "// Actual coclasses" << endl; + declOut << classes; + } + if (inlines.size()) { + declOut << "// member function implementation" << endl; + declOut << "#ifndef QAX_DUMPCPP_" << libName.toUpper() << "_NOINLINES" << endl; + declOut << inlines << endl; + declOut << "#endif" << endl << endl; + } + // close namespace + declOut << "}" << endl; + declOut << endl; + + // partial template specialization for qMetaTypeConstructHelper + for (int t = 0; t < subtypes.count(); ++t) { + QByteArray subType(subtypes.at(t)); + declOut << "template<>" << endl; + declOut << "inline void *qMetaTypeConstructHelper(const " << libName << "::" << subType << " *t)" << endl; + declOut << "{ Q_ASSERT(!t); return new " << libName << "::" << subType << "; }" << endl; + declOut << endl; + } + + declOut << "#endif" << endl; + declOut << endl; + } + + typelib->Release(); + return true; +} + +QT_END_NAMESPACE + +QT_USE_NAMESPACE + +int main(int argc, char **argv) +{ + qax_dispatchEqualsIDispatch = false; + + CoInitialize(0); + + uint category = DefaultObject; + + enum State { + Default = 0, + Output, + NameSpace, + GetTypeLib + } state; + state = Default; + + QByteArray outname; + QByteArray typeLib; + + for (int a = 1; a < argc; ++a) { + QByteArray arg(argv[a]); + const char first = arg[0]; + switch(state) { + case Default: + if (first == '-' || first == '/') { + arg = arg.mid(1); + arg.toLower(); + + if (arg == "o") { + state = Output; + } else if (arg == "n") { + state = NameSpace; + } else if (arg == "v") { + qWarning("dumpcpp: Version 1.0"); + return 0; + } else if (arg == "nometaobject") { + category |= NoMetaObject; + } else if (arg == "impl") { + category |= NoDeclaration; + } else if (arg == "decl") { + category |= NoImplementation; + } else if (arg == "donothing") { + category = DoNothing; + break; + } else if (arg == "compat") { + qax_dispatchEqualsIDispatch = true; + break; + } else if (arg == "getfile") { + state = GetTypeLib; + break; + } else if (arg == "h") { + qWarning("dumpcpp Version1.0\n\n" + "Generate a C++ namespace from a type library.\n\n" + "Usage:\n" + "dumpcpp input [-[-n <namespace>] [-o <filename>]\n\n" + " input: A type library file, type library ID, ProgID or CLSID\n\n" + "Optional parameters:\n" + " namespace: The name of the generated C++ namespace\n" + " filename: The file name (without extension) of the generated files\n" + "\n" + "Other parameters:\n" + " -nometaobject Don't generate meta object information (no .cpp file)\n" + " -impl Only generate the .cpp file\n" + " -decl Only generate the .h file\n" + " -compat Treat all coclass parameters as IDispatch\n" + "\n" + "Examples:\n" + " dumpcpp Outlook.Application -o outlook\n" + " dumpcpp {3B756301-0075-4E40-8BE8-5A81DE2426B7}\n" + "\n"); + return 0; + } + } else { + typeLib = arg; + } + break; + + case Output: + outname = arg; + state = Default; + break; + + case NameSpace: + nameSpace = arg; + state = Default; + break; + + case GetTypeLib: + typeLib = arg; + state = Default; + category = TypeLibID; + break; + default: + break; + } + } + + if (category == TypeLibID) { + QSettings settings(QLatin1String("HKEY_LOCAL_MACHINE\\Software\\Classes\\TypeLib\\") + + QString::fromLatin1(typeLib.constData()), QSettings::NativeFormat); + typeLib = QByteArray(); + QStringList codes = settings.childGroups(); + for (int c = 0; c < codes.count(); ++c) { + typeLib = settings.value(QLatin1String("/") + codes.at(c) + QLatin1String("/0/win32/.")).toByteArray(); + if (QFile::exists(QString::fromLatin1(typeLib))) { + break; + } + } + + if (!typeLib.isEmpty()) + fprintf(stdout, "\"%s\"\n", typeLib.data()); + return 0; + } + + if (category == DoNothing) + return 0; + + if (typeLib.isEmpty()) { + qWarning("dumpcpp: No object class or type library name provided.\n" + " Use -h for help."); + return -1; + } + + // not a file - search registry + if (!QFile::exists(QString::fromLatin1(typeLib.constData()))) { + bool isObject = false; + QSettings settings(QLatin1String("HKEY_LOCAL_MACHINE\\Software\\Classes"), QSettings::NativeFormat); + + // regular string and not a file - must be ProgID + if (typeLib.at(0) != '{') { + CLSID clsid; + if (CLSIDFromProgID(reinterpret_cast<const wchar_t *>(QString(QLatin1String(typeLib)).utf16()), &clsid) != S_OK) { + qWarning("dumpcpp: '%s' is not a type library and not a registered ProgID", typeLib.constData()); + return -2; + } + QUuid uuid(clsid); + typeLib = uuid.toString().toLatin1(); + isObject = true; + } + + // check if CLSID + if (!isObject) { + QVariant test = settings.value(QLatin1String("/CLSID/") + + QString::fromLatin1(typeLib.constData()) + QLatin1String("/.")); + isObject = test.isValid(); + } + + // search typelib ID for CLSID + if (isObject) + typeLib = settings.value(QLatin1String("/CLSID/") + + QString::fromLatin1(typeLib.constData()) + QLatin1String("/Typelib/.")).toByteArray(); + + // interpret input as type library ID + QString key = QLatin1String("/TypeLib/") + QLatin1String(typeLib); + settings.beginGroup(key); + QStringList versions = settings.childGroups(); + QStringList codes; + if (versions.count()) { + settings.beginGroup(QLatin1String("/") + versions.last()); + codes = settings.childGroups(); + key += QLatin1String("/") + versions.last(); + settings.endGroup(); + } + settings.endGroup(); + + for (int c = 0; c < codes.count(); ++c) { + typeLib = settings.value(key + QLatin1String("/") + codes.at(c) + QLatin1String("/win32/.")).toByteArray(); + if (QFile::exists(QString::fromLatin1(typeLib.constData()))) { + break; + } + } + } + + if (!QFile::exists(QString::fromLatin1(typeLib.constData()))) { + qWarning("dumpcpp: type library '%s' not found", typeLib.constData()); + return -2; + } + + if (!generateTypeLibrary(typeLib, outname, (ObjectCategory)category)) { + qWarning("dumpcpp: error processing type library '%s'", typeLib.constData()); + return -1; + } + + return 0; +} diff --git a/tools/activeqt/dumpdoc/dumpdoc.pro b/tools/activeqt/dumpdoc/dumpdoc.pro new file mode 100644 index 0000000..3c93525 --- /dev/null +++ b/tools/activeqt/dumpdoc/dumpdoc.pro @@ -0,0 +1,5 @@ +TEMPLATE = app + +CONFIG += console qaxcontainer + +SOURCES += main.cpp diff --git a/tools/activeqt/dumpdoc/main.cpp b/tools/activeqt/dumpdoc/main.cpp new file mode 100644 index 0000000..87b9540 --- /dev/null +++ b/tools/activeqt/dumpdoc/main.cpp @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QAxObject> +#include <QFile> +#include <QTextStream> +#include <qt_windows.h> + +QT_USE_NAMESPACE + +int main(int argc, char **argv) +{ + CoInitialize(0); + + enum State { + Default = 0, + OutOption + } state; + state = Default; + + QByteArray outname; + QByteArray object; + + for (int a = 1; a < argc; ++a) { + QByteArray arg(argv[a]); + const char first = arg[0]; + switch(state) { + case Default: + if (first == '-' || first == '/') { + arg = arg.mid(1); + arg.toLower(); + if (arg == "o") + state = OutOption; + else if (arg == "v") { + qWarning("dumpdoc: Version 1.0"); + return 0; + } else if (arg == "h") { + qWarning("dumpdoc Usage:\n\tdumpdoc object [-o <file>]" + " \n\tobject : object[/subobject]*" + " \n\tsubobject: property\n" + " \nexample:\n\tdumpdoc Outlook.Application/Session/CurrentUser -o outlook.html"); + return 0; + } + } else { + object = arg; + } + break; + case OutOption: + outname = arg; + state = Default; + break; + + default: + break; + } + } + + if (object.isEmpty()) { + qWarning("dumpdoc: No object name provided.\n" + " Use -h for help."); + return -1; + } + QFile outfile; + if (!outname.isEmpty()) { + outfile.setFileName(QString::fromLatin1(outname.constData())); + if (!outfile.open(QIODevice::WriteOnly | QIODevice::Text)) { + qWarning("dumpdoc: Could not open output file '%s'", outname.data()); + } + } else { + outfile.open(stdout, QIODevice::WriteOnly); + } + QTextStream out(&outfile); + + QByteArray subobject = object; + int index = subobject.indexOf('/'); + if (index != -1) + subobject = subobject.left(index); + + QAxObject topobject(QString::fromLatin1(subobject.constData())); + + if (topobject.isNull()) { + qWarning("dumpdoc: Could not instantiate COM object '%s'", subobject.data()); + return -2; + } + + QAxObject *axobject = &topobject; + while (index != -1 && axobject) { + index++; + subobject = object.mid(index); + if (object.indexOf('/', index) != -1) { + int oldindex = index; + index = object.indexOf('/', index); + subobject = object.mid(oldindex, index-oldindex); + } else { + index = -1; + } + + axobject = axobject->querySubObject(subobject); + } + if (!axobject || axobject->isNull()) { + qWarning("dumpdoc: Subobject '%s' does not exist in '%s'", subobject.data(), object.data()); + return -3; + } + + QString docu = axobject->generateDocumentation(); + out << docu; + return 0; +} diff --git a/tools/activeqt/testcon/ambientproperties.cpp b/tools/activeqt/testcon/ambientproperties.cpp new file mode 100644 index 0000000..8e284d8 --- /dev/null +++ b/tools/activeqt/testcon/ambientproperties.cpp @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "ambientproperties.h" + +#include <QtGui> + +QT_BEGIN_NAMESPACE + +AmbientProperties::AmbientProperties(QWidget *parent) +: QDialog(parent), container(0) +{ + setupUi(this); + + connect(buttonClose, SIGNAL(clicked()), this, SLOT(close())); +} + +void AmbientProperties::setControl(QWidget *widget) +{ + container = widget; + + QColor c = container->palette().color(container->backgroundRole()); + QPalette p = backSample->palette(); p.setColor(backSample->backgroundRole(), c); backSample->setPalette(p); + + c = container->palette().color(container->foregroundRole()); + p = foreSample->palette(); p.setColor(foreSample->backgroundRole(), c); foreSample->setPalette(p); + + fontSample->setFont( container->font() ); + buttonEnabled->setChecked( container->isEnabled() ); + enabledSample->setEnabled( container->isEnabled() ); +} + +void AmbientProperties::on_buttonBackground_clicked() +{ + QColor c = QColorDialog::getColor(backSample->palette().color(backSample->backgroundRole()), this); + QPalette p = backSample->palette(); p.setColor(backSample->backgroundRole(), c); backSample->setPalette(p); + p = container->palette(); p.setColor(container->backgroundRole(), c); container->setPalette(p); + + if (QWorkspace *ws = qobject_cast<QWorkspace*>(container)) { + QWidgetList list( ws->windowList() ); + for (int i = 0; i < list.count(); ++i) { + QWidget *widget = list.at(i); + p = widget->palette(); p.setColor(widget->backgroundRole(), c); widget->setPalette(p); + } + } +} + +void AmbientProperties::on_buttonForeground_clicked() +{ + QColor c = QColorDialog::getColor(foreSample->palette().color(foreSample->backgroundRole()), this); + QPalette p = foreSample->palette(); p.setColor(foreSample->backgroundRole(), c); foreSample->setPalette(p); + p = container->palette(); p.setColor(container->foregroundRole(), c); container->setPalette(p); + + if (QWorkspace *ws = qobject_cast<QWorkspace*>(container)) { + QWidgetList list( ws->windowList() ); + for (int i = 0; i < list.count(); ++i) { + QWidget *widget = list.at(i); + p = widget->palette(); p.setColor(widget->foregroundRole(), c); widget->setPalette(p); + } + } +} + +void AmbientProperties::on_buttonFont_clicked() +{ + bool ok; + QFont f = QFontDialog::getFont( &ok, fontSample->font(), this ); + if ( !ok ) + return; + fontSample->setFont( f ); + container->setFont( f ); + + if (QWorkspace *ws = qobject_cast<QWorkspace*>(container)) { + QWidgetList list( ws->windowList() ); + for (int i = 0; i < list.count(); ++i) { + QWidget *widget = list.at(i); + widget->setFont( f ); + } + } +} + +void AmbientProperties::on_buttonEnabled_toggled(bool on) +{ + enabledSample->setEnabled( on ); + container->setEnabled( on ); +} + +QT_END_NAMESPACE diff --git a/tools/activeqt/testcon/ambientproperties.h b/tools/activeqt/testcon/ambientproperties.h new file mode 100644 index 0000000..fa15158 --- /dev/null +++ b/tools/activeqt/testcon/ambientproperties.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef AMBIENTPROPERTIES_H +#define AMBIENTPROPERTIES_H + +#include <QtCore/qglobal.h> + +#include "ui_ambientproperties.h" + +QT_BEGIN_NAMESPACE + +class AmbientProperties : public QDialog, Ui::AmbientProperties +{ + Q_OBJECT +public: + AmbientProperties(QWidget *parent); + + void setControl(QWidget *widget); + +public slots: + void on_buttonBackground_clicked(); + void on_buttonForeground_clicked(); + void on_buttonFont_clicked(); + void on_buttonEnabled_toggled(bool on); + +private: + QWidget *container; +}; + +QT_END_NAMESPACE + +#endif // AMBIENTPROPERTIES_H diff --git a/tools/activeqt/testcon/ambientproperties.ui b/tools/activeqt/testcon/ambientproperties.ui new file mode 100644 index 0000000..5c68825 --- /dev/null +++ b/tools/activeqt/testcon/ambientproperties.ui @@ -0,0 +1,299 @@ +<ui version="4.0" > + <author></author> + <comment>********************************************************************* +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +*********************************************************************</comment> + <exportmacro></exportmacro> + <class>AmbientProperties</class> + <widget class="QDialog" name="AmbientProperties" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>185</width> + <height>173</height> + </rect> + </property> + <property name="windowTitle" > + <string>Change Ambient Properties</string> + </property> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>11</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QGroupBox" name="boxProperties" > + <property name="title" > + <string>&Properties</string> + </property> + <layout class="QGridLayout" > + <property name="margin" > + <number>11</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="0" column="0" > + <widget class="QLabel" name="TextLabel1" > + <property name="text" > + <string>Background:</string> + </property> + </widget> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="TextLabel2" > + <property name="text" > + <string>Foreground:</string> + </property> + </widget> + </item> + <item row="2" column="0" > + <widget class="QLabel" name="TextLabel3" > + <property name="text" > + <string>Font:</string> + </property> + </widget> + </item> + <item row="3" column="0" > + <widget class="QLabel" name="TextLabel4" > + <property name="text" > + <string>Enabled:</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QFrame" name="foreSample" > + <property name="frameShape" > + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow" > + <enum>QFrame::Raised</enum> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QFrame" name="backSample" > + <property name="frameShape" > + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow" > + <enum>QFrame::Raised</enum> + </property> + </widget> + </item> + <item row="0" column="2" > + <widget class="QToolButton" name="buttonBackground" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>...</string> + </property> + </widget> + </item> + <item row="1" column="2" > + <widget class="QToolButton" name="buttonForeground" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>...</string> + </property> + </widget> + </item> + <item row="2" column="2" > + <widget class="QToolButton" name="buttonFont" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>...</string> + </property> + </widget> + </item> + <item row="3" column="1" > + <widget class="QFrame" name="Frame6" > + <property name="frameShape" > + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow" > + <enum>QFrame::Raised</enum> + </property> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>0</number> + </property> + <item> + <widget class="QLabel" name="enabledSample" > + <property name="enabled" > + <bool>true</bool> + </property> + <property name="text" > + <string><sample></string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="3" column="2" > + <widget class="QToolButton" name="buttonEnabled" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>...</string> + </property> + <property name="checkable" > + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="QFrame" name="fontSample" > + <property name="frameShape" > + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow" > + <enum>QFrame::Raised</enum> + </property> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLabel" name="TextLabel6" > + <property name="text" > + <string><sample></string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" > + <size> + <width>1</width> + <height>1</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="buttonClose" > + <property name="text" > + <string>C&lose</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11" /> + <pixmapfunction></pixmapfunction> + <resources/> + <connections> + <connection> + <sender>buttonClose</sender> + <signal>clicked()</signal> + <receiver>AmbientProperties</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel" > + <x>141</x> + <y>150</y> + </hint> + <hint type="destinationlabel" > + <x>51</x> + <y>141</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/tools/activeqt/testcon/changeproperties.cpp b/tools/activeqt/testcon/changeproperties.cpp new file mode 100644 index 0000000..64387cc --- /dev/null +++ b/tools/activeqt/testcon/changeproperties.cpp @@ -0,0 +1,286 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "changeproperties.h" + +#include <QtGui> +#include <qt_windows.h> +#include <ActiveQt/ActiveQt> + +QT_BEGIN_NAMESPACE + +ChangeProperties::ChangeProperties(QWidget *parent) +: QDialog(parent), activex(0) +{ + setupUi(this); + + listProperties->setColumnCount(3); + listProperties->headerItem()->setText(0, QLatin1String("Name")); + listProperties->headerItem()->setText(1, QLatin1String("Type")); + listProperties->headerItem()->setText(2, QLatin1String("Value")); + + listEditRequests->setColumnCount(1); + listEditRequests->headerItem()->setText(0, QLatin1String("Name")); +} + +void ChangeProperties::setControl(QAxWidget *ax) +{ + activex = ax; + updateProperties(); +} + +void ChangeProperties::on_listProperties_currentItemChanged(QTreeWidgetItem *current) +{ + editValue->setEnabled(current != 0); + buttonSet->setEnabled(current != 0); + valueLabel->setEnabled(current != 0); + + if (!current) + return; + + editValue->setText(current->text(2)); + QString prop = current->text(0); + valueLabel->setText(prop + QLatin1String(" =")); + + const QMetaObject *mo = activex->metaObject(); + const QMetaProperty property = mo->property(mo->indexOfProperty(prop.toLatin1())); + + valueLabel->setEnabled(property.isWritable()); + editValue->setEnabled(property.isWritable()); + buttonSet->setEnabled(property.isWritable()); +} + +void ChangeProperties::on_buttonSet_clicked() +{ + QTreeWidgetItem *item = listProperties->currentItem(); + if (!item) + return; + + QString prop = item->text(0); + QVariant value = activex->property(prop.toLatin1()); + QVariant::Type type = value.type(); + if (!value.isValid()) { + const QMetaObject *mo = activex->metaObject(); + const QMetaProperty property = mo->property(mo->indexOfProperty(prop.toLatin1())); + type = QVariant::nameToType(property.typeName()); + } + switch (type) { + case QVariant::Color: + { + QColor col; + col.setNamedColor(editValue->text()); + if (col.isValid()) { + value = qVariantFromValue(col); + } else { + QMessageBox::warning(this, tr("Can't parse input"), + QString(tr("Failed to create a color from %1\n" + "The string has to be a valid color name (e.g. 'red')\n" + "or a RGB triple of format '#rrggbb'." + ).arg(editValue->text()))); + } + } + break; + case QVariant::Font: + { + QFont fnt; + if (fnt.fromString(editValue->text())) { + value = qVariantFromValue(fnt); + } else { + QMessageBox::warning(this, tr("Can't parse input"), + (tr("Failed to create a font from %1\n" + "The string has to have a format family,<point size> or\n" + "family,pointsize,stylehint,weight,italic,underline,strikeout,fixedpitch,rawmode." + ).arg(editValue->text()))); + } + } + break; + case QVariant::Pixmap: + { + QString fileName = editValue->text(); + if (fileName.isEmpty()) + fileName = QFileDialog::getOpenFileName(this); + QPixmap pm(fileName); + if (pm.isNull()) + return; + + value = qVariantFromValue(pm); + } + break; + case QVariant::Bool: + { + QString txt = editValue->text().toLower(); + value = QVariant(txt != QLatin1String("0") && txt != QLatin1String("false")); + } + break; + case QVariant::List: + { + QStringList txtList = editValue->text().split(QRegExp(QLatin1String("[,;]"))); + QList<QVariant> varList; + for (int i = 0; i < txtList.count(); ++i) { + QVariant svar(txtList.at(i)); + QString str = svar.toString(); + str = str.trimmed(); + bool ok; + int n = str.toInt(&ok); + if (ok) { + varList << n; + continue; + } + double d = str.toDouble(&ok); + if (ok) { + varList << d; + continue; + } + varList << str; + } + value = varList; + } + break; + + default: + value = editValue->text(); + break; + } + + Q_ASSERT(activex->setProperty(prop.toLatin1(), value)); + updateProperties(); + listProperties->setCurrentItem(listProperties->findItems(prop, Qt::MatchExactly).at(0)); +} + +void ChangeProperties::on_listEditRequests_itemChanged(QTreeWidgetItem *item) +{ + if (!item) + return; + + QString property = item->text(0); + activex->setPropertyWritable(property.toLatin1(), item->checkState(0) == Qt::Checked); +} + + +void ChangeProperties::updateProperties() +{ + bool hasControl = activex && !activex->isNull(); + tabWidget->setEnabled(hasControl); + + listProperties->clear(); + listEditRequests->clear(); + if (hasControl) { + const QMetaObject *mo = activex->metaObject(); + const int numprops = mo->propertyCount(); + for (int i = mo->propertyOffset(); i < numprops; ++i) { + const QMetaProperty property = mo->property(i); + QTreeWidgetItem *item = new QTreeWidgetItem(listProperties); + item->setText(0, QString::fromLatin1(property.name())); + item->setText(1, QString::fromLatin1(property.typeName())); + if (!property.isDesignable()) { + item->setTextColor(0, Qt::gray); + item->setTextColor(1, Qt::gray); + item->setTextColor(2, Qt::gray); + } + QVariant var = activex->property(property.name()); + + switch (var.type()) { + case QVariant::Color: + { + QColor col = qvariant_cast<QColor>(var); + item->setText(2, col.name()); + } + break; + case QVariant::Font: + { + QFont fnt = qvariant_cast<QFont>(var); + item->setText(2, fnt.toString()); + } + break; + case QVariant::Bool: + { + item->setText(2, var.toBool() ? QLatin1String("true") : QLatin1String("false")); + } + break; + case QVariant::Pixmap: + { + QPixmap pm = qvariant_cast<QPixmap>(var); + item->setIcon(2, pm); + } + break; + case QVariant::List: + { + QList<QVariant> varList = var.toList(); + QStringList strList; + for (int i = 0; i < varList.count(); ++i) { + QVariant var = varList.at(i); + strList << var.toString(); + } + item->setText(2, strList.join(QLatin1String(", "))); + } + break; + case QVariant::Int: + if (property.isEnumType()) { + const QMetaEnum enumerator = mo->enumerator(mo->indexOfEnumerator(property.typeName())); + item->setText(2, QString::fromLatin1(enumerator.valueToKey(var.toInt()))); + break; + } + //FALLTHROUGH + default: + item->setText(2, var.toString()); + break; + } + + bool requesting = false; +#if 0 + { + void *argv[] = { &requesting }; + activex->qt_metacall(QMetaObject::Call(0x10000000) /*RequestingEdit*/, i, argv); + } +#endif + if (requesting) { + QTreeWidgetItem *check = new QTreeWidgetItem(listEditRequests); + check->setText(0, QString::fromLatin1(property.name())); + check->setCheckState(0, activex->propertyWritable(property.name()) ? Qt::Checked : Qt::Unchecked); + } + } + listProperties->setCurrentItem(listProperties->topLevelItem(0)); + } else { + editValue->clear(); + } +} + +QT_END_NAMESPACE diff --git a/tools/activeqt/testcon/changeproperties.h b/tools/activeqt/testcon/changeproperties.h new file mode 100644 index 0000000..5bb053a --- /dev/null +++ b/tools/activeqt/testcon/changeproperties.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CHANGEPROPERTIES_H +#define CHANGEPROPERTIES_H + +#include <QtCore/qglobal.h> +#include "ui_changeproperties.h" + +QT_BEGIN_NAMESPACE + +class QAxWidget; + +class ChangeProperties : public QDialog, Ui::ChangeProperties +{ + Q_OBJECT +public: + ChangeProperties(QWidget *parent); + + void setControl(QAxWidget *control); + +public slots: + void updateProperties(); + +protected slots: + void on_listProperties_currentItemChanged(QTreeWidgetItem *current); + void on_listEditRequests_itemChanged(QTreeWidgetItem *item); + void on_buttonSet_clicked(); + +private: + QAxWidget *activex; +}; + +QT_END_NAMESPACE + +#endif // CHANGEPROPERTIES_H diff --git a/tools/activeqt/testcon/changeproperties.ui b/tools/activeqt/testcon/changeproperties.ui new file mode 100644 index 0000000..2714b99 --- /dev/null +++ b/tools/activeqt/testcon/changeproperties.ui @@ -0,0 +1,211 @@ +<ui version="4.0" > + <author></author> + <comment>********************************************************************* +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +*********************************************************************</comment> + <exportmacro></exportmacro> + <class>ChangeProperties</class> + <widget class="QDialog" name="ChangeProperties" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>728</width> + <height>584</height> + </rect> + </property> + <property name="windowTitle" > + <string>Change Control Properties</string> + </property> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>11</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QTabWidget" name="tabWidget" > + <widget class="QWidget" name="propertiesTab" > + <attribute name="title" > + <string>&Properties</string> + </attribute> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>11</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QTreeWidget" name="listProperties" > + <property name="rootIsDecorated" > + <bool>false</bool> + </property> + <column> + <property name="text" > + <string>Property</string> + </property> + </column> + <column> + <property name="text" > + <string>Type</string> + </property> + </column> + <column> + <property name="text" > + <string>Value</string> + </property> + </column> + </widget> + </item> + <item> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLabel" name="valueLabel" > + <property name="text" > + <string>Property &Value:</string> + </property> + <property name="buddy" > + <cstring>editValue</cstring> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="editValue" /> + </item> + <item> + <widget class="QToolButton" name="buttonSet" > + <property name="text" > + <string>&Set</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QWidget" name="requestTab" > + <attribute name="title" > + <string>Property Edit &Requests</string> + </attribute> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>11</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QTreeWidget" name="listEditRequests" > + <column> + <property name="text" > + <string>Property</string> + </property> + </column> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" > + <size> + <width>1</width> + <height>1</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="buttonClose" > + <property name="text" > + <string>C&lose</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11" /> + <pixmapfunction></pixmapfunction> + <resources/> + <connections> + <connection> + <sender>buttonClose</sender> + <signal>clicked()</signal> + <receiver>ChangeProperties</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel" > + <x>669</x> + <y>558</y> + </hint> + <hint type="destinationlabel" > + <x>566</x> + <y>551</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/tools/activeqt/testcon/controlinfo.cpp b/tools/activeqt/testcon/controlinfo.cpp new file mode 100644 index 0000000..8c76448 --- /dev/null +++ b/tools/activeqt/testcon/controlinfo.cpp @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "controlinfo.h" + +#include <QtGui> + +QT_BEGIN_NAMESPACE + +ControlInfo::ControlInfo(QWidget *parent) + : QDialog(parent) +{ + setupUi(this); + + listInfo->setColumnCount(2); + listInfo->headerItem()->setText(0, tr("Item")); + listInfo->headerItem()->setText(1, tr("Details")); +} + +void ControlInfo::setControl(QWidget *activex) +{ + listInfo->clear(); + + const QMetaObject *mo = activex->metaObject(); + QTreeWidgetItem *group = new QTreeWidgetItem(listInfo); + group->setText(0, tr("Class Info")); + group->setText(1, QString::number(mo->classInfoCount())); + + QTreeWidgetItem *item = 0; + int i; + int count; + for (i = mo->classInfoOffset(); i < mo->classInfoCount(); ++i) { + const QMetaClassInfo info = mo->classInfo(i); + item = new QTreeWidgetItem(group); + item->setText(0, QString::fromLatin1(info.name())); + item->setText(1, QString::fromLatin1(info.value())); + } + group = new QTreeWidgetItem(listInfo); + group->setText(0, tr("Signals")); + + count = 0; + for (i = mo->methodOffset(); i < mo->methodCount(); ++i) { + const QMetaMethod method = mo->method(i); + if (method.methodType() == QMetaMethod::Signal) { + ++count; + item = new QTreeWidgetItem(group); + item->setText(0, QString::fromLatin1(method.signature())); + } + } + group->setText(1, QString::number(count)); + + group = new QTreeWidgetItem(listInfo); + group->setText(0, tr("Slots")); + + count = 0; + for (i = mo->methodOffset(); i < mo->methodCount(); ++i) { + const QMetaMethod method = mo->method(i); + if (method.methodType() == QMetaMethod::Slot) { + ++count; + item = new QTreeWidgetItem(group); + item->setText(0, QString::fromLatin1(method.signature())); + } + } + group->setText(1, QString::number(count)); + + group = new QTreeWidgetItem(listInfo); + group->setText(0, tr("Properties")); + + count = 0; + for (i = mo->propertyOffset(); i < mo->propertyCount(); ++i) { + ++count; + const QMetaProperty property = mo->property(i); + item = new QTreeWidgetItem(group); + item->setText(0, QString::fromLatin1(property.name())); + item->setText(1, QString::fromLatin1(property.typeName())); + if (!property.isDesignable()) { + item->setTextColor(0, Qt::gray); + item->setTextColor(1, Qt::gray); + } + } + group->setText(1, QString::number(count)); +} + +QT_END_NAMESPACE diff --git a/tools/activeqt/testcon/controlinfo.h b/tools/activeqt/testcon/controlinfo.h new file mode 100644 index 0000000..11235bb --- /dev/null +++ b/tools/activeqt/testcon/controlinfo.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CONTROLINFO_H +#define CONTROLINFO_H + +#include <QtCore/qglobal.h> +#include "ui_controlinfo.h" + +QT_BEGIN_NAMESPACE + +class ControlInfo : public QDialog, Ui::ControlInfo +{ + Q_OBJECT +public: + ControlInfo(QWidget *parent); + + void setControl(QWidget *activex); +}; + +QT_END_NAMESPACE + +#endif // CONTROLINFO_H diff --git a/tools/activeqt/testcon/controlinfo.ui b/tools/activeqt/testcon/controlinfo.ui new file mode 100644 index 0000000..3aeaf58 --- /dev/null +++ b/tools/activeqt/testcon/controlinfo.ui @@ -0,0 +1,134 @@ +<ui version="4.0" > + <author></author> + <comment>********************************************************************* +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +*********************************************************************</comment> + <exportmacro></exportmacro> + <class>ControlInfo</class> + <widget class="QDialog" name="ControlInfo" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>600</width> + <height>480</height> + </rect> + </property> + <property name="windowTitle" > + <string>Control Details</string> + </property> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>11</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QTreeWidget" name="listInfo" > + <column> + <property name="text" > + <string>Item</string> + </property> + </column> + <column> + <property name="text" > + <string>Value</string> + </property> + </column> + </widget> + </item> + <item> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" > + <size> + <width>1</width> + <height>1</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="buttonClose" > + <property name="text" > + <string>C&lose</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11" /> + <pixmapfunction></pixmapfunction> + <resources/> + <connections> + <connection> + <sender>buttonClose</sender> + <signal>clicked()</signal> + <receiver>ControlInfo</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel" > + <x>536</x> + <y>457</y> + </hint> + <hint type="destinationlabel" > + <x>428</x> + <y>449</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/tools/activeqt/testcon/docuwindow.cpp b/tools/activeqt/testcon/docuwindow.cpp new file mode 100644 index 0000000..b0b2d81 --- /dev/null +++ b/tools/activeqt/testcon/docuwindow.cpp @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "docuwindow.h" +#include <QTextBrowser> +#include <QTextDocument> +#include <QToolBar> +#include <QToolButton> +#include <QFileDialog> +#include <QFile> +#include <QStatusBar> +#include <QPrinter> +#include <QPainter> +#include <QPrintDialog> +#include <QTextStream> + +QT_BEGIN_NAMESPACE + +static const char *filesave[] = { +" 14 14 4 1", +". c #040404", +"# c #808304", +"a c #bfc2bf", +"b c None", +"..............", +".#.aaaaaaaa.a.", +".#.aaaaaaaa...", +".#.aaaaaaaa.#.", +".#.aaaaaaaa.#.", +".#.aaaaaaaa.#.", +".#.aaaaaaaa.#.", +".##........##.", +".############.", +".##.........#.", +".##......aa.#.", +".##......aa.#.", +".##......aa.#.", +"b............." +}; + +static const char *fileprint[] = { +" 16 14 6 1", +". c #000000", +"# c #848284", +"a c #c6c3c6", +"b c #ffff00", +"c c #ffffff", +"d c None", +"ddddd.........dd", +"dddd.cccccccc.dd", +"dddd.c.....c.ddd", +"ddd.cccccccc.ddd", +"ddd.c.....c....d", +"dd.cccccccc.a.a.", +"d..........a.a..", +".aaaaaaaaaa.a.a.", +".............aa.", +".aaaaaa###aa.a.d", +".aaaaaabbbaa...d", +".............a.d", +"d.aaaaaaaaa.a.dd", +"dd...........ddd" +}; + + +DocuWindow::DocuWindow(const QString& docu, QWidget *parent, QWidget *source) + : QMainWindow(parent) +{ + setAttribute(Qt::WA_DeleteOnClose); + setWindowTitle(tr("%1 - Documentation").arg(source->windowTitle())); + + browser = new QTextBrowser(this); + browser->setHtml(docu); + + setCentralWidget(browser); + + QToolBar *fileTools = new QToolBar(tr("File Operations"), this); + fileTools->addAction(QPixmap(filesave), tr("Save File"), this, SLOT(save())); + fileTools->addAction(QPixmap(fileprint), tr("Print"), this, SLOT(print())); + + addToolBar(fileTools); + statusBar(); +} + +void DocuWindow::save() +{ + QString filename = QFileDialog::getSaveFileName(this); + + if (filename.isEmpty()) + return; + + QString text = browser->document()->toHtml(); + QFile f(filename); + if (!f.open(QIODevice::WriteOnly)) { + statusBar()->showMessage(tr("Could not write to %1").arg(filename), 2000); + return; + } + + QTextStream t(&f); + t << text; + f.close(); + + statusBar()->showMessage(tr("File %1 saved").arg(filename), 2000); +} + +void DocuWindow::print() +{ + QPrinter printer; + if (printer.printerName().isEmpty()) { + statusBar()->showMessage(tr("No printer installed"), 2000); + return; + } + + QPrintDialog printDialog(&printer, this); + if (!printDialog.exec()) { + statusBar()->showMessage(tr("Printing aborted"), 2000); + return; + } + + browser->document()->print(&printer); +} + +QT_END_NAMESPACE diff --git a/tools/activeqt/testcon/docuwindow.h b/tools/activeqt/testcon/docuwindow.h new file mode 100644 index 0000000..99d0286 --- /dev/null +++ b/tools/activeqt/testcon/docuwindow.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DOCUWINDOW_H +#define DOCUWINDOW_H + +#include <QMainWindow> + +QT_BEGIN_NAMESPACE + +class QTextBrowser; + +class DocuWindow : public QMainWindow +{ + Q_OBJECT +public: + DocuWindow( const QString& docu, QWidget *parent, QWidget *source ); + +public slots: + void save(); + void print(); + +private: + QTextBrowser *browser; +}; + +QT_END_NAMESPACE + +#endif // DOCUWINDOW_H diff --git a/tools/activeqt/testcon/invokemethod.cpp b/tools/activeqt/testcon/invokemethod.cpp new file mode 100644 index 0000000..7319adc --- /dev/null +++ b/tools/activeqt/testcon/invokemethod.cpp @@ -0,0 +1,170 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "invokemethod.h" + +#include <qt_windows.h> +#include <ActiveQt/ActiveQt> + +QT_BEGIN_NAMESPACE + +InvokeMethod::InvokeMethod(QWidget *parent) +: QDialog(parent), activex(0) +{ + setupUi(this); + + listParameters->setColumnCount(3); + listParameters->headerItem()->setText(0, tr("Parameter")); + listParameters->headerItem()->setText(1, tr("Type")); + listParameters->headerItem()->setText(2, tr("Value")); +} + +void InvokeMethod::setControl(QAxBase *ax) +{ + activex = ax; + bool hasControl = activex && !activex->isNull(); + labelMethods->setEnabled(hasControl); + comboMethods->setEnabled(hasControl); + buttonInvoke->setEnabled(hasControl); + boxParameters->setEnabled(hasControl); + + comboMethods->clear(); + listParameters->clear(); + + if (!hasControl) { + editValue->clear(); + return; + } + + const QMetaObject *mo = activex->metaObject(); + if (mo->methodCount()) { + for (int i = mo->methodOffset(); i < mo->methodCount(); ++i) { + const QMetaMethod method = mo->method(i); + if (method.methodType() == QMetaMethod::Slot) + comboMethods->addItem(QString::fromLatin1(method.signature())); + } + comboMethods->model()->sort(0); + + on_comboMethods_activated(comboMethods->currentText()); + } +} + +void InvokeMethod::on_buttonInvoke_clicked() +{ + if (!activex) + return; + + on_buttonSet_clicked(); + QString method = comboMethods->currentText(); + QList<QVariant> vars; + + int itemCount = listParameters->topLevelItemCount(); + for (int i = 0; i < itemCount; ++i) { + QTreeWidgetItem *parameter = listParameters->topLevelItem(i); + vars << parameter->text(2); + } + QVariant result = activex->dynamicCall(method.toLatin1(), vars); + + int v = 0; + for (int i = 0; i < itemCount; ++i) { + QTreeWidgetItem *parameter = listParameters->topLevelItem(i); + parameter->setText(2, vars[v++].toString()); + } + + QString resString = result.toString(); + QString resType = QString::fromLatin1(result.typeName()); + editReturn->setText(resType + QLatin1String(" ") + resString); +} + +void InvokeMethod::on_comboMethods_activated(const QString &method) +{ + if (!activex) + return; + listParameters->clear(); + + const QMetaObject *mo = activex->metaObject(); + const QMetaMethod slot = mo->method(mo->indexOfSlot(method.toLatin1())); + QString signature = QString::fromLatin1(slot.signature()); + signature = signature.mid(signature.indexOf(QLatin1Char('(')) + 1); + signature.truncate(signature.length()-1); + + QList<QByteArray> pnames = slot.parameterNames(); + QList<QByteArray> ptypes = slot.parameterTypes(); + + for (int p = 0; p < ptypes.count(); ++p) { + QString ptype(QString::fromLatin1(ptypes.at(p))); + if (ptype.isEmpty()) + continue; + QString pname(QString::fromLatin1(pnames.at(p).constData())); + if (pname.isEmpty()) + pname = QString::fromLatin1("<unnamed %1>").arg(p); + QTreeWidgetItem *item = new QTreeWidgetItem(listParameters); + item->setText(0, pname); + item->setText(1, ptype); + } + + if (listParameters->topLevelItemCount()) + listParameters->setCurrentItem(listParameters->topLevelItem(0)); + editReturn->setText(QString::fromLatin1(slot.typeName())); +} + +void InvokeMethod::on_listParameters_currentItemChanged(QTreeWidgetItem *item) +{ + if (!activex) + return; + editValue->setEnabled(item != 0); + buttonSet->setEnabled(item != 0); + if (!item) + return; + editValue->setText(item->text(2)); +} + +void InvokeMethod::on_buttonSet_clicked() +{ + if (!activex) + return; + QTreeWidgetItem *item = listParameters->currentItem(); + if (!item) + return; + item->setText(2, editValue->text()); +} + +QT_END_NAMESPACE diff --git a/tools/activeqt/testcon/invokemethod.h b/tools/activeqt/testcon/invokemethod.h new file mode 100644 index 0000000..c374bad --- /dev/null +++ b/tools/activeqt/testcon/invokemethod.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef INVOKEMETHOD_H +#define INVOKEMETHOD_H + +#include <QtCore/qglobal.h> +#include "ui_invokemethod.h" + +QT_BEGIN_NAMESPACE + +class QAxBase; + +class InvokeMethod : public QDialog, Ui::InvokeMethod +{ + Q_OBJECT +public: + InvokeMethod(QWidget *parent); + + void setControl(QAxBase *ax); + +protected slots: + void on_buttonInvoke_clicked(); + void on_buttonSet_clicked(); + + void on_comboMethods_activated(const QString &method); + void on_listParameters_currentItemChanged(QTreeWidgetItem *item); + +private: + QAxBase *activex; +}; + +QT_END_NAMESPACE + +#endif // INVOKEMETHOD_H diff --git a/tools/activeqt/testcon/invokemethod.ui b/tools/activeqt/testcon/invokemethod.ui new file mode 100644 index 0000000..c92ab0c --- /dev/null +++ b/tools/activeqt/testcon/invokemethod.ui @@ -0,0 +1,270 @@ +<ui version="4.0" > + <author></author> + <comment>********************************************************************* +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +*********************************************************************</comment> + <exportmacro></exportmacro> + <class>InvokeMethod</class> + <widget class="QDialog" name="InvokeMethod" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>503</width> + <height>416</height> + </rect> + </property> + <property name="windowTitle" > + <string>Invoke Methods</string> + </property> + <layout class="QGridLayout" > + <property name="margin" > + <number>11</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="1" column="0" colspan="2" > + <widget class="QGroupBox" name="boxParameters" > + <property name="title" > + <string>&Parameter List</string> + </property> + <layout class="QGridLayout" > + <property name="margin" > + <number>11</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="0" column="0" colspan="3" > + <widget class="QTreeWidget" name="listParameters" > + <property name="rootIsDecorated" > + <bool>false</bool> + </property> + <column> + <property name="text" > + <string>Parameter</string> + </property> + </column> + <column> + <property name="text" > + <string>Type</string> + </property> + </column> + <column> + <property name="text" > + <string>Value</string> + </property> + </column> + </widget> + </item> + <item row="1" column="2" > + <widget class="QToolButton" name="buttonSet" > + <property name="text" > + <string>&Set</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QLineEdit" name="editValue" /> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="TextLabel3" > + <property name="text" > + <string>Parameter &Value:</string> + </property> + <property name="buddy" > + <cstring>editValue</cstring> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="0" column="0" colspan="2" > + <layout class="QGridLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="1" column="1" > + <widget class="QLineEdit" name="editReturn" > + <property name="readOnly" > + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QComboBox" name="comboMethods" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="editable" > + <bool>true</bool> + </property> + <property name="insertPolicy" > + <enum>QComboBox::NoInsert</enum> + </property> + <property name="autoCompletion" > + <bool>true</bool> + </property> + <property name="duplicatesEnabled" > + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="0" > + <widget class="QLabel" name="labelMethods" > + <property name="text" > + <string>&Method Name:</string> + </property> + <property name="buddy" > + <cstring>comboMethods</cstring> + </property> + </widget> + </item> + <item row="0" column="2" > + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Preferred</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="TextLabel1" > + <property name="text" > + <string>Returned Value:</string> + </property> + </widget> + </item> + <item row="0" column="3" > + <widget class="QPushButton" name="buttonInvoke" > + <property name="text" > + <string>&Invoke</string> + </property> + <property name="default" > + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="2" colspan="2" > + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" > + <size> + <width>111</width> + <height>21</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item row="2" column="0" > + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" > + <size> + <width>361</width> + <height>21</height> + </size> + </property> + </spacer> + </item> + <item row="2" column="1" > + <widget class="QPushButton" name="buttonClose" > + <property name="text" > + <string>C&lose</string> + </property> + <property name="autoDefault" > + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11" /> + <pixmapfunction></pixmapfunction> + <resources/> + <connections> + <connection> + <sender>buttonClose</sender> + <signal>clicked()</signal> + <receiver>InvokeMethod</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel" > + <x>453</x> + <y>396</y> + </hint> + <hint type="destinationlabel" > + <x>327</x> + <y>384</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/tools/activeqt/testcon/main.cpp b/tools/activeqt/testcon/main.cpp new file mode 100644 index 0000000..1800fcb --- /dev/null +++ b/tools/activeqt/testcon/main.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mainwindow.h" + +#include <QApplication> +#include <QAxFactory> + +QAXFACTORY_DEFAULT(MainWindow, + QLatin1String("{5f5ce700-48a8-47b1-9b06-3b7f79e41d7c}"), + QLatin1String("{3fc86f5f-8b15-4428-8f6b-482bae91f1ae}"), + QLatin1String("{02a268cd-24b4-4fd9-88ff-b01b683ef39d}"), + QLatin1String("{4a43e44d-9d1d-47e5-a1e5-58fe6f7be0a4}"), + QLatin1String("{16ee5998-77d2-412f-ad91-8596e29f123f}")) + +QT_USE_NAMESPACE + +int main( int argc, char **argv ) +{ + QApplication app( argc, argv ); + + MainWindow mw; + mw.show(); + + return app.exec();; +} diff --git a/tools/activeqt/testcon/mainwindow.cpp b/tools/activeqt/testcon/mainwindow.cpp new file mode 100644 index 0000000..15f9d4c --- /dev/null +++ b/tools/activeqt/testcon/mainwindow.cpp @@ -0,0 +1,461 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mainwindow.h" +#include "changeproperties.h" +#include "invokemethod.h" +#include "ambientproperties.h" +#include "controlinfo.h" +#include "docuwindow.h" + +#include <QtGui> +#include <qt_windows.h> +#include <ActiveQt/ActiveQt> + +QT_BEGIN_NAMESPACE + +QAxObject *ax_mainWindow = 0; + +static QTextEdit *debuglog = 0; + +static void redirectDebugOutput(QtMsgType type, const char*msg) +{ + Q_UNUSED(type); + debuglog->append(QLatin1String(msg)); +} + +QT_END_NAMESPACE + +QT_USE_NAMESPACE + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) +{ + setupUi(this); + setObjectName(QLatin1String("MainWindow")); + + QAxScriptManager::registerEngine(QLatin1String("PerlScript"), QLatin1String(".pl")); + QAxScriptManager::registerEngine(QLatin1String("Python"), QLatin1String(".py")); + + dlgInvoke = 0; + dlgProperties = 0; + dlgAmbient = 0; + scripts = 0; + debuglog = logDebug; + oldDebugHandler = qInstallMsgHandler(redirectDebugOutput); + QHBoxLayout *layout = new QHBoxLayout(Workbase); + workspace = new QWorkspace(Workbase); + layout->addWidget(workspace); + layout->setMargin(0); + + connect(workspace, SIGNAL(windowActivated(QWidget*)), this, SLOT(updateGUI())); + connect(actionFileExit, SIGNAL(triggered()), qApp, SLOT(quit())); +} + +MainWindow::~MainWindow() +{ + qInstallMsgHandler(oldDebugHandler); + debuglog = 0; +} + + +void MainWindow::on_actionFileNew_triggered() +{ + QAxSelect select(this); + if (select.exec()) { + QAxWidget *container = new QAxWidget(workspace); + container->setAttribute(Qt::WA_DeleteOnClose); + container->setControl(select.clsid()); + container->setObjectName(container->windowTitle()); + workspace->addWindow(container); + container->show(); + } + updateGUI(); +} + +void MainWindow::on_actionFileLoad_triggered() +{ + QString fname = QFileDialog::getOpenFileName(this, tr("Load"), QString(), QLatin1String("*.qax")); + if (fname.isEmpty()) + return; + + QFile file(fname); + if (!file.open(QIODevice::ReadOnly)) { + QMessageBox::information(this, tr("Error Loading File"), tr("The file could not be opened for reading.\n%1").arg(fname)); + return; + } + + QAxWidget *container = new QAxWidget(workspace); + workspace->addWindow(container); + + QDataStream d(&file); + d >> *container; + + container->setObjectName(container->windowTitle()); + container->show(); + + updateGUI(); +} + +void MainWindow::on_actionFileSave_triggered() +{ + QAxWidget *container = qobject_cast<QAxWidget*>(workspace->activeWindow()); + if (!container) + return; + + QString fname = QFileDialog::getSaveFileName(this, tr("Save"), QString(), QLatin1String("*.qax")); + if (fname.isEmpty()) + return; + + QFile file(fname); + if (!file.open(QIODevice::WriteOnly)) { + QMessageBox::information(this, tr("Error Saving File"), tr("The file could not be opened for writing.\n%1").arg(fname)); + return; + } + QDataStream d(&file); + d << *container; +} + + +void MainWindow::on_actionContainerSet_triggered() +{ + QAxWidget *container = qobject_cast<QAxWidget*>(workspace->activeWindow()); + if (!container) + return; + + QAxSelect select(this); + if (select.exec()) + container->setControl(select.clsid()); + updateGUI(); +} + +void MainWindow::on_actionContainerClear_triggered() +{ + QAxWidget *container = qobject_cast<QAxWidget*>(workspace->activeWindow()); + if (container) + container->clear(); + updateGUI(); +} + +void MainWindow::on_actionContainerProperties_triggered() +{ + if (!dlgAmbient) { + dlgAmbient = new AmbientProperties(this); + dlgAmbient->setControl(workspace); + } + dlgAmbient->show(); +} + + +void MainWindow::on_actionControlInfo_triggered() +{ + QAxWidget *container = qobject_cast<QAxWidget*>(workspace->activeWindow()); + if (!container) + return; + + ControlInfo info(this); + info.setControl(container); + info.exec(); +} + +void MainWindow::on_actionControlProperties_triggered() +{ + QAxWidget *container = qobject_cast<QAxWidget*>(workspace->activeWindow()); + if (!container) + return; + + if (!dlgProperties) { + dlgProperties = new ChangeProperties(this); + connect(container, SIGNAL(propertyChanged(const QString&)), dlgProperties, SLOT(updateProperties())); + } + dlgProperties->setControl(container); + dlgProperties->show(); +} + +void MainWindow::on_actionControlMethods_triggered() +{ + QAxWidget *container = qobject_cast<QAxWidget*>(workspace->activeWindow()); + if (!container) + return; + + if (!dlgInvoke) + dlgInvoke = new InvokeMethod(this); + dlgInvoke->setControl(container); + dlgInvoke->show(); +} + +void MainWindow::on_VerbMenu_aboutToShow() +{ + VerbMenu->clear(); + + QAxWidget *container = qobject_cast<QAxWidget*>(workspace->activeWindow()); + if (!container) + return; + + QStringList verbs = container->verbs(); + for (int i = 0; i < verbs.count(); ++i) { + VerbMenu->addAction(verbs.at(i)); + } + + if (!verbs.count()) { // no verbs? + VerbMenu->addAction(tr("-- Object does not support any verbs --"))->setEnabled(false); + } +} + +void MainWindow::on_VerbMenu_triggered(QAction *action) +{ + QAxWidget *container = qobject_cast<QAxWidget*>(workspace->activeWindow()); + if (!container) + return; + + container->doVerb(action->text()); +} + +void MainWindow::on_actionControlDocumentation_triggered() +{ + QAxWidget *container = qobject_cast<QAxWidget*>(workspace->activeWindow()); + if (!container) + return; + + QString docu = container->generateDocumentation(); + if (docu.isEmpty()) + return; + + DocuWindow *docwindow = new DocuWindow(docu, workspace, container); + workspace->addWindow(docwindow); + docwindow->show(); +} + + +void MainWindow::on_actionControlPixmap_triggered() +{ + QAxWidget *container = qobject_cast<QAxWidget*>(workspace->activeWindow()); + if (!container) + return; + + QPixmap pm = QPixmap::grabWidget(container); + + QLabel *label = new QLabel(workspace); + label->setAttribute(Qt::WA_DeleteOnClose); + label->setPixmap(pm); + label->setWindowTitle(tr("%1 - Pixmap").arg(container->windowTitle())); + + workspace->addWindow(label); + label->show(); +} + +void MainWindow::on_actionScriptingRun_triggered() +{ +#ifndef QT_NO_QAXSCRIPT + if (!scripts) + return; + + // If we have only one script loaded we can use the cool dialog + QStringList scriptList = scripts->scriptNames(); + if (scriptList.count() == 1) { + InvokeMethod scriptInvoke(this); + scriptInvoke.setWindowTitle(tr("Execute Script Function")); + scriptInvoke.setControl(scripts->script(scriptList[0])->scriptEngine()); + scriptInvoke.exec(); + return; + } + + bool ok = false; + QStringList macroList = scripts->functions(QAxScript::FunctionNames); + QString macro = QInputDialog::getItem(this, tr("Select Macro"), tr("Macro:"), macroList, 0, true, &ok); + + if (!ok) + return; + + QVariant result = scripts->call(macro); + if (result.isValid()) + logMacros->append(tr("Return value of %1: %2").arg(macro).arg(result.toString())); +#endif +} + +void MainWindow::on_actionScriptingLoad_triggered() +{ +#ifndef QT_NO_QAXSCRIPT + QString file = QFileDialog::getOpenFileName(this, tr("Open Script"), QString(), QAxScriptManager::scriptFileFilter()); + + if (file.isEmpty()) + return; + + if (!scripts) { + scripts = new QAxScriptManager(this); + scripts->addObject(this); + } + + QWidgetList widgets = workspace->windowList(); + QWidgetList::Iterator it(widgets.begin()); + while (it != widgets.end()) { + QAxBase *ax = (QAxBase*)(*it)->qt_metacast("QAxBase"); + ++it; + if (!ax) + continue; + scripts->addObject(ax); + } + + QAxScript *script = scripts->load(file, file); + if (script) { + connect(script, SIGNAL(error(int, const QString&, int, const QString&)), + this, SLOT(logMacro(int, const QString&, int, const QString&))); + actionScriptingRun->setEnabled(true); + } +#else + QMessageBox::information(this, tr("Function not available"), + tr("QAxScript functionality is not available with this compiler.")); +#endif +} + +void MainWindow::updateGUI() +{ + QAxWidget *container = qobject_cast<QAxWidget*>(workspace->activeWindow()); + + bool hasControl = container && !container->isNull(); + actionFileNew->setEnabled(true); + actionFileLoad->setEnabled(true); + actionFileSave->setEnabled(hasControl); + actionContainerSet->setEnabled(container != 0); + actionContainerClear->setEnabled(hasControl); + actionControlProperties->setEnabled(hasControl); + actionControlMethods->setEnabled(hasControl); + actionControlInfo->setEnabled(hasControl); + actionControlDocumentation->setEnabled(hasControl); + actionControlPixmap->setEnabled(hasControl); + VerbMenu->setEnabled(hasControl); + if (dlgInvoke) + dlgInvoke->setControl(hasControl ? container : 0); + if (dlgProperties) + dlgProperties->setControl(hasControl ? container : 0); + + QWidgetList list = workspace->windowList(); + QWidgetList::Iterator it = list.begin(); + while (it != list.end()) { + QWidget *container = *it; + + QAxWidget *ax = qobject_cast<QAxWidget*>(container); + if (ax) { + container->disconnect(SIGNAL(signal(const QString&, int, void*))); + if (actionLogSignals->isChecked()) + connect(container, SIGNAL(signal(const QString&, int, void*)), this, SLOT(logSignal(const QString&, int, void*))); + + container->disconnect(SIGNAL(exception(int,const QString&,const QString&,const QString&))); + connect(container, SIGNAL(exception(int,const QString&,const QString&,const QString&)), + this, SLOT(logException(int,const QString&,const QString&,const QString&))); + + container->disconnect(SIGNAL(propertyChanged(const QString&))); + if (actionLogProperties->isChecked()) + connect(container, SIGNAL(propertyChanged(const QString&)), this, SLOT(logPropertyChanged(const QString&))); + container->blockSignals(actionFreezeEvents->isChecked()); + } + + ++it; + } +} + + +void MainWindow::logPropertyChanged(const QString &prop) +{ + QAxWidget *container = qobject_cast<QAxWidget*>(workspace->activeWindow()); + if (!container) + return; + + QVariant var = container->property(prop.toLatin1()); + logProperties->append(tr("%1: Property Change: %2 - { %3 }").arg(container->windowTitle(), prop, var.toString())); +} + +void MainWindow::logSignal(const QString &signal, int argc, void *argv) +{ + QAxWidget *container = qobject_cast<QAxWidget*>(workspace->activeWindow()); + if (!container) + return; + + QString paramlist; + VARIANT *params = (VARIANT*)argv; + for (int a = argc-1; a >= 0; --a) { + if (a == argc-1) + paramlist = QLatin1String(" - {"); + QVariant qvar = VARIANTToQVariant(params[a], 0); + paramlist += QLatin1String(" ") + qvar.toString(); + if (a > 0) + paramlist += QLatin1String(","); + else + paramlist += QLatin1String(" "); + } + if (argc) + paramlist += QLatin1String("}"); + logSignals->append(container->windowTitle() + QLatin1String(": ") + signal + paramlist); +} + +void MainWindow::logException(int code, const QString&source, const QString&desc, const QString&help) +{ + Q_UNUSED(desc); + QAxWidget *container = qobject_cast<QAxWidget*>(sender()); + if (!container) + return; + + QString str = tr("%1: Exception code %2 thrown by %3"). + arg(container->windowTitle()).arg(code).arg(source); + logDebug->append(str); + logDebug->append(tr("\tDescription: %1").arg(desc)); + + if (!help.isEmpty()) + logDebug->append(tr("\tHelp available at %1").arg(help)); + else + logDebug->append(tr("\tNo help available.")); +} + +void MainWindow::logMacro(int code, const QString &description, int sourcePosition, const QString &sourceText) +{ + /* FIXME This needs to be rewritten to not use string concatentation, such + * that it can be translated in a sane way. */ + QString message = tr("Script: "); + if (code) + message += QString::number(code) + QLatin1String(" "); + message += QLatin1String("'") + description + QLatin1String("'"); + if (sourcePosition) + message += tr(" at position ") + QString::number(sourcePosition); + if (!sourceText.isEmpty()) + message += QLatin1String(" '") + sourceText + QLatin1String("'"); + + logMacros->append(message); +} diff --git a/tools/activeqt/testcon/mainwindow.h b/tools/activeqt/testcon/mainwindow.h new file mode 100644 index 0000000..abab47e --- /dev/null +++ b/tools/activeqt/testcon/mainwindow.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include "ui_mainwindow.h" + +QT_BEGIN_NAMESPACE + +class InvokeMethod; +class ChangeProperties; +class AmbientProperties; +class QAxScriptManager; + +class QWorkspace; + +QT_END_NAMESPACE + +QT_USE_NAMESPACE + + +class MainWindow : public QMainWindow, public Ui::MainWindow +{ + Q_OBJECT +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + +protected slots: + void on_actionFileNew_triggered(); + void on_actionFileLoad_triggered(); + void on_actionFileSave_triggered(); + + void on_actionContainerSet_triggered(); + void on_actionContainerClear_triggered(); + void on_actionContainerProperties_triggered(); + + void on_actionControlInfo_triggered(); + void on_actionControlDocumentation_triggered(); + void on_actionControlPixmap_triggered(); + void on_actionControlProperties_triggered(); + void on_actionControlMethods_triggered(); + void on_VerbMenu_aboutToShow(); + + void on_actionScriptingLoad_triggered(); + void on_actionScriptingRun_triggered(); + +private: + InvokeMethod *dlgInvoke; + ChangeProperties *dlgProperties; + AmbientProperties *dlgAmbient; + QAxScriptManager *scripts; + QWorkspace *workspace; + + QtMsgHandler oldDebugHandler; + +private slots: + void updateGUI(); + void logPropertyChanged(const QString &prop); + void logSignal(const QString &signal, int argc, void *argv); + void logException(int code, const QString&source, const QString&desc, const QString&help); + void logMacro(int code, const QString &description, int sourcePosition, const QString &sourceText); + + void on_VerbMenu_triggered(QAction *action); +}; + +#endif // MAINWINDOW_H diff --git a/tools/activeqt/testcon/mainwindow.ui b/tools/activeqt/testcon/mainwindow.ui new file mode 100644 index 0000000..96fe7bd --- /dev/null +++ b/tools/activeqt/testcon/mainwindow.ui @@ -0,0 +1,682 @@ +<ui version="4.0" stdsetdef="1" > + <author></author> + <comment>********************************************************************* +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +*********************************************************************</comment> + <exportmacro></exportmacro> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow" > + <property name="objectName" > + <string notr="true" >MainWindow</string> + </property> + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>929</width> + <height>620</height> + </rect> + </property> + <property name="windowTitle" > + <string>ActiveX Control Test Container</string> + </property> + <widget class="QWidget" name="centralWidget"> + <layout class="QHBoxLayout" > + <property name="objectName" > + <string notr="true" >unnamed</string> + </property> + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QFrame" name="Frame" > + <property name="objectName" > + <string notr="true" >Frame</string> + </property> + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape" > + <enum>StyledPanel</enum> + </property> + <property name="frameShadow" > + <enum>Sunken</enum> + </property> + <layout class="QVBoxLayout" > + <property name="objectName" > + <string notr="true" >unnamed</string> + </property> + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>0</number> + </property> + <item> + <widget class="QSplitter" name="Splitter2" > + <property name="objectName" > + <string notr="true" >Splitter2</string> + </property> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <widget class="QFrame" name="Workbase" > + <property name="objectName" > + <string notr="true" >Workbase</string> + </property> + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape" > + <enum>NoFrame</enum> + </property> + <property name="frameShadow" > + <enum>Raised</enum> + </property> + </widget> + <widget class="QTabWidget" name="TabWidget2" > + <property name="objectName" > + <string notr="true" >TabWidget2</string> + </property> + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>4</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <widget class="QWidget" name="logSignalsTab" > + <property name="objectName" > + <string notr="true" >logSignalsTab</string> + </property> + <attribute name="title" > + <string>Signal log</string> + </attribute> + <layout class="QHBoxLayout" > + <property name="objectName" > + <string notr="true" >unnamed</string> + </property> + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QTextEdit" name="logSignals" > + <property name="objectName" > + <string notr="true" >logSignals</string> + </property> + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="readOnly" > + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="logPropertiesTab" > + <property name="objectName" > + <string notr="true" >logPropertiesTab</string> + </property> + <attribute name="title" > + <string>Property log</string> + </attribute> + <layout class="QHBoxLayout" > + <property name="objectName" > + <string notr="true" >unnamed</string> + </property> + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QTextEdit" name="logProperties" > + <property name="objectName" > + <string notr="true" >logProperties</string> + </property> + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="readOnly" > + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="TabPage" > + <property name="objectName" > + <string notr="true" >TabPage</string> + </property> + <attribute name="title" > + <string>Macro Log</string> + </attribute> + <layout class="QHBoxLayout" > + <property name="objectName" > + <string notr="true" >unnamed</string> + </property> + <property name="margin" > + <number>0</number> + </property> + <item> + <widget class="QTextEdit" name="logMacros" > + <property name="objectName" > + <string notr="true" >logMacros</string> + </property> + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="readOnly" > + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="logDebugTab" > + <property name="objectName" > + <string notr="true" >logDebugTab</string> + </property> + <attribute name="title" > + <string>Debug log</string> + </attribute> + <layout class="QHBoxLayout" > + <property name="objectName" > + <string notr="true" >unnamed</string> + </property> + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QTextEdit" name="logDebug" > + <property name="objectName" > + <string notr="true" >logDebug</string> + </property> + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="readOnly" > + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <widget class="QToolBar" name="Toolbar_2" > + <property name="objectName" > + <string notr="true" >Toolbar_2</string> + </property> + <property name="windowTitle" > + <string>Toolbar_2</string> + </property> + <addaction name="actionFileNew" /> + <addaction name="actionControlMethods" /> + <addaction name="actionControlProperties" /> + </widget> + <widget class="QMenuBar" name="menubar" > + <property name="objectName" > + <string notr="true" >menubar</string> + </property> + <widget class="QMenu" name="FileMenu" > + <property name="objectName" > + <string notr="true" >FileMenu</string> + </property> + <property name="title" > + <string>&File</string> + </property> + <addaction name="actionFileNew" /> + <addaction name="actionFileLoad" /> + <addaction name="actionFileSave" /> + <addaction name="separator" /> + <addaction name="actionFileExit" /> + </widget> + <widget class="QMenu" name="ContainerMenu" > + <property name="objectName" > + <string notr="true" >ContainerMenu</string> + </property> + <property name="title" > + <string>Con&tainer</string> + </property> + <addaction name="actionContainerSet" /> + <addaction name="actionContainerClear" /> + <addaction name="separator" /> + <addaction name="actionContainerProperties" /> + </widget> + <widget class="QMenu" name="ControlMenu" > + <property name="objectName" > + <string notr="true" >ControlMenu</string> + </property> + <property name="title" > + <string>&Control</string> + </property> + <widget class="QMenu" name="VerbMenu" > + <property name="objectName" > + <string notr="true" >VerbMenu</string> + </property> + <property name="title" > + <string>&Verbs...</string> + </property> + <property name="enabled" > + <bool>false</bool> + </property> + </widget> + <addaction name="actionControlMethods" /> + <addaction name="actionControlProperties" /> + <addaction name="VerbMenu" /> + <addaction name="separator" /> + <addaction name="actionControlInfo" /> + <addaction name="actionControlDocumentation" /> + <addaction name="actionControlPixmap" /> + </widget> + <widget class="QMenu" name="ScriptMenu" > + <property name="objectName" > + <string notr="true" >ScriptMenu</string> + </property> + <property name="title" > + <string>&Scripting</string> + </property> + <addaction name="actionScriptingLoad" /> + <addaction name="actionScriptingRun" /> + </widget> + <widget class="QMenu" name="OptionsMenu" > + <property name="objectName" > + <string notr="true" >OptionsMenu</string> + </property> + <property name="title" > + <string>&Options</string> + </property> + <widget class="QMenu" name="LoggingMenu" > + <property name="objectName" > + <string notr="true" >LoggingMenu</string> + </property> + <property name="title" > + <string>Log...</string> + </property> + <addaction name="actionLogSignals" /> + <addaction name="actionLogProperties" /> + </widget> + <addaction name="actionFreezeEvents" /> + <addaction name="actionGroupLogging" /> + <addaction name="LoggingMenu" /> + </widget> + <addaction name="FileMenu" /> + <addaction name="ContainerMenu" /> + <addaction name="ControlMenu" /> + <addaction name="ScriptMenu" /> + <addaction name="OptionsMenu" /> + </widget> + <action name="actionFileExit" > + <property name="objectName" > + <string>actionFileExit</string> + </property> + <property name="iconText" > + <string>Exit</string> + </property> + <property name="text" > + <string>E&xit</string> + </property> + </action> + <action name="actionContainerSet" > + <property name="objectName" > + <string>actionContainerSet</string> + </property> + <property name="enabled" > + <bool>false</bool> + </property> + <property name="iconText" > + <string>Set Control</string> + </property> + <property name="text" > + <string>&Set Control</string> + </property> + <property name="shortcut" > + <string>Ctrl+S</string> + </property> + </action> + <action name="actionControlMethods" > + <property name="objectName" > + <string>actionControlMethods</string> + </property> + <property name="enabled" > + <bool>false</bool> + </property> + <property name="icon" > + <iconset>image0</iconset> + </property> + <property name="iconText" > + <string>Invoke Methods</string> + </property> + <property name="text" > + <string>Invoke &Methods</string> + </property> + <property name="shortcut" > + <string>Ctrl+M</string> + </property> + </action> + <action name="actionControlProperties" > + <property name="objectName" > + <string>actionControlProperties</string> + </property> + <property name="enabled" > + <bool>false</bool> + </property> + <property name="icon" > + <iconset>image1</iconset> + </property> + <property name="iconText" > + <string>Change Properties</string> + </property> + <property name="text" > + <string>Change &Properties</string> + </property> + <property name="shortcut" > + <string>Ctrl+P</string> + </property> + </action> + <action name="actionContainerClear" > + <property name="objectName" > + <string>actionContainerClear</string> + </property> + <property name="enabled" > + <bool>false</bool> + </property> + <property name="iconText" > + <string>Clear Control</string> + </property> + <property name="text" > + <string>C&lear Control</string> + </property> + <property name="shortcut" > + <string/> + </property> + </action> + <action name="actionContainerProperties" > + <property name="objectName" > + <string>actionContainerProperties</string> + </property> + <property name="iconText" > + <string>Ambient Properties</string> + </property> + <property name="text" > + <string>Ambient &Properties</string> + </property> + <property name="shortcut" > + <string>Ctrl+A</string> + </property> + </action> + <action name="actionControlInfo" > + <property name="objectName" > + <string>actionControlInfo</string> + </property> + <property name="enabled" > + <bool>false</bool> + </property> + <property name="iconText" > + <string>Details</string> + </property> + <property name="text" > + <string>&Details</string> + </property> + <property name="shortcut" > + <string>Ctrl+I</string> + </property> + </action> + <action name="actionFileSave" > + <property name="objectName" > + <string>actionFileSave</string> + </property> + <property name="enabled" > + <bool>false</bool> + </property> + <property name="iconText" > + <string>Save Control</string> + </property> + <property name="text" > + <string>&Save Control</string> + </property> + </action> + <action name="actionFileLoad" > + <property name="objectName" > + <string>actionFileLoad</string> + </property> + <property name="iconText" > + <string>Load Control</string> + </property> + <property name="text" > + <string>&Load Control</string> + </property> + </action> + <action name="actionFreezeEvents" > + <property name="objectName" > + <string>actionFreezeEvents</string> + </property> + <property name="checkable" > + <bool>true</bool> + </property> + <property name="iconText" > + <string>Freeze Events</string> + </property> + <property name="text" > + <string>&Freeze Events</string> + </property> + </action> + <action name="actionFileNew" > + <property name="objectName" > + <string>actionFileNew</string> + </property> + <property name="icon" > + <iconset>image2</iconset> + </property> + <property name="iconText" > + <string>Insert Control</string> + </property> + <property name="text" > + <string>&Insert Control</string> + </property> + <property name="shortcut" > + <string>Ctrl+N</string> + </property> + </action> + <action name="actionControlDocumentation" > + <property name="objectName" > + <string>actionControlDocumentation</string> + </property> + <property name="enabled" > + <bool>false</bool> + </property> + <property name="iconText" > + <string>Show Documentation</string> + </property> + <property name="text" > + <string>Show D&ocumentation</string> + </property> + <property name="shortcut" > + <string>Ctrl+D</string> + </property> + </action> + <action name="actionControlPixmap" > + <property name="objectName" > + <string>actionControlPixmap</string> + </property> + <property name="enabled" > + <bool>false</bool> + </property> + <property name="iconText" > + <string>Render to Pixmap</string> + </property> + <property name="text" > + <string>Render to Pi&xmap</string> + </property> + <property name="shortcut" > + <string>Ctrl+X</string> + </property> + </action> + <action name="actionScriptingLoad" > + <property name="objectName" > + <string>actionScriptingLoad</string> + </property> + <property name="iconText" > + <string>Load Script</string> + </property> + <property name="text" > + <string>&Load Script</string> + </property> + </action> + <action name="actionScriptingRun" > + <property name="objectName" > + <string>actionScriptingRun</string> + </property> + <property name="enabled" > + <bool>false</bool> + </property> + <property name="iconText" > + <string>Run Macro</string> + </property> + <property name="text" > + <string>&Run Macro...</string> + </property> + </action> + <actiongroup name="actionGroupLogging" > + <action name="actionLogSignals" > + <property name="objectName" > + <string>actionLogSignals</string> + </property> + <property name="checkable" > + <bool>true</bool> + </property> + <property name="checked" > + <bool>true</bool> + </property> + <property name="iconText" > + <string>Signals</string> + </property> + <property name="text" > + <string>&Signals</string> + </property> + </action> + <action name="actionLogProperties" > + <property name="objectName" > + <string>actionLogProperties</string> + </property> + <property name="checkable" > + <bool>true</bool> + </property> + <property name="checked" > + <bool>true</bool> + </property> + <property name="iconText" > + <string>Properties</string> + </property> + <property name="text" > + <string>&Properties</string> + </property> + </action> + <property name="objectName" > + <string>actionGroupLogging</string> + </property> + <property name="exclusive" > + <bool>false</bool> + </property> + </actiongroup> + </widget> + <layoutdefault spacing="6" margin="11" /> + <pixmapfunction></pixmapfunction> + <images> + <image name="image0" > + <data format="XPM.GZ" length="3502" >789cdd95c96e1c371086ef7a8a81eb6604e56e92bd21c84192175996648d6559b2831cd85cb4ef23d95290770fe72f36e3003ee41220485373f8543f975a587cf17c76b8bb3d7bfe62e56e6117276ee68eededecb9bfbfb878fcf5b75f7e5f79a6d42cfdd54d3553cf7e5a79365fccdc6ce7ea322cc19e26a0aa51aaeb964c31b3ee46d8a9b05b32b7994d27f3178523ecbb99bbbe87fdaef000be06b7ca0e067c9b791c5af04d6637c87e8f99fde0c11edc6935c2193e01f7dab91a1cc083314ef4c7e0b15141ece29f6b4c68c047998720fb7d01473d8e60b24bae2b1d1cf416faba36cacbfe1b99b597f5e04f6d4c081af335b86f5c80ff74091eda3a20beb40376ad8b381fbd0487ce44890f83a3a92cf6a3fd25abca682beb7d15ee42141ec0e90016fed366e6c6223ff498b91d2b30ceab5462d93f1416ff9accdd28e741bc9531e388fcd3c7c292fff7e0c67827febf05b74de5e47c3db84b2cfedf64ae9dc4df1496fc55e0bed15eceb75758ce578387a6f1a81fda288cfa639db9f5d89f55610b7d07b64defc51f3f71407c18f95163aa0fd9ff43662bf543a867e51b9ff3391696fa719943107f241ea189926f96fc84b68a92df3785113fdece5c47a9af77e09818fef2566615e5bea1de75ddb6c284fbaa753b487df03770d34ef532070f5d9bf90aecbb18253ec8bf317d88f08f719f4d3ba8cca83f330c5d147f5f67ee33239fc60e6366ec6fc6c10933fa87f1b6ca7c9fb98e12af0770b05a98d05f4cb42633eaade9c6364afe5e816d2a47e94fb86f9dafea0af1b617e05018fe76b1f0f9927b5df80c1c2a55213f16fd607085d14f6c5d18f7c7b6f5584b3da03e6d5718f567fb494f5bc2c5be061e26b6a847ebea3460477c6c2c8cfa18abb2de2ab8ae7d2df15907ab625f084f768bfa1c4d61d4ef38d4a196787e02db693e8bbef84f88d718ea584b7f417cdd5fe7c1fbe14a7c08f7d9a9e581c088af3385515fae298cfcbbb6d295f49327e1c9ce9fc1dd6467dc1fd7173dfab9f3aa5672dfd06f5c2c76f4575fa9f481b19eaf0be37df46a623e04ebc2e8b7de28ad64ff03705318f7c1b73a7d60c4d35b6514fa29a19ffa7162467ff7ae30f2e17d39afecef8b1dfdd7c7c2a8ff6074aba53f20fea1cc679bd954a2473f0d41754ade7ff497d8a85e49ffc47b145b6db5f403f817fb62477ca29dd623f49fe8d4a0a4dff4994725fde25a58a701463f8d5e375afadb7ae6c9be96396aa92fbcbf3198f4c1de656e8ccc9f67b606e7e5d5ccde483fb9126efa46ce7f29dc9a56d6bbc8dcb4b21eea2dc6f41ccbfb762edca6171b7c26dc990ef3e78b7f3efe2f7a26b6e9473cb24be43970e4a3328ef9e47b3d9ff2199ff3055ff2155ff34dfacf2ddff182eff901e32b7fe3c7499f567d4ada555ee3757ec9aff835bf493336f82d6ff23bde4a639b77f83def66bde5397fe03dfec8fb697ce2033ee4cf69c617aeb866958666c30db765fd8efbac9619437285e60bb2349223bfd453a038e9e9888e8b7a9f4ee894cee89c2ed28c4bbaa26bd67443b73fd6d3091fd01d2de89e1e92fe2b7d4b3e2cf58f3fd243fd44abb446eb49fd925ed16b7a431bf496368b7ee4757af737f5166d27f50ebda75d9ad307daa38fb43fe9e9131dd0217d4e3e7ea12aa96b5249adc950432d75d427f560d9d2942f6be9c98ed6d1c27a1b6c5ac71ed9e3149b3d7b92e2b249fb497dfa7d3dd8337b6e2fd2b8b45789aeed8dbdb5777661693952b3a0ff763dff6bfa3f7e5ef9138fb14e09</data> + </image> + <image name="image1" > + <data format="XPM.GZ" length="2493" >789ca59459531b391446dff9152ef4464dddb8dbbd566a1eb2af10c84a929a87de8c0dd86c76623235ff3dfa8eb0878c3309a9e850a64fe9d3b5a4967c6babb7bfbbdddbbab57131ab66e3a6d78caaf3de563b9f4c2e3ffef5e7df1b9b71dcf37f45de8b37ffd8d8dc9bf59adecec9b493d8dc8bebd3f0311e09fc151e0b7c07af05fe146f84dca9b88b1241ff17794cc347782ac89fc90791a07f8a27026ff042e043bc128c3fc51b417f8db7028ff14ee0bbc1b3a62af177f850e07bc1b3b60aeb3b90277d81bfc0a33caac37c3b9c86bfc67381b77821f00778990f9bd09fe0b5c01fe26d91b561bf2a79da17acf7088f044e7db693bc9be003c1f847c1cb7e17fad9ff341178a84f23ff12cf04fe18cfcbbc633f1dfb91760277f2ac2fc8e7782ce83fc60782fe90e70be83fc77dbbdaef27782ee83fc40b814f975e87fdb8c0ebacaec3f933bc13f878e94d582fe7271b0afc64e94da8cff9c9fdfb6dc2f9e1fbf381c039df795aa55d78df255e0abcc03b81bf97737cc378e65b1455d186f1295e099cfd28ea2a6d42bd7dbc15cc8ffb500e04fd039c463ff7b96c05fd91bc4a05fe1c2f57f7611baf57e7bf8fb702ff20e7ba87f7fb0c4f933809e7330b2ef0b7f850e097f22616cc8ffbc2750df35fe089c0efe079522661fdbc9fa62cea229c8f37782df0bbf2364eda24cc77125ce0fc3eb449e11bfe19678138e7b3ed047e4fdec5abfbc3ef5397e4691ed6c7fdeb0a817fc22b81df970fe3b44ccbf0637b737e276fce2aabadf14fad7536bc7a3ab0918dd7f376684776ec99d8d44e3ca776e69fce3d1736b3f9b7799ffe649f6de1b9f47cb13b76d7eed97dfff4c01eda237b1c4684bc3df1b5437a39e2a93db3e7b6edd9b117b66b7b9ef92affd2cf63710d8d187b5e79c6365fb2cabffe4f5e23deb09a7f797b2dff6e2d2ff6ed3dff3f58df7f46d7f2f177f3034b2cb5cc726c3d5f58e9cc3957b93a8c708d1f915c8dfe79fd856b9577ddffe44b3774076ee419933ef4335fb8237774d3fadfb09677c77ee6233771ad9b527f0427eb7977fa6bf5dd19f54757d55b774efd095c7c273ffbc5f9cffddb8e7e8cbb767e18f1537ef73ede28ffcfed8daf804d6c7a</data> + </image> + <image name="image2" > + <data format="XPM.GZ" length="1232" >789ccdd24b4fe2501c86f13d9fa2811d99a8ad9442cc2c44f082327169625c1c4e5b4f552e721398cc771f9f570907837bff0f8bfef226400287d5e0eeb617540f4bd399991536b0ce4c826a3a1f0c56f70fbfff96ca5114bcbf6a6110967f95ca07810dfe8c8619cfeefdb972a483e7306c107c84518de0293c360473312598c15a83602a1a8256b404fb30d64103eb09c10a4c9a047bb019119c8931c12e3475821dd88f094ec53ac1b5a8834bd1127c13738237d08604afc498e0b5a88313982604dba221f82a5a82633127b882594470211e137c116382976242f0496c121c8929c10b3127f80cf3238267624870282604e76293604bd4978603516f0d0b51a7ffd8dedb2c15d3b7699ae58feecb522936e7dcee62b6cb93db59fadbe5f9c5f98bdd0c03371c8d9db7a4dee770fb96e275329ded5f8af9e2eddb65f9a396cc5f566b6f392d8ad6fcf3ceda1d6f396f5d5c2e3e6ed5beea7a8b1b5fdf2c3f6edde9f6bce5c0ed9cff6b7fff3fd8b3fc3b29fd07f8c43cbd</data> + </image> + </images> +</ui> diff --git a/tools/activeqt/testcon/scripts/javascript.js b/tools/activeqt/testcon/scripts/javascript.js new file mode 100644 index 0000000..e2bd54b --- /dev/null +++ b/tools/activeqt/testcon/scripts/javascript.js @@ -0,0 +1,25 @@ +function QAxWidget2::Click() +{ + QAxWidget2.lineWidth++; + MainWindow.logMacro(0, "Hello from JavaScript: QAxWidget2::Click", 0, ""); +} + +function fatLines() +{ + QAxWidget2.lineWidth = 25; +} + +function thinLines() +{ + QAxWidget2.lineWidth = 1; +} + +function setLineWidth(width) +{ + QAxWidget2.lineWidth = width; +} + +function getLineWidth() +{ + return(QAxWidget2.lineWidth) +} diff --git a/tools/activeqt/testcon/scripts/perlscript.pl b/tools/activeqt/testcon/scripts/perlscript.pl new file mode 100644 index 0000000..029bdc2 --- /dev/null +++ b/tools/activeqt/testcon/scripts/perlscript.pl @@ -0,0 +1,24 @@ +sub QAxWidget2_Click { + $QAxWidget2->{'lineWidth'} = $QAxWidget2->{'lineWidth'} + 1; + $MainWindow->logMacro(0, "Hello from Perl: QAxWidget2_Click", 0, ""); +} + +sub fatLines +{ + $QAxWidget2->{'lineWidth'} = 25; +} + +sub thinLines +{ + $QAxWidget2->{'lineWidth'} = 1; +} + +sub setLineWidth(width) +{ + $QAxWidget2->{'lineWidth'} = width; +} + +sub getLineWidth() +{ + return $QAxWidget2->{'lineWidth'}; +} diff --git a/tools/activeqt/testcon/scripts/pythonscript.py b/tools/activeqt/testcon/scripts/pythonscript.py new file mode 100644 index 0000000..79bca87 --- /dev/null +++ b/tools/activeqt/testcon/scripts/pythonscript.py @@ -0,0 +1,15 @@ +def QAxWidget2_Click(): + QAxWidget2.lineWidth = QAxWidget2.lineWidth + 1; + MainWindow.logMacro(0, "Hello from Python: QAxWidget2_Click", 0, ""); + +def fatLines(): + QAxWidget2.lineWidth = 25; + +def thinLines(): + QAxWidget2.lineWidth = 1; + +def setLineWidth(width): + QAxWidget2.lineWidth = width; + +def getLineWidth(): + return QAxWidget2.lineWidth; diff --git a/tools/activeqt/testcon/scripts/vbscript.vbs b/tools/activeqt/testcon/scripts/vbscript.vbs new file mode 100644 index 0000000..bd29f19 --- /dev/null +++ b/tools/activeqt/testcon/scripts/vbscript.vbs @@ -0,0 +1,20 @@ +Sub QAxWidget2_Click + QAxWidget2.lineWidth = QAxWidget2.lineWidth + 1 + MainWindow.logMacro 0, "Hello from VBScript: QAxWidget2_Click", 0, "" +End Sub + +Sub fatLines + QAxWidget2.lineWidth = 25 +End Sub + +Sub thinLines + QAxWidget2.lineWidth = 1 +End Sub + +Sub setLineWidth(width) + QAxWidget2.lineWidth = width +End Sub + +Public Function getLineWidth + getLineWidth = QAxWidget2.lineWidth +End Function diff --git a/tools/activeqt/testcon/testcon.idl b/tools/activeqt/testcon/testcon.idl new file mode 100644 index 0000000..7dd88a5 --- /dev/null +++ b/tools/activeqt/testcon/testcon.idl @@ -0,0 +1,44 @@ +/**************************************************************************** +** Interface definition generated for ActiveQt project +** +** 'C:\depot\qt\3.3\extensions\activeqt\tools\testcon\testcon.exe' +** +** Created: Fr 31. Okt 15:33:50 2003 +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ + +import "ocidl.idl"; +#include <olectl.h> + +[ + uuid(4A43E44D-9D1D-47E5-A1E5-58FE6F7BE0A4), + version(1.0), + helpstring("testcon 1.0 Type Library") +] +library testconLib +{ + importlib("stdole32.tlb"); + importlib("stdole2.tlb"); + + [ + uuid(3FC86F5F-8B15-4428-8F6B-482BAE91F1AE), + helpstring("MainWindow Interface") + ] + dispinterface IMainWindow + { + properties: + methods: + [id(7)] void logMacro( [in] int p_code, [in] BSTR p_description, [in] int p_sourcePosition, [in] BSTR p_sourceText); + }; + + [ + aggregatable, + helpstring("MainWindow Class"), + uuid(5F5CE700-48A8-47B1-9B06-3B7F79E41D7C) + ] + coclass MainWindow + { + [default] dispinterface IMainWindow; + }; +}; diff --git a/tools/activeqt/testcon/testcon.pro b/tools/activeqt/testcon/testcon.pro new file mode 100644 index 0000000..dc98218 --- /dev/null +++ b/tools/activeqt/testcon/testcon.pro @@ -0,0 +1,21 @@ +TEMPLATE = app + +CONFIG += qaxserver qaxserver_no_postlink qaxcontainer +# QT += qt3support + +# ui_qaxselect.h +INCLUDEPATH += $$QT_SOURCE_TREE/tools/activeqt/container/debug \ + $$QT_SOURCE_TREE/tools/activeqt/container/release \ + $$QT_BUILD_TREE/src/activeqt/container \ + +SOURCES = main.cpp docuwindow.cpp mainwindow.cpp invokemethod.cpp changeproperties.cpp ambientproperties.cpp controlinfo.cpp +HEADERS = docuwindow.h mainwindow.h invokemethod.h changeproperties.h ambientproperties.h controlinfo.h +FORMS = mainwindow.ui invokemethod.ui changeproperties.ui ambientproperties.ui controlinfo.ui +RC_FILE = testcon.rc + +win32-borland { + QMAKE_POST_LINK = -midl $$QT_SOURCE_TREE/tools/activeqt/testcon/testcon.idl +} else { + !win32-g++:QMAKE_POST_LINK = midl $$QT_SOURCE_TREE/tools/activeqt/testcon/testcon.idl && move testcon.tlb $(TARGETDIR) + +} diff --git a/tools/activeqt/testcon/testcon.rc b/tools/activeqt/testcon/testcon.rc new file mode 100644 index 0000000..6fe4036 --- /dev/null +++ b/tools/activeqt/testcon/testcon.rc @@ -0,0 +1,35 @@ +#ifndef Q_CC_BOR +#include <winver.h> +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 3, 2, 0, 0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0x0L + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "Nokia Corporation and/or its subsidiary(-ies)\0" + VALUE "FileDescription", "ActiveQt Test Container\0" + VALUE "FileVersion", "1,0,0,1\0" + VALUE "InternalName", "testcon\0" + VALUE "LegalCopyright", "Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "testcon.exe\0" + VALUE "ProductName", "ActiveQt Test Container\0" + VALUE "ProductVersion", "3, 2, 0, 0\0" + END + END + END +/* End of Version info */ + |