diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2009-03-23 10:18:55 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-03-23 10:18:55 +0100 |
commit | e5fcad302d86d316390c6b0f62759a067313e8a9 (patch) | |
tree | c2afbf6f1066b6ce261f14341cf6d310e5595bc1 /tools/designer/src/plugins | |
download | qt4-tools-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.gz |
Long live Qt 4.5!
Diffstat (limited to 'tools/designer/src/plugins')
83 files changed, 9172 insertions, 0 deletions
diff --git a/tools/designer/src/plugins/activeqt/activeqt.pro b/tools/designer/src/plugins/activeqt/activeqt.pro new file mode 100644 index 0000000000..f58df8a388 --- /dev/null +++ b/tools/designer/src/plugins/activeqt/activeqt.pro @@ -0,0 +1,32 @@ +TARGET = $$qtLibraryTarget(qaxwidget) +TEMPLATE = lib +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/designer + +CONFIG += qt warn_on qaxcontainer plugin designer debug_and_release +build_all:!build_pass { + CONFIG -= build_all + CONFIG += release +} + +INCLUDEPATH += $$QT_SOURCE_TREE/src/activeqt/shared/ \ + $$QT_BUILD_TREE/src/activeqt/container \ + ../../lib/uilib + +# Input +SOURCES += qaxwidgetextrainfo.cpp \ +qaxwidgetplugin.cpp \ +qdesigneraxwidget.cpp \ +qaxwidgetpropertysheet.cpp \ +qaxwidgettaskmenu.cpp \ + $$QT_SOURCE_TREE/src/activeqt/shared/qaxtypes.cpp + +HEADERS += qaxwidgetextrainfo.h \ +qaxwidgetplugin.h \ +qdesigneraxwidget.h \ +qaxwidgetpropertysheet.h \ +qaxwidgettaskmenu.h \ + $$QT_SOURCE_TREE/src/activeqt/shared/qaxtypes.h + +# install +target.path = $$[QT_INSTALL_PLUGINS]/designer +INSTALLS += target diff --git a/tools/designer/src/plugins/activeqt/qaxwidgetextrainfo.cpp b/tools/designer/src/plugins/activeqt/qaxwidgetextrainfo.cpp new file mode 100644 index 0000000000..369cd7fbb4 --- /dev/null +++ b/tools/designer/src/plugins/activeqt/qaxwidgetextrainfo.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "qaxwidgetextrainfo.h" +#include "qdesigneraxwidget.h" +#include "qaxwidgetpropertysheet.h" + +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/private/ui4_p.h> + +QT_BEGIN_NAMESPACE + +QAxWidgetExtraInfo::QAxWidgetExtraInfo(QDesignerAxWidget *widget, QDesignerFormEditorInterface *core, QObject *parent) + : QObject(parent), m_widget(widget), m_core(core) +{ +} + +QWidget *QAxWidgetExtraInfo::widget() const +{ + return m_widget; +} + +QDesignerFormEditorInterface *QAxWidgetExtraInfo::core() const +{ + return m_core; +} + +bool QAxWidgetExtraInfo::saveUiExtraInfo(DomUI *) +{ + return false; +} + +bool QAxWidgetExtraInfo::loadUiExtraInfo(DomUI *) +{ + return false; +} + +bool QAxWidgetExtraInfo::saveWidgetExtraInfo(DomWidget *ui_widget) +{ + /* Turn off standard setters and make sure "control" is in front, + * otherwise, previews will not work as the properties are not applied via + * the caching property sheet, them. */ + typedef QList<DomProperty *> DomPropertyList; + DomPropertyList props = ui_widget->elementProperty(); + const int size = props.size(); + const QString controlProperty = QLatin1String(QAxWidgetPropertySheet::controlPropertyName); + for (int i = 0; i < size; i++) { + props.at(i)->setAttributeStdset(false); + if (i > 0 && props.at(i)->attributeName() == controlProperty) { + qSwap(props[0], props[i]); + ui_widget->setElementProperty(props); + } + + } + return true; +} + +bool QAxWidgetExtraInfo::loadWidgetExtraInfo(DomWidget *) +{ + return false; +} + +QAxWidgetExtraInfoFactory::QAxWidgetExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent) + : QExtensionFactory(parent), m_core(core) +{ +} + +QObject *QAxWidgetExtraInfoFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const +{ + if (iid != Q_TYPEID(QDesignerExtraInfoExtension)) + return 0; + + if (QDesignerAxWidget *w = qobject_cast<QDesignerAxWidget*>(object)) + return new QAxWidgetExtraInfo(w, m_core, parent); + + return 0; +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/activeqt/qaxwidgetextrainfo.h b/tools/designer/src/plugins/activeqt/qaxwidgetextrainfo.h new file mode 100644 index 0000000000..343bb76376 --- /dev/null +++ b/tools/designer/src/plugins/activeqt/qaxwidgetextrainfo.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 ACTIVEQT_EXTRAINFO_H +#define ACTIVEQT_EXTRAINFO_H + +#include <QtDesigner/QDesignerExtraInfoExtension> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/QExtensionFactory> + +#include <QtCore/QPointer> + +QT_BEGIN_NAMESPACE + +class QDesignerAxWidget; + +class QAxWidgetExtraInfo: public QObject, public QDesignerExtraInfoExtension +{ + Q_OBJECT + Q_INTERFACES(QDesignerExtraInfoExtension) +public: + QAxWidgetExtraInfo(QDesignerAxWidget *widget, QDesignerFormEditorInterface *core, QObject *parent); + + virtual QWidget *widget() const; + virtual QDesignerFormEditorInterface *core() const; + + virtual bool saveUiExtraInfo(DomUI *ui); + virtual bool loadUiExtraInfo(DomUI *ui); + + virtual bool saveWidgetExtraInfo(DomWidget *ui_widget); + virtual bool loadWidgetExtraInfo(DomWidget *ui_widget); + +private: + QPointer<QDesignerAxWidget> m_widget; + QPointer<QDesignerFormEditorInterface> m_core; +}; + +class QAxWidgetExtraInfoFactory: public QExtensionFactory +{ + Q_OBJECT +public: + QAxWidgetExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + +protected: + virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; + +private: + QDesignerFormEditorInterface *m_core; +}; + +QT_END_NAMESPACE + +#endif // ACTIVEQT_EXTRAINFO_H diff --git a/tools/designer/src/plugins/activeqt/qaxwidgetplugin.cpp b/tools/designer/src/plugins/activeqt/qaxwidgetplugin.cpp new file mode 100644 index 0000000000..f80df141c3 --- /dev/null +++ b/tools/designer/src/plugins/activeqt/qaxwidgetplugin.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 Qt Designer 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 "qaxwidgetplugin.h" +#include "qaxwidgetextrainfo.h" +#include "qdesigneraxwidget.h" +#include "qaxwidgetpropertysheet.h" +#include "qaxwidgettaskmenu.h" + +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/QDesignerFormWindowInterface> + +#include <QtCore/qplugin.h> +#include <QtGui/QIcon> +#include <ActiveQt/QAxWidget> + +QT_BEGIN_NAMESPACE + +QAxWidgetPlugin::QAxWidgetPlugin(QObject *parent) : + QObject(parent), + m_core(0) +{ +} + +QString QAxWidgetPlugin::name() const +{ + return QLatin1String("QAxWidget"); +} + +QString QAxWidgetPlugin::group() const +{ + return QLatin1String("Containers"); +} + +QString QAxWidgetPlugin::toolTip() const +{ + return tr("ActiveX control"); +} + +QString QAxWidgetPlugin::whatsThis() const +{ + return tr("ActiveX control widget"); +} + +QString QAxWidgetPlugin::includeFile() const +{ + return QLatin1String("qaxwidget.h"); +} + +QIcon QAxWidgetPlugin::icon() const +{ + return QIcon(QDesignerAxWidget::widgetIcon()); +} + +bool QAxWidgetPlugin::isContainer() const +{ + return false; +} + +QWidget *QAxWidgetPlugin::createWidget(QWidget *parent) +{ + // Construction from Widget box or on a form? + const bool isFormEditor = parent != 0 && QDesignerFormWindowInterface::findFormWindow(parent) != 0; + QDesignerAxWidget *rc = new QDesignerAxPluginWidget(parent); + if (!isFormEditor) + rc->setDrawFlags(QDesignerAxWidget::DrawFrame|QDesignerAxWidget::DrawControl); + return rc; +} + +bool QAxWidgetPlugin::isInitialized() const +{ + return m_core != 0; +} + +void QAxWidgetPlugin::initialize(QDesignerFormEditorInterface *core) +{ + if (m_core != 0) + return; + + m_core = core; + + QExtensionManager *mgr = core->extensionManager(); + ActiveXPropertySheetFactory::registerExtension(mgr); + ActiveXTaskMenuFactory::registerExtension(mgr, Q_TYPEID(QDesignerTaskMenuExtension)); + QAxWidgetExtraInfoFactory *extraInfoFactory = new QAxWidgetExtraInfoFactory(core, mgr); + mgr->registerExtensions(extraInfoFactory, Q_TYPEID(QDesignerExtraInfoExtension)); +} + +QString QAxWidgetPlugin::domXml() const +{ + return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"QAxWidget\" name=\"axWidget\">\ + <property name=\"geometry\">\ + <rect>\ + <x>0</x>\ + <y>0</y>\ + <width>80</width>\ + <height>70</height>\ + </rect>\ + </property>\ + </widget>\ +</ui>"); +} + +Q_EXPORT_PLUGIN(QAxWidgetPlugin) + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/activeqt/qaxwidgetplugin.h b/tools/designer/src/plugins/activeqt/qaxwidgetplugin.h new file mode 100644 index 0000000000..662c490ef9 --- /dev/null +++ b/tools/designer/src/plugins/activeqt/qaxwidgetplugin.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 ACTIVEXPLUGIN_H +#define ACTIVEXPLUGIN_H + +#include <QtDesigner/QDesignerCustomWidgetInterface> +#include <QtCore/QObject> + +QT_BEGIN_NAMESPACE + +class QDesignerFormEditorInterface; + +class QAxWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + explicit inline QAxWidgetPlugin(QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString domXml() const; + +private: + QDesignerFormEditorInterface *m_core; +}; + +QT_END_NAMESPACE + +#endif diff --git a/tools/designer/src/plugins/activeqt/qaxwidgetpropertysheet.cpp b/tools/designer/src/plugins/activeqt/qaxwidgetpropertysheet.cpp new file mode 100644 index 0000000000..f94da88696 --- /dev/null +++ b/tools/designer/src/plugins/activeqt/qaxwidgetpropertysheet.cpp @@ -0,0 +1,189 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "qaxwidgetpropertysheet.h" +#include "qdesigneraxwidget.h" + +#include <QtDesigner/QDesignerMemberSheetExtension> +#include <QtDesigner/QDesignerFormWindowInterface> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/QDesignerPropertyEditorInterface> + +#include <QtDesigner/QExtensionManager> +#include <QtCore/QDebug> +#include <QtCore/QTimer> + +static const char *geometryPropertyC = "geometry"; + +QT_BEGIN_NAMESPACE + +const char *QAxWidgetPropertySheet::controlPropertyName = "control"; + +QAxWidgetPropertySheet::QAxWidgetPropertySheet(QDesignerAxWidget *object, QObject *parent) : + QDesignerPropertySheet(object, parent), + m_controlProperty(controlPropertyName), + m_propertyGroup(QLatin1String("QAxWidget")) +{ + if (!axWidget()->loaded()) { // For some obscure reason.... + const int controlIndex = QDesignerPropertySheet::indexOf(m_controlProperty); + setPropertyGroup(controlIndex, m_propertyGroup); + } +} + +bool QAxWidgetPropertySheet::isEnabled(int index) const +{ + if (propertyName(index) == m_controlProperty) + return false; + return QDesignerPropertySheet::isEnabled(index); +} + +bool QAxWidgetPropertySheet::dynamicPropertiesAllowed() const +{ + return false; +} + +QDesignerAxWidget *QAxWidgetPropertySheet::axWidget() const +{ + return static_cast<QDesignerAxWidget*>(object()); +} + +// Reload as the meta object changes. +bool QAxWidgetPropertySheet::reset(int index) +{ + const QString name = propertyName(index); + QMap<QString, QVariant>::iterator it = m_currentProperties.changedProperties.find(name); + if (it != m_currentProperties.changedProperties.end()) + m_currentProperties.changedProperties.erase(it); + if (name != m_controlProperty) + return QDesignerPropertySheet::reset(index); + axWidget()->resetControl(); + QTimer::singleShot(0, this, SLOT(updatePropertySheet())); + return true; +} + +void QAxWidgetPropertySheet::setProperty(int index, const QVariant &value) +{ + + // take care of all changed properties + const QString name = propertyName(index); + m_currentProperties.changedProperties[name] = value; + if (name != m_controlProperty) { + QDesignerPropertySheet::setProperty(index, value); + return; + } + // Loading forms: Reload + if (name == m_controlProperty) { + const QString clsid = value.toString(); + if (clsid.isEmpty() || !axWidget()->loadControl(clsid)) + reset(index); + else + QTimer::singleShot(100, this, SLOT(updatePropertySheet())); + } +} + +int QAxWidgetPropertySheet::indexOf(const QString &name) const +{ + const int index = QDesignerPropertySheet::indexOf(name); + if (index != -1) + return index; + // Loading before recreation of sheet in timer slot: Add a fake property to store the value + const QVariant dummValue(0); + QAxWidgetPropertySheet *that = const_cast<QAxWidgetPropertySheet *>(this); + const int newIndex = that->createFakeProperty(name, dummValue); + that->setPropertyGroup(newIndex, m_propertyGroup); + return newIndex; +} + +void QAxWidgetPropertySheet::updatePropertySheet() +{ + // refresh the property sheet (we are deleting m_currentProperties) + struct SavedProperties tmp = m_currentProperties; + QDesignerAxWidget *axw = axWidget(); + QDesignerFormWindowInterface *formWin = QDesignerFormWindowInterface::findFormWindow(axw); + Q_ASSERT(formWin != 0); + tmp.widget = axw; + tmp.clsid = axw->control(); + // Delete the sheets as they cache the meta object and other information + delete this; + delete qt_extension<QDesignerMemberSheetExtension *>(formWin->core()->extensionManager(), axw); + reloadPropertySheet(tmp, formWin); +} + +void QAxWidgetPropertySheet::reloadPropertySheet(const struct SavedProperties &properties, QDesignerFormWindowInterface *formWin) +{ + QDesignerFormEditorInterface *core = formWin->core(); + //Recreation of the property sheet + QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension *>(core->extensionManager(), properties.widget); + + bool foundGeometry = false; + const QString geometryProperty = QLatin1String(geometryPropertyC); + const SavedProperties::NamePropertyMap::const_iterator cend = properties.changedProperties.constEnd(); + for (SavedProperties::NamePropertyMap::const_iterator i = properties.changedProperties.constBegin(); i != cend; ++i) { + const QString name = i.key(); + const int index = sheet->indexOf(name); + if (index == -1) + continue; + // filter out geometry as this will resize the control + // to is default size even if it is attached to an layout + // but set the changed flag to work around preview bug... + if (name == geometryProperty) { + sheet->setChanged(index, true); + foundGeometry = true; + continue; + } + if (name == QLatin1String(controlPropertyName)) { + sheet->setChanged(index, !i.value().toString().isEmpty()); + continue; + } + sheet->setChanged(index, true); + sheet->setProperty(index, i.value()); + } + + if (!foundGeometry) // Make sure geometry is always changed in Designer + sheet->setChanged(sheet->indexOf(geometryProperty), true); + + if (core->propertyEditor()->object() == properties.widget) { + formWin->clearSelection(true); + formWin->selectWidget(properties.widget); + } +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/activeqt/qaxwidgetpropertysheet.h b/tools/designer/src/plugins/activeqt/qaxwidgetpropertysheet.h new file mode 100644 index 0000000000..64caf3cfa0 --- /dev/null +++ b/tools/designer/src/plugins/activeqt/qaxwidgetpropertysheet.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 QACTIVEXPROPERTYSHEET_H +#define QACTIVEXPROPERTYSHEET_H + +#include <QtDesigner/private/qdesigner_propertysheet_p.h> + +QT_BEGIN_NAMESPACE + +class QDesignerAxWidget; +class QDesignerFormWindowInterface; + +/* The propertysheet has a method to delete itself and repopulate + * if the "control" property changes. Pre 4.5, the control property + * might not be the first one, so, the properties are stored and + * re-applied. If the "control" is the first one, it should be + * sufficient to reapply the changed flags, however, care must be taken when + * resetting the control. + * Resetting a control: The current behaviour is that the modified Active X properties are added again + * as Fake-Properties, which is a nice side-effect as not cause a loss. */ + +class QAxWidgetPropertySheet: public QDesignerPropertySheet +{ + Q_OBJECT + Q_INTERFACES(QDesignerPropertySheetExtension) +public: + explicit QAxWidgetPropertySheet(QDesignerAxWidget *object, QObject *parent = 0); + + virtual bool isEnabled(int index) const; + virtual void setProperty(int index, const QVariant &value); + virtual bool reset(int index); + int indexOf(const QString &name) const; + bool dynamicPropertiesAllowed() const; + + static const char *controlPropertyName; + +public slots: + void updatePropertySheet(); + +private: + QDesignerAxWidget *axWidget() const; + + const QString m_controlProperty; + const QString m_propertyGroup; + int m_controlIndex; + struct SavedProperties { + typedef QMap<QString, QVariant> NamePropertyMap; + NamePropertyMap changedProperties; + QWidget *widget; + QString clsid; + } m_currentProperties; + + static void reloadPropertySheet(const struct SavedProperties &properties, QDesignerFormWindowInterface *formWin); +}; + +typedef QDesignerPropertySheetFactory<QDesignerAxWidget, QAxWidgetPropertySheet> ActiveXPropertySheetFactory; + +QT_END_NAMESPACE + +#endif diff --git a/tools/designer/src/plugins/activeqt/qaxwidgettaskmenu.cpp b/tools/designer/src/plugins/activeqt/qaxwidgettaskmenu.cpp new file mode 100644 index 0000000000..96b209fe6d --- /dev/null +++ b/tools/designer/src/plugins/activeqt/qaxwidgettaskmenu.cpp @@ -0,0 +1,186 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "qaxwidgettaskmenu.h" +#include "qdesigneraxwidget.h" +#include "qaxwidgetpropertysheet.h" + +#include <QtDesigner/QDesignerFormWindowInterface> +#include <QtDesigner/QDesignerFormWindowCursorInterface> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/QExtensionManager> + +#include <QtGui/QUndoCommand> +#include <QtGui/QMessageBox> +#include <QtGui/QUndoStack> +#include <QtCore/QUuid> +#include <ActiveQt/qaxselect.h> + +#include <olectl.h> +#include <qaxtypes.h> + +QT_BEGIN_NAMESPACE + +/* SetControlCommand: An undo commands that sets a control bypassing + Designer's property system which cannot handle the changing + of the 'control' property's index and other cached information + when modifying it. */ + +class SetControlCommand : public QUndoCommand +{ +public: + SetControlCommand(QDesignerAxWidget *ax, QDesignerFormWindowInterface *core, const QString &newClsid = QString()); + + virtual void redo() { apply(m_newClsid); } + virtual void undo() { apply(m_oldClsid); } + +private: + bool apply(const QString &clsid); + + QDesignerAxWidget *m_axWidget; + QDesignerFormWindowInterface *m_formWindow; + QString m_oldClsid; + QString m_newClsid; +}; + +SetControlCommand::SetControlCommand(QDesignerAxWidget *ax, QDesignerFormWindowInterface *fw, const QString &newClsid) : + m_axWidget(ax), + m_formWindow(fw), + m_oldClsid(ax->control()), + m_newClsid(newClsid) +{ + if (m_newClsid.isEmpty()) + setText(QDesignerAxWidget::tr("Reset control")); + else + setText(QDesignerAxWidget::tr("Set control")); +} + +bool SetControlCommand::apply(const QString &clsid) +{ + if (m_oldClsid == m_newClsid) + return true; + + QObject *ext = m_formWindow->core()->extensionManager()->extension(m_axWidget, Q_TYPEID(QDesignerPropertySheetExtension)); + QAxWidgetPropertySheet *sheet = qobject_cast<QAxWidgetPropertySheet*>(ext); + if (!sheet) + return false; + + const bool hasClsid = !clsid.isEmpty(); + const int index = sheet->indexOf(QLatin1String(QAxWidgetPropertySheet::controlPropertyName)); + if (hasClsid) + sheet->setProperty(index, clsid); + else + sheet->reset(index); + return true; +} + +// -------------------- QAxWidgetTaskMenu +QAxWidgetTaskMenu::QAxWidgetTaskMenu(QDesignerAxWidget *object, QObject *parent) : + QObject(parent), + m_axwidget(object), + m_setAction(new QAction(tr("Set Control"), this)), + m_resetAction(new QAction(tr("Reset Control"), this)) +{ + connect(m_setAction, SIGNAL(triggered()), this, SLOT(setActiveXControl())); + connect(m_resetAction, SIGNAL(triggered()), this, SLOT(resetActiveXControl())); + m_taskActions.push_back(m_setAction); + m_taskActions.push_back(m_resetAction); +} + +QAxWidgetTaskMenu::~QAxWidgetTaskMenu() +{ +} + +QList<QAction*> QAxWidgetTaskMenu::taskActions() const +{ + const bool loaded = m_axwidget->loaded(); + m_setAction->setEnabled(!loaded); + m_resetAction->setEnabled(loaded); + return m_taskActions; +} + +void QAxWidgetTaskMenu::resetActiveXControl() +{ + QDesignerFormWindowInterface *formWin = QDesignerFormWindowInterface::findFormWindow(m_axwidget); + Q_ASSERT(formWin != 0); + formWin->commandHistory()->push(new SetControlCommand(m_axwidget, formWin)); +} + +void QAxWidgetTaskMenu::setActiveXControl() +{ + QAxSelect *dialog = new QAxSelect(m_axwidget->topLevelWidget()); + if (dialog->exec()) { + QUuid clsid = dialog->clsid(); + QString key; + + IClassFactory2 *cf2 = 0; + CoGetClassObject(clsid, CLSCTX_SERVER, 0, IID_IClassFactory2, (void**)&cf2); + + if (cf2) { + BSTR bKey; + HRESULT hres = cf2->RequestLicKey(0, &bKey); + if (hres == CLASS_E_NOTLICENSED) { + QMessageBox::warning(m_axwidget->topLevelWidget(), tr("Licensed Control"), + tr("The control requires a design-time license")); + clsid = QUuid(); + } else { + key = QString::fromUtf16((ushort *)bKey); + } + + cf2->Release(); + } + + if (!clsid.isNull()) { + QDesignerFormWindowInterface *formWin = QDesignerFormWindowInterface::findFormWindow(m_axwidget); + + Q_ASSERT(formWin != 0); + QString value = clsid.toString(); + if (!key.isEmpty()) { + value += QLatin1Char(':'); + value += key; + } + formWin->commandHistory()->push(new SetControlCommand(m_axwidget, formWin, value)); + } + } + delete dialog; +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/activeqt/qaxwidgettaskmenu.h b/tools/designer/src/plugins/activeqt/qaxwidgettaskmenu.h new file mode 100644 index 0000000000..9520673cd7 --- /dev/null +++ b/tools/designer/src/plugins/activeqt/qaxwidgettaskmenu.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 QACTIVEXTASKMENU_H +#define QACTIVEXTASKMENU_H + +#include <QtDesigner/QDesignerTaskMenuExtension> +#include <QtDesigner/private/extensionfactory_p.h> + +QT_BEGIN_NAMESPACE + +class QDesignerAxWidget; + +class QAxWidgetTaskMenu: public QObject, public QDesignerTaskMenuExtension +{ + Q_OBJECT + Q_INTERFACES(QDesignerTaskMenuExtension) +public: + explicit QAxWidgetTaskMenu(QDesignerAxWidget *object, QObject *parent = 0); + virtual ~QAxWidgetTaskMenu(); + virtual QList<QAction*> taskActions() const; + +private slots: + void setActiveXControl(); + void resetActiveXControl(); + +private: + QDesignerAxWidget *m_axwidget; + QAction *m_setAction; + QAction *m_resetAction; + QList<QAction*> m_taskActions; +}; + +typedef qdesigner_internal::ExtensionFactory<QDesignerTaskMenuExtension, QDesignerAxWidget, QAxWidgetTaskMenu> ActiveXTaskMenuFactory; + +QT_END_NAMESPACE + +#endif // QACTIVEXTASKMENU diff --git a/tools/designer/src/plugins/activeqt/qdesigneraxwidget.cpp b/tools/designer/src/plugins/activeqt/qdesigneraxwidget.cpp new file mode 100644 index 0000000000..48245f1ecc --- /dev/null +++ b/tools/designer/src/plugins/activeqt/qdesigneraxwidget.cpp @@ -0,0 +1,272 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "qdesigneraxwidget.h" + +#include <QtCore/QMetaProperty> +#include <QtCore/QDebug> +#include <QtGui/QIcon> +#include <QtGui/QPainter> +#include <QtGui/QResizeEvent> + +#include <ActiveQt/QAxWidget> + +#include <olectl.h> +#include <qaxtypes.h> + +enum { debugAxWidget = 0 }; + +QT_BEGIN_NAMESPACE + +/* XPM */ +const char *widgetIconXPM[]={ +"22 22 6 1", +"a c #000000", +"# c #808080", +"+ c #aaa5a0", +"b c #dddddd", +"* c #d4d0c8", +". c none", +".........#aa#...#aa#..", +".........abba...abba..", +".........abba...abba..", +".........#aa#...#aa#..", +"..........aa.....aa...", +"..........aa.....aa...", +"..........aa.....aa...", +".......aaaaaaaaaaaaaaa", +".......a*************a", +".......a************#a", +".......a***********+#a", +".......a***********+#a", +".......a***********+#a", +"#aa#...a***********+#a", +"abbaaaaa***********+#a", +"abbaaaaa***********+#a", +"#aa#...a***********+#a", +".......a***********+#a", +".......a***********+#a", +".......a**++++++++++#a", +".......a*############a", +".......aaaaaaaaaaaaaaa"}; + +QDesignerAxWidget::QDesignerAxWidget(QWidget *parent) : + QWidget(parent), + m_defaultSize(80, 70), + m_drawFlags(DrawIndicator|DrawFrame|DrawControl), + m_axobject(0), + m_axImage(widgetIcon()) +{ +} + +QDesignerAxWidget::~QDesignerAxWidget() +{ + delete m_axobject; +} + +QPixmap QDesignerAxWidget::widgetIcon() +{ + return QPixmap(widgetIconXPM); +} + +QString QDesignerAxWidget::control() const +{ + if (m_axobject) + return m_axobject->control(); + return QString(); +} + +void QDesignerAxWidget::setControl(const QString &clsid) +{ + if (clsid == control()) + return; + if (clsid.isEmpty()) { + resetControl(); + } else { + loadControl(clsid); + } +} +void QDesignerAxWidget::resetControl() +{ + if (!m_axobject) + return; + delete m_axobject; + m_axobject = 0; + update(); +} + +bool QDesignerAxWidget::loadControl(const QString &clsid) +{ + if (clsid.isEmpty()) + return false; + if (m_axobject) + resetControl(); + m_axobject = new QAxWidget(); + + if (!m_axobject->setControl(clsid)) { + delete m_axobject; + m_axobject = 0; + return false; + } + update(); + return true; +} + +QSize QDesignerAxWidget::sizeHint() const +{ + if (m_axobject) + return m_axobject->sizeHint(); + return m_defaultSize; +} + +QSize QDesignerAxWidget::minimumSizeHint() const +{ + if (m_axobject) + return m_axobject->minimumSizeHint(); + return QWidget::minimumSizeHint(); +} + +void QDesignerAxWidget::paintEvent(QPaintEvent * /*event */) +{ + QPainter p(this); + const QRect r = contentsRect(); + const int contentsWidth = r.width(); + const int contentsHeight= r.height(); + if (m_axobject) { // QAxWidget has no concept of sizeHint() + if (m_drawFlags & DrawControl) { + m_axobject->resize(size()); + m_axobject->render(&p); + } + if (m_drawFlags & DrawIndicator) { + static const QString loaded = tr("Control loaded"); + QColor patternColor(Qt::green); + if (m_drawFlags & DrawControl) + patternColor.setAlpha(80); + p.setBrush(QBrush(patternColor, Qt::BDiagPattern)); + p.setPen(Qt::black); + if (r.height() > 5) + p.drawText(5,contentsHeight - 5, loaded); + } + } + if (m_drawFlags & DrawFrame) { + p.drawRect(r.adjusted(0, 0, -1, -1)); + } + if (m_drawFlags & DrawIndicator) { + if (contentsWidth > m_axImage.width() && contentsHeight > m_axImage.height()) + p.drawPixmap((contentsWidth - m_axImage.width()) / 2, + (contentsHeight-m_axImage.height()) / 2, m_axImage); + } +} + +// --------- QDesignerAxPluginWidget +QDesignerAxPluginWidget::QDesignerAxPluginWidget(QWidget *parent) : + QDesignerAxWidget(parent) +{ +} + +QDesignerAxPluginWidget::~QDesignerAxPluginWidget() +{ +} + +const QMetaObject *QDesignerAxPluginWidget::metaObject() const +{ + if (const QAxWidget *aw = axobject()) + return aw->metaObject(); + + return QDesignerAxWidget::metaObject(); +} + +static QString msgComException(const QObject *o, const QMetaObject::Call call, int index) +{ + return QDesignerAxWidget::tr("A COM exception occurred when executing a meta call of type %1, index %2 of \"%3\"."). + arg(call).arg(index).arg(o->objectName()); +} + +int QDesignerAxPluginWidget::qt_metacall(QMetaObject::Call call, int signal, void **argv) +{ + QAxWidget *aw = axobject(); + if (!aw) + return QDesignerAxWidget::qt_metacall(call,signal,argv); + + + const QMetaObject *mo = metaObject(); + // Have base class handle inherited stuff (geometry, enabled...) + const bool inherited = call == QMetaObject::InvokeMetaMethod ? + (signal < mo->methodOffset()) : (signal < mo->propertyOffset()); + if (inherited) + return QDesignerAxWidget::qt_metacall(call, signal, argv); + + int rc = -1; +#ifndef QT_NO_EXCEPTIONS + try { +#endif + if (debugAxWidget) + if (call != QMetaObject::InvokeMetaMethod) + qDebug() << objectName() << call << signal << mo->property(signal).name(); + switch (call) { + case QMetaObject::QueryPropertyStored: // Pretend all changed properties are stored for them to be saved + if (m_propValues.contains(signal)) + if (argv[0]) + *reinterpret_cast< bool*>(argv[0]) = true; + break; + case QMetaObject::ResetProperty: + rc = aw->qt_metacall(call, signal, argv); + update(); + m_propValues.remove(signal); + break; + case QMetaObject::WriteProperty: + rc = aw->qt_metacall(call, signal, argv); + update(); + m_propValues.insert(signal, true); + break; + default: + rc = aw->qt_metacall(call, signal, argv); + break; + } +#ifndef QT_NO_EXCEPTIONS + } catch(...) { + qWarning(msgComException(this, call, signal).toUtf8()); + } +#endif + return rc; +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/activeqt/qdesigneraxwidget.h b/tools/designer/src/plugins/activeqt/qdesigneraxwidget.h new file mode 100644 index 0000000000..290ce8fa40 --- /dev/null +++ b/tools/designer/src/plugins/activeqt/qdesigneraxwidget.h @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 QACTIVEXPLUGINOBJECT_H +#define QACTIVEXPLUGINOBJECT_H + +#include <QtCore/QPointer> +#include <QtCore/QMap> +#include <QtGui/QWidget> +#include <QtGui/QPixmap> + +QT_BEGIN_NAMESPACE + +class QAxWidget; + +/* QDesignerAxWidget aggregates QAxWidget to keep it out of the event loop while applying + * properties directly. + * Thus, it is possible to set property values in designer that are out of range + * for the control, which might cause it to throw exceptions. + * + * QDesignerAxWidget is the base class following the internal naming + * conventions that makes the control property visible to the introspection interface. + * + * The trick to aggregate a QAxWidget is to overwrite the metaObject() function + * generated by moc to return the QMetaObject of QAxWidget. This is what QDesignerAxPluginWidget does. */ + +class QDesignerAxWidget : public QWidget +{ + Q_OBJECT + Q_PROPERTY(QString control READ control WRITE setControl RESET resetControl DESIGNABLE true) + Q_DISABLE_COPY(QDesignerAxWidget) + +protected: + explicit QDesignerAxWidget(QWidget *parent); + +public: + virtual ~QDesignerAxWidget(); + + bool loadControl(const QString &clsid); + + void resetControl(); + void setControl(const QString &clsid); + QString control() const; + + QSize sizeHint() const; + QSize minimumSizeHint() const; + + bool loaded() { return (m_axobject != 0); } + + static QPixmap widgetIcon(); + + enum { DrawIndicator = 0x1, DrawFrame = 0x2, DrawControl = 0x4 }; + + unsigned drawFlags() const { return m_drawFlags; } + void setDrawFlags(unsigned f) { m_drawFlags = f; } + +protected: + void paintEvent(QPaintEvent *event); + QAxWidget *axobject() const { return m_axobject; } + +private: + const QSize m_defaultSize; + unsigned m_drawFlags; + QAxWidget *m_axobject; + QPixmap m_axImage; +}; + +class QDesignerAxPluginWidget : public QDesignerAxWidget +{ + // No Q_OBJECT here! - meta functionality is overriden +public: + explicit QDesignerAxPluginWidget(QWidget *parent); + virtual ~QDesignerAxPluginWidget(); + + virtual const QMetaObject *metaObject() const; + virtual int qt_metacall(QMetaObject::Call, int, void **); + +private: + QMap<int, bool> m_propValues; +}; + +#if defined Q_CC_MSVC && _MSC_VER < 1300 +template <> inline QDesignerAxWidget *qobject_cast_helper<QDesignerAxWidget*>(QObject *o, QDesignerAxWidget*) +#else +template <> inline QDesignerAxWidget *qobject_cast<QDesignerAxWidget*>(QObject *o) +#endif +{ + if (!o) + return 0; + + // Unloaded state + if (strcmp(o->metaObject()->className(), "QDesignerAxWidget") == 0) + return static_cast<QDesignerAxPluginWidget*>(o); + + // Loaded state with fake meta object + if (strcmp(o->metaObject()->className(), "QAxWidget") == 0) + return static_cast<QDesignerAxPluginWidget*>(o); + + return 0; +} + +QT_END_NAMESPACE + +#endif // ACTIVEQT_EXTRAINFO_H diff --git a/tools/designer/src/plugins/phononwidgets/images/seekslider.png b/tools/designer/src/plugins/phononwidgets/images/seekslider.png Binary files differnew file mode 100644 index 0000000000..a1f4cb0d50 --- /dev/null +++ b/tools/designer/src/plugins/phononwidgets/images/seekslider.png diff --git a/tools/designer/src/plugins/phononwidgets/images/videoplayer.png b/tools/designer/src/plugins/phononwidgets/images/videoplayer.png Binary files differnew file mode 100644 index 0000000000..55d86a6d33 --- /dev/null +++ b/tools/designer/src/plugins/phononwidgets/images/videoplayer.png diff --git a/tools/designer/src/plugins/phononwidgets/images/videowidget.png b/tools/designer/src/plugins/phononwidgets/images/videowidget.png Binary files differnew file mode 100644 index 0000000000..3e8706e456 --- /dev/null +++ b/tools/designer/src/plugins/phononwidgets/images/videowidget.png diff --git a/tools/designer/src/plugins/phononwidgets/images/volumeslider.png b/tools/designer/src/plugins/phononwidgets/images/volumeslider.png Binary files differnew file mode 100644 index 0000000000..ea81dd2a11 --- /dev/null +++ b/tools/designer/src/plugins/phononwidgets/images/volumeslider.png diff --git a/tools/designer/src/plugins/phononwidgets/phononcollection.cpp b/tools/designer/src/plugins/phononwidgets/phononcollection.cpp new file mode 100644 index 0000000000..3d32fd445a --- /dev/null +++ b/tools/designer/src/plugins/phononwidgets/phononcollection.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "videoplayerplugin.h" +#include "seeksliderplugin.h" +#include "volumesliderplugin.h" + +#include <QtDesigner/QDesignerCustomWidgetCollectionInterface> +#include <QtCore/qplugin.h> + +QT_BEGIN_NAMESPACE + +class PhononCollection: public QObject, public QDesignerCustomWidgetCollectionInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetCollectionInterface) +public: + explicit PhononCollection(QObject *parent = 0); + + virtual QList<QDesignerCustomWidgetInterface*> customWidgets() const; + +private: + QList<QDesignerCustomWidgetInterface*> m_plugins; +}; + +PhononCollection::PhononCollection(QObject *parent) : + QObject(parent) +{ + const QString group = QLatin1String("Phonon"); + m_plugins.push_back(new VideoPlayerPlugin(group, this)); + m_plugins.push_back(new SeekSliderPlugin(group, this)); + m_plugins.push_back(new VolumeSliderPlugin(group, this)); +} + +QList<QDesignerCustomWidgetInterface*> PhononCollection::customWidgets() const +{ + return m_plugins; +} + +Q_EXPORT_PLUGIN(PhononCollection) + +QT_END_NAMESPACE + +#include "phononcollection.moc" diff --git a/tools/designer/src/plugins/phononwidgets/phononwidgets.pro b/tools/designer/src/plugins/phononwidgets/phononwidgets.pro new file mode 100644 index 0000000000..4e0f0cc1af --- /dev/null +++ b/tools/designer/src/plugins/phononwidgets/phononwidgets.pro @@ -0,0 +1,24 @@ +TEMPLATE = lib +TARGET = phononwidgets +CONFIG += qt warn_on plugin +QT += phonon + +include(../plugins.pri) +build_all:!build_pass { + CONFIG -= build_all + CONFIG += release +} + +# Input +SOURCES += videoplayerplugin.cpp \ + videoplayertaskmenu.cpp \ + seeksliderplugin.cpp \ + volumesliderplugin.cpp \ + phononcollection.cpp + +HEADERS += videoplayerplugin.h \ + videoplayertaskmenu.h \ + seeksliderplugin.h \ + volumesliderplugin.h + +RESOURCES += phononwidgets.qrc diff --git a/tools/designer/src/plugins/phononwidgets/phononwidgets.qrc b/tools/designer/src/plugins/phononwidgets/phononwidgets.qrc new file mode 100644 index 0000000000..aa51330fd7 --- /dev/null +++ b/tools/designer/src/plugins/phononwidgets/phononwidgets.qrc @@ -0,0 +1,8 @@ +<RCC> + <qresource prefix="/trolltech/phononwidgets"> + <file>images/videoplayer.png</file> + <file>images/videowidget.png</file> + <file>images/seekslider.png</file> + <file>images/volumeslider.png</file> + </qresource> +</RCC> diff --git a/tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp b/tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp new file mode 100644 index 0000000000..9bb1317a67 --- /dev/null +++ b/tools/designer/src/plugins/phononwidgets/seeksliderplugin.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "seeksliderplugin.h" + +#include <phonon/seekslider.h> + +static const char *toolTipC = "Phonon Seek Slider"; + +QT_BEGIN_NAMESPACE + +SeekSliderPlugin::SeekSliderPlugin(const QString &group, QObject *parent) : + QObject(parent), + m_group(group), + m_initialized(false) +{ +} + +QString SeekSliderPlugin::name() const +{ + return QLatin1String("Phonon::SeekSlider"); +} + +QString SeekSliderPlugin::group() const +{ + return m_group; +} + +QString SeekSliderPlugin::toolTip() const +{ + return QString(QLatin1String(toolTipC)); +} + +QString SeekSliderPlugin::whatsThis() const +{ + return QString(QLatin1String(toolTipC)); +} + +QString SeekSliderPlugin::includeFile() const +{ + return QLatin1String("<phonon/seekslider.h>"); +} + +QIcon SeekSliderPlugin::icon() const +{ + return QIcon(QLatin1String(":/trolltech/phononwidgets/images/seekslider.png")); +} + +bool SeekSliderPlugin::isContainer() const +{ + return false; +} + +QWidget *SeekSliderPlugin::createWidget(QWidget *parent) +{ + return new Phonon::SeekSlider(parent); +} + +bool SeekSliderPlugin::isInitialized() const +{ + return m_initialized; +} + +void SeekSliderPlugin::initialize(QDesignerFormEditorInterface *) +{ + if (m_initialized) + return; + m_initialized = true; +} + +QString SeekSliderPlugin::domXml() const +{ + return QLatin1String("\ + <ui language=\"c++\">\ + <widget class=\"Phonon::SeekSlider\" name=\"seekSlider\"/>\ + </ui>"); +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/phononwidgets/seeksliderplugin.h b/tools/designer/src/plugins/phononwidgets/seeksliderplugin.h new file mode 100644 index 0000000000..6facefe02e --- /dev/null +++ b/tools/designer/src/plugins/phononwidgets/seeksliderplugin.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 SEEKSLIDER_PLUGIN_H +#define SEEKSLIDER_PLUGIN_H + +#include <QtDesigner/QDesignerCustomWidgetInterface> + +QT_BEGIN_NAMESPACE + +class SeekSliderPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + explicit SeekSliderPlugin(const QString &group, QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString domXml() const; + +private: + const QString m_group; + bool m_initialized; +}; + +QT_END_NAMESPACE + +#endif // SEEKSLIDER_PLUGIN_H diff --git a/tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp b/tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp new file mode 100644 index 0000000000..a111b1aee3 --- /dev/null +++ b/tools/designer/src/plugins/phononwidgets/videoplayerplugin.cpp @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "videoplayerplugin.h" +#include "videoplayertaskmenu.h" + +#include <QtDesigner/QExtensionFactory> +#include <QtDesigner/QExtensionManager> +#include <QtDesigner/QDesignerFormEditorInterface> + +#include <QtCore/qplugin.h> +#include <phonon/videoplayer.h> + +static const char *toolTipC = "Phonon Video Player"; + +QT_BEGIN_NAMESPACE + +VideoPlayerPlugin::VideoPlayerPlugin(const QString &group, QObject *parent) : + QObject(parent), + m_group(group), + m_initialized(false) +{ +} + +QString VideoPlayerPlugin::name() const +{ + return QLatin1String("Phonon::VideoPlayer"); +} + +QString VideoPlayerPlugin::group() const +{ + return m_group; +} + +QString VideoPlayerPlugin::toolTip() const +{ + return QString(QLatin1String(toolTipC)); +} + +QString VideoPlayerPlugin::whatsThis() const +{ + return QString(QLatin1String(toolTipC)); +} + +QString VideoPlayerPlugin::includeFile() const +{ + return QLatin1String("<phonon/videoplayer.h>"); +} + +QIcon VideoPlayerPlugin::icon() const +{ + return QIcon(QLatin1String(":/trolltech/phononwidgets/images/videoplayer.png")); +} + +bool VideoPlayerPlugin::isContainer() const +{ + return false; +} + +QWidget *VideoPlayerPlugin::createWidget(QWidget *parent) +{ + return new Phonon::VideoPlayer(Phonon::NoCategory, parent); +} + +bool VideoPlayerPlugin::isInitialized() const +{ + return m_initialized; +} + +void VideoPlayerPlugin::initialize(QDesignerFormEditorInterface * core) +{ + if (m_initialized) + return; + + QExtensionManager *mgr = core->extensionManager(); + VideoPlayerTaskMenuFactory::registerExtension(mgr, Q_TYPEID(QDesignerTaskMenuExtension)); + m_initialized = true; +} + +QString VideoPlayerPlugin::domXml() const +{ + return QLatin1String("\ + <ui language=\"c++\">\ + <widget class=\"Phonon::VideoPlayer\" name=\"videoPlayer\">\ + <property name=\"geometry\">\ + <rect>\ + <x>0</x>\ + <y>0</y>\ + <width>300</width>\ + <height>200</height>\ + </rect>\ + </property>\ + </widget>\ + </ui>"); +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/phononwidgets/videoplayerplugin.h b/tools/designer/src/plugins/phononwidgets/videoplayerplugin.h new file mode 100644 index 0000000000..1f88dc6186 --- /dev/null +++ b/tools/designer/src/plugins/phononwidgets/videoplayerplugin.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 VIDEOPLAYER_PLUGIN_H +#define VIDEOPLAYER_PLUGIN_H + +#include <QtDesigner/QDesignerCustomWidgetInterface> + +QT_BEGIN_NAMESPACE + +class VideoPlayerPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + explicit VideoPlayerPlugin(const QString &group, QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString domXml() const; + +private: + const QString m_group; + bool m_initialized; +}; + +QT_END_NAMESPACE + +#endif // VIDEOPLAYER_PLUGIN_H diff --git a/tools/designer/src/plugins/phononwidgets/videoplayertaskmenu.cpp b/tools/designer/src/plugins/phononwidgets/videoplayertaskmenu.cpp new file mode 100644 index 0000000000..9c1f2f7415 --- /dev/null +++ b/tools/designer/src/plugins/phononwidgets/videoplayertaskmenu.cpp @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "videoplayertaskmenu.h" + +#include <QtDesigner/QDesignerFormWindowInterface> +#include <QtDesigner/QDesignerFormWindowCursorInterface> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/QExtensionManager> + +#include <phonon/videoplayer.h> +#include <phonon/mediaobject.h> + +#include <QtGui/QPlainTextEdit> +#include <QtGui/QDialogButtonBox> +#include <QtGui/QAction> +#include <QtGui/QVBoxLayout> +#include <QtGui/QFileDialog> +#include <QtGui/QMessageBox> + +QT_BEGIN_NAMESPACE + +// ----------------- MimeTypeDialog: Display mime types in scrollable text + +class MimeTypeDialog : public QDialog { + Q_DISABLE_COPY(MimeTypeDialog) +public: + explicit MimeTypeDialog(QWidget *parent = 0); + + void setMimeTypes(const QStringList &); + +private: + QPlainTextEdit *m_plainTextEdit; +}; + +MimeTypeDialog::MimeTypeDialog(QWidget *parent) : + QDialog(parent), + m_plainTextEdit(new QPlainTextEdit) +{ + setModal(true); + setWindowTitle(VideoPlayerTaskMenu::tr("Available Mime Types")); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + + QVBoxLayout *layout = new QVBoxLayout; + m_plainTextEdit->setReadOnly(true); + layout->addWidget(m_plainTextEdit); + + QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok); + connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + layout->addWidget(buttonBox); + + setLayout(layout); +} + +void MimeTypeDialog::setMimeTypes(const QStringList &l) +{ + m_plainTextEdit->setPlainText(l.join(QString(1, QLatin1Char('\n')))); +} + +// ----------------- VideoPlayerTaskMenu +VideoPlayerTaskMenu::VideoPlayerTaskMenu(Phonon::VideoPlayer *object, QObject *parent) : + QObject(parent), + m_widget(object), + m_displayMimeTypesAction(new QAction(tr("Display supported mime types..."), this)), + m_loadAction(new QAction(tr("Load..."), this)), + m_playAction(new QAction(tr("Play"), this)), + m_pauseAction(new QAction(tr("Pause"), this)), + m_stopAction(new QAction(tr("Stop"), this)) +{ + m_taskActions << m_displayMimeTypesAction << m_loadAction << m_playAction << m_pauseAction << m_stopAction; + + connect(m_widget->mediaObject(), SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(mediaObjectStateChanged(Phonon::State,Phonon::State))); + connect(m_displayMimeTypesAction, SIGNAL(triggered()), this, SLOT(slotMimeTypes())); + connect(m_loadAction, SIGNAL(triggered()), this, SLOT(slotLoad())); + connect(m_playAction, SIGNAL(triggered()), object, SLOT(play())); + connect(m_pauseAction, SIGNAL(triggered()), object, SLOT(pause())); + connect(m_stopAction, SIGNAL(triggered()), object, SLOT(stop())); +} + +QList<QAction*> VideoPlayerTaskMenu::taskActions() const +{ + const bool isPlaying = m_widget->isPlaying(); + const bool isPaused = m_widget->isPlaying(); + m_loadAction->setEnabled(!isPlaying && !isPaused); + m_playAction->setEnabled(!isPlaying); + m_pauseAction->setEnabled(isPlaying); + m_stopAction->setEnabled(isPlaying || isPaused); + return m_taskActions; +} + +void VideoPlayerTaskMenu::slotMimeTypes() +{ + MimeTypeDialog mimeTypeDialog(m_widget->window()); + mimeTypeDialog.setMimeTypes(Phonon::BackendCapabilities::availableMimeTypes()); + mimeTypeDialog.exec(); +} + +void VideoPlayerTaskMenu::slotLoad() +{ + const QString fileName = QFileDialog::getOpenFileName(m_widget->window(), tr("Choose Video Player Media Source")); + if (fileName.isEmpty()) + return; + m_widget->load(Phonon::MediaSource(fileName)); + +} + +void VideoPlayerTaskMenu::mediaObjectStateChanged(Phonon::State newstate, Phonon::State /* oldstate */) +{ + if (newstate == Phonon::ErrorState) { + const QString msg = tr("An error has occurred in '%1': %2").arg(m_widget->objectName(), m_widget->mediaObject()->errorString()); + QMessageBox::warning(m_widget->window(), tr("Video Player Error"), msg); + } +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/phononwidgets/videoplayertaskmenu.h b/tools/designer/src/plugins/phononwidgets/videoplayertaskmenu.h new file mode 100644 index 0000000000..d58d62d5eb --- /dev/null +++ b/tools/designer/src/plugins/phononwidgets/videoplayertaskmenu.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 VIDEOPLAYERTASKMENU_H +#define VIDEOPLAYERTASKMENU_H + + +#include <QtCore/QObject> +#include <QtDesigner/QDesignerTaskMenuExtension> +#include <QtDesigner/private/extensionfactory_p.h> + +#include <phonon> + +QT_BEGIN_NAMESPACE + +class VideoPlayerTaskMenu: public QObject, public QDesignerTaskMenuExtension +{ + Q_OBJECT + Q_INTERFACES(QDesignerTaskMenuExtension) +public: + explicit VideoPlayerTaskMenu(Phonon::VideoPlayer *object, QObject *parent = 0); + virtual QList<QAction*> taskActions() const; + +private slots: + void slotLoad(); + void slotMimeTypes(); + void mediaObjectStateChanged(Phonon::State newstate, Phonon::State oldstate); + +private: + Phonon::VideoPlayer *m_widget; + QAction *m_displayMimeTypesAction; + QAction *m_loadAction; + QAction *m_playAction; + QAction *m_pauseAction; + QAction *m_stopAction; + + QList<QAction*> m_taskActions; +}; + +typedef qdesigner_internal::ExtensionFactory<QDesignerTaskMenuExtension, Phonon::VideoPlayer, VideoPlayerTaskMenu> VideoPlayerTaskMenuFactory; + +QT_END_NAMESPACE + +#endif // VIDEOPLAYERTASKMENU_H diff --git a/tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp b/tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp new file mode 100644 index 0000000000..61625cc7c2 --- /dev/null +++ b/tools/designer/src/plugins/phononwidgets/volumesliderplugin.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "volumesliderplugin.h" + +#include <phonon/volumeslider.h> + +static const char *toolTipC = "Phonon Volume Slider"; + +QT_BEGIN_NAMESPACE + +VolumeSliderPlugin::VolumeSliderPlugin(const QString &group, QObject *parent) : + QObject(parent), + m_group(group), + m_initialized(false) +{ +} + +QString VolumeSliderPlugin::name() const +{ + return QLatin1String("Phonon::VolumeSlider"); +} + +QString VolumeSliderPlugin::group() const +{ + return m_group; +} + +QString VolumeSliderPlugin::toolTip() const +{ + return QString(QLatin1String(toolTipC)); +} + +QString VolumeSliderPlugin::whatsThis() const +{ + return QString(QLatin1String(toolTipC)); +} + +QString VolumeSliderPlugin::includeFile() const +{ + return QLatin1String("<phonon/volumeslider.h>"); +} + +QIcon VolumeSliderPlugin::icon() const +{ + return QIcon(QLatin1String(":/trolltech/phononwidgets/images/volumeslider.png")); +} + +bool VolumeSliderPlugin::isContainer() const +{ + return false; +} + +QWidget *VolumeSliderPlugin::createWidget(QWidget *parent) +{ + return new Phonon::VolumeSlider(parent); +} + +bool VolumeSliderPlugin::isInitialized() const +{ + return m_initialized; +} + +void VolumeSliderPlugin::initialize(QDesignerFormEditorInterface *) +{ + if (m_initialized) + return; + m_initialized = true; +} + +QString VolumeSliderPlugin::domXml() const +{ + return QLatin1String("\ + <ui language=\"c++\">\ + <widget class=\"Phonon::VolumeSlider\" name=\"volumeSlider\"/>\ + </ui>"); +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/phononwidgets/volumesliderplugin.h b/tools/designer/src/plugins/phononwidgets/volumesliderplugin.h new file mode 100644 index 0000000000..02c5fe1abf --- /dev/null +++ b/tools/designer/src/plugins/phononwidgets/volumesliderplugin.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 VOLUMESLIDER_PLUGIN_H +#define VOLUMESLIDER_PLUGIN_H + +#include <QtDesigner/QDesignerCustomWidgetInterface> + +QT_BEGIN_NAMESPACE + +class VolumeSliderPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + explicit VolumeSliderPlugin(const QString &group, QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString domXml() const; + +private: + const QString m_group; + bool m_initialized; +}; + +QT_END_NAMESPACE + +#endif // VOLUMESLIDER_PLUGIN_H diff --git a/tools/designer/src/plugins/plugins.pri b/tools/designer/src/plugins/plugins.pri new file mode 100644 index 0000000000..e5edfe2f2e --- /dev/null +++ b/tools/designer/src/plugins/plugins.pri @@ -0,0 +1,8 @@ +CONFIG += designer +win32|mac: CONFIG+= debug_and_release +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/designer +contains(TEMPLATE, ".*lib"):TARGET = $$qtLibraryTarget($$TARGET) + +# install +target.path = $$[QT_INSTALL_PLUGINS]/designer +INSTALLS += target diff --git a/tools/designer/src/plugins/plugins.pro b/tools/designer/src/plugins/plugins.pro new file mode 100644 index 0000000000..baf5261139 --- /dev/null +++ b/tools/designer/src/plugins/plugins.pro @@ -0,0 +1,9 @@ +TEMPLATE = subdirs +CONFIG += ordered + +REQUIRES = !CONFIG(static,shared|static) +contains(QT_CONFIG, qt3support): SUBDIRS += widgets +win32:!contains(QT_EDITION, OpenSource):SUBDIRS += activeqt +# contains(QT_CONFIG, opengl): SUBDIRS += tools/view3d +contains(QT_CONFIG, webkit): SUBDIRS += qwebview +contains(QT_CONFIG, phonon): SUBDIRS += phononwidgets diff --git a/tools/designer/src/plugins/qwebview/images/qwebview.png b/tools/designer/src/plugins/qwebview/images/qwebview.png Binary files differnew file mode 100644 index 0000000000..01a0920c93 --- /dev/null +++ b/tools/designer/src/plugins/qwebview/images/qwebview.png diff --git a/tools/designer/src/plugins/qwebview/qwebview.pro b/tools/designer/src/plugins/qwebview/qwebview.pro new file mode 100644 index 0000000000..b1f6371d15 --- /dev/null +++ b/tools/designer/src/plugins/qwebview/qwebview.pro @@ -0,0 +1,15 @@ +TEMPLATE = lib +TARGET = qwebview +CONFIG += qt warn_on plugin +QT += webkit + +include(../plugins.pri) +build_all:!build_pass { + CONFIG -= build_all + CONFIG += release +} + +# Input +SOURCES += qwebview_plugin.cpp +HEADERS += qwebview_plugin.h +RESOURCES += qwebview_plugin.qrc diff --git a/tools/designer/src/plugins/qwebview/qwebview_plugin.cpp b/tools/designer/src/plugins/qwebview/qwebview_plugin.cpp new file mode 100644 index 0000000000..9b0932a99e --- /dev/null +++ b/tools/designer/src/plugins/qwebview/qwebview_plugin.cpp @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "qwebview_plugin.h" + +#include <QtDesigner/QExtensionFactory> +#include <QtDesigner/QExtensionManager> + +#include <QtCore/qplugin.h> +#include <QtWebKit/QWebView> + +static const char *toolTipC = "QtWebKit Web widget"; + +QT_BEGIN_NAMESPACE + +QWebViewPlugin::QWebViewPlugin(QObject *parent) : + QObject(parent), + m_initialized(false) +{ +} + +QString QWebViewPlugin::name() const +{ + return QLatin1String("QWebView"); +} + +QString QWebViewPlugin::group() const +{ + return QLatin1String("Display Widgets"); +} + +QString QWebViewPlugin::toolTip() const +{ + return QString(QLatin1String(toolTipC)); +} + +QString QWebViewPlugin::whatsThis() const +{ + return QString(QLatin1String(toolTipC)); +} + +QString QWebViewPlugin::includeFile() const +{ + return QLatin1String("QtWebKit/QWebView"); +} + +QIcon QWebViewPlugin::icon() const +{ + return QIcon(QLatin1String(":/trolltech/qwebview/images/qwebview.png")); +} + +bool QWebViewPlugin::isContainer() const +{ + return false; +} + +QWidget *QWebViewPlugin::createWidget(QWidget *parent) +{ + return new QWebView(parent); +} + +bool QWebViewPlugin::isInitialized() const +{ + return m_initialized; +} + +void QWebViewPlugin::initialize(QDesignerFormEditorInterface * /*core*/) +{ + if (m_initialized) + return; + + m_initialized = true; +} + +QString QWebViewPlugin::domXml() const +{ + return QLatin1String("\ + <ui language=\"c++\">\ + <widget class=\"QWebView\" name=\"webView\">\ + <property name=\"url\">\ + <url>\ + <string>about:blank</string>\ + </url>\ + </property>\ + <property name=\"geometry\">\ + <rect>\ + <x>0</x>\ + <y>0</y>\ + <width>300</width>\ + <height>200</height>\ + </rect>\ + </property>\ + </widget>\ + </ui>"); +} + +Q_EXPORT_PLUGIN2(customwidgetplugin, QWebViewPlugin) + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/qwebview/qwebview_plugin.h b/tools/designer/src/plugins/qwebview/qwebview_plugin.h new file mode 100644 index 0000000000..345daa76c6 --- /dev/null +++ b/tools/designer/src/plugins/qwebview/qwebview_plugin.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 Qt Designer 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 QWEBPAGE_PLUGIN_H +#define QWEBPAGE_PLUGIN_H + +#include <QtDesigner/QDesignerCustomWidgetInterface> + +QT_BEGIN_NAMESPACE + +class QWebViewPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + QWebViewPlugin(QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString domXml() const; + +private: + bool m_initialized; +}; + +QT_END_NAMESPACE + +#endif // QWEBPAGE_PLUGIN_H diff --git a/tools/designer/src/plugins/qwebview/qwebview_plugin.qrc b/tools/designer/src/plugins/qwebview/qwebview_plugin.qrc new file mode 100644 index 0000000000..a3e2b90169 --- /dev/null +++ b/tools/designer/src/plugins/qwebview/qwebview_plugin.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/trolltech/qwebview"> + <file>images/qwebview.png</file> + </qresource> +</RCC> diff --git a/tools/designer/src/plugins/tools/view3d/view3d.cpp b/tools/designer/src/plugins/tools/view3d/view3d.cpp new file mode 100644 index 0000000000..97d90975f1 --- /dev/null +++ b/tools/designer/src/plugins/tools/view3d/view3d.cpp @@ -0,0 +1,492 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 <QtCore> +#include <QtGui> +#include <QtOpenGL> + +#include "abstractformeditor.h" +#include "abstractmetadatabase.h" +#include "abstractformwindow.h" +#include "view3d.h" + +#define SELECTION_BUFSIZE 512 + +/******************************************************************************* +** QView3DWidget +*/ + +class QView3DWidget : public QGLWidget +{ + Q_OBJECT +public: + QView3DWidget(QWidget *parent); + virtual void initializeGL(); + virtual void resizeGL(int w, int h); + virtual void paintGL(); + void clear(); + + void addTexture(QWidget *w, const QPixmap &pm); + + void beginAddingWidgets(QWidget *form); + void addWidget(int depth, QWidget *w); + void endAddingWidgets(); + + QWidget *widgetAt(const QPoint &pos); + +signals: + void updateForm(); + +protected: + void mousePressEvent(QMouseEvent *); + void mouseReleaseEvent(QMouseEvent *); + void mouseMoveEvent(QMouseEvent *); + void wheelEvent(QWheelEvent *); + void keyReleaseEvent(QKeyEvent *); + + void contextMenuEvent(QContextMenuEvent *); + +private: + QWidget *m_form; + QPoint m_old_pos; + bool m_layer_coloring; + bool m_use_mipmaps; + GLuint m_form_list_id; + + typedef QMap<QWidget*, GLuint> TextureMap; + TextureMap m_texture_map; + + typedef QMap<GLuint, QWidget*> WidgetNameMap; + GLuint m_next_widget_name; + WidgetNameMap m_widget_name_map; +}; + +QView3DWidget::QView3DWidget(QWidget *parent) + : QGLWidget(parent) + , m_layer_coloring(true) + , m_form_list_id(0) + , m_next_widget_name(0) +{ + setFocusPolicy(Qt::StrongFocus); +} + +static int nearestSize(int v) +{ + int n = 0, last = 0; + for (int s = 0; s < 32; ++s) { + if (((v>>s) & 1) == 1) { + ++n; + last = s; + } + } + if (n > 1) + return 1 << (last+1); + return 1 << last; +} + +// static int pm_cnt = 0; + +void QView3DWidget::addTexture(QWidget *w, const QPixmap &pm) +{ + int tx_w = nearestSize(pm.width()); + int tx_h = nearestSize(pm.height()); + + QPixmap tmp(tx_w, tx_h); + tmp.fill(QColor(0,0,0)); + QPainter p(&tmp); + p.drawPixmap(0, tx_h - pm.height(), pm); + p.end(); + QImage tex = tmp.toImage(); + +// QString file_name = QString("pixmapDump%1.png").arg(pm_cnt++); +// qDebug() << "grabWidget():" << file_name << tex.save(file_name, "PNG"); + + tex = QGLWidget::convertToGLFormat(tex); + + GLuint tx_id; + glGenTextures(1, &tx_id); + glBindTexture(GL_TEXTURE_2D, tx_id); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + if (m_use_mipmaps) { + //glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST); + //glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16.f); + } else { + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + } + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, tex.width(), tex.height(), 0, GL_RGBA, + GL_UNSIGNED_BYTE, tex.bits()); + m_texture_map[w] = tx_id; +} + +void QView3DWidget::addWidget(int depth, QWidget *widget) +{ + TextureMap::const_iterator it = m_texture_map.find(widget); + Q_ASSERT(it != m_texture_map.end()); + + makeCurrent(); + + int w = m_form->size().width(); + int h = m_form->size().height(); + int max = qMax(w, h); + QRect r = widget->rect(); + QPoint pos = widget->mapToGlobal(QPoint(0, 0)); + r.moveTopLeft(m_form->mapFromGlobal(pos)); + + float s = r.width()/float(nearestSize(r.width())); + float t = r.height()/float(nearestSize(r.height())); + + if (m_layer_coloring) + glColor4f(1.0 - depth/10.0, 1.0 - depth/10.0, 1.0, 1.0 - depth/20.0); + else + glColor4f(1.0, 1.0, 1.0, 1.0); + + glBindTexture(GL_TEXTURE_2D, *it); + glBegin(GL_QUADS); + glLoadName(m_next_widget_name); + glTexCoord2f(0.0, 0.0); glVertex3f(r.left() - w/2, r.bottom() - h/2, depth*max/8); + glTexCoord2f(s, 0.0); glVertex3f(r.right() - w/2, r.bottom()- h/2, depth*max/8); + glTexCoord2f(s, t); glVertex3f(r.right() - w/2, r.top() - h/2, depth*max/8); + glTexCoord2f(0.0, t); glVertex3f(r.left() - w/2, r.top() - h/2, depth*max/8); + glEnd(); + + m_widget_name_map[m_next_widget_name++] = widget; +} + +void QView3DWidget::clear() +{ + makeCurrent(); + glDeleteLists(m_form_list_id, 1); + foreach (GLuint id, m_texture_map) + glDeleteTextures(1, &id); + m_texture_map.clear(); + m_widget_name_map.clear(); + m_next_widget_name = 0; +} + +void QView3DWidget::beginAddingWidgets(QWidget *form) +{ + makeCurrent(); + m_form = form; + m_form_list_id = glGenLists(1); + glNewList(m_form_list_id, GL_COMPILE); + glInitNames(); + glPushName(-1); + m_next_widget_name = 0; +} + +void QView3DWidget::endAddingWidgets() +{ + makeCurrent(); + glEndList(); +} + +void QView3DWidget::initializeGL() +{ + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + qglClearColor(palette().color(QPalette::Window).dark()); + glColor3f (1.0, 1.0, 1.0); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LEQUAL); + + glShadeModel(GL_FLAT); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + QString extensions(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS))); + m_use_mipmaps = false;// extensions.contains("GL_SGIS_generate_mipmap"); +} + +void QView3DWidget::resizeGL(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-width/2, width/2, height/2, -height/2, -999999, 999999); +} + +void QView3DWidget::paintGL() +{ + glColor4f(1.0, 1.0, 1.0, 1.0); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glCallList(m_form_list_id); + + glPushAttrib(GL_ENABLE_BIT); + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + glDisable(GL_TEXTURE_2D); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + glTranslatef(-width()/2, -height()/2, 0.0); + + QFontMetrics fm(font()); + glColor4f(0.4, 0.4, 0.4, 0.7); + glRecti(0, height() - fm.lineSpacing()*2.5, width(), height()); + + glColor3f(1.0, 1.0, 1.0); + renderText(10, height() - fm.lineSpacing()*1.5, + "Press and hold left/right mouse button = tilt the view."); + renderText(10, height() - fm.lineSpacing()*0.5, + "Mouse wheel = zoom. 't' = toggle layer coloring. 'r' = reset transform."); + glPopMatrix(); + glPopAttrib(); +} + +QWidget *QView3DWidget::widgetAt(const QPoint &pos) +{ + makeCurrent(); + GLuint selectBuf[SELECTION_BUFSIZE]; + glSelectBuffer(SELECTION_BUFSIZE, selectBuf); + glRenderMode (GL_SELECT); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + + glCallList(m_form_list_id); + return 0; +} + +void QView3DWidget::keyReleaseEvent(QKeyEvent *e) +{ + if (e->key() == Qt::Key_T) { + m_layer_coloring = !m_layer_coloring; + emit updateForm(); + } else if (e->key() == Qt::Key_R) { + makeCurrent(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + } + + updateGL(); +} + +void QView3DWidget::mousePressEvent(QMouseEvent *e) +{ + m_old_pos = e->pos(); +} + +void QView3DWidget::mouseReleaseEvent(QMouseEvent *e) +{ + m_old_pos = e->pos(); +} + +void QView3DWidget::mouseMoveEvent(QMouseEvent *e) +{ + if (e->buttons() & (Qt::LeftButton | Qt::RightButton)) { + GLfloat rx = (GLfloat) (e->x() - m_old_pos.x()) / width(); + GLfloat ry = (GLfloat) (e->y() - m_old_pos.y()) / height(); + + makeCurrent(); + glMatrixMode(GL_MODELVIEW); + if (e->buttons() & Qt::LeftButton) { + // Left button down - rotate around X and Y axes + glRotatef(-180*ry, 1, 0, 0); + glRotatef(180*rx, 0, 1, 0); + } else if (e->buttons() & Qt::RightButton) { + // Right button down - rotate around X and Z axes + glRotatef(-180*ry, 1, 0, 0); + glRotatef(-180*rx, 0, 0, 1); + } + updateGL(); + m_old_pos = e->pos(); + } else { + + } +} + +void QView3DWidget::wheelEvent(QWheelEvent *e) +{ + makeCurrent(); + glMatrixMode(GL_MODELVIEW); + if (e->delta() < 0) + glScalef(0.9, 0.9, 0.9); + else + glScalef(1.1, 1.1, 1.1); + updateGL(); +} + +void QView3DWidget::contextMenuEvent(QContextMenuEvent *e) +{ + e->accept(); +} + +/******************************************************************************* +** Misc tools +*/ + +class WalkWidgetTreeFunction +{ +public: + virtual void operator () (int depth, QWidget *widget) const = 0; +}; + +static bool skipWidget(QDesignerFormEditorInterface *core, QWidget *widget) +{ + QDesignerMetaDataBaseItemInterface *item = core->metaDataBase()->item(widget); + if (item == 0) + return true; + QString name = widget->metaObject()->className(); + if (name == "QLayoutWidget") + return true; + + return false; +} + +static void walkWidgetTree(QDesignerFormEditorInterface *core, int depth, QWidget *widget, const WalkWidgetTreeFunction &func) +{ + if (widget == 0) + return; + if (!widget->isVisible()) + return; + + if (!skipWidget(core, widget)) + func(depth++, widget); + + QObjectList child_obj_list = widget->children(); + foreach (QObject *child_obj, child_obj_list) { + QWidget *child = qobject_cast<QWidget*>(child_obj); + if (child != 0) + walkWidgetTree(core, depth, child, func); + } +} + +static void grabWidget_helper(QWidget *widget, QPixmap &res, QPixmap &buf, + const QRect &r, const QPoint &offset, QDesignerFormEditorInterface *core) +{ + buf.fill(widget, r.topLeft()); + QPainter::setRedirected(widget, &buf, r.topLeft()); + QPaintEvent e(r & widget->rect()); + QApplication::sendEvent(widget, &e); + QPainter::restoreRedirected(widget); + { + QPainter pt(&res); + pt.drawPixmap(offset.x(), offset.y(), buf, 0, 0, r.width(), r.height()); + } + + const QObjectList children = widget->children(); + for (int i = 0; i < children.size(); ++i) { + QWidget *child = qobject_cast<QWidget*>(children.at(i)); + if (child == 0 || child->isWindow()) + continue; + if (child->isHidden() || !child->geometry().intersects(r)) + continue; + if (core->metaDataBase()->item(child) != 0) + continue; + QRect cr = r & child->geometry(); + cr.translate(-child->pos()); + grabWidget_helper(child, res, buf, cr, offset + child->pos(), core); + } +} + +static QPixmap grabWidget(QWidget * widget, QDesignerFormEditorInterface *core) +{ + if (!widget) + return QPixmap(); + + QRect r = widget->rect(); + QSize s = widget->size(); + + QPixmap res(s), buf(s); + + grabWidget_helper(widget, res, buf, r, QPoint(), core); + + return res; +} + +/******************************************************************************* +** QView3D +*/ + +class AddTexture : public WalkWidgetTreeFunction +{ +public: + inline AddTexture(QDesignerFormEditorInterface *core, QView3DWidget *w) + : m_core(core), m_3d_widget(w) {} + inline virtual void operator ()(int, QWidget *w) const + { m_3d_widget->addTexture(w, ::grabWidget(w, m_core)); } + QDesignerFormEditorInterface *m_core; + QView3DWidget *m_3d_widget; +}; + +class AddWidget : public WalkWidgetTreeFunction +{ +public: + inline AddWidget(QView3DWidget *w) : m_3d_widget(w) {} + inline virtual void operator ()(int depth, QWidget *w) const + { m_3d_widget->addWidget(depth, w); } + QView3DWidget *m_3d_widget; +}; + +QView3D::QView3D(QDesignerFormWindowInterface *form_window, QWidget *parent) + : QWidget(parent) +{ + m_form_window = form_window; + m_3d_widget = new QView3DWidget(this); + connect(m_3d_widget, SIGNAL(updateForm()), this, SLOT(updateForm())); + + QGridLayout *layout = new QGridLayout(this); + layout->setMargin(0); + layout->addWidget(m_3d_widget, 0, 0, 1, 1); + + updateForm(); +} + +void QView3D::updateForm() +{ + QWidget *w = m_form_window->mainContainer(); + if (w == 0) + return; + + m_3d_widget->clear(); + + walkWidgetTree(m_form_window->core(), 0, w, AddTexture(m_form_window->core(), m_3d_widget)); + m_3d_widget->beginAddingWidgets(w); + walkWidgetTree(m_form_window->core(), 0, w, AddWidget(m_3d_widget)); + m_3d_widget->endAddingWidgets(); +} + +#include "view3d.moc" diff --git a/tools/designer/src/plugins/tools/view3d/view3d.h b/tools/designer/src/plugins/tools/view3d/view3d.h new file mode 100644 index 0000000000..bc6b58332e --- /dev/null +++ b/tools/designer/src/plugins/tools/view3d/view3d.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 VIEW3D_H +#define VIEW3D_H + +#include "view3d_global.h" +#include <QtGui/QWidget> + +QT_BEGIN_NAMESPACE + +class QScrollBar; +class QGLWidget; +class QDesignerFormWindowInterface; + +class QView3DWidget; + +class QView3D : public QWidget +{ + Q_OBJECT + +public: + QView3D(QDesignerFormWindowInterface *form_window, QWidget *parent); + +public slots: + void updateForm(); + +private: + QView3DWidget *m_3d_widget; + QDesignerFormWindowInterface *m_form_window; + + void addWidget(int depth, QWidget *w); + void addTexture(QWidget *w); +}; + +#endif // VIEW3D_H + + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/tools/view3d/view3d.pro b/tools/designer/src/plugins/tools/view3d/view3d.pro new file mode 100644 index 0000000000..c28c706930 --- /dev/null +++ b/tools/designer/src/plugins/tools/view3d/view3d.pro @@ -0,0 +1,17 @@ + +TEMPLATE = lib +QT += opengl +CONFIG += qt warn_on plugin +DESTDIR = +TARGET = view3d + +include(../../plugins.pri) +build_all:!build_pass { + CONFIG -= build_all + CONFIG += release +} + +# Input +SOURCES += view3d.cpp view3d_tool.cpp view3d_plugin.cpp +HEADERS += view3d.h view3d_tool.h view3d_plugin.h view3d_global.h + diff --git a/tools/designer/src/plugins/tools/view3d/view3d_global.h b/tools/designer/src/plugins/tools/view3d/view3d_global.h new file mode 100644 index 0000000000..90c8ce2528 --- /dev/null +++ b/tools/designer/src/plugins/tools/view3d/view3d_global.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 Qt Designer 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 VIEW3D_GLOBAL_H +#define VIEW3D_GLOBAL_H + +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE + +#ifdef Q_OS_WIN +#ifdef VIEW3D_LIBRARY +# define VIEW3D_EXPORT +#else +# define VIEW3D_EXPORT +#endif +#else +#define VIEW3D_EXPORT +#endif + +#endif // VIEW3D_GLOBAL_H + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/tools/view3d/view3d_plugin.cpp b/tools/designer/src/plugins/tools/view3d/view3d_plugin.cpp new file mode 100644 index 0000000000..a599e7e4b3 --- /dev/null +++ b/tools/designer/src/plugins/tools/view3d/view3d_plugin.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 <QtCore/qdebug.h> +#include <QtCore/qplugin.h> +#include <QtGui/QAction> +#include "view3d_plugin.h" +#include "view3d_tool.h" + +QView3DPlugin::QView3DPlugin() +{ + m_core = 0; + m_action = 0; +} + +bool QView3DPlugin::isInitialized() const +{ + return m_core != 0; +} + +void QView3DPlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_ASSERT(!isInitialized()); + + m_action = new QAction(tr("3D View"), this); + m_core = core; + setParent(core); + + connect(core->formWindowManager(), SIGNAL(formWindowAdded(QDesignerFormWindowInterface*)), + this, SLOT(addFormWindow(QDesignerFormWindowInterface*))); + + connect(core->formWindowManager(), SIGNAL(formWindowRemoved(QDesignerFormWindowInterface*)), + this, SLOT(removeFormWindow(QDesignerFormWindowInterface*))); + + connect(core->formWindowManager(), SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)), + this, SLOT(activeFormWindowChanged(QDesignerFormWindowInterface*))); +} + +QAction *QView3DPlugin::action() const +{ + return m_action; +} + +QDesignerFormEditorInterface *QView3DPlugin::core() const +{ + return m_core; +} + +void QView3DPlugin::activeFormWindowChanged(QDesignerFormWindowInterface *formWindow) +{ + m_action->setEnabled(formWindow != 0); +} + +void QView3DPlugin::addFormWindow(QDesignerFormWindowInterface *formWindow) +{ + Q_ASSERT(formWindow != 0); + Q_ASSERT(m_tool_list.contains(formWindow) == false); + + QView3DTool *tool = new QView3DTool(formWindow, this); + m_tool_list[formWindow] = tool; + connect(m_action, SIGNAL(triggered()), tool->action(), SLOT(trigger())); + formWindow->registerTool(tool); +} + +void QView3DPlugin::removeFormWindow(QDesignerFormWindowInterface *formWindow) +{ + Q_ASSERT(formWindow != 0); + Q_ASSERT(m_tool_list.contains(formWindow)); + + QView3DTool *tool = m_tool_list.value(formWindow); + m_tool_list.remove(formWindow); + disconnect(m_action, SIGNAL(triggered()), tool->action(), SLOT(trigger())); + + delete tool; +} + +Q_EXPORT_PLUGIN2(view3d, QView3DPlugin) diff --git a/tools/designer/src/plugins/tools/view3d/view3d_plugin.h b/tools/designer/src/plugins/tools/view3d/view3d_plugin.h new file mode 100644 index 0000000000..a9db8a6147 --- /dev/null +++ b/tools/designer/src/plugins/tools/view3d/view3d_plugin.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3VIEW3D_PLUGIN_H +#define Q3VIEW3D_PLUGIN_H + +#include <QtCore/QList> +#include <QtCore/QHash> +#include <QtDesigner/QDesignerFormEditorPluginInterface> +#include "view3d_global.h" + +QT_BEGIN_NAMESPACE + +class QView3DTool; +class QAction; + +class VIEW3D_EXPORT QView3DPlugin : public QObject, public QDesignerFormEditorPluginInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerFormEditorPluginInterface) + +public: + QView3DPlugin(); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QAction *action() const; + virtual QDesignerFormEditorInterface *core() const; + +public slots: + void activeFormWindowChanged(QDesignerFormWindowInterface *formWindow); + +private slots: + void addFormWindow(QDesignerFormWindowInterface *formWindow); + void removeFormWindow(QDesignerFormWindowInterface *formWindow); + +private: + QPointer<QDesignerFormEditorInterface> m_core; + QHash<QDesignerFormWindowInterface*, QView3DTool*> m_tool_list; + QAction *m_action; +}; + +#endif // QVIEW3D_PLUGIN_H + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/tools/view3d/view3d_tool.cpp b/tools/designer/src/plugins/tools/view3d/view3d_tool.cpp new file mode 100644 index 0000000000..05015c3519 --- /dev/null +++ b/tools/designer/src/plugins/tools/view3d/view3d_tool.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 <QtGui/QAction> +#include "view3d_tool.h" + +QView3DTool::QView3DTool(QDesignerFormWindowInterface *formWindow, QObject *parent) + : QDesignerFormWindowToolInterface(parent) +{ + m_action = new QAction(tr("3DView"), this); + m_formWindow = formWindow; +} + +QDesignerFormEditorInterface *QView3DTool::core() const +{ + return m_formWindow->core(); +} + +QDesignerFormWindowInterface *QView3DTool::formWindow() const +{ + return m_formWindow; +} + +QWidget *QView3DTool::editor() const +{ + if (m_editor == 0) + m_editor = new QView3D(formWindow(), 0); + + return m_editor; +} + +QAction *QView3DTool::action() const +{ + return m_action; +} + +void QView3DTool::activated() +{ + if (m_editor != 0) + m_editor->updateForm(); +} + +void QView3DTool::deactivated() +{ +} + +bool QView3DTool::handleEvent(QWidget*, QWidget*, QEvent*) +{ + return false; +} diff --git a/tools/designer/src/plugins/tools/view3d/view3d_tool.h b/tools/designer/src/plugins/tools/view3d/view3d_tool.h new file mode 100644 index 0000000000..d099019eab --- /dev/null +++ b/tools/designer/src/plugins/tools/view3d/view3d_tool.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 VIEW3D_TOOL_H +#define VIEW3D_TOOL_H + +#include "view3d_global.h" +#include "view3d.h" +#include <QtDesigner/QDesignerFormWindowToolInterface> + +QT_BEGIN_NAMESPACE + +class VIEW3D_EXPORT QView3DTool : public QDesignerFormWindowToolInterface +{ + Q_OBJECT + +public: + explicit QView3DTool(QDesignerFormWindowInterface *formWindow, QObject *parent = 0); + virtual QDesignerFormEditorInterface *core() const; + virtual QDesignerFormWindowInterface *formWindow() const; + virtual QWidget *editor() const; + + virtual QAction *action() const; + + virtual void activated(); + virtual void deactivated(); + + virtual bool handleEvent(QWidget *widget, QWidget *managedWidget, QEvent *event); + +private: + QDesignerFormWindowInterface *m_formWindow; + mutable QPointer<QView3D> m_editor; + QAction *m_action; +}; + +#endif // VIEW3D_TOOL_H + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3iconview/q3iconview_extrainfo.cpp b/tools/designer/src/plugins/widgets/q3iconview/q3iconview_extrainfo.cpp new file mode 100644 index 0000000000..3f0b0b51fb --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3iconview/q3iconview_extrainfo.cpp @@ -0,0 +1,183 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3iconview_extrainfo.h" + +#include <QtDesigner/QDesignerIconCacheInterface> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/private/ui4_p.h> + +#include <Qt3Support/Q3IconView> + +QT_BEGIN_NAMESPACE + +inline QHash<QString, DomProperty *> propertyMap(const QList<DomProperty *> &properties) // ### remove me +{ + QHash<QString, DomProperty *> map; + + for (int i=0; i<properties.size(); ++i) { + DomProperty *p = properties.at(i); + map.insert(p->attributeName(), p); + } + + return map; +} + +Q3IconViewExtraInfo::Q3IconViewExtraInfo(Q3IconView *widget, QDesignerFormEditorInterface *core, QObject *parent) + : QObject(parent), m_widget(widget), m_core(core) +{} + +QWidget *Q3IconViewExtraInfo::widget() const +{ return m_widget; } + +QDesignerFormEditorInterface *Q3IconViewExtraInfo::core() const +{ return m_core; } + +bool Q3IconViewExtraInfo::saveUiExtraInfo(DomUI *ui) +{ Q_UNUSED(ui); return false; } + +bool Q3IconViewExtraInfo::loadUiExtraInfo(DomUI *ui) +{ Q_UNUSED(ui); return false; } + + +bool Q3IconViewExtraInfo::saveWidgetExtraInfo(DomWidget *ui_widget) +{ + // ### finish me + Q3IconView *iconView = qobject_cast<Q3IconView*>(widget()); + Q_ASSERT(iconView != 0); + + QList<DomItem*> ui_items; + + Q3IconViewItem *__item = iconView->firstItem(); + while (__item != 0) { + DomItem *ui_item = new DomItem(); + + QList<DomProperty*> properties; + + // text property + DomProperty *ptext = new DomProperty(); + DomString *str = new DomString(); + str->setText(__item->text()); + ptext->setAttributeName(QLatin1String("text")); + ptext->setElementString(str); + properties.append(ptext); + + ui_item->setElementProperty(properties); + ui_items.append(ui_item); + + if (__item->pixmap() != 0 && core()->iconCache()) { + QPixmap pix = *__item->pixmap(); + QString filePath = core()->iconCache()->pixmapToFilePath(pix); + QString qrcPath = core()->iconCache()->pixmapToQrcPath(pix); + DomResourcePixmap *ui_pix = new DomResourcePixmap(); + if (!qrcPath.isEmpty()) + ui_pix->setAttributeResource(qrcPath); + ui_pix->setText(filePath); + + DomProperty *ppix = new DomProperty(); + ppix->setAttributeName(QLatin1String("pixmap")); + ppix->setElementPixmap(ui_pix); + properties.append(ppix); + } + + __item = __item->nextItem(); + } + + ui_widget->setElementItem(ui_items); + + return true; +} + +bool Q3IconViewExtraInfo::loadWidgetExtraInfo(DomWidget *ui_widget) +{ + Q3IconView *iconView = qobject_cast<Q3IconView*>(widget()); + Q_ASSERT(iconView != 0); + Q_UNUSED(iconView); + + if (ui_widget->elementItem().size()) { + initializeQ3IconViewItems(ui_widget->elementItem()); + } + + return true; +} + +void Q3IconViewExtraInfo::initializeQ3IconViewItems(const QList<DomItem *> &items) +{ + Q3IconView *iconView = qobject_cast<Q3IconView*>(widget()); + Q_ASSERT(iconView != 0); + + for (int i=0; i<items.size(); ++i) { + DomItem *item = items.at(i); + + Q3IconViewItem *__item = new Q3IconViewItem(iconView); + + QList<DomProperty*> properties = item->elementProperty(); + for (int i=0; i<properties.size(); ++i) { + DomProperty *p = properties.at(i); + if (p->attributeName() == QLatin1String("text")) + __item->setText(p->elementString()->text()); + + if (p->attributeName() == QLatin1String("pixmap")) { + DomResourcePixmap *pix = p->elementPixmap(); + QPixmap pixmap(core()->iconCache()->resolveQrcPath(pix->text(), pix->attributeResource(), workingDirectory())); + __item->setPixmap(pixmap); + } + } + } +} + + +Q3IconViewExtraInfoFactory::Q3IconViewExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent) + : QExtensionFactory(parent), m_core(core) +{} + +QObject *Q3IconViewExtraInfoFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const +{ + if (iid != Q_TYPEID(QDesignerExtraInfoExtension)) + return 0; + + if (Q3IconView *w = qobject_cast<Q3IconView*>(object)) + return new Q3IconViewExtraInfo(w, m_core, parent); + + return 0; +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3iconview/q3iconview_extrainfo.h b/tools/designer/src/plugins/widgets/q3iconview/q3iconview_extrainfo.h new file mode 100644 index 0000000000..bd07bf616e --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3iconview/q3iconview_extrainfo.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3ICONVIEW_EXTRAINFO_H +#define Q3ICONVIEW_EXTRAINFO_H + +#include <QtDesigner/QDesignerExtraInfoExtension> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/QExtensionFactory> + +#include <QtCore/QPointer> + +QT_BEGIN_NAMESPACE + +class Q3IconView; +class Q3IconViewItem; +class DomItem; + +class Q3IconViewExtraInfo: public QObject, public QDesignerExtraInfoExtension +{ + Q_OBJECT + Q_INTERFACES(QDesignerExtraInfoExtension) +public: + Q3IconViewExtraInfo(Q3IconView *widget, QDesignerFormEditorInterface *core, QObject *parent); + + virtual QWidget *widget() const; + virtual QDesignerFormEditorInterface *core() const; + + virtual bool saveUiExtraInfo(DomUI *ui); + virtual bool loadUiExtraInfo(DomUI *ui); + + virtual bool saveWidgetExtraInfo(DomWidget *ui_widget); + virtual bool loadWidgetExtraInfo(DomWidget *ui_widget); + + void initializeQ3IconViewItems(const QList<DomItem *> &items); + +private: + QPointer<Q3IconView> m_widget; + QPointer<QDesignerFormEditorInterface> m_core; +}; + +class Q3IconViewExtraInfoFactory: public QExtensionFactory +{ + Q_OBJECT +public: + Q3IconViewExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + +protected: + virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; + +private: + QDesignerFormEditorInterface *m_core; +}; + +QT_END_NAMESPACE + +#endif // Q3ICONVIEW_EXTRAINFO_H diff --git a/tools/designer/src/plugins/widgets/q3iconview/q3iconview_plugin.cpp b/tools/designer/src/plugins/widgets/q3iconview/q3iconview_plugin.cpp new file mode 100644 index 0000000000..6d85326d32 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3iconview/q3iconview_plugin.cpp @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3iconview_plugin.h" +#include "q3iconview_extrainfo.h" + +#include <QtDesigner/QExtensionFactory> +#include <QtDesigner/QExtensionManager> + +#include <QtCore/qplugin.h> +#include <QtGui/QIcon> +#include <Qt3Support/Q3IconView> + +QT_BEGIN_NAMESPACE + +Q3IconViewPlugin::Q3IconViewPlugin(const QIcon &icon, QObject *parent) + : QObject(parent), m_initialized(false), m_icon(icon) +{} + +QString Q3IconViewPlugin::name() const +{ return QLatin1String("Q3IconView"); } + +QString Q3IconViewPlugin::group() const +{ return QLatin1String("Qt 3 Support"); } + +QString Q3IconViewPlugin::toolTip() const +{ return QString(); } + +QString Q3IconViewPlugin::whatsThis() const +{ return QString(); } + +QString Q3IconViewPlugin::includeFile() const +{ return QLatin1String("q3iconview.h"); } + +QIcon Q3IconViewPlugin::icon() const +{ return m_icon; } + +bool Q3IconViewPlugin::isContainer() const +{ return false; } + +QWidget *Q3IconViewPlugin::createWidget(QWidget *parent) +{ return new Q3IconView(parent); } + +bool Q3IconViewPlugin::isInitialized() const +{ return m_initialized; } + +void Q3IconViewPlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + + if (m_initialized) + return; + + QExtensionManager *mgr = core->extensionManager(); + Q_ASSERT(mgr != 0); + + mgr->registerExtensions(new Q3IconViewExtraInfoFactory(core, mgr), Q_TYPEID(QDesignerExtraInfoExtension)); + + m_initialized = true; +} + +QString Q3IconViewPlugin::codeTemplate() const +{ return QString(); } + +QString Q3IconViewPlugin::domXml() const +{ return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"Q3IconView\" name=\"iconView\">\ + <property name=\"geometry\">\ + <rect>\ + <x>0</x>\ + <y>0</y>\ + <width>100</width>\ + <height>80</height>\ + </rect>\ + </property>\ + </widget>\ +</ui>"); +} + + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3iconview/q3iconview_plugin.h b/tools/designer/src/plugins/widgets/q3iconview/q3iconview_plugin.h new file mode 100644 index 0000000000..982bbf3489 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3iconview/q3iconview_plugin.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3ICONVIEW_PLUGIN_H +#define Q3ICONVIEW_PLUGIN_H + +#include <QtDesigner/QDesignerCustomWidgetInterface> + +QT_BEGIN_NAMESPACE + +class Q3IconViewPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3IconViewPlugin(const QIcon &icon, QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString codeTemplate() const; + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +QT_END_NAMESPACE + +#endif // Q3ICONVIEW_PLUGIN_H diff --git a/tools/designer/src/plugins/widgets/q3listbox/q3listbox_extrainfo.cpp b/tools/designer/src/plugins/widgets/q3listbox/q3listbox_extrainfo.cpp new file mode 100644 index 0000000000..36a6fc18ad --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3listbox/q3listbox_extrainfo.cpp @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3listbox_extrainfo.h" + +#include <QtDesigner/QDesignerIconCacheInterface> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/private/ui4_p.h> + +#include <Qt3Support/Q3ListBox> + +QT_BEGIN_NAMESPACE + +inline QHash<QString, DomProperty *> propertyMap(const QList<DomProperty *> &properties) // ### remove me +{ + QHash<QString, DomProperty *> map; + + for (int i=0; i<properties.size(); ++i) { + DomProperty *p = properties.at(i); + map.insert(p->attributeName(), p); + } + + return map; +} + +Q3ListBoxExtraInfo::Q3ListBoxExtraInfo(Q3ListBox *widget, QDesignerFormEditorInterface *core, QObject *parent) + : QObject(parent), m_widget(widget), m_core(core) +{} + +QWidget *Q3ListBoxExtraInfo::widget() const +{ return m_widget; } + +QDesignerFormEditorInterface *Q3ListBoxExtraInfo::core() const +{ return m_core; } + +bool Q3ListBoxExtraInfo::saveUiExtraInfo(DomUI *ui) +{ Q_UNUSED(ui); return false; } + +bool Q3ListBoxExtraInfo::loadUiExtraInfo(DomUI *ui) +{ Q_UNUSED(ui); return false; } + + +bool Q3ListBoxExtraInfo::saveWidgetExtraInfo(DomWidget *ui_widget) +{ + Q3ListBox *listBox = qobject_cast<Q3ListBox*>(widget()); + Q_ASSERT(listBox != 0); + + QList<DomItem *> items; + const int childCount = listBox->count(); + for (int i = 0; i < childCount; ++i) { + DomItem *item = new DomItem(); + + QList<DomProperty*> properties; + + DomString *str = new DomString(); + str->setText(listBox->text(i)); + + DomProperty *ptext = new DomProperty(); + ptext->setAttributeName(QLatin1String("text")); + ptext->setElementString(str); + + properties.append(ptext); + item->setElementProperty(properties); + items.append(item); + } + ui_widget->setElementItem(items); + + return true; +} + +bool Q3ListBoxExtraInfo::loadWidgetExtraInfo(DomWidget *ui_widget) +{ + Q3ListBox *listBox = qobject_cast<Q3ListBox*>(widget()); + Q_ASSERT(listBox != 0); + + QList<DomItem *> items = ui_widget->elementItem(); + for (int i = 0; i < items.size(); ++i) { + DomItem *item = items.at(i); + + QHash<QString, DomProperty*> properties = propertyMap(item->elementProperty()); + DomProperty *text = properties.value(QLatin1String("text")); + DomProperty *pixmap = properties.value(QLatin1String("pixmap")); + + QString txt = text->elementString()->text(); + + if (pixmap != 0) { + DomResourcePixmap *pix = pixmap->elementPixmap(); + QPixmap pixmap(core()->iconCache()->resolveQrcPath(pix->text(), pix->attributeResource(), workingDirectory())); + listBox->insertItem(pixmap, txt); + } else { + listBox->insertItem(txt); + } + } + + return true; +} + +Q3ListBoxExtraInfoFactory::Q3ListBoxExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent) + : QExtensionFactory(parent), m_core(core) +{} + +QObject *Q3ListBoxExtraInfoFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const +{ + if (iid != Q_TYPEID(QDesignerExtraInfoExtension)) + return 0; + + if (Q3ListBox *w = qobject_cast<Q3ListBox*>(object)) + return new Q3ListBoxExtraInfo(w, m_core, parent); + + return 0; +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3listbox/q3listbox_extrainfo.h b/tools/designer/src/plugins/widgets/q3listbox/q3listbox_extrainfo.h new file mode 100644 index 0000000000..ddfa83f7d2 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3listbox/q3listbox_extrainfo.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3LISTBOX_EXTRAINFO_H +#define Q3LISTBOX_EXTRAINFO_H + +#include <QtDesigner/QDesignerExtraInfoExtension> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/QExtensionFactory> + +#include <QtCore/QPointer> + +QT_BEGIN_NAMESPACE + +class Q3ListBox; +class Q3ListBoxItem; +class DomItem; + +class Q3ListBoxExtraInfo: public QObject, public QDesignerExtraInfoExtension +{ + Q_OBJECT + Q_INTERFACES(QDesignerExtraInfoExtension) +public: + Q3ListBoxExtraInfo(Q3ListBox *widget, QDesignerFormEditorInterface *core, QObject *parent); + + virtual QWidget *widget() const; + virtual QDesignerFormEditorInterface *core() const; + + virtual bool saveUiExtraInfo(DomUI *ui); + virtual bool loadUiExtraInfo(DomUI *ui); + + virtual bool saveWidgetExtraInfo(DomWidget *ui_widget); + virtual bool loadWidgetExtraInfo(DomWidget *ui_widget); + +private: + QPointer<Q3ListBox> m_widget; + QPointer<QDesignerFormEditorInterface> m_core; +}; + +class Q3ListBoxExtraInfoFactory: public QExtensionFactory +{ + Q_OBJECT +public: + Q3ListBoxExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + +protected: + virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; + +private: + QDesignerFormEditorInterface *m_core; +}; + +QT_END_NAMESPACE + +#endif // Q3LISTBOX_EXTRAINFO_H diff --git a/tools/designer/src/plugins/widgets/q3listbox/q3listbox_plugin.cpp b/tools/designer/src/plugins/widgets/q3listbox/q3listbox_plugin.cpp new file mode 100644 index 0000000000..ab383f52be --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3listbox/q3listbox_plugin.cpp @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3listbox_plugin.h" +#include "q3listbox_extrainfo.h" + +#include <QtDesigner/QExtensionFactory> +#include <QtDesigner/QExtensionManager> + +#include <QtCore/qplugin.h> +#include <QtGui/QIcon> +#include <Qt3Support/Q3ListBox> + +QT_BEGIN_NAMESPACE + +Q3ListBoxPlugin::Q3ListBoxPlugin(const QIcon &icon, QObject *parent) + : QObject(parent), m_initialized(false), m_icon(icon) +{} + +QString Q3ListBoxPlugin::name() const +{ return QLatin1String("Q3ListBox"); } + +QString Q3ListBoxPlugin::group() const +{ return QLatin1String("Qt 3 Support"); } + +QString Q3ListBoxPlugin::toolTip() const +{ return QString(); } + +QString Q3ListBoxPlugin::whatsThis() const +{ return QString(); } + +QString Q3ListBoxPlugin::includeFile() const +{ return QLatin1String("q3listbox.h"); } + +QIcon Q3ListBoxPlugin::icon() const +{ return m_icon; } + +bool Q3ListBoxPlugin::isContainer() const +{ return false; } + +QWidget *Q3ListBoxPlugin::createWidget(QWidget *parent) +{ return new Q3ListBox(parent); } + +bool Q3ListBoxPlugin::isInitialized() const +{ return m_initialized; } + +void Q3ListBoxPlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + + if (m_initialized) + return; + + QExtensionManager *mgr = core->extensionManager(); + Q_ASSERT(mgr != 0); + + mgr->registerExtensions(new Q3ListBoxExtraInfoFactory(core, mgr), Q_TYPEID(QDesignerExtraInfoExtension)); + + m_initialized = true; +} + +QString Q3ListBoxPlugin::codeTemplate() const +{ return QString(); } + +QString Q3ListBoxPlugin::domXml() const +{ return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"Q3ListBox\" name=\"listBox\">\ + <property name=\"geometry\">\ + <rect>\ + <x>0</x>\ + <y>0</y>\ + <width>100</width>\ + <height>80</height>\ + </rect>\ + </property>\ + </widget>\ +</ui>"); +} + + + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3listbox/q3listbox_plugin.h b/tools/designer/src/plugins/widgets/q3listbox/q3listbox_plugin.h new file mode 100644 index 0000000000..e48f8985e2 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3listbox/q3listbox_plugin.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3LISTBOX_PLUGIN_H +#define Q3LISTBOX_PLUGIN_H + +#include <QtDesigner/QDesignerCustomWidgetInterface> + +QT_BEGIN_NAMESPACE + +class Q3ListBoxPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3ListBoxPlugin(const QIcon &icon, QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString codeTemplate() const; + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +QT_END_NAMESPACE + +#endif // Q3LISTBOX_PLUGIN_H diff --git a/tools/designer/src/plugins/widgets/q3listview/q3listview_extrainfo.cpp b/tools/designer/src/plugins/widgets/q3listview/q3listview_extrainfo.cpp new file mode 100644 index 0000000000..8ba507ddf3 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3listview/q3listview_extrainfo.cpp @@ -0,0 +1,249 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3listview_extrainfo.h" + +#include <QtDesigner/QDesignerIconCacheInterface> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/private/ui4_p.h> + +#include <Qt3Support/Q3ListView> +#include <Qt3Support/Q3Header> + +QT_BEGIN_NAMESPACE + +inline QHash<QString, DomProperty *> propertyMap(const QList<DomProperty *> &properties) // ### remove me +{ + QHash<QString, DomProperty *> map; + + for (int i=0; i<properties.size(); ++i) { + DomProperty *p = properties.at(i); + map.insert(p->attributeName(), p); + } + + return map; +} + +Q3ListViewExtraInfo::Q3ListViewExtraInfo(Q3ListView *widget, QDesignerFormEditorInterface *core, QObject *parent) + : QObject(parent), m_widget(widget), m_core(core) +{} + +QWidget *Q3ListViewExtraInfo::widget() const +{ return m_widget; } + +QDesignerFormEditorInterface *Q3ListViewExtraInfo::core() const +{ return m_core; } + +bool Q3ListViewExtraInfo::saveUiExtraInfo(DomUI *ui) +{ Q_UNUSED(ui); return false; } + +bool Q3ListViewExtraInfo::loadUiExtraInfo(DomUI *ui) +{ Q_UNUSED(ui); return false; } + + +bool Q3ListViewExtraInfo::saveWidgetExtraInfo(DomWidget *ui_widget) +{ + // ### finish me + Q3ListView *listView = qobject_cast<Q3ListView*>(widget()); + Q_ASSERT(listView != 0); + + QList<DomColumn*> columns; + Q3Header *header = listView->header(); + for (int i=0; i<header->count(); ++i) { + DomColumn *c = new DomColumn(); + + QList<DomProperty*> properties; + + DomString *str = new DomString(); + str->setText(header->label(i)); + + DomProperty *ptext = new DomProperty(); + ptext->setAttributeName(QLatin1String("text")); + ptext->setElementString(str); + + DomProperty *pclickable = new DomProperty(); + pclickable->setAttributeName(QLatin1String("clickable")); + pclickable->setElementBool(header->isClickEnabled(i) ? QLatin1String("true") : QLatin1String("false")); + + DomProperty *presizable = new DomProperty(); + presizable->setAttributeName(QLatin1String("resizable")); + presizable->setElementBool(header->isResizeEnabled(i) ? QLatin1String("true") : QLatin1String("false")); + + properties.append(ptext); + properties.append(pclickable); + properties.append(presizable); + + c->setElementProperty(properties); + columns.append(c); + } + + ui_widget->setElementColumn(columns); + + QList<DomItem *> items; + Q3ListViewItem *child = listView->firstChild(); + while (child) { + items.append(saveQ3ListViewItem(child)); + child = child->nextSibling(); + } + ui_widget->setElementItem(items); + + + return true; +} + +bool Q3ListViewExtraInfo::loadWidgetExtraInfo(DomWidget *ui_widget) +{ + Q3ListView *listView = qobject_cast<Q3ListView*>(widget()); + Q_ASSERT(listView != 0); + + Q3Header *header = listView->header(); + + QList<DomColumn*> columns = ui_widget->elementColumn(); + for (int i=0; i<columns.size(); ++i) { + DomColumn *column = columns.at(i); + + QHash<QString, DomProperty*> properties = propertyMap(column->elementProperty()); + DomProperty *text = properties.value(QLatin1String("text")); + DomProperty *pixmap = properties.value(QLatin1String("pixmap")); + DomProperty *clickable = properties.value(QLatin1String("clickable")); + DomProperty *resizable = properties.value(QLatin1String("resizable")); + + QString txt = text->elementString()->text(); + + if (pixmap != 0) { + DomResourcePixmap *pix = pixmap->elementPixmap(); + QIcon icon(core()->iconCache()->resolveQrcPath(pix->text(), pix->attributeResource(), workingDirectory())); + listView->addColumn(icon, txt); + } else { + listView->addColumn(txt); + } + + if (clickable != 0) { + header->setClickEnabled(clickable->elementBool() == QLatin1String("true"), header->count() - 1); + } + + if (resizable != 0) { + header->setResizeEnabled(resizable->elementBool() == QLatin1String("true"), header->count() - 1); + } + } + + if (ui_widget->elementItem().size()) { + initializeQ3ListViewItems(ui_widget->elementItem()); + } + + return true; +} + +DomItem *Q3ListViewExtraInfo::saveQ3ListViewItem(Q3ListViewItem *item) const +{ + DomItem *pitem = new DomItem(); + QList<DomProperty *> properties; + const int columnCount = static_cast<Q3ListView*>(widget())->columns(); + for (int i = 0; i < columnCount; ++i) { + DomString *str = new DomString(); + str->setText(item->text(i)); + + DomProperty *ptext = new DomProperty(); + ptext->setAttributeName(QLatin1String("text")); + ptext->setElementString(str); + + properties.append(ptext); + } + pitem->setElementProperty(properties); + QList<DomItem *> items; + Q3ListViewItem *child = item->firstChild(); + while (child) { + items.append(saveQ3ListViewItem(child)); + child = child->nextSibling(); + } + pitem->setElementItem(items); + return pitem; +} + +void Q3ListViewExtraInfo::initializeQ3ListViewItems(const QList<DomItem *> &items, Q3ListViewItem *parentItem) +{ + for (int i=0; i<items.size(); ++i) { + DomItem *item = items.at(i); + + Q3ListViewItem *__item = 0; + if (parentItem != 0) + __item = new Q3ListViewItem(parentItem); + else + __item = new Q3ListViewItem(static_cast<Q3ListView*>(widget())); + + int textCount = 0, pixCount = 0; + QList<DomProperty*> properties = item->elementProperty(); + for (int i=0; i<properties.size(); ++i) { + DomProperty *p = properties.at(i); + if (p->attributeName() == QLatin1String("text")) + __item->setText(textCount++, p->elementString()->text()); + + if (p->attributeName() == QLatin1String("pixmap")) { + DomResourcePixmap *pix = p->elementPixmap(); + QPixmap pixmap(core()->iconCache()->resolveQrcPath(pix->text(), pix->attributeResource(), workingDirectory())); + __item->setPixmap(pixCount++, pixmap); + } + } + + if (item->elementItem().size()) { + __item->setOpen(true); + initializeQ3ListViewItems(item->elementItem(), __item); + } + } +} + + +Q3ListViewExtraInfoFactory::Q3ListViewExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent) + : QExtensionFactory(parent), m_core(core) +{} + +QObject *Q3ListViewExtraInfoFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const +{ + if (iid != Q_TYPEID(QDesignerExtraInfoExtension)) + return 0; + + if (Q3ListView *w = qobject_cast<Q3ListView*>(object)) + return new Q3ListViewExtraInfo(w, m_core, parent); + + return 0; +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3listview/q3listview_extrainfo.h b/tools/designer/src/plugins/widgets/q3listview/q3listview_extrainfo.h new file mode 100644 index 0000000000..15fb0dc734 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3listview/q3listview_extrainfo.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3LISTVIEW_EXTRAINFO_H +#define Q3LISTVIEW_EXTRAINFO_H + +#include <QtDesigner/QDesignerExtraInfoExtension> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/QExtensionFactory> + +#include <QtCore/QPointer> + +QT_BEGIN_NAMESPACE + +class Q3ListView; +class Q3ListViewItem; +class DomItem; + +class Q3ListViewExtraInfo: public QObject, public QDesignerExtraInfoExtension +{ + Q_OBJECT + Q_INTERFACES(QDesignerExtraInfoExtension) +public: + Q3ListViewExtraInfo(Q3ListView *widget, QDesignerFormEditorInterface *core, QObject *parent); + + virtual QWidget *widget() const; + virtual QDesignerFormEditorInterface *core() const; + + virtual bool saveUiExtraInfo(DomUI *ui); + virtual bool loadUiExtraInfo(DomUI *ui); + + virtual bool saveWidgetExtraInfo(DomWidget *ui_widget); + virtual bool loadWidgetExtraInfo(DomWidget *ui_widget); + + DomItem *saveQ3ListViewItem(Q3ListViewItem *item) const; + void initializeQ3ListViewItems(const QList<DomItem *> &items, Q3ListViewItem *parentItem = 0); + +private: + QPointer<Q3ListView> m_widget; + QPointer<QDesignerFormEditorInterface> m_core; +}; + +class Q3ListViewExtraInfoFactory: public QExtensionFactory +{ + Q_OBJECT +public: + Q3ListViewExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + +protected: + virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; + +private: + QDesignerFormEditorInterface *m_core; +}; + +QT_END_NAMESPACE + +#endif // Q3LISTVIEW_EXTRAINFO_H diff --git a/tools/designer/src/plugins/widgets/q3listview/q3listview_plugin.cpp b/tools/designer/src/plugins/widgets/q3listview/q3listview_plugin.cpp new file mode 100644 index 0000000000..16e417957d --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3listview/q3listview_plugin.cpp @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3listview_plugin.h" +#include "q3listview_extrainfo.h" + +#include <QtDesigner/QExtensionFactory> +#include <QtDesigner/QExtensionManager> + +#include <QtCore/qplugin.h> +#include <QtGui/QIcon> +#include <Qt3Support/Q3ListView> + +QT_BEGIN_NAMESPACE + +Q3ListViewPlugin::Q3ListViewPlugin(const QIcon &icon, QObject *parent) + : QObject(parent), m_initialized(false), m_icon(icon) +{} + +QString Q3ListViewPlugin::name() const +{ return QLatin1String("Q3ListView"); } + +QString Q3ListViewPlugin::group() const +{ return QLatin1String("Qt 3 Support"); } + +QString Q3ListViewPlugin::toolTip() const +{ return QString(); } + +QString Q3ListViewPlugin::whatsThis() const +{ return QString(); } + +QString Q3ListViewPlugin::includeFile() const +{ return QLatin1String("q3listview.h"); } + +QIcon Q3ListViewPlugin::icon() const +{ return m_icon; } + +bool Q3ListViewPlugin::isContainer() const +{ return false; } + +QWidget *Q3ListViewPlugin::createWidget(QWidget *parent) +{ return new Q3ListView(parent); } + +bool Q3ListViewPlugin::isInitialized() const +{ return m_initialized; } + +void Q3ListViewPlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + + if (m_initialized) + return; + + QExtensionManager *mgr = core->extensionManager(); + Q_ASSERT(mgr != 0); + + mgr->registerExtensions(new Q3ListViewExtraInfoFactory(core, mgr), Q_TYPEID(QDesignerExtraInfoExtension)); + + m_initialized = true; +} + +QString Q3ListViewPlugin::codeTemplate() const +{ return QString(); } + +QString Q3ListViewPlugin::domXml() const +{ return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"Q3ListView\" name=\"listView\">\ + <property name=\"geometry\">\ + <rect>\ + <x>0</x>\ + <y>0</y>\ + <width>100</width>\ + <height>80</height>\ + </rect>\ + </property>\ + </widget>\ +</ui>"); +} + + + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3listview/q3listview_plugin.h b/tools/designer/src/plugins/widgets/q3listview/q3listview_plugin.h new file mode 100644 index 0000000000..85e35c6367 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3listview/q3listview_plugin.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3LISTVIEW_PLUGIN_H +#define Q3LISTVIEW_PLUGIN_H + +#include <QtDesigner/QDesignerCustomWidgetInterface> + +QT_BEGIN_NAMESPACE + +class Q3ListViewPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3ListViewPlugin(const QIcon &icon, QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString codeTemplate() const; + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +QT_END_NAMESPACE + +#endif // Q3LISTVIEW_PLUGIN_H diff --git a/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_container.cpp b/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_container.cpp new file mode 100644 index 0000000000..f0bebd5d8d --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_container.cpp @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3mainwindow_container.h" + +#include <Qt3Support/Q3MainWindow> + +#include <QtCore/qdebug.h> +#include <QtGui/QToolBar> +#include <QtGui/QMenuBar> +#include <QtGui/QStatusBar> + +#include <Qt3Support/Q3ToolBar> + +QT_BEGIN_NAMESPACE + +Q3MainWindowContainer::Q3MainWindowContainer(Q3MainWindow *widget, QObject *parent) + : QObject(parent), + m_mainWindow(widget) +{} + +int Q3MainWindowContainer::count() const +{ + return m_widgets.count(); +} + +QWidget *Q3MainWindowContainer::widget(int index) const +{ + if (index == -1) + return 0; + + return m_widgets.at(index); +} + +int Q3MainWindowContainer::currentIndex() const +{ + return m_mainWindow->centralWidget() ? 0 : -1; +} + +void Q3MainWindowContainer::setCurrentIndex(int index) +{ + Q_UNUSED(index); +} + +void Q3MainWindowContainer::addWidget(QWidget *widget) +{ + if (qobject_cast<QToolBar*>(widget)) { + m_widgets.append(widget); + } else if (qobject_cast<Q3ToolBar*>(widget)) { + m_widgets.append(widget); + } else if (qobject_cast<QMenuBar*>(widget)) { + (void) m_mainWindow->menuBar(); + m_widgets.append(widget); + } else if (qobject_cast<QStatusBar*>(widget)) { + (void) m_mainWindow->statusBar(); + m_widgets.append(widget); + } else { + Q_ASSERT(m_mainWindow->centralWidget() == 0); + widget->setParent(m_mainWindow); + m_mainWindow->setCentralWidget(widget); + m_widgets.prepend(widget); + } +} + +void Q3MainWindowContainer::insertWidget(int index, QWidget *widget) +{ + m_widgets.insert(index, widget); +} + +void Q3MainWindowContainer::remove(int index) +{ + m_widgets.removeAt(index); +} + +Q3MainWindowContainerFactory::Q3MainWindowContainerFactory(QExtensionManager *parent) + : QExtensionFactory(parent) +{ +} + +QObject *Q3MainWindowContainerFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const +{ + if (iid != Q_TYPEID(QDesignerContainerExtension)) + return 0; + + if (Q3MainWindow *w = qobject_cast<Q3MainWindow*>(object)) + return new Q3MainWindowContainer(w, parent); + + return 0; +} + + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_container.h b/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_container.h new file mode 100644 index 0000000000..ad44265740 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_container.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3MAINWINDOW_CONTAINER_H +#define Q3MAINWINDOW_CONTAINER_H + +#include <QtDesigner/QDesignerContainerExtension> +#include <QtDesigner/QExtensionFactory> + +QT_BEGIN_NAMESPACE + +class Q3MainWindow; + +class Q3MainWindowContainer: public QObject, public QDesignerContainerExtension +{ + Q_OBJECT + Q_INTERFACES(QDesignerContainerExtension) +public: + explicit Q3MainWindowContainer(Q3MainWindow *widget, QObject *parent = 0); + + virtual int count() const; + virtual QWidget *widget(int index) const; + virtual int currentIndex() const; + virtual void setCurrentIndex(int index); + virtual void addWidget(QWidget *widget); + virtual void insertWidget(int index, QWidget *widget); + virtual void remove(int index); + +private: + Q3MainWindow *m_mainWindow; + QList<QWidget*> m_widgets; +}; + +class Q3MainWindowContainerFactory: public QExtensionFactory +{ + Q_OBJECT +public: + explicit Q3MainWindowContainerFactory(QExtensionManager *parent = 0); + +protected: + virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; +}; + +QT_END_NAMESPACE + +#endif // Q3MAINWINDOW_CONTAINER_H diff --git a/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_plugin.cpp b/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_plugin.cpp new file mode 100644 index 0000000000..dd21833cce --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_plugin.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3mainwindow_plugin.h" +#include "q3mainwindow_container.h" + +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/QExtensionManager> + +#include <QtCore/qplugin.h> +#include <Qt3Support/Q3MainWindow> + +QT_BEGIN_NAMESPACE + +Q3MainWindowPlugin::Q3MainWindowPlugin(const QIcon &icon, QObject *parent) + : QObject(parent), m_initialized(false), m_icon(icon) +{} + +QString Q3MainWindowPlugin::name() const +{ return QLatin1String("Q3MainWindow"); } + +QString Q3MainWindowPlugin::group() const +{ return QLatin1String("[invisible]"); } + +QString Q3MainWindowPlugin::toolTip() const +{ return QString(); } + +QString Q3MainWindowPlugin::whatsThis() const +{ return QString(); } + +QString Q3MainWindowPlugin::includeFile() const +{ return QLatin1String("q3mainwindow.h"); } + +QIcon Q3MainWindowPlugin::icon() const +{ return m_icon; } + +bool Q3MainWindowPlugin::isContainer() const +{ return true; } + +QWidget *Q3MainWindowPlugin::createWidget(QWidget *parent) +{ return new Q3MainWindow(parent); } + +bool Q3MainWindowPlugin::isInitialized() const +{ return m_initialized; } + +void Q3MainWindowPlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + + if (m_initialized) + return; + + m_initialized = true; + QExtensionManager *mgr = core->extensionManager(); + mgr->registerExtensions(new Q3MainWindowContainerFactory(mgr), Q_TYPEID(QDesignerContainerExtension)); +} + +QString Q3MainWindowPlugin::codeTemplate() const +{ return QString(); } + +QString Q3MainWindowPlugin::domXml() const +{ + return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"Q3MainWindow\" name=\"mainWindow\">\ + <property name=\"geometry\">\ + <rect>\ + <x>0</x>\ + <y>0</y>\ + <width>100</width>\ + <height>80</height>\ + </rect>\ + </property>\ + <widget class=\"QWidget\" name=\"centralWidget\" />\ + </widget>\ +</ui>"); +} + + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_plugin.h b/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_plugin.h new file mode 100644 index 0000000000..524506f567 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_plugin.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3MAINWINDOW_PLUGIN_H +#define Q3MAINWINDOW_PLUGIN_H + +#include <QtDesigner/QDesignerCustomWidgetInterface> + +QT_BEGIN_NAMESPACE + +class Q3MainWindowPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3MainWindowPlugin(const QIcon &icon, QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString codeTemplate() const; + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +QT_END_NAMESPACE + +#endif // Q3MAINWINDOW_PLUGIN_H diff --git a/tools/designer/src/plugins/widgets/q3table/q3table_extrainfo.cpp b/tools/designer/src/plugins/widgets/q3table/q3table_extrainfo.cpp new file mode 100644 index 0000000000..83534663ac --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3table/q3table_extrainfo.cpp @@ -0,0 +1,196 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3table_extrainfo.h" + +#include <QtDesigner/QDesignerIconCacheInterface> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/private/ui4_p.h> + +#include <Qt3Support/Q3Table> + +QT_BEGIN_NAMESPACE + +inline QHash<QString, DomProperty *> propertyMap(const QList<DomProperty *> &properties) // ### remove me +{ + QHash<QString, DomProperty *> map; + + for (int i=0; i<properties.size(); ++i) { + DomProperty *p = properties.at(i); + map.insert(p->attributeName(), p); + } + + return map; +} + +Q3TableExtraInfo::Q3TableExtraInfo(Q3Table *widget, QDesignerFormEditorInterface *core, QObject *parent) + : QObject(parent), m_widget(widget), m_core(core) +{} + +QWidget *Q3TableExtraInfo::widget() const +{ return m_widget; } + +QDesignerFormEditorInterface *Q3TableExtraInfo::core() const +{ return m_core; } + +bool Q3TableExtraInfo::saveUiExtraInfo(DomUI *ui) +{ Q_UNUSED(ui); return false; } + +bool Q3TableExtraInfo::loadUiExtraInfo(DomUI *ui) +{ Q_UNUSED(ui); return false; } + + +bool Q3TableExtraInfo::saveWidgetExtraInfo(DomWidget *ui_widget) +{ + Q_UNUSED(ui_widget); + + Q3Table *table = qobject_cast<Q3Table*>(widget()); + Q_ASSERT(table != 0); + + Q3Header *hHeader = table->horizontalHeader(); + + QList<DomColumn*> columns; + for (int i=0; i<hHeader->count(); ++i) { + DomColumn *column = new DomColumn(); + QList<DomProperty *> properties; + + DomProperty *property = new DomProperty(); + DomString *string = new DomString(); + string->setText(hHeader->label(i)); + property->setElementString(string); + property->setAttributeName("text"); + properties.append(property); + + column->setElementProperty(properties); + columns.append(column); + } + ui_widget->setElementColumn(columns); + + Q3Header *vHeader = table->verticalHeader(); + + QList<DomRow*> rows; + for (int i=0; i<vHeader->count(); ++i) { + DomRow *row = new DomRow(); + QList<DomProperty *> properties; + + DomProperty *property = new DomProperty(); + DomString *string = new DomString(); + string->setText(vHeader->label(i)); + property->setElementString(string); + property->setAttributeName("text"); + properties.append(property); + + row->setElementProperty(properties); + rows.append(row); + } + ui_widget->setElementRow(rows); + + return true; +} + +bool Q3TableExtraInfo::loadWidgetExtraInfo(DomWidget *ui_widget) +{ + Q_UNUSED(ui_widget); + + Q3Table *table = qobject_cast<Q3Table*>(widget()); + Q_ASSERT(table != 0); + + Q3Header *hHeader = table->horizontalHeader(); + + QList<DomColumn*> columns = ui_widget->elementColumn(); + for (int i=0; i<columns.size(); ++i) { + DomColumn *column = columns.at(i); + + QHash<QString, DomProperty*> properties = propertyMap(column->elementProperty()); + DomProperty *text = properties.value(QLatin1String("text")); + DomProperty *pixmap = properties.value(QLatin1String("pixmap")); + + QString txt = text->elementString()->text(); + + if (pixmap != 0) { + DomResourcePixmap *pix = pixmap->elementPixmap(); + QIcon icon(core()->iconCache()->resolveQrcPath(pix->text(), pix->attributeResource(), workingDirectory())); + hHeader->setLabel(i, icon, txt); + } else { + hHeader->setLabel(i, txt); + } + } + + Q3Header *vHeader = table->verticalHeader(); + + QList<DomRow*> rows = ui_widget->elementRow(); + for (int i=0; i<rows.size(); ++i) { + DomRow *row = rows.at(i); + + QHash<QString, DomProperty*> properties = propertyMap(row->elementProperty()); + DomProperty *text = properties.value(QLatin1String("text")); + DomProperty *pixmap = properties.value(QLatin1String("pixmap")); + + QString txt = text->elementString()->text(); + + if (pixmap != 0) { + DomResourcePixmap *pix = pixmap->elementPixmap(); + QIcon icon(core()->iconCache()->resolveQrcPath(pix->text(), pix->attributeResource(), workingDirectory())); + vHeader->setLabel(i, icon, txt); + } else { + vHeader->setLabel(i, txt); + } + } + + return true; +} + +Q3TableExtraInfoFactory::Q3TableExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent) + : QExtensionFactory(parent), m_core(core) +{} + +QObject *Q3TableExtraInfoFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const +{ + if (iid != Q_TYPEID(QDesignerExtraInfoExtension)) + return 0; + + if (Q3Table *w = qobject_cast<Q3Table*>(object)) + return new Q3TableExtraInfo(w, m_core, parent); + + return 0; +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3table/q3table_extrainfo.h b/tools/designer/src/plugins/widgets/q3table/q3table_extrainfo.h new file mode 100644 index 0000000000..6dc7a30051 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3table/q3table_extrainfo.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3TABLE_EXTRAINFO_H +#define Q3TABLE_EXTRAINFO_H + +#include <QtDesigner/QDesignerExtraInfoExtension> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/QExtensionFactory> + +#include <QtCore/QPointer> + +QT_BEGIN_NAMESPACE + +class Q3Table; +class Q3TableItem; +class DomItem; + +class Q3TableExtraInfo: public QObject, public QDesignerExtraInfoExtension +{ + Q_OBJECT + Q_INTERFACES(QDesignerExtraInfoExtension) +public: + Q3TableExtraInfo(Q3Table *widget, QDesignerFormEditorInterface *core, QObject *parent); + + virtual QWidget *widget() const; + virtual QDesignerFormEditorInterface *core() const; + + virtual bool saveUiExtraInfo(DomUI *ui); + virtual bool loadUiExtraInfo(DomUI *ui); + + virtual bool saveWidgetExtraInfo(DomWidget *ui_widget); + virtual bool loadWidgetExtraInfo(DomWidget *ui_widget); + +private: + QPointer<Q3Table> m_widget; + QPointer<QDesignerFormEditorInterface> m_core; +}; + +class Q3TableExtraInfoFactory: public QExtensionFactory +{ + Q_OBJECT +public: + Q3TableExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + +protected: + virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; + +private: + QDesignerFormEditorInterface *m_core; +}; + +QT_END_NAMESPACE + +#endif // Q3TABLE_EXTRAINFO_H diff --git a/tools/designer/src/plugins/widgets/q3table/q3table_plugin.cpp b/tools/designer/src/plugins/widgets/q3table/q3table_plugin.cpp new file mode 100644 index 0000000000..142a15b216 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3table/q3table_plugin.cpp @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3table_plugin.h" +#include "q3table_extrainfo.h" + +#include <QtDesigner/QExtensionFactory> +#include <QtDesigner/QExtensionManager> + +#include <QtCore/qplugin.h> +#include <QtGui/QIcon> +#include <Qt3Support/Q3Table> + +QT_BEGIN_NAMESPACE + +Q3TablePlugin::Q3TablePlugin(const QIcon &icon, QObject *parent) + : QObject(parent), m_initialized(false), m_icon(icon) +{} + +QString Q3TablePlugin::name() const +{ return QLatin1String("Q3Table"); } + +QString Q3TablePlugin::group() const +{ return QLatin1String("Qt 3 Support"); } + +QString Q3TablePlugin::toolTip() const +{ return QString(); } + +QString Q3TablePlugin::whatsThis() const +{ return QString(); } + +QString Q3TablePlugin::includeFile() const +{ return QLatin1String("q3table.h"); } + +QIcon Q3TablePlugin::icon() const +{ return m_icon; } + +bool Q3TablePlugin::isContainer() const +{ return false; } + +QWidget *Q3TablePlugin::createWidget(QWidget *parent) +{ return new Q3Table(parent); } + +bool Q3TablePlugin::isInitialized() const +{ return m_initialized; } + +void Q3TablePlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + + if (m_initialized) + return; + + QExtensionManager *mgr = core->extensionManager(); + Q_ASSERT(mgr != 0); + + mgr->registerExtensions(new Q3TableExtraInfoFactory(core, mgr), Q_TYPEID(QDesignerExtraInfoExtension)); + + m_initialized = true; +} + +QString Q3TablePlugin::codeTemplate() const +{ return QString(); } + +QString Q3TablePlugin::domXml() const +{ return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"Q3Table\" name=\"table\">\ + <property name=\"geometry\">\ + <rect>\ + <x>0</x>\ + <y>0</y>\ + <width>100</width>\ + <height>80</height>\ + </rect>\ + </property>\ + </widget>\ +</ui>"); +} + + + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3table/q3table_plugin.h b/tools/designer/src/plugins/widgets/q3table/q3table_plugin.h new file mode 100644 index 0000000000..0a23e97aa9 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3table/q3table_plugin.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3TABLE_PLUGIN_H +#define Q3TABLE_PLUGIN_H + +#include <QtDesigner/QDesignerCustomWidgetInterface> + +QT_BEGIN_NAMESPACE + +class Q3TablePlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3TablePlugin(const QIcon &icon, QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString codeTemplate() const; + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +QT_END_NAMESPACE + +#endif // Q3TABLE_PLUGIN_H diff --git a/tools/designer/src/plugins/widgets/q3textedit/q3textedit_extrainfo.cpp b/tools/designer/src/plugins/widgets/q3textedit/q3textedit_extrainfo.cpp new file mode 100644 index 0000000000..f60c395281 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3textedit/q3textedit_extrainfo.cpp @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3textedit_extrainfo.h" + +#include <QtDesigner/QDesignerIconCacheInterface> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/private/ui4_p.h> + +#include <Qt3Support/Q3TextEdit> + +QT_BEGIN_NAMESPACE + +inline QHash<QString, DomProperty *> propertyMap(const QList<DomProperty *> &properties) // ### remove me +{ + QHash<QString, DomProperty *> map; + + for (int i=0; i<properties.size(); ++i) { + DomProperty *p = properties.at(i); + map.insert(p->attributeName(), p); + } + + return map; +} + +Q3TextEditExtraInfo::Q3TextEditExtraInfo(Q3TextEdit *widget, QDesignerFormEditorInterface *core, QObject *parent) + : QObject(parent), m_widget(widget), m_core(core) +{} + +QWidget *Q3TextEditExtraInfo::widget() const +{ return m_widget; } + +QDesignerFormEditorInterface *Q3TextEditExtraInfo::core() const +{ return m_core; } + +bool Q3TextEditExtraInfo::saveUiExtraInfo(DomUI *ui) +{ Q_UNUSED(ui); return false; } + +bool Q3TextEditExtraInfo::loadUiExtraInfo(DomUI *ui) +{ Q_UNUSED(ui); return false; } + + +bool Q3TextEditExtraInfo::saveWidgetExtraInfo(DomWidget *ui_widget) +{ + Q_UNUSED(ui_widget); + + Q3TextEdit *textEdit = qobject_cast<Q3TextEdit*>(widget()); + Q_ASSERT(textEdit != 0); + Q_UNUSED(textEdit); + return true; +} + +bool Q3TextEditExtraInfo::loadWidgetExtraInfo(DomWidget *ui_widget) +{ + Q_UNUSED(ui_widget); + + Q3TextEdit *textEdit = qobject_cast<Q3TextEdit*>(widget()); + Q_ASSERT(textEdit != 0); + Q_UNUSED(textEdit); + return true; +} + +Q3TextEditExtraInfoFactory::Q3TextEditExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent) + : QExtensionFactory(parent), m_core(core) +{} + +QObject *Q3TextEditExtraInfoFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const +{ + if (iid != Q_TYPEID(QDesignerExtraInfoExtension)) + return 0; + + if (Q3TextEdit *w = qobject_cast<Q3TextEdit*>(object)) + return new Q3TextEditExtraInfo(w, m_core, parent); + + return 0; +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3textedit/q3textedit_extrainfo.h b/tools/designer/src/plugins/widgets/q3textedit/q3textedit_extrainfo.h new file mode 100644 index 0000000000..3ccc211802 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3textedit/q3textedit_extrainfo.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3TEXTEDIT_EXTRAINFO_H +#define Q3TEXTEDIT_EXTRAINFO_H + +#include <QtDesigner/QDesignerExtraInfoExtension> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/QExtensionFactory> + +#include <QtCore/QPointer> + +QT_BEGIN_NAMESPACE + +class Q3TextEdit; +class Q3TextEditItem; +class DomItem; + +class Q3TextEditExtraInfo: public QObject, public QDesignerExtraInfoExtension +{ + Q_OBJECT + Q_INTERFACES(QDesignerExtraInfoExtension) +public: + Q3TextEditExtraInfo(Q3TextEdit *widget, QDesignerFormEditorInterface *core, QObject *parent); + + virtual QWidget *widget() const; + virtual QDesignerFormEditorInterface *core() const; + + virtual bool saveUiExtraInfo(DomUI *ui); + virtual bool loadUiExtraInfo(DomUI *ui); + + virtual bool saveWidgetExtraInfo(DomWidget *ui_widget); + virtual bool loadWidgetExtraInfo(DomWidget *ui_widget); + +private: + QPointer<Q3TextEdit> m_widget; + QPointer<QDesignerFormEditorInterface> m_core; +}; + +class Q3TextEditExtraInfoFactory: public QExtensionFactory +{ + Q_OBJECT +public: + Q3TextEditExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + +protected: + virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; + +private: + QDesignerFormEditorInterface *m_core; +}; + +QT_END_NAMESPACE + +#endif // Q3TEXTEDIT_EXTRAINFO_H diff --git a/tools/designer/src/plugins/widgets/q3textedit/q3textedit_plugin.cpp b/tools/designer/src/plugins/widgets/q3textedit/q3textedit_plugin.cpp new file mode 100644 index 0000000000..804c4cd4c2 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3textedit/q3textedit_plugin.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 Qt Designer 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 "q3textedit_plugin.h" +#include "q3textedit_extrainfo.h" + +#include <QtDesigner/QExtensionFactory> +#include <QtDesigner/QExtensionManager> + +#include <QtCore/qplugin.h> +#include <QtGui/QIcon> +#include <Qt3Support/Q3TextEdit> + +QT_BEGIN_NAMESPACE + +Q3TextEditPlugin::Q3TextEditPlugin(const QIcon &icon, QObject *parent) + : QObject(parent), m_initialized(false), m_icon(icon) +{} + +QString Q3TextEditPlugin::name() const +{ return QLatin1String("Q3TextEdit"); } + +QString Q3TextEditPlugin::group() const +{ return QLatin1String("Qt 3 Support"); } + +QString Q3TextEditPlugin::toolTip() const +{ return QString(); } + +QString Q3TextEditPlugin::whatsThis() const +{ return QString(); } + +QString Q3TextEditPlugin::includeFile() const +{ return QLatin1String("q3textedit.h"); } + +QIcon Q3TextEditPlugin::icon() const +{ return m_icon; } + + +bool Q3TextEditPlugin::isContainer() const +{ return false; } + +QWidget *Q3TextEditPlugin::createWidget(QWidget *parent) +{ return new Q3TextEdit(parent); } + +bool Q3TextEditPlugin::isInitialized() const +{ return m_initialized; } + +void Q3TextEditPlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + + if (m_initialized) + return; + + QExtensionManager *mgr = core->extensionManager(); + Q_ASSERT(mgr != 0); + + mgr->registerExtensions(new Q3TextEditExtraInfoFactory(core, mgr), Q_TYPEID(QDesignerExtraInfoExtension)); + + m_initialized = true; +} + +QString Q3TextEditPlugin::codeTemplate() const +{ return QString(); } + +QString Q3TextEditPlugin::domXml() const +{ return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"Q3TextEdit\" name=\"textEdit\">\ + <property name=\"geometry\">\ + <rect>\ + <x>0</x>\ + <y>0</y>\ + <width>100</width>\ + <height>80</height>\ + </rect>\ + </property>\ + </widget>\ +</ui>"); +} + + + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3textedit/q3textedit_plugin.h b/tools/designer/src/plugins/widgets/q3textedit/q3textedit_plugin.h new file mode 100644 index 0000000000..7ab94c7d71 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3textedit/q3textedit_plugin.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3TEXTEDIT_PLUGIN_H +#define Q3TEXTEDIT_PLUGIN_H + +#include <QtDesigner/QDesignerCustomWidgetInterface> + +QT_BEGIN_NAMESPACE + +class Q3TextEditPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3TextEditPlugin(const QIcon &icon, QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString codeTemplate() const; + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +QT_END_NAMESPACE + +#endif // Q3TEXTEDIT_PLUGIN_H diff --git a/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_extrainfo.cpp b/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_extrainfo.cpp new file mode 100644 index 0000000000..0ad538c7ac --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_extrainfo.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3toolbar_extrainfo.h" + +#include <QtDesigner/QDesignerIconCacheInterface> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/private/ui4_p.h> + +#include <Qt3Support/Q3ToolBar> + +QT_BEGIN_NAMESPACE + +inline QHash<QString, DomProperty *> propertyMap(const QList<DomProperty *> &properties) // ### remove me +{ + QHash<QString, DomProperty *> map; + + for (int i=0; i<properties.size(); ++i) { + DomProperty *p = properties.at(i); + map.insert(p->attributeName(), p); + } + + return map; +} + +Q3ToolBarExtraInfo::Q3ToolBarExtraInfo(Q3ToolBar *widget, QDesignerFormEditorInterface *core, QObject *parent) + : QObject(parent), m_widget(widget), m_core(core) +{} + +QWidget *Q3ToolBarExtraInfo::widget() const +{ return m_widget; } + +QDesignerFormEditorInterface *Q3ToolBarExtraInfo::core() const +{ return m_core; } + +bool Q3ToolBarExtraInfo::saveUiExtraInfo(DomUI *ui) +{ Q_UNUSED(ui); return false; } + +bool Q3ToolBarExtraInfo::loadUiExtraInfo(DomUI *ui) +{ Q_UNUSED(ui); return false; } + + +bool Q3ToolBarExtraInfo::saveWidgetExtraInfo(DomWidget *ui_widget) +{ + Q_UNUSED(ui_widget); + return true; +} + +bool Q3ToolBarExtraInfo::loadWidgetExtraInfo(DomWidget *ui_widget) +{ + Q_UNUSED(ui_widget); + return true; +} + +Q3ToolBarExtraInfoFactory::Q3ToolBarExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent) + : QExtensionFactory(parent), m_core(core) +{} + +QObject *Q3ToolBarExtraInfoFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const +{ + if (iid != Q_TYPEID(QDesignerExtraInfoExtension)) + return 0; + + if (Q3ToolBar *w = qobject_cast<Q3ToolBar*>(object)) + return new Q3ToolBarExtraInfo(w, m_core, parent); + + return 0; +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_extrainfo.h b/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_extrainfo.h new file mode 100644 index 0000000000..c2e3c54aeb --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_extrainfo.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3TOOLBAR_EXTRAINFO_H +#define Q3TOOLBAR_EXTRAINFO_H + +#include <QtDesigner/QDesignerExtraInfoExtension> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/QExtensionFactory> + +#include <QtCore/QPointer> + +QT_BEGIN_NAMESPACE + +class Q3ToolBar; +class DomItem; + +class Q3ToolBarExtraInfo: public QObject, public QDesignerExtraInfoExtension +{ + Q_OBJECT + Q_INTERFACES(QDesignerExtraInfoExtension) +public: + Q3ToolBarExtraInfo(Q3ToolBar *widget, QDesignerFormEditorInterface *core, QObject *parent); + + virtual QWidget *widget() const; + virtual QDesignerFormEditorInterface *core() const; + + virtual bool saveUiExtraInfo(DomUI *ui); + virtual bool loadUiExtraInfo(DomUI *ui); + + virtual bool saveWidgetExtraInfo(DomWidget *ui_widget); + virtual bool loadWidgetExtraInfo(DomWidget *ui_widget); + +private: + QPointer<Q3ToolBar> m_widget; + QPointer<QDesignerFormEditorInterface> m_core; +}; + +class Q3ToolBarExtraInfoFactory: public QExtensionFactory +{ + Q_OBJECT +public: + Q3ToolBarExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + +protected: + virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; + +private: + QDesignerFormEditorInterface *m_core; +}; + +QT_END_NAMESPACE + +#endif // Q3TOOLBAR_EXTRAINFO_H diff --git a/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_plugin.cpp b/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_plugin.cpp new file mode 100644 index 0000000000..1f5debe91b --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_plugin.cpp @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3toolbar_plugin.h" +#include "q3toolbar_extrainfo.h" + +#include <QtDesigner/QExtensionFactory> +#include <QtDesigner/QExtensionManager> + +#include <QtCore/qplugin.h> +#include <QtGui/QIcon> +#include <QtCore/QDebug> + +#include <Qt3Support/Q3MainWindow> +#include <Qt3Support/Q3ToolBar> +#include <QtGui/QMainWindow> +#include <QtGui/QToolBar> + +QT_BEGIN_NAMESPACE + +Q3ToolBarPlugin::Q3ToolBarPlugin(const QIcon &icon, QObject *parent) + : QObject(parent), m_initialized(false), m_icon(icon) +{} + +QString Q3ToolBarPlugin::name() const +{ return QLatin1String("Q3ToolBar"); } + +QString Q3ToolBarPlugin::group() const +{ return QLatin1String("Qt 3 Support"); } + +QString Q3ToolBarPlugin::toolTip() const +{ return QString(); } + +QString Q3ToolBarPlugin::whatsThis() const +{ return QString(); } + +QString Q3ToolBarPlugin::includeFile() const +{ return QLatin1String("q3listview.h"); } + +QIcon Q3ToolBarPlugin::icon() const +{ return m_icon; } + +bool Q3ToolBarPlugin::isContainer() const +{ return false; } + +QWidget *Q3ToolBarPlugin::createWidget(QWidget *parent) +{ + if (!parent) + return new Q3ToolBar; + // If there is a parent, it must be a Q3MainWindow + if (Q3MainWindow *mw3 = qobject_cast<Q3MainWindow*>(parent)) + return new Q3ToolBar(mw3); + // Somebody hacked up a form? + if (QMainWindow *mw4 = qobject_cast<QMainWindow*>(parent)) { + qDebug() << "*** WARNING QMainWindow was passed as a parent widget of Q3ToolBar. Creating a QToolBar..."; + return new QToolBar(mw4); + } + // Can't be helped + const QString msg = QString::fromUtf8("*** WARNING Parent widget of Q3ToolBar must be a Q3MainWindow (%1)!").arg(QLatin1String(parent->metaObject()->className())); + qDebug() << msg; + return 0; +} + +bool Q3ToolBarPlugin::isInitialized() const +{ return m_initialized; } + +void Q3ToolBarPlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + + if (m_initialized) + return; + + QExtensionManager *mgr = core->extensionManager(); + Q_ASSERT(mgr != 0); + + mgr->registerExtensions(new Q3ToolBarExtraInfoFactory(core, mgr), Q_TYPEID(QDesignerExtraInfoExtension)); + + m_initialized = true; +} + +QString Q3ToolBarPlugin::codeTemplate() const +{ return QString(); } + +QString Q3ToolBarPlugin::domXml() const +{ return QString(); } + + + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_plugin.h b/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_plugin.h new file mode 100644 index 0000000000..7cb85bb814 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_plugin.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3TOOLBAR_PLUGIN_H +#define Q3TOOLBAR_PLUGIN_H + +#include <QtDesigner/QDesignerCustomWidgetInterface> + +QT_BEGIN_NAMESPACE + +class Q3ToolBarPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3ToolBarPlugin(const QIcon &icon, QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString codeTemplate() const; + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +QT_END_NAMESPACE + +#endif // Q3TOOLBAR_PLUGIN_H diff --git a/tools/designer/src/plugins/widgets/q3widgets/q3widget_plugins.cpp b/tools/designer/src/plugins/widgets/q3widgets/q3widget_plugins.cpp new file mode 100644 index 0000000000..faf3da6956 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3widgets/q3widget_plugins.cpp @@ -0,0 +1,601 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3widget_plugins.h" + +#include <QtCore/qplugin.h> +#include <QtGui/QIcon> +#include <QtGui/QLayout> +#include <Qt3Support/Q3ButtonGroup> +#include <Qt3Support/Q3ComboBox> +#include <Qt3Support/Q3DateEdit> +#include <Qt3Support/Q3DateTimeEdit> +#include <Qt3Support/Q3Frame> +#include <Qt3Support/Q3GroupBox> +#include <Qt3Support/Q3ProgressBar> +#include <Qt3Support/Q3TextBrowser> +#include <Qt3Support/Q3TimeEdit> + +static const char *groupNameC = "Qt 3 Support"; + +QT_BEGIN_NAMESPACE + +Q3ButtonGroupPlugin::Q3ButtonGroupPlugin(const QIcon &icon, QObject *parent) : + QObject(parent), + m_initialized(false), + m_icon(icon) +{ +} + +Q3ButtonGroupPlugin::~Q3ButtonGroupPlugin() +{ +} + +QString Q3ButtonGroupPlugin::name() const +{ + return QLatin1String("Q3ButtonGroup"); +} + +QString Q3ButtonGroupPlugin::group() const +{ + return QLatin1String(groupNameC); +} + +QString Q3ButtonGroupPlugin::toolTip() const +{ + return QString(); +} + +QString Q3ButtonGroupPlugin::whatsThis() const +{ + return QString(); +} + +QString Q3ButtonGroupPlugin::includeFile() const +{ + return QLatin1String("Qt3Support/Q3ButtonGroup"); +} + +QIcon Q3ButtonGroupPlugin::icon() const +{ + return m_icon; +} + +bool Q3ButtonGroupPlugin::isContainer() const +{ + return true; +} + +QWidget *Q3ButtonGroupPlugin::createWidget(QWidget *parent) +{ + Q3ButtonGroup *g = new Q3ButtonGroup(parent); + g->setColumnLayout(0, Qt::Vertical); + g->setInsideMargin(0); + g->layout()->setSpacing(-1); + return g; +} + +bool Q3ButtonGroupPlugin::isInitialized() const +{ + return m_initialized; +} + +void Q3ButtonGroupPlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + m_initialized = true; +} + +QString Q3ButtonGroupPlugin::domXml() const +{ + return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"Q3ButtonGroup\" name=\"buttonGroup\">\ + <property name=\"geometry\">\ + <rect>\ + <x>0</x>\ + <y>0</y>\ + <width>100</width>\ + <height>80</height>\ + </rect>\ + </property>\ + </widget>\ +</ui>"); +} + +Q3ComboBoxPlugin::Q3ComboBoxPlugin(const QIcon &icon, QObject *parent) : + QObject(parent), + m_initialized(false), + m_icon(icon) +{ +} + +Q3ComboBoxPlugin::~Q3ComboBoxPlugin() +{ +} + +QString Q3ComboBoxPlugin::name() const +{ + return QLatin1String("Q3ComboBox"); +} + +QString Q3ComboBoxPlugin::group() const +{ + return QLatin1String(groupNameC); +} + +QString Q3ComboBoxPlugin::toolTip() const +{ + return QString(); +} + +QString Q3ComboBoxPlugin::whatsThis() const +{ + return QString(); +} + +QString Q3ComboBoxPlugin::includeFile() const +{ + return QLatin1String("Qt3Support/Q3ComboBox"); +} + +QIcon Q3ComboBoxPlugin::icon() const +{ + return m_icon; +} + +bool Q3ComboBoxPlugin::isContainer() const +{ + return false; +} + +QWidget *Q3ComboBoxPlugin::createWidget(QWidget *parent) +{ + return new Q3ComboBox(parent); +} + +bool Q3ComboBoxPlugin::isInitialized() const +{ + return m_initialized; +} + +QString Q3ComboBoxPlugin::domXml() const +{ + return QLatin1String("\ +<ui language=\"c++\">\ +<widget class=\"Q3ComboBox\" name=\"comboBox\"/>\ +</ui>"); +} + +void Q3ComboBoxPlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + m_initialized = true; +} + +Q3DateEditPlugin::Q3DateEditPlugin(const QIcon &icon, QObject *parent) + : QObject(parent), m_initialized(false), m_icon(icon) +{} + +QString Q3DateEditPlugin::name() const +{ return QLatin1String("Q3DateEdit"); } + +QString Q3DateEditPlugin::group() const +{ return QLatin1String(groupNameC); } + +QString Q3DateEditPlugin::toolTip() const +{ return QString(); } + +QString Q3DateEditPlugin::whatsThis() const +{ return QString(); } + +QString Q3DateEditPlugin::includeFile() const +{ return QLatin1String("Qt3Support/Q3DateEdit"); } + +QIcon Q3DateEditPlugin::icon() const +{ return m_icon; } + +bool Q3DateEditPlugin::isContainer() const +{ return false; } + +QWidget *Q3DateEditPlugin::createWidget(QWidget *parent) +{ return new Q3DateEdit(parent); } + +bool Q3DateEditPlugin::isInitialized() const +{ return m_initialized; } + +void Q3DateEditPlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + m_initialized = true; +} + +QString Q3DateEditPlugin::domXml() const +{ + return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"Q3DateEdit\" name=\"dateEdit\"/>\ +</ui>"); +} + +Q3DateTimeEditPlugin::Q3DateTimeEditPlugin(const QIcon &icon, QObject *parent) + : QObject(parent), m_initialized(false), m_icon(icon) +{} + +QString Q3DateTimeEditPlugin::name() const +{ return QLatin1String("Q3DateTimeEdit"); } + +QString Q3DateTimeEditPlugin::group() const +{ return QLatin1String(groupNameC); } + +QString Q3DateTimeEditPlugin::toolTip() const +{ return QString(); } + +QString Q3DateTimeEditPlugin::whatsThis() const +{ return QString(); } + +QString Q3DateTimeEditPlugin::includeFile() const +{ return QLatin1String("Qt3Support/Q3DateTimeEdit"); } + +QIcon Q3DateTimeEditPlugin::icon() const +{ return m_icon; } + +bool Q3DateTimeEditPlugin::isContainer() const +{ return false; } + +QWidget *Q3DateTimeEditPlugin::createWidget(QWidget *parent) +{ return new Q3DateTimeEdit(parent); } + +bool Q3DateTimeEditPlugin::isInitialized() const +{ return m_initialized; } + +void Q3DateTimeEditPlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + m_initialized = true; +} + +QString Q3DateTimeEditPlugin::domXml() const +{ + return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"Q3DateTimeEdit\" name=\"dateTimeEdit\"/>\ +</ui>"); +} + +Q3FramePlugin::Q3FramePlugin(const QIcon &icon, QObject *parent) + : QObject(parent), + m_initialized(false), + m_icon(icon) +{ +} + +Q3FramePlugin::~Q3FramePlugin() +{ +} + +QString Q3FramePlugin::name() const +{ + return QLatin1String("Q3Frame"); +} + +QString Q3FramePlugin::group() const +{ + return QLatin1String(groupNameC); +} + +QString Q3FramePlugin::toolTip() const +{ + return QString(); +} + +QString Q3FramePlugin::whatsThis() const +{ + return QString(); +} + +QString Q3FramePlugin::includeFile() const +{ + return QLatin1String("Qt3Support/Q3Frame"); +} + +QIcon Q3FramePlugin::icon() const +{ + return m_icon; +} + +bool Q3FramePlugin::isContainer() const +{ + return true; +} + +QWidget *Q3FramePlugin::createWidget(QWidget *parent) +{ + return new Q3Frame(parent); +} + +bool Q3FramePlugin::isInitialized() const +{ + return m_initialized; +} + +void Q3FramePlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + m_initialized = true; +} + +QString Q3FramePlugin::domXml() const +{ + return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"Q3Frame\" name=\"frame\">\ + <property name=\"geometry\">\ + <rect>\ + <x>0</x>\ + <y>0</y>\ + <width>100</width>\ + <height>80</height>\ + </rect>\ + </property>\ + </widget>\ +</ui>"); +} + +Q3GroupBoxPlugin::Q3GroupBoxPlugin(const QIcon &icon, QObject *parent) + : QObject(parent), + m_initialized(false), + m_icon(icon) +{ +} + +Q3GroupBoxPlugin::~Q3GroupBoxPlugin() +{ +} + +QString Q3GroupBoxPlugin::name() const +{ + return QLatin1String("Q3GroupBox"); +} + +QString Q3GroupBoxPlugin::group() const +{ + return QLatin1String(groupNameC); +} + +QString Q3GroupBoxPlugin::toolTip() const +{ + return QString(); +} + +QString Q3GroupBoxPlugin::whatsThis() const +{ + return QString(); +} + +QString Q3GroupBoxPlugin::includeFile() const +{ + return QLatin1String("Qt3Support/Q3GroupBox"); +} + +QIcon Q3GroupBoxPlugin::icon() const +{ + return m_icon; +} + +bool Q3GroupBoxPlugin::isContainer() const +{ + return true; +} + +QWidget *Q3GroupBoxPlugin::createWidget(QWidget *parent) +{ + Q3GroupBox *g = new Q3GroupBox(parent); + g->setColumnLayout(0, Qt::Vertical); + g->setInsideMargin(0); + g->layout()->setSpacing(-1); + return g; +} + +bool Q3GroupBoxPlugin::isInitialized() const +{ + return m_initialized; +} + +void Q3GroupBoxPlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + m_initialized = true; +} + +QString Q3GroupBoxPlugin::domXml() const +{ + return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"Q3GroupBox\" name=\"groupBox\">\ + <property name=\"geometry\">\ + <rect>\ + <x>0</x>\ + <y>0</y>\ + <width>100</width>\ + <height>80</height>\ + </rect>\ + </property>\ + </widget>\ +</ui>"); +} + +Q3ProgressBarPlugin::Q3ProgressBarPlugin(const QIcon &icon, QObject *parent) + : QObject(parent), m_initialized(false), m_icon(icon) +{} + +QString Q3ProgressBarPlugin::name() const +{ return QLatin1String("Q3ProgressBar"); } + +QString Q3ProgressBarPlugin::group() const +{ return QLatin1String(groupNameC); } + +QString Q3ProgressBarPlugin::toolTip() const +{ return QString(); } + +QString Q3ProgressBarPlugin::whatsThis() const +{ return QString(); } + +QString Q3ProgressBarPlugin::includeFile() const +{ return QLatin1String("Qt3Support/Q3ProgressBar"); } + +QIcon Q3ProgressBarPlugin::icon() const +{ return m_icon; } + +bool Q3ProgressBarPlugin::isContainer() const +{ return false; } + +QWidget *Q3ProgressBarPlugin::createWidget(QWidget *parent) +{ return new Q3ProgressBar(parent); } + +bool Q3ProgressBarPlugin::isInitialized() const +{ return m_initialized; } + +void Q3ProgressBarPlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + m_initialized = true; +} + +QString Q3ProgressBarPlugin::domXml() const +{ + return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"Q3ProgressBar\" name=\"progressBar\"/>\ +</ui>"); +} + +Q3TextBrowserPlugin::Q3TextBrowserPlugin(const QIcon &icon, QObject *parent) + : QObject(parent), m_initialized(false), m_icon(icon) +{} + +QString Q3TextBrowserPlugin::name() const +{ return QLatin1String("Q3TextBrowser"); } + +QString Q3TextBrowserPlugin::group() const +{ return QLatin1String(groupNameC); } + +QString Q3TextBrowserPlugin::toolTip() const +{ return QString(); } + +QString Q3TextBrowserPlugin::whatsThis() const +{ return QString(); } + +QString Q3TextBrowserPlugin::includeFile() const +{ return QLatin1String("Qt3Support/Q3TextBrowser"); } + +QIcon Q3TextBrowserPlugin::icon() const +{ return m_icon; } + +bool Q3TextBrowserPlugin::isContainer() const +{ return false; } + +QWidget *Q3TextBrowserPlugin::createWidget(QWidget *parent) +{ return new Q3TextBrowser(parent); } + +bool Q3TextBrowserPlugin::isInitialized() const +{ return m_initialized; } + +void Q3TextBrowserPlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + m_initialized = true; +} + +QString Q3TextBrowserPlugin::domXml() const +{ + return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"Q3TextBrowser\" name=\"textBrowser\"/>\ +</ui>"); +} + +Q3TimeEditPlugin::Q3TimeEditPlugin(const QIcon &icon, QObject *parent) + : QObject(parent), m_initialized(false), m_icon(icon) +{} + +QString Q3TimeEditPlugin::name() const +{ return QLatin1String("Q3TimeEdit"); } + +QString Q3TimeEditPlugin::group() const +{ return QLatin1String(groupNameC); } + +QString Q3TimeEditPlugin::toolTip() const +{ return QString(); } + +QString Q3TimeEditPlugin::whatsThis() const +{ return QString(); } + +QString Q3TimeEditPlugin::includeFile() const +{ return QLatin1String("Qt3Support/Q3TimeEdit"); } + +QIcon Q3TimeEditPlugin::icon() const +{ return m_icon; } + +bool Q3TimeEditPlugin::isContainer() const +{ return false; } + +QWidget *Q3TimeEditPlugin::createWidget(QWidget *parent) +{ return new Q3TimeEdit(parent); } + +bool Q3TimeEditPlugin::isInitialized() const +{ return m_initialized; } + +void Q3TimeEditPlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + m_initialized = true; +} + +QString Q3TimeEditPlugin::domXml() const +{ + return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"Q3TimeEdit\" name=\"timeEdit\"/>\ +</ui>"); +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3widgets/q3widget_plugins.h b/tools/designer/src/plugins/widgets/q3widgets/q3widget_plugins.h new file mode 100644 index 0000000000..76a14c50a3 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3widgets/q3widget_plugins.h @@ -0,0 +1,287 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3WIDGET_PLUGINS_H +#define Q3WIDGET_PLUGINS_H + +#include <QtDesigner/QDesignerCustomWidgetInterface> + +QT_BEGIN_NAMESPACE + +class Q3ButtonGroupPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3ButtonGroupPlugin(const QIcon &icon, QObject *parent = 0); + virtual ~Q3ButtonGroupPlugin(); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + + virtual bool isContainer() const; + + virtual QWidget *createWidget(QWidget *parent); + + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +class Q3ComboBoxPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3ComboBoxPlugin(const QIcon &icon, QObject *parent = 0); + virtual ~Q3ComboBoxPlugin(); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + + virtual bool isContainer() const; + + virtual QWidget *createWidget(QWidget *parent); + + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +class Q3DateEditPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3DateEditPlugin(const QIcon &icon, QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +class Q3DateTimeEditPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3DateTimeEditPlugin(const QIcon &icon, QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +class Q3FramePlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3FramePlugin(const QIcon &icon, QObject *parent = 0); + virtual ~Q3FramePlugin(); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + + virtual bool isContainer() const; + + virtual QWidget *createWidget(QWidget *parent); + + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +class Q3GroupBoxPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3GroupBoxPlugin(const QIcon &icon, QObject *parent = 0); + virtual ~Q3GroupBoxPlugin(); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + + virtual bool isContainer() const; + + virtual QWidget *createWidget(QWidget *parent); + + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +class Q3ProgressBarPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3ProgressBarPlugin(const QIcon &icon, QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +class Q3TextBrowserPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3TextBrowserPlugin(const QIcon &icon, QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +class Q3TimeEditPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3TimeEditPlugin(const QIcon &icon, QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +QT_END_NAMESPACE + +#endif // Q3WIDGET_PLUGINS_H diff --git a/tools/designer/src/plugins/widgets/q3widgetstack/q3widgetstack_container.cpp b/tools/designer/src/plugins/widgets/q3widgetstack/q3widgetstack_container.cpp new file mode 100644 index 0000000000..9482d4bcce --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3widgetstack/q3widgetstack_container.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3widgetstack_container.h" +#include "qdesigner_q3widgetstack_p.h" + +#include <QtCore/qdebug.h> + +QT_BEGIN_NAMESPACE + +Q3WidgetStackContainer::Q3WidgetStackContainer(QDesignerQ3WidgetStack *widget, QObject *parent) + : QObject(parent), + m_widget(widget) +{} + +int Q3WidgetStackContainer::count() const +{ return m_pages.count(); } + +QWidget *Q3WidgetStackContainer::widget(int index) const +{ + if (index == -1) + return 0; + + return m_pages.at(index); +} + +int Q3WidgetStackContainer::currentIndex() const +{ return m_pages.indexOf(m_widget->visibleWidget()); } + +void Q3WidgetStackContainer::setCurrentIndex(int index) +{ m_widget->raiseWidget(m_pages.at(index)); } + +void Q3WidgetStackContainer::addWidget(QWidget *widget) +{ + m_pages.append(widget); + m_widget->addWidget(widget); +} + +void Q3WidgetStackContainer::insertWidget(int index, QWidget *widget) +{ + m_pages.insert(index, widget); + m_widget->addWidget(widget); + m_widget->setCurrentIndex(index); +} + +void Q3WidgetStackContainer::remove(int index) +{ + int current = currentIndex(); + m_widget->removeWidget(m_pages.at(index)); + m_pages.removeAt(index); + if (index == current) { + if (count() > 0) + m_widget->setCurrentIndex((index == count()) ? index-1 : index); + } else if (index < current) { + if (current > 0) + m_widget->setCurrentIndex(current-1); + } +} + +Q3WidgetStackContainerFactory::Q3WidgetStackContainerFactory(QExtensionManager *parent) + : QExtensionFactory(parent) +{ +} + +QObject *Q3WidgetStackContainerFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const +{ + if (iid != Q_TYPEID(QDesignerContainerExtension)) + return 0; + + if (QDesignerQ3WidgetStack *w = qobject_cast<QDesignerQ3WidgetStack*>(object)) + return new Q3WidgetStackContainer(w, parent); + + return 0; +} + + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3widgetstack/q3widgetstack_container.h b/tools/designer/src/plugins/widgets/q3widgetstack/q3widgetstack_container.h new file mode 100644 index 0000000000..3d6045de26 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3widgetstack/q3widgetstack_container.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3WIDGETSTACK_CONTAINER_H +#define Q3WIDGETSTACK_CONTAINER_H + +#include <QtDesigner/QDesignerContainerExtension> +#include <QtDesigner/QExtensionFactory> + +QT_BEGIN_NAMESPACE + +class QDesignerQ3WidgetStack; + +class Q3WidgetStackContainer: public QObject, public QDesignerContainerExtension +{ + Q_OBJECT + Q_INTERFACES(QDesignerContainerExtension) +public: + explicit Q3WidgetStackContainer(QDesignerQ3WidgetStack *widget, QObject *parent = 0); + + virtual int count() const; + virtual QWidget *widget(int index) const; + virtual int currentIndex() const; + virtual void setCurrentIndex(int index); + virtual void addWidget(QWidget *widget); + virtual void insertWidget(int index, QWidget *widget); + virtual void remove(int index); + +private: + QDesignerQ3WidgetStack *m_widget; + QList<QWidget*> m_pages; +}; + +class Q3WidgetStackContainerFactory: public QExtensionFactory +{ + Q_OBJECT +public: + explicit Q3WidgetStackContainerFactory(QExtensionManager *parent = 0); + +protected: + virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; +}; + +QT_END_NAMESPACE + +#endif // Q3WIDGETSTACK_CONTAINER_H diff --git a/tools/designer/src/plugins/widgets/q3widgetstack/q3widgetstack_plugin.cpp b/tools/designer/src/plugins/widgets/q3widgetstack/q3widgetstack_plugin.cpp new file mode 100644 index 0000000000..61907a6077 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3widgetstack/q3widgetstack_plugin.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3widgetstack_plugin.h" +#include "q3widgetstack_container.h" + +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/QExtensionManager> + +#include <QtCore/qplugin.h> +#include "qdesigner_q3widgetstack_p.h" + +QT_BEGIN_NAMESPACE + +Q3WidgetStackPlugin::Q3WidgetStackPlugin(const QIcon &icon, QObject *parent) + : QObject(parent), m_initialized(false), m_icon(icon) +{} + +QString Q3WidgetStackPlugin::name() const +{ return QLatin1String("Q3WidgetStack"); } + +QString Q3WidgetStackPlugin::group() const +{ return QLatin1String("Qt 3 Support"); } + +QString Q3WidgetStackPlugin::toolTip() const +{ return QString(); } + +QString Q3WidgetStackPlugin::whatsThis() const +{ return QString(); } + +QString Q3WidgetStackPlugin::includeFile() const +{ return QLatin1String("q3widgetstack.h"); } + +QIcon Q3WidgetStackPlugin::icon() const +{ return m_icon; } + +bool Q3WidgetStackPlugin::isContainer() const +{ return true; } + +QWidget *Q3WidgetStackPlugin::createWidget(QWidget *parent) +{ return new QDesignerQ3WidgetStack(parent); } + +bool Q3WidgetStackPlugin::isInitialized() const +{ return m_initialized; } + +void Q3WidgetStackPlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + + if (m_initialized) + return; + + m_initialized = true; + QExtensionManager *mgr = core->extensionManager(); + mgr->registerExtensions(new Q3WidgetStackContainerFactory(mgr), Q_TYPEID(QDesignerContainerExtension)); +} + +QString Q3WidgetStackPlugin::codeTemplate() const +{ return QString(); } + +QString Q3WidgetStackPlugin::domXml() const +{ + return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"Q3WidgetStack\" name=\"widgetStack\">\ + <property name=\"geometry\">\ + <rect>\ + <x>0</x>\ + <y>0</y>\ + <width>100</width>\ + <height>80</height>\ + </rect>\ + </property>\ + <widget class=\"QWidget\" name=\"page\"/>\ + <widget class=\"QWidget\" name=\"page_2\"/>\ + </widget>\ +</ui>"); +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3widgetstack/q3widgetstack_plugin.h b/tools/designer/src/plugins/widgets/q3widgetstack/q3widgetstack_plugin.h new file mode 100644 index 0000000000..bbe85ff5fe --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3widgetstack/q3widgetstack_plugin.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3WIDGETSTACK_PLUGIN_H +#define Q3WIDGETSTACK_PLUGIN_H + +#include <QtDesigner/QDesignerCustomWidgetInterface> + +QT_BEGIN_NAMESPACE + +class Q3WidgetStackPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3WidgetStackPlugin(const QIcon &icon, QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString codeTemplate() const; + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +QT_END_NAMESPACE + +#endif // Q3WIDGETSTACK_PLUGIN_H diff --git a/tools/designer/src/plugins/widgets/q3widgetstack/qdesigner_q3widgetstack.cpp b/tools/designer/src/plugins/widgets/q3widgetstack/qdesigner_q3widgetstack.cpp new file mode 100644 index 0000000000..adb3d56bcd --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3widgetstack/qdesigner_q3widgetstack.cpp @@ -0,0 +1,217 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "qdesigner_q3widgetstack_p.h" +#include "../../../lib/shared/qdesigner_propertycommand_p.h" + +#include <QtDesigner/QDesignerFormWindowInterface> +#include <QtDesigner/QDesignerContainerExtension> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/QExtensionManager> + +#include <QtCore/QEvent> +#include <QtGui/QToolButton> + +QT_BEGIN_NAMESPACE + +namespace { + QToolButton *createToolButton(QWidget *parent, Qt::ArrowType at, const QString &name) { + QToolButton *rc = new QToolButton(); + rc->setAttribute(Qt::WA_NoChildEventsForParent, true); + rc->setParent(parent); + rc->setObjectName(name); + rc->setArrowType(at); + rc->setAutoRaise(true); + rc->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + rc->setFixedSize(QSize(15, 15)); + return rc; + } +} + +QDesignerQ3WidgetStack::QDesignerQ3WidgetStack(QWidget *parent) : + Q3WidgetStack(parent), + m_prev(createToolButton(this, Qt::LeftArrow, QLatin1String("__qt__passive_prev"))), + m_next(createToolButton(this, Qt::RightArrow, QLatin1String("__qt__passive_next"))) +{ + connect(m_prev, SIGNAL(clicked()), this, SLOT(prevPage())); + connect(m_next, SIGNAL(clicked()), this, SLOT(nextPage())); + updateButtons(); + + connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int))); +} + +QDesignerFormWindowInterface *QDesignerQ3WidgetStack::formWindow() +{ + return QDesignerFormWindowInterface::findFormWindow(this); +} + +QDesignerContainerExtension *QDesignerQ3WidgetStack::container() +{ + if (formWindow()) { + QDesignerFormEditorInterface *core = formWindow()->core(); + return qt_extension<QDesignerContainerExtension*>(core->extensionManager(), this); + } + return 0; +} + +int QDesignerQ3WidgetStack::count() +{ + return container() ? container()->count() : 0; +} + +int QDesignerQ3WidgetStack::currentIndex() +{ + return container() ? container()->currentIndex() : -1; +} + +void QDesignerQ3WidgetStack::setCurrentIndex(int index) +{ + if (container() && (index >= 0) && (index < count())) { + container()->setCurrentIndex(index); + emit currentChanged(index); + } +} + +QWidget *QDesignerQ3WidgetStack::widget(int index) +{ + return container() ? container()->widget(index) : 0; +} + +void QDesignerQ3WidgetStack::updateButtons() +{ + if (m_prev) { + m_prev->move(width() - 31, 1); + m_prev->show(); + m_prev->raise(); + } + + if (m_next) { + m_next->move(width() - 16, 1); + m_next->show(); + m_next->raise(); + } +} + +void QDesignerQ3WidgetStack::gotoPage(int page) { + // Are we on a form or in a preview? + if (QDesignerFormWindowInterface *fw = formWindow()) { + qdesigner_internal::SetPropertyCommand *cmd = new qdesigner_internal::SetPropertyCommand(fw); + cmd->init(this, QLatin1String("currentIndex"), page); + fw->commandHistory()->push(cmd); + fw->emitSelectionChanged(); // Magically prevent an endless loop triggered by auto-repeat. + } else { + setCurrentIndex(page); + } + updateButtons(); +} + + +void QDesignerQ3WidgetStack::prevPage() +{ + if (count() > 1) { + int newIndex = currentIndex() - 1; + if (newIndex < 0) + newIndex = count() - 1; + gotoPage(newIndex); + } +} + +void QDesignerQ3WidgetStack::nextPage() +{ + if (count() > 1) + gotoPage((currentIndex() + 1) % count()); +} + +QString QDesignerQ3WidgetStack::currentPageName() +{ + if (currentIndex() == -1) + return QString(); + + return widget(currentIndex())->objectName(); +} + +void QDesignerQ3WidgetStack::setCurrentPageName(const QString &pageName) +{ + if (currentIndex() == -1) + return; + + if (QWidget *w = widget(currentIndex())) + w->setObjectName(pageName); +} + +bool QDesignerQ3WidgetStack::event(QEvent *e) +{ + if (e->type() == QEvent::LayoutRequest) { + updateButtons(); + } + + return Q3WidgetStack::event(e); +} + +void QDesignerQ3WidgetStack::childEvent(QChildEvent *e) +{ + Q3WidgetStack::childEvent(e); + updateButtons(); +} + +void QDesignerQ3WidgetStack::resizeEvent(QResizeEvent *e) +{ + Q3WidgetStack::resizeEvent(e); + updateButtons(); +} + +void QDesignerQ3WidgetStack::showEvent(QShowEvent *e) +{ + Q3WidgetStack::showEvent(e); + updateButtons(); +} + +void QDesignerQ3WidgetStack::slotCurrentChanged(int index) +{ + if (widget(index)) { + if (QDesignerFormWindowInterface *fw = formWindow()) { + fw->clearSelection(); + fw->selectWidget(this, true); + } + } +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3widgetstack/qdesigner_q3widgetstack_p.h b/tools/designer/src/plugins/widgets/q3widgetstack/qdesigner_q3widgetstack_p.h new file mode 100644 index 0000000000..5c35514d43 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3widgetstack/qdesigner_q3widgetstack_p.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of Qt Designer. This header +// file may change from version to version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QDESIGNER_Q3WIDGETSTACK_P_H +#define QDESIGNER_Q3WIDGETSTACK_P_H + +#include <Qt3Support/Q3WidgetStack> + +QT_BEGIN_NAMESPACE + +class QDesignerFormWindowInterface; +class QDesignerContainerExtension; +class QToolButton; +class QChildEvent; +class QResizeEvent; +class QShowEvent; +class QEvent; + +class QDesignerQ3WidgetStack : public Q3WidgetStack +{ + Q_OBJECT + Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex STORED false DESIGNABLE true) + Q_PROPERTY(QString currentPageName READ currentPageName WRITE setCurrentPageName STORED false DESIGNABLE true) +public: + QDesignerQ3WidgetStack(QWidget *parent = 0); + int currentIndex(); + QString currentPageName(); + +public slots: + void updateButtons(); + void setCurrentIndex(int index); + void setCurrentPageName(const QString &pageName); + +private slots: + void prevPage(); + void nextPage(); + void slotCurrentChanged(int index); + +signals: + void currentChanged(int index); + +protected: + virtual void childEvent(QChildEvent *e); + virtual void resizeEvent(QResizeEvent *e); + virtual void showEvent(QShowEvent *e); + virtual bool event(QEvent *e); + +private: + void gotoPage(int page); + QDesignerFormWindowInterface *formWindow(); + QDesignerContainerExtension *container(); + int count(); + QWidget *widget(int index); + QToolButton *m_prev, *m_next; +}; + +QT_END_NAMESPACE + +#endif // !QDESIGNER_Q3WIDGETSTACK_P_H diff --git a/tools/designer/src/plugins/widgets/q3wizard/q3wizard_container.cpp b/tools/designer/src/plugins/widgets/q3wizard/q3wizard_container.cpp new file mode 100644 index 0000000000..57252b99bc --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3wizard/q3wizard_container.cpp @@ -0,0 +1,235 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3wizard_container.h" +#include <Qt3Support/Q3Wizard> + +#include <QtDesigner/QDesignerFormWindowInterface> +#include <QtDesigner/private/ui4_p.h> + +#include <QtCore/qdebug.h> + +QT_BEGIN_NAMESPACE + +static const char *currentPageText = "currentPageText"; + +Q3WizardHelper::Q3WizardHelper(Q3Wizard *wizard) + : QObject(wizard), + m_wizard(wizard) +{ + connect(m_wizard, SIGNAL(selected(const QString &)), this, SLOT(slotCurrentChanged())); +} + +void Q3WizardHelper::slotCurrentChanged() +{ + if (QDesignerFormWindowInterface *fw = QDesignerFormWindowInterface::findFormWindow(m_wizard)) { + fw->clearSelection(); + fw->selectWidget(m_wizard, true); + } +} + +Q3WizardExtraInfo::Q3WizardExtraInfo(Q3Wizard *wizard, QDesignerFormEditorInterface *core, QObject *parent) + : QObject(parent), m_wizard(wizard), m_core(core) +{} + +QWidget *Q3WizardExtraInfo::widget() const +{ return m_wizard; } + +Q3Wizard *Q3WizardExtraInfo::wizard() const +{ return m_wizard; } + +QDesignerFormEditorInterface *Q3WizardExtraInfo::core() const +{ return m_core; } + +bool Q3WizardExtraInfo::saveUiExtraInfo(DomUI *ui) +{ Q_UNUSED(ui); return false; } + +bool Q3WizardExtraInfo::loadUiExtraInfo(DomUI *ui) +{ Q_UNUSED(ui); return false; } + +bool Q3WizardExtraInfo::saveWidgetExtraInfo(DomWidget *ui_widget) +{ + int i = 0; + foreach (DomWidget *ui_child, ui_widget->elementWidget()) { + DomProperty *p = new DomProperty(); + p->setAttributeName(QLatin1String("title")); + DomString *str = new DomString(); + str->setText(wizard()->title(wizard()->page(i))); + p->setElementString(str); + + QList<DomProperty *> attributes = ui_child->elementAttribute(); + attributes.append(p); + ui_child->setElementAttribute(attributes); + + i++; + } + return true; +} + +bool Q3WizardExtraInfo::loadWidgetExtraInfo(DomWidget *ui_widget) +{ + int i = 0; + foreach (const DomWidget *ui_child, ui_widget->elementWidget()) { + foreach (const DomProperty *ui_prop, ui_child->elementAttribute()) { + if (ui_prop->attributeName() == QLatin1String("title")) { + const DomString *ui_string = ui_prop->elementString(); + if (ui_string) + wizard()->setTitle(wizard()->page(i), ui_string->text()); + } + } + i++; + } + return true; +} + +Q3WizardExtraInfoFactory::Q3WizardExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent) + : QExtensionFactory(parent), m_core(core) +{} + +QObject *Q3WizardExtraInfoFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const +{ + if (iid != Q_TYPEID(QDesignerExtraInfoExtension)) + return 0; + + if (Q3Wizard *w = qobject_cast<Q3Wizard *>(object)) + return new Q3WizardExtraInfo(w, m_core, parent); + + return 0; +} + +Q3WizardContainer::Q3WizardContainer(Q3Wizard *wizard, QObject *parent) + : QObject(parent), + m_wizard(wizard) +{} + +int Q3WizardContainer::count() const +{ + return m_wizard->pageCount(); +} + +QWidget *Q3WizardContainer::widget(int index) const +{ + Q_ASSERT(index != -1); + return m_wizard->page(index); +} + +int Q3WizardContainer::currentIndex() const +{ + if (m_wizard->currentPage() == 0 && m_wizard->pageCount()) + m_wizard->showPage(widget(0)); + + return m_wizard->indexOf(m_wizard->currentPage()); +} + +void Q3WizardContainer::setCurrentIndex(int index) +{ + const bool blocked = m_wizard->signalsBlocked(); + m_wizard->blockSignals(true); + m_wizard->showPage(widget(index)); + m_wizard->blockSignals(blocked); +} + +void Q3WizardContainer::addWidget(QWidget *widget) +{ + m_wizard->addPage(widget, tr("Page")); +} + +void Q3WizardContainer::insertWidget(int index, QWidget *widget) +{ + m_wizard->insertPage(widget, tr("Page"), index); +} + +void Q3WizardContainer::remove(int index) +{ + m_wizard->removePage(widget(index)); +} + +Q3WizardContainerFactory::Q3WizardContainerFactory(QExtensionManager *parent) + : QExtensionFactory(parent) +{ +} + +QObject *Q3WizardContainerFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const +{ + if (iid != Q_TYPEID(QDesignerContainerExtension)) + return 0; + + if (Q3Wizard *w = qobject_cast<Q3Wizard*>(object)) + return new Q3WizardContainer(w, parent); + + return 0; +} + +Q3WizardPropertySheet::Q3WizardPropertySheet(Q3Wizard *object, QObject *parent) + : QDesignerPropertySheet(object, parent), m_wizard(object) +{ + createFakeProperty(QLatin1String(currentPageText), QString()); +} + +void Q3WizardPropertySheet::setProperty(int index, const QVariant &value) +{ + const QString prop = propertyName(index); + if (prop == QLatin1String(currentPageText)) { + m_wizard->setTitle(m_wizard->currentPage(), value.toString()); + return; + } + QDesignerPropertySheet::setProperty(index, value); +} + +QVariant Q3WizardPropertySheet::property(int index) const +{ + const QString prop = propertyName(index); + if (prop == QLatin1String(currentPageText)) + return m_wizard->title(m_wizard->currentPage()); + return QDesignerPropertySheet::property(index); +} + +bool Q3WizardPropertySheet::reset(int index) +{ + const QString prop = propertyName(index); + if (prop == QLatin1String(currentPageText)) { + m_wizard->setTitle(m_wizard->currentPage(), QString()); + return true; + } + return QDesignerPropertySheet::reset(index); +} + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3wizard/q3wizard_container.h b/tools/designer/src/plugins/widgets/q3wizard/q3wizard_container.h new file mode 100644 index 0000000000..1e28176355 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3wizard/q3wizard_container.h @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3WIZARD_CONTAINER_H +#define Q3WIZARD_CONTAINER_H + +#include <QtDesigner/QDesignerContainerExtension> +#include <QtDesigner/QExtensionFactory> +#include <QtDesigner/QDesignerExtraInfoExtension> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/private/qdesigner_propertysheet_p.h> + +#include <QtCore/QPointer> +#include <Qt3Support/Q3Wizard> + +QT_BEGIN_NAMESPACE + +class Q3Wizard; + +class Q3WizardHelper : public QObject +{ + Q_OBJECT +public: + Q3WizardHelper(Q3Wizard *wizard); +private slots: + void slotCurrentChanged(); +private: + Q3Wizard *m_wizard; +}; + +class Q3WizardExtraInfo: public QObject, public QDesignerExtraInfoExtension +{ + Q_OBJECT + Q_INTERFACES(QDesignerExtraInfoExtension) +public: + Q3WizardExtraInfo(Q3Wizard *wizard, QDesignerFormEditorInterface *core, QObject *parent); + + virtual QWidget *widget() const; + virtual Q3Wizard *wizard() const; + virtual QDesignerFormEditorInterface *core() const; + + virtual bool saveUiExtraInfo(DomUI *ui); + virtual bool loadUiExtraInfo(DomUI *ui); + + virtual bool saveWidgetExtraInfo(DomWidget *ui_widget); + virtual bool loadWidgetExtraInfo(DomWidget *ui_widget); + +private: + QPointer<Q3Wizard> m_wizard; + QPointer<QDesignerFormEditorInterface> m_core; +}; + +class Q3WizardExtraInfoFactory: public QExtensionFactory +{ + Q_OBJECT +public: + Q3WizardExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + +protected: + virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; + +private: + QDesignerFormEditorInterface *m_core; +}; + +class Q3WizardContainer: public QObject, public QDesignerContainerExtension +{ + Q_OBJECT + Q_INTERFACES(QDesignerContainerExtension) +public: + explicit Q3WizardContainer(Q3Wizard *wizard, QObject *parent = 0); + + virtual int count() const; + virtual QWidget *widget(int index) const; + virtual int currentIndex() const; + virtual void setCurrentIndex(int index); + virtual void addWidget(QWidget *widget); + virtual void insertWidget(int index, QWidget *widget); + virtual void remove(int index); + +private: + Q3Wizard *m_wizard; +}; + +class Q3WizardContainerFactory: public QExtensionFactory +{ + Q_OBJECT +public: + explicit Q3WizardContainerFactory(QExtensionManager *parent = 0); + +protected: + virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; +}; + +class Q3WizardPropertySheet : public QDesignerPropertySheet { +public: + explicit Q3WizardPropertySheet(Q3Wizard *object, QObject *parent = 0); + + virtual void setProperty(int index, const QVariant &value); + virtual QVariant property(int index) const; + virtual bool reset(int index); + +private: + Q3Wizard *m_wizard; +}; + +typedef QDesignerPropertySheetFactory<Q3Wizard, Q3WizardPropertySheet> Q3WizardPropertySheetFactory; + +QT_END_NAMESPACE + +#endif // Q3WIZARD_CONTAINER_H diff --git a/tools/designer/src/plugins/widgets/q3wizard/q3wizard_plugin.cpp b/tools/designer/src/plugins/widgets/q3wizard/q3wizard_plugin.cpp new file mode 100644 index 0000000000..bdd6ddc722 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3wizard/q3wizard_plugin.cpp @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3wizard_plugin.h" +#include "q3wizard_container.h" + +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/QExtensionManager> + +#include <QtCore/qplugin.h> +#include <QtGui/QPushButton> +#include <Qt3Support/Q3Wizard> + +QT_BEGIN_NAMESPACE + +Q3WizardPlugin::Q3WizardPlugin(const QIcon &icon, QObject *parent) + : QObject(parent), m_initialized(false), m_icon(icon) +{} + +QString Q3WizardPlugin::name() const +{ return QLatin1String("Q3Wizard"); } + +QString Q3WizardPlugin::group() const +{ return QLatin1String("[invisible]"); } + +QString Q3WizardPlugin::toolTip() const +{ return QString(); } + +QString Q3WizardPlugin::whatsThis() const +{ return QString(); } + +QString Q3WizardPlugin::includeFile() const +{ return QLatin1String("q3wizard.h"); } + +QIcon Q3WizardPlugin::icon() const +{ return m_icon; } + +bool Q3WizardPlugin::isContainer() const +{ return true; } + +QWidget *Q3WizardPlugin::createWidget(QWidget *parent) +{ + Q3Wizard *wizard = new Q3Wizard(parent); + new Q3WizardHelper(wizard); + wizard->backButton()->setObjectName(QLatin1String("__qt__passive_") + wizard->backButton()->objectName()); + wizard->nextButton()->setObjectName(QLatin1String("__qt__passive_") + wizard->nextButton()->objectName()); + return wizard; +} + +bool Q3WizardPlugin::isInitialized() const +{ return m_initialized; } + +void Q3WizardPlugin::initialize(QDesignerFormEditorInterface *core) +{ + Q_UNUSED(core); + + if (m_initialized) + return; + + m_initialized = true; + QExtensionManager *mgr = core->extensionManager(); + Q3WizardPropertySheetFactory::registerExtension(mgr); + mgr->registerExtensions(new Q3WizardContainerFactory(mgr), Q_TYPEID(QDesignerContainerExtension)); + mgr->registerExtensions(new Q3WizardExtraInfoFactory(core, mgr), Q_TYPEID(QDesignerExtraInfoExtension)); +} + +QString Q3WizardPlugin::codeTemplate() const +{ return QString(); } + +QString Q3WizardPlugin::domXml() const +{ + return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"Q3Wizard\" name=\"wizard\">\ + <property name=\"geometry\">\ + <rect>\ + <x>0</x>\ + <y>0</y>\ + <width>100</width>\ + <height>80</height>\ + </rect>\ + </property>\ + <widget class=\"QWidget\" />\ + <widget class=\"QWidget\" />\ + </widget>\ +</ui>"); +} + + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/widgets/q3wizard/q3wizard_plugin.h b/tools/designer/src/plugins/widgets/q3wizard/q3wizard_plugin.h new file mode 100644 index 0000000000..f21dfd3221 --- /dev/null +++ b/tools/designer/src/plugins/widgets/q3wizard/q3wizard_plugin.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 Q3WIZARD_PLUGIN_H +#define Q3WIZARD_PLUGIN_H + +#include <QtDesigner/QDesignerCustomWidgetInterface> + +QT_BEGIN_NAMESPACE + +class Q3WizardPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + Q3WizardPlugin(const QIcon &icon, QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString codeTemplate() const; + virtual QString domXml() const; + +private: + bool m_initialized; + QIcon m_icon; +}; + +QT_END_NAMESPACE + +#endif // Q3WIZARD_PLUGIN_H diff --git a/tools/designer/src/plugins/widgets/qt3supportwidgets.cpp b/tools/designer/src/plugins/widgets/qt3supportwidgets.cpp new file mode 100644 index 0000000000..eafcf7a28b --- /dev/null +++ b/tools/designer/src/plugins/widgets/qt3supportwidgets.cpp @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the Qt Designer 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 "q3toolbar/q3toolbar_plugin.h" +#include "q3iconview/q3iconview_plugin.h" +#include "q3wizard/q3wizard_plugin.h" +#include "q3mainwindow/q3mainwindow_plugin.h" +#include "q3widgetstack/q3widgetstack_plugin.h" +#include "q3listview/q3listview_plugin.h" +#include "q3table/q3table_plugin.h" +#include "q3listbox/q3listbox_plugin.h" +#include "q3listview/q3listview_plugin.h" +#include "q3textedit/q3textedit_plugin.h" +#include "q3widgets/q3widget_plugins.h" + +#include <QtDesigner/QDesignerCustomWidgetCollectionInterface> +#include <QtCore/qplugin.h> +#include <QtCore/qdebug.h> +#include <QtGui/QIcon> + +QT_BEGIN_NAMESPACE + +class Qt3SupportWidgets: public QObject, public QDesignerCustomWidgetCollectionInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetCollectionInterface) +public: + Qt3SupportWidgets(QObject *parent = 0); + + virtual QList<QDesignerCustomWidgetInterface*> customWidgets() const; + +private: + QList<QDesignerCustomWidgetInterface*> m_plugins; +}; + +Qt3SupportWidgets::Qt3SupportWidgets(QObject *parent) + : QObject(parent) +{ + const QIcon qt3Icon(QLatin1String(":/trolltech/formeditor/images/qt3logo.png")); + m_plugins.append(new Q3ToolBarPlugin(qt3Icon, this)); + m_plugins.append(new Q3IconViewPlugin(qt3Icon, this)); + m_plugins.append(new Q3GroupBoxPlugin(qt3Icon, this)); + m_plugins.append(new Q3FramePlugin(qt3Icon, this)); + m_plugins.append(new Q3WizardPlugin(qt3Icon, this)); + m_plugins.append(new Q3MainWindowPlugin(qt3Icon, this)); + m_plugins.append(new Q3WidgetStackPlugin(qt3Icon, this)); + m_plugins.append(new Q3ButtonGroupPlugin(qt3Icon, this)); + m_plugins.append(new Q3TablePlugin(qt3Icon, this)); + m_plugins.append(new Q3ListBoxPlugin(qt3Icon, this)); + m_plugins.append(new Q3ListViewPlugin(qt3Icon, this)); + m_plugins.append(new Q3ComboBoxPlugin(qt3Icon, this)); + m_plugins.append(new Q3TextEditPlugin(qt3Icon, this)); + m_plugins.append(new Q3DateEditPlugin(qt3Icon, this)); + m_plugins.append(new Q3TimeEditPlugin(qt3Icon, this)); + m_plugins.append(new Q3DateTimeEditPlugin(qt3Icon, this)); + m_plugins.append(new Q3ProgressBarPlugin(qt3Icon, this)); + m_plugins.append(new Q3TextBrowserPlugin(qt3Icon, this)); +} + +QList<QDesignerCustomWidgetInterface*> Qt3SupportWidgets::customWidgets() const +{ + return m_plugins; +} + +Q_EXPORT_PLUGIN(Qt3SupportWidgets) + +QT_END_NAMESPACE + +#include "qt3supportwidgets.moc" diff --git a/tools/designer/src/plugins/widgets/widgets.pro b/tools/designer/src/plugins/widgets/widgets.pro new file mode 100644 index 0000000000..4d8f9bae84 --- /dev/null +++ b/tools/designer/src/plugins/widgets/widgets.pro @@ -0,0 +1,82 @@ +QT += qt3support +TEMPLATE = lib +CONFIG += plugin +DESTDIR = +TARGET = qt3supportwidgets + +CONFIG += qt warn_on qt_no_compat_warning + +include(../plugins.pri) +build_all:!build_pass { + CONFIG -= build_all + CONFIG += release +} + +DEPENDPATH += q3iconview \ + q3listview \ + q3mainwindow \ + q3toolbar \ + q3widgetstack \ + q3wizard \ + q3listbox \ + q3table \ + q3textedit \ + q3widgets + +INCLUDEPATH += . \ + q3iconview \ + q3listview \ + q3mainwindow \ + q3toolbar \ + q3widgetstack \ + q3wizard \ + q3listbox \ + q3table \ + q3textedit \ + q3widgets + + +SOURCES += qt3supportwidgets.cpp + +# Input +HEADERS += q3iconview/q3iconview_extrainfo.h \ + q3iconview/q3iconview_plugin.h \ + q3listview/q3listview_extrainfo.h \ + q3listview/q3listview_plugin.h \ + q3mainwindow/q3mainwindow_container.h \ + q3mainwindow/q3mainwindow_plugin.h \ + q3toolbar/q3toolbar_extrainfo.h \ + q3toolbar/q3toolbar_plugin.h \ + q3widgetstack/q3widgetstack_container.h \ + q3widgetstack/q3widgetstack_plugin.h \ + q3widgetstack/qdesigner_q3widgetstack_p.h \ + q3wizard/q3wizard_container.h \ + q3wizard/q3wizard_plugin.h \ + q3listbox/q3listbox_extrainfo.h \ + q3listbox/q3listbox_plugin.h \ + q3table/q3table_extrainfo.h \ + q3table/q3table_plugin.h \ + q3textedit/q3textedit_extrainfo.h \ + q3textedit/q3textedit_plugin.h \ + q3widgets/q3widget_plugins.h \ + +SOURCES += q3iconview/q3iconview_extrainfo.cpp \ + q3iconview/q3iconview_plugin.cpp \ + q3listview/q3listview_extrainfo.cpp \ + q3listview/q3listview_plugin.cpp \ + q3mainwindow/q3mainwindow_container.cpp \ + q3mainwindow/q3mainwindow_plugin.cpp \ + q3toolbar/q3toolbar_extrainfo.cpp \ + q3toolbar/q3toolbar_plugin.cpp \ + q3widgetstack/q3widgetstack_container.cpp \ + q3widgetstack/q3widgetstack_plugin.cpp \ + q3widgetstack/qdesigner_q3widgetstack.cpp \ + q3wizard/q3wizard_container.cpp \ + q3wizard/q3wizard_plugin.cpp \ + q3listbox/q3listbox_extrainfo.cpp \ + q3listbox/q3listbox_plugin.cpp \ + q3table/q3table_extrainfo.cpp \ + q3table/q3table_plugin.cpp \ + q3textedit/q3textedit_extrainfo.cpp \ + q3textedit/q3textedit_plugin.cpp \ + q3widgets/q3widget_plugins.cpp |