summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-05-13 09:16:24 +0200
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-05-13 09:16:24 +0200
commit23de78e764c06ea62560a0d7690315456c0ff9d0 (patch)
tree7ae090b5c407491a6ba6bdf55a95c3861fa438b1
parent45431ee2cf2daafe350ce54d3a3bc9f4a683e8b8 (diff)
downloadqttools-23de78e764c06ea62560a0d7690315456c0ff9d0.tar.gz
Designer: BC cleanup of QDesignerIntegrationInterface.
Add features enumeration similar to that of QDesignerFormWindowInterface. Add missing virtuals for IDE integration. Make a cleaned-up version of Qt Designer's implemenation public as QDesignerIntegration such that IDE integrations can use an integration class derived from it. Add a bit of documentation, marked as \internal. Reviewed-by: Jarek Kobus <jkobus@trolltech.com>
-rw-r--r--src/designer/src/components/formeditor/formeditor.cpp12
-rw-r--r--src/designer/src/components/lib/qdesigner_components.cpp10
-rw-r--r--src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp4
-rw-r--r--src/designer/src/designer/qdesigner_actions.cpp6
-rw-r--r--src/designer/src/designer/qdesigner_formwindow.cpp1
-rw-r--r--src/designer/src/designer/qdesigner_workbench.cpp4
-rw-r--r--src/designer/src/designer/qdesigner_workbench.h5
-rw-r--r--src/designer/src/lib/sdk/abstractintegration.cpp707
-rw-r--r--src/designer/src/lib/sdk/abstractintegration.h112
-rw-r--r--src/designer/src/lib/shared/formwindowbase.cpp8
-rw-r--r--src/designer/src/lib/shared/formwindowbase_p.h4
-rw-r--r--src/designer/src/lib/shared/iconselector.cpp13
-rw-r--r--src/designer/src/lib/shared/plugindialog.cpp37
-rw-r--r--src/designer/src/lib/shared/qdesigner_integration.cpp496
-rw-r--r--src/designer/src/lib/shared/qdesigner_integration_p.h152
-rw-r--r--src/designer/src/lib/shared/qdesigner_propertycommand.cpp2
-rw-r--r--src/designer/src/lib/shared/qdesigner_propertycommand_p.h3
-rw-r--r--src/designer/src/lib/shared/qdesigner_taskmenu.cpp14
-rw-r--r--src/designer/src/lib/shared/shared.pri2
-rw-r--r--src/designer/src/lib/shared/stylesheeteditor.cpp6
20 files changed, 856 insertions, 742 deletions
diff --git a/src/designer/src/components/formeditor/formeditor.cpp b/src/designer/src/components/formeditor/formeditor.cpp
index 517c5d799..ad021a3f2 100644
--- a/src/designer/src/components/formeditor/formeditor.cpp
+++ b/src/designer/src/components/formeditor/formeditor.cpp
@@ -62,12 +62,11 @@
#include "qdesigner_toolbox_p.h"
#include "qdesigner_tabwidget_p.h"
#include "qtresourcemodel_p.h"
-#include "qdesigner_integration_p.h"
#include "itemview_propertysheet.h"
// sdk
#include <QtDesigner/QExtensionManager>
-
+#include <QtDesigner/QDesignerIntegrationInterface>
// shared
#include <pluginmanager_p.h>
#include <qdesigner_taskmenu_p.h>
@@ -168,14 +167,13 @@ FormEditor::~FormEditor()
void FormEditor::slotQrcFileChangedExternally(const QString &path)
{
- QDesignerIntegration *designerIntegration = qobject_cast<QDesignerIntegration *>(integration());
- if (!designerIntegration)
+ if (!integration())
return;
- QDesignerIntegration::ResourceFileWatcherBehaviour behaviour = designerIntegration->resourceFileWatcherBehaviour();
- if (behaviour == QDesignerIntegration::NoWatcher) {
+ QDesignerIntegration::ResourceFileWatcherBehaviour behaviour = integration()->resourceFileWatcherBehaviour();
+ if (behaviour == QDesignerIntegration::NoResourceFileWatcher) {
return;
- } else if (behaviour == QDesignerIntegration::PromptAndReload) {
+ } else if (behaviour == QDesignerIntegration::PromptToReloadResourceFile) {
QMessageBox::StandardButton button = dialogGui()->message(topLevel(), QDesignerDialogGuiInterface::FileChangedMessage, QMessageBox::Warning,
tr("Resource File Changed"),
tr("The file \"%1\" has changed outside Designer. Do you want to reload it?").arg(path),
diff --git a/src/designer/src/components/lib/qdesigner_components.cpp b/src/designer/src/components/lib/qdesigner_components.cpp
index 9b7457f46..ef87d1357 100644
--- a/src/designer/src/components/lib/qdesigner_components.cpp
+++ b/src/designer/src/components/lib/qdesigner_components.cpp
@@ -51,7 +51,6 @@
#include <objectinspector/objectinspector.h>
#include <taskmenu/taskmenu_component.h>
#include "qtresourceview_p.h"
-#include <qdesigner_integration_p.h>
#include <signalsloteditor/signalsloteditorwindow.h>
#include <buddyeditor/buddyeditor_plugin.h>
@@ -60,6 +59,7 @@
#include <QtDesigner/QDesignerLanguageExtension>
#include <QtDesigner/QExtensionManager>
+#include <QtDesigner/QDesignerIntegrationInterface>
#include <QtDesigner/QDesignerResourceBrowserInterface>
#include <QtCore/qplugin.h>
@@ -139,7 +139,7 @@ void QDesignerComponents::initializeResources()
Initializes the plugins used by the components.*/
void QDesignerComponents::initializePlugins(QDesignerFormEditorInterface *core)
{
- qdesigner_internal::QDesignerIntegration::initializePlugins(core);
+ QDesignerIntegration::initializePlugins(core);
}
/*!
@@ -258,11 +258,11 @@ QWidget *QDesignerComponents::createResourceEditor(QDesignerFormEditorInterface
QtResourceView *resourceView = new QtResourceView(core, parent);
resourceView->setResourceModel(core->resourceModel());
resourceView->setSettingsKey(QLatin1String("ResourceBrowser"));
- qdesigner_internal::QDesignerIntegration *designerIntegration = qobject_cast<qdesigner_internal::QDesignerIntegration *>(core->integration());
// Note for integrators: make sure you call createResourceEditor() after you instantiated your subclass of designer integration
// (designer doesn't do that since by default editing resources is enabled)
- if (designerIntegration)
- resourceView->setResourceEditingEnabled(designerIntegration->isResourceEditingEnabled());
+ const QDesignerIntegrationInterface *integration = core->integration();
+ if (integration && !integration->hasFeature(QDesignerIntegrationInterface::ResourceEditorFeature))
+ resourceView->setResourceEditingEnabled(false);
return resourceView;
}
diff --git a/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp b/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp
index b06a66f2c..0d0683554 100644
--- a/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp
+++ b/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp
@@ -42,7 +42,6 @@
#include "signalsloteditorwindow.h"
#include "signalsloteditor_p.h"
#include "signalsloteditor.h"
-#include "qdesigner_integration_p.h"
#include "signalslot_utils_p.h"
#include <iconloader_p.h>
@@ -53,6 +52,7 @@
#include <QtDesigner/QDesignerFormEditorInterface>
#include <QtDesigner/QDesignerFormWindowManagerInterface>
#include <QtDesigner/QExtensionManager>
+#include <QtDesigner/QDesignerIntegrationInterface>
#include <QtDesigner/QDesignerContainerExtension>
#include <QtDesigner/QDesignerMetaDataBaseInterface>
#include <QtDesigner/QDesignerFormWindowCursorInterface>
@@ -757,7 +757,7 @@ SignalSlotEditorWindow::SignalSlotEditorWindow(QDesignerFormEditorInterface *cor
void SignalSlotEditorWindow::setActiveFormWindow(QDesignerFormWindowInterface *form)
{
- QDesignerIntegration *integration = qobject_cast<QDesignerIntegration *>(m_core->integration());
+ QDesignerIntegrationInterface *integration = m_core->integration();
if (!m_editor.isNull()) {
disconnect(m_view->selectionModel(),
diff --git a/src/designer/src/designer/qdesigner_actions.cpp b/src/designer/src/designer/qdesigner_actions.cpp
index a84e0732d..8b76294f1 100644
--- a/src/designer/src/designer/qdesigner_actions.cpp
+++ b/src/designer/src/designer/qdesigner_actions.cpp
@@ -59,11 +59,11 @@
#include <previewmanager_p.h>
#include <codedialog_p.h>
#include <qdesigner_formwindowmanager_p.h>
-#include "qdesigner_integration_p.h"
// sdk
#include <QtDesigner/QDesignerFormEditorInterface>
#include <QtDesigner/QDesignerFormWindowInterface>
+#include <QtDesigner/QDesignerIntegrationInterface>
#include <QtDesigner/QDesignerLanguageExtension>
#include <QtDesigner/QDesignerMetaDataBaseInterface>
#include <QtDesigner/QDesignerFormWindowManagerInterface>
@@ -1089,9 +1089,7 @@ QAction *QDesignerActions::editWidgets() const
void QDesignerActions::showWidgetSpecificHelp()
{
- QString helpId;
- if (const qdesigner_internal::QDesignerIntegration *integration = qobject_cast<qdesigner_internal::QDesignerIntegration *>(core()->integration()))
- helpId = integration->contextHelpId();
+ const QString helpId = core()->integration()->contextHelpId();
if (helpId.isEmpty()) {
showDesignerHelp();
diff --git a/src/designer/src/designer/qdesigner_formwindow.cpp b/src/designer/src/designer/qdesigner_formwindow.cpp
index 4770d2a58..dfee657da 100644
--- a/src/designer/src/designer/qdesigner_formwindow.cpp
+++ b/src/designer/src/designer/qdesigner_formwindow.cpp
@@ -93,7 +93,6 @@ QDesignerFormWindow::QDesignerFormWindow(QDesignerFormWindowInterface *editor, Q
connect(m_editor->commandHistory(), SIGNAL(indexChanged(int)), this, SLOT(updateChanged()));
connect(m_editor, SIGNAL(geometryChanged()), this, SLOT(geometryChanged()));
- qdesigner_internal::FormWindowBase::setupDefaultAction(m_editor);
}
QDesignerFormWindow::~QDesignerFormWindow()
diff --git a/src/designer/src/designer/qdesigner_workbench.cpp b/src/designer/src/designer/qdesigner_workbench.cpp
index ffc4b8c7a..d6c925dc6 100644
--- a/src/designer/src/designer/qdesigner_workbench.cpp
+++ b/src/designer/src/designer/qdesigner_workbench.cpp
@@ -56,7 +56,7 @@
#include <QtDesigner/QDesignerMetaDataBaseInterface>
#include <QtDesigner/QDesignerComponents>
-#include <QtDesigner/private/qdesigner_integration_p.h>
+#include <QtDesigner/QDesignerIntegrationInterface>
#include <QtDesigner/private/pluginmanager_p.h>
#include <QtDesigner/private/formwindowbase_p.h>
#include <QtDesigner/private/actioneditor_p.h>
@@ -231,7 +231,7 @@ QDesignerWorkbench::QDesignerWorkbench() :
connect(toolWindow, SIGNAL(closeEventReceived(QCloseEvent*)), this, SLOT(handleCloseEvent(QCloseEvent*)));
}
// Integration
- m_integration = new qdesigner_internal::QDesignerIntegration(m_core, this);
+ m_integration = new QDesignerIntegration(m_core, this);
connect(m_integration, SIGNAL(helpRequested(QString,QString)), m_actionManager, SLOT(helpRequested(QString,QString)));
// remaining view options (config toolbars)
diff --git a/src/designer/src/designer/qdesigner_workbench.h b/src/designer/src/designer/qdesigner_workbench.h
index 9266eea60..d174baaa6 100644
--- a/src/designer/src/designer/qdesigner_workbench.h
+++ b/src/designer/src/designer/qdesigner_workbench.h
@@ -75,10 +75,7 @@ class ToolBarManager;
class QDesignerFormEditorInterface;
class QDesignerFormWindowInterface;
class QDesignerFormWindowManagerInterface;
-
-namespace qdesigner_internal {
class QDesignerIntegration;
-}
class QDesignerWorkbench: public QObject
{
@@ -161,7 +158,7 @@ private:
void saveSettings() const;
QDesignerFormEditorInterface *m_core;
- qdesigner_internal::QDesignerIntegration *m_integration;
+ QDesignerIntegration *m_integration;
QDesignerActions *m_actionManager;
QActionGroup *m_windowActions;
diff --git a/src/designer/src/lib/sdk/abstractintegration.cpp b/src/designer/src/lib/sdk/abstractintegration.cpp
index 66a5187d4..c222e1966 100644
--- a/src/designer/src/lib/sdk/abstractintegration.cpp
+++ b/src/designer/src/lib/sdk/abstractintegration.cpp
@@ -40,19 +40,203 @@
****************************************************************************/
#include "abstractintegration.h"
+#include "abstractformwindow.h"
+#include "abstractformwindowmanager.h"
+#include "abstractformwindowcursor.h"
#include "abstractformeditor.h"
+#include "abstractactioneditor.h"
+#include "abstractwidgetbox.h"
+#include "abstractresourcebrowser.h"
+#include "propertysheet.h"
+#include "abstractpropertyeditor.h"
+#include "qextensionmanager.h"
+
+#include <qtresourcemodel_p.h>
+
+#include <qdesigner_propertycommand_p.h>
+#include <qdesigner_propertyeditor_p.h>
+#include <qdesigner_objectinspector_p.h>
+#include <widgetdatabase_p.h>
+#include <pluginmanager_p.h>
+#include <widgetfactory_p.h>
+#include <qdesigner_widgetbox_p.h>
+#include <qtgradientmanager.h>
+#include <qtgradientutils.h>
+#include <qtresourcemodel_p.h>
+
+#include <QtCore/QVariant>
+#include <QtCore/QFile>
+#include <QtCore/QDir>
+
+#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
+/*!
+ \class QDesignerIntegrationInterface
+
+ \brief The QDesignerIntegrationInterface glues together parts of \QD
+ and allows for overwriting functionality for IDE integration.
+
+ \internal
+
+ \inmodule QtDesigner
+
+ \sa QDesignerFormEditorInterface
+*/
+
+/*!
+ \enum QDesignerIntegrationInterface::ResourceFileWatcherBehaviour
+
+ \internal
+
+ This enum describes if and how resource files are watched.
+
+ \value NoResourceFileWatcher Do not watch for changes
+ \value ReloadResourceFileSilently Reload files silently.
+ \value PromptToReloadResourceFile Prompt the user to reload.
+*/
+
+/*!
+ \enum QDesignerIntegrationInterface::FeatureFlag
+
+ \internal
+
+ This enum describes the features that are available and can be
+ controlled by the integration.
+
+ \value ResourceEditorFeature The resource editor is enabled.
+ \value SlotNavigationFeature Provide context menu entry offering 'Go to slot'.
+ \value DefaultWidgetActionFeature Trigger the preferred action of
+ QDesignerTaskMenuExtension when widget is activated.
+ \value DefaultFeature Default for \QD
+
+ \sa hasFeature(), features()
+*/
+
+/*!
+ \property QDesignerIntegrationInterface::headerSuffix
+
+ Returns the suffix of the header of promoted widgets.
+*/
+
+/*!
+ \property QDesignerIntegrationInterface::headerLowercase
+
+ Returns whether headers of promoted widgets should be lower-cased (as the user types the class name).
+*/
+
+/*!
+ \fn virtual void QDesignerIntegrationInterface::updateSelection()
+
+ \brief Sets the selected widget of the form window in various components.
+
+ \internal
+
+ In IDE integrations, the method can be overwritten to move the selection handles
+ of the form's main window, should it be selected.
+*/
+
+/*!
+ \fn virtual QWidget *QDesignerIntegrationInterface::containerWindow(QWidget *widget) const
+
+ \brief Returns the outer window containing a form for applying main container geometries.
+
+ \internal
+
+ Should be implemented by IDE integrations.
+*/
+
+/*!
+ \fn virtual QDesignerResourceBrowserInterface *QDesignerIntegrationInterface::createResourceBrowser(QWidget *parent = 0)
+
+ \brief Creates a resource browser depending on IDE integration.
+
+ \internal
+
+ \note Language integration takes precedence.
+*/
+
+/*!
+ \fn virtual void QDesignerIntegrationInterface::updateProperty(const QString &name, const QVariant &value, bool enableSubPropertyHandling)
+
+ \brief Triggered by the property editor to update a property value.
+
+ \internal
+
+ If a different property editor is used, it should invoke this function.
+*/
+
+/*!
+ \fn virtual void QDesignerIntegrationInterface::updateProperty(const QString &name, const QVariant &value)
+
+ \brief Triggered by the property editor to update a property value without subproperty handling.
+
+ \internal
+
+ If a different property editor is used, it should invoke this function.
+*/
+
+/*!
+ \fn virtual void QDesignerIntegrationInterface::resetProperty(const QString &name)
+
+ \brief Triggered by the property editor to reset a property value.
+
+ \internal
+
+ If a different property editor is used, it should invoke this function.
+*/
+
+/*!
+ \fn virtual void QDesignerIntegrationInterface::addDynamicProperty(const QString &name, const QVariant &value)
+
+ \brief Triggered by the property editor to add a dynamic property value.
+
+ \internal
+
+ If a different property editor is used, it should invoke this function.
+*/
+
+/*!
+ \fn virtual void QDesignerIntegrationInterface::removeDynamicProperty(const QString &name)
+
+ \brief Triggered by the property editor to remove a dynamic property.
+
+ \internal
+
+ If a different property editor is used, it should invoke this function.
+*/
+
+/*!
+ \fn virtual void QDesignerIntegrationInterface::updateActiveFormWindow(QDesignerFormWindowInterface *formWindow)
+
+ \brief Sets up the active form window.
+
+ \internal
+*/
+
+/*!
+ \fn virtual void QDesignerIntegrationInterface::setupFormWindow(QDesignerFormWindowInterface *formWindow)
+
+ \brief Sets up the new form window.
+
+ \internal
+*/
+
+/*!
+ \fn virtual void QDesignerIntegrationInterface::updateCustomWidgetPlugins()
+
+ \brief Triggers a reload of the custom widget plugins.
+
+ \internal
+*/
+
class QDesignerIntegrationInterfacePrivate
{
public:
QDesignerIntegrationInterfacePrivate(QDesignerFormEditorInterface *core) :
- headerSuffix(QLatin1String(".h")),
- headerLowercase(true), m_core(core) {}
+ m_core(core) {}
- QString headerSuffix;
- bool headerLowercase;
QDesignerFormEditorInterface *m_core;
};
@@ -66,29 +250,532 @@ QDesignerIntegrationInterface::~QDesignerIntegrationInterface()
{
}
-QString QDesignerIntegrationInterface::headerSuffix() const
+QDesignerFormEditorInterface *QDesignerIntegrationInterface::core() const
+{
+ return d->m_core;
+}
+
+bool QDesignerIntegrationInterface::hasFeature(Feature f) const
+{
+ return (features() & f) != 0;
+}
+
+void QDesignerIntegrationInterface::emitObjectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object, const QString &newName, const QString &oldName)
+{
+ emit objectNameChanged(formWindow, object, newName, oldName);
+}
+
+void QDesignerIntegrationInterface::emitNavigateToSlot(const QString &objectName,
+ const QString &signalSignature,
+ const QStringList &parameterNames)
+{
+ emit navigateToSlot(objectName, signalSignature, parameterNames);
+}
+
+void QDesignerIntegrationInterface::emitNavigateToSlot(const QString &slotSignature)
+{
+ emit navigateToSlot(slotSignature);
+}
+
+void QDesignerIntegrationInterface::emitHelpRequested(const QString &manual, const QString &document)
+{
+ emit helpRequested(manual, document);
+}
+
+/*!
+ \class QDesignerIntegration
+
+ \brief The QDesignerIntegration class is \QD's implementation of
+ QDesignerIntegrationInterface.
+
+ \internal
+
+ \inmodule QtDesigner
+
+ IDE integrations should register classes derived from QDesignerIntegration
+ with QDesignerFormEditorInterface.
+*/
+
+namespace qdesigner_internal {
+
+class QDesignerIntegrationPrivate {
+public:
+ explicit QDesignerIntegrationPrivate(QDesignerIntegration *qq);
+
+ QWidget *containerWindow(QWidget *widget) const;
+
+ // Load plugins into widget database and factory.
+ static void initializePlugins(QDesignerFormEditorInterface *formEditor);
+
+ QString contextHelpId() const;
+
+ void updateProperty(const QString &name, const QVariant &value, bool enableSubPropertyHandling);
+ void resetProperty(const QString &name);
+ void addDynamicProperty(const QString &name, const QVariant &value);
+ void removeDynamicProperty(const QString &name);
+
+ void setupFormWindow(QDesignerFormWindowInterface *formWindow);
+ void updateSelection();
+ void updateCustomWidgetPlugins();
+
+ void updatePropertyPrivate(const QString &name, const QVariant &value);
+
+ void initialize();
+ void getSelection(qdesigner_internal::Selection &s);
+ QObject *propertyEditorObject();
+
+ QDesignerIntegration *q;
+ QString headerSuffix;
+ bool headerLowercase;
+ QDesignerIntegrationInterface::Feature m_features;
+ QDesignerIntegrationInterface::ResourceFileWatcherBehaviour m_resourceFileWatcherBehaviour;
+ QString m_gradientsPath;
+ QtGradientManager *m_gradientManager;
+ QDesignerIntegrationInterface::ResourceFileWatcherBehaviour m_fileWatcherBehaviour;
+};
+
+QDesignerIntegrationPrivate::QDesignerIntegrationPrivate(QDesignerIntegration *qq) :
+ q(qq),
+ headerSuffix(QLatin1String(".h")),
+ headerLowercase(true),
+ m_features(QDesignerIntegrationInterface::DefaultFeature),
+ m_resourceFileWatcherBehaviour(QDesignerIntegrationInterface::PromptToReloadResourceFile),
+ m_gradientManager(0),
+ m_fileWatcherBehaviour(QDesignerIntegrationInterface::PromptToReloadResourceFile)
+{
+}
+
+void QDesignerIntegrationPrivate::initialize()
+{
+ //
+ // integrate the `Form Editor component'
+ //
+
+ // Extensions
+ QDesignerFormEditorInterface *core = q->core();
+ if (QDesignerPropertyEditor *designerPropertyEditor= qobject_cast<QDesignerPropertyEditor *>(core->propertyEditor())) {
+ QObject::connect(designerPropertyEditor, SIGNAL(propertyValueChanged(QString,QVariant,bool)), q, SLOT(updateProperty(QString,QVariant,bool)));
+ QObject::connect(designerPropertyEditor, SIGNAL(resetProperty(QString)), q, SLOT(resetProperty(QString)));
+ QObject::connect(designerPropertyEditor, SIGNAL(addDynamicProperty(QString,QVariant)),
+ q, SLOT(addDynamicProperty(QString,QVariant)));
+ QObject::connect(designerPropertyEditor, SIGNAL(removeDynamicProperty(QString)),
+ q, SLOT(removeDynamicProperty(QString)));
+ } else {
+ QObject::connect(core->propertyEditor(), SIGNAL(propertyChanged(QString,QVariant)),
+ q, SLOT(updatePropertyPrivate(QString,QVariant)));
+ }
+
+ QObject::connect(core->formWindowManager(), SIGNAL(formWindowAdded(QDesignerFormWindowInterface*)),
+ q, SLOT(setupFormWindow(QDesignerFormWindowInterface*)));
+
+ QObject::connect(core->formWindowManager(), SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)),
+ q, SLOT(updateActiveFormWindow(QDesignerFormWindowInterface*)));
+
+ m_gradientManager = new QtGradientManager(q);
+ core->setGradientManager(m_gradientManager);
+
+ QString designerFolder = QDir::homePath();
+ designerFolder += QDir::separator();
+ designerFolder += QLatin1String(".designer");
+ m_gradientsPath = designerFolder;
+ m_gradientsPath += QDir::separator();
+ m_gradientsPath += QLatin1String("gradients.xml");
+
+ QFile f(m_gradientsPath);
+ if (f.open(QIODevice::ReadOnly)) {
+ QtGradientUtils::restoreState(m_gradientManager, QString::fromAscii(f.readAll()));
+ f.close();
+ } else {
+ QFile defaultGradients(QLatin1String(":/trolltech/designer/defaultgradients.xml"));
+ if (defaultGradients.open(QIODevice::ReadOnly)) {
+ QtGradientUtils::restoreState(m_gradientManager, QString::fromAscii(defaultGradients.readAll()));
+ defaultGradients.close();
+ }
+ }
+
+ if (WidgetDataBase *widgetDataBase = qobject_cast<WidgetDataBase*>(core->widgetDataBase()))
+ widgetDataBase->grabStandardWidgetBoxIcons();
+}
+
+void QDesignerIntegrationPrivate::updateProperty(const QString &name, const QVariant &value, bool enableSubPropertyHandling)
+{
+ QDesignerFormWindowInterface *formWindow = q->core()->formWindowManager()->activeFormWindow();
+ if (!formWindow)
+ return;
+
+ Selection selection;
+ getSelection(selection);
+ if (selection.empty())
+ return;
+
+ SetPropertyCommand *cmd = new SetPropertyCommand(formWindow);
+ // find a reference object to compare to and to find the right group
+ if (cmd->init(selection.selection(), name, value, propertyEditorObject(), enableSubPropertyHandling)) {
+ formWindow->commandHistory()->push(cmd);
+ } else {
+ delete cmd;
+ qDebug() << "Unable to set property " << name << '.';
+ }
+}
+
+void QDesignerIntegrationPrivate::resetProperty(const QString &name)
+{
+ QDesignerFormWindowInterface *formWindow = q->core()->formWindowManager()->activeFormWindow();
+ if (!formWindow)
+ return;
+
+ Selection selection;
+ getSelection(selection);
+ if (selection.empty())
+ return;
+
+ ResetPropertyCommand *cmd = new ResetPropertyCommand(formWindow);
+ // find a reference object to find the right group
+ if (cmd->init(selection.selection(), name, propertyEditorObject())) {
+ formWindow->commandHistory()->push(cmd);
+ } else {
+ delete cmd;
+ qDebug() << "** WARNING Unable to reset property " << name << '.';
+ }
+}
+
+void QDesignerIntegrationPrivate::addDynamicProperty(const QString &name, const QVariant &value)
+{
+ QDesignerFormWindowInterface *formWindow = q->core()->formWindowManager()->activeFormWindow();
+ if (!formWindow)
+ return;
+
+ Selection selection;
+ getSelection(selection);
+ if (selection.empty())
+ return;
+
+ AddDynamicPropertyCommand *cmd = new AddDynamicPropertyCommand(formWindow);
+ if (cmd->init(selection.selection(), propertyEditorObject(), name, value)) {
+ formWindow->commandHistory()->push(cmd);
+ } else {
+ delete cmd;
+ qDebug() << "** WARNING Unable to add dynamic property " << name << '.';
+ }
+}
+
+void QDesignerIntegrationPrivate::removeDynamicProperty(const QString &name)
+{
+ QDesignerFormWindowInterface *formWindow = q->core()->formWindowManager()->activeFormWindow();
+ if (!formWindow)
+ return;
+
+ Selection selection;
+ getSelection(selection);
+ if (selection.empty())
+ return;
+
+ RemoveDynamicPropertyCommand *cmd = new RemoveDynamicPropertyCommand(formWindow);
+ if (cmd->init(selection.selection(), propertyEditorObject(), name)) {
+ formWindow->commandHistory()->push(cmd);
+ } else {
+ delete cmd;
+ qDebug() << "** WARNING Unable to remove dynamic property " << name << '.';
+ }
+
+}
+
+void QDesignerIntegrationPrivate::setupFormWindow(QDesignerFormWindowInterface *formWindow)
+{
+ QObject::connect(formWindow, SIGNAL(selectionChanged()), q, SLOT(updateSelection()));
+}
+
+void QDesignerIntegrationPrivate::updateSelection()
+{
+ QDesignerFormEditorInterface *core = q->core();
+ QDesignerFormWindowInterface *formWindow = core->formWindowManager()->activeFormWindow();
+ QWidget *selection = 0;
+
+ if (formWindow) {
+ selection = formWindow->cursor()->current();
+ }
+
+ if (QDesignerActionEditorInterface *actionEditor = core->actionEditor())
+ actionEditor->setFormWindow(formWindow);
+
+ if (QDesignerPropertyEditorInterface *propertyEditor = core->propertyEditor())
+ propertyEditor->setObject(selection);
+
+ if (QDesignerObjectInspectorInterface *objectInspector = core->objectInspector())
+ objectInspector->setFormWindow(formWindow);
+
+}
+
+QWidget *QDesignerIntegrationPrivate::containerWindow(QWidget *widget) const
+{
+ // Find the parent window to apply a geometry to.
+ while (widget) {
+ if (widget->isWindow())
+ break;
+ if (!qstrcmp(widget->metaObject()->className(), "QMdiSubWindow"))
+ break;
+
+ widget = widget->parentWidget();
+ }
+
+ return widget;
+}
+
+void QDesignerIntegrationPrivate::getSelection(Selection &s)
+{
+ QDesignerFormEditorInterface *core = q->core();
+ // Get multiselection from object inspector
+ if (QDesignerObjectInspector *designerObjectInspector = qobject_cast<QDesignerObjectInspector *>(core->objectInspector())) {
+ designerObjectInspector->getSelection(s);
+ // Action editor puts actions that are not on the form yet
+ // into the property editor only.
+ if (s.empty())
+ if (QObject *object = core->propertyEditor()->object())
+ s.objects.push_back(object);
+
+ } else {
+ // Just in case someone plugs in an old-style object inspector: Emulate selection
+ s.clear();
+ QDesignerFormWindowInterface *formWindow = core->formWindowManager()->activeFormWindow();
+ if (!formWindow)
+ return;
+
+ QObject *object = core->propertyEditor()->object();
+ if (object->isWidgetType()) {
+ QWidget *widget = static_cast<QWidget*>(object);
+ QDesignerFormWindowCursorInterface *cursor = formWindow->cursor();
+ if (cursor->isWidgetSelected(widget)) {
+ s.managed.push_back(widget);
+ } else {
+ s.unmanaged.push_back(widget);
+ }
+ } else {
+ s.objects.push_back(object);
+ }
+ }
+}
+
+QObject *QDesignerIntegrationPrivate::propertyEditorObject()
+{
+ if (QDesignerPropertyEditorInterface *propertyEditor = q->core()->propertyEditor())
+ return propertyEditor->object();
+ return 0;
+}
+
+// Load plugins into widget database and factory.
+void QDesignerIntegrationPrivate::initializePlugins(QDesignerFormEditorInterface *formEditor)
+{
+ // load the plugins
+ qdesigner_internal::WidgetDataBase *widgetDataBase = qobject_cast<qdesigner_internal::WidgetDataBase*>(formEditor->widgetDataBase());
+ if (widgetDataBase) {
+ widgetDataBase->loadPlugins();
+ }
+
+ if (qdesigner_internal::WidgetFactory *widgetFactory = qobject_cast<qdesigner_internal::WidgetFactory*>(formEditor->widgetFactory())) {
+ widgetFactory->loadPlugins();
+ }
+
+ if (widgetDataBase) {
+ widgetDataBase->grabDefaultPropertyValues();
+ }
+}
+
+void QDesignerIntegrationPrivate::updateCustomWidgetPlugins()
+{
+ QDesignerFormEditorInterface *formEditor = q->core();
+ if (QDesignerPluginManager *pm = formEditor->pluginManager())
+ pm->registerNewPlugins();
+
+ initializePlugins(formEditor);
+
+ // Do not just reload the last file as the WidgetBox merges the compiled-in resources
+ // and $HOME/.designer/widgetbox.xml. This would also double the scratchpad.
+ if (QDesignerWidgetBox *wb = qobject_cast<QDesignerWidgetBox*>(formEditor->widgetBox())) {
+ const QDesignerWidgetBox::LoadMode oldLoadMode = wb->loadMode();
+ wb->setLoadMode(QDesignerWidgetBox::LoadCustomWidgetsOnly);
+ wb->load();
+ wb->setLoadMode(oldLoadMode);
+ }
+}
+
+static QString fixHelpClassName(const QString &className)
+{
+ // ### generalize using the Widget Data Base
+ if (className == QLatin1String("Line"))
+ return QLatin1String("QFrame");
+ if (className == QLatin1String("Spacer"))
+ return QLatin1String("QSpacerItem");
+ if (className == QLatin1String("QLayoutWidget"))
+ return QLatin1String("QLayout");
+ return className;
+}
+
+// Return class in which the property is defined
+static QString classForProperty(QDesignerFormEditorInterface *core,
+ QObject *object,
+ const QString &property)
+{
+ if (const QDesignerPropertySheetExtension *ps = qt_extension<QDesignerPropertySheetExtension *>(core->extensionManager(), object)) {
+ const int index = ps->indexOf(property);
+ if (index >= 0)
+ return ps->propertyGroup(index);
+ }
+ return QString();
+}
+
+QString QDesignerIntegrationPrivate::contextHelpId() const
+{
+ QDesignerFormEditorInterface *core = q->core();
+ QObject *currentObject = core->propertyEditor()->object();
+ if (!currentObject)
+ return QString();
+ // Return a help index id consisting of "class::property"
+ QString className;
+ QString currentPropertyName = core->propertyEditor()->currentPropertyName();
+ if (!currentPropertyName.isEmpty())
+ className = classForProperty(core, currentObject, currentPropertyName);
+ if (className.isEmpty()) {
+ currentPropertyName.clear(); // We hit on some fake property.
+ className = qdesigner_internal::WidgetFactory::classNameOf(core, currentObject);
+ }
+ QString helpId = fixHelpClassName(className);
+ if (!currentPropertyName.isEmpty()) {
+ helpId += QLatin1String("::");
+ helpId += currentPropertyName;
+ }
+ return helpId;
+}
+
+} // namespace qdesigner_internal
+
+// -------------- QDesignerIntegration
+// As of 4.4, the header will be distributed with the Eclipse plugin.
+
+QDesignerIntegration::QDesignerIntegration(QDesignerFormEditorInterface *core, QObject *parent) :
+ QDesignerIntegrationInterface(core, parent),
+ d(new qdesigner_internal::QDesignerIntegrationPrivate(this))
+{
+ d->initialize();
+}
+
+QDesignerIntegration::~QDesignerIntegration()
+{
+ QFile f(d->m_gradientsPath);
+ if (f.open(QIODevice::WriteOnly)) {
+ f.write(QtGradientUtils::saveState(d->m_gradientManager).toUtf8());
+ f.close();
+ }
+}
+
+QString QDesignerIntegration::headerSuffix() const
{
return d->headerSuffix;
}
-void QDesignerIntegrationInterface::setHeaderSuffix(const QString &headerSuffix)
+void QDesignerIntegration::setHeaderSuffix(const QString &headerSuffix)
{
d->headerSuffix = headerSuffix;
}
-bool QDesignerIntegrationInterface::isHeaderLowercase() const
+bool QDesignerIntegration::isHeaderLowercase() const
{
return d->headerLowercase;
}
-void QDesignerIntegrationInterface::setHeaderLowercase(bool headerLowercase)
+void QDesignerIntegration::setHeaderLowercase(bool headerLowercase)
{
d->headerLowercase = headerLowercase;
}
-QDesignerFormEditorInterface *QDesignerIntegrationInterface::core() const
+QDesignerIntegrationInterface::Feature QDesignerIntegration::features() const
{
- return d->m_core;
+ return d->m_features;
+}
+
+void QDesignerIntegration::setFeatures(Feature f)
+{
+ d->m_features = f;
+}
+
+QDesignerIntegrationInterface::ResourceFileWatcherBehaviour QDesignerIntegration::resourceFileWatcherBehaviour() const
+{
+ return d->m_resourceFileWatcherBehaviour;
+}
+
+void QDesignerIntegration::setResourceFileWatcherBehaviour(ResourceFileWatcherBehaviour behaviour)
+{
+ if (d->m_resourceFileWatcherBehaviour != behaviour) {
+ d->m_resourceFileWatcherBehaviour = behaviour;
+ core()->resourceModel()->setWatcherEnabled(behaviour != QDesignerIntegrationInterface::NoResourceFileWatcher);
+ }
+}
+
+void QDesignerIntegration::updateProperty(const QString &name, const QVariant &value, bool enableSubPropertyHandling)
+{
+ d->updateProperty(name, value, enableSubPropertyHandling);
+ emit propertyChanged(core()->formWindowManager()->activeFormWindow(), name, value);
+}
+
+void QDesignerIntegration::updateProperty(const QString &name, const QVariant &value)
+{
+ updateProperty(name, value, true);
+}
+
+void QDesignerIntegration::resetProperty(const QString &name)
+{
+ d->resetProperty(name);
+}
+
+void QDesignerIntegration::addDynamicProperty(const QString &name, const QVariant &value)
+{
+ d->addDynamicProperty(name, value);
+}
+
+void QDesignerIntegration::removeDynamicProperty(const QString &name)
+{
+ d->removeDynamicProperty(name);
+}
+
+void QDesignerIntegration::updateActiveFormWindow(QDesignerFormWindowInterface *)
+{
+ d->updateSelection();
+}
+
+void QDesignerIntegration::setupFormWindow(QDesignerFormWindowInterface *formWindow)
+{
+ d->setupFormWindow(formWindow);
+ connect(formWindow, SIGNAL(selectionChanged()), this, SLOT(updateSelection()));
+}
+
+void QDesignerIntegration::updateSelection()
+{
+ d->updateSelection();
+}
+
+QWidget *QDesignerIntegration::containerWindow(QWidget *widget) const
+{
+ return d->containerWindow(widget);
+}
+
+// Load plugins into widget database and factory.
+void QDesignerIntegration::initializePlugins(QDesignerFormEditorInterface *formEditor)
+{
+ qdesigner_internal::QDesignerIntegrationPrivate::initializePlugins(formEditor);
+}
+
+void QDesignerIntegration::updateCustomWidgetPlugins()
+{
+ d->updateCustomWidgetPlugins();
+}
+
+QDesignerResourceBrowserInterface *QDesignerIntegration::createResourceBrowser(QWidget *)
+{
+ return 0;
+}
+
+QString QDesignerIntegration::contextHelpId() const
+{
+ return d->contextHelpId();
}
QT_END_NAMESPACE
diff --git a/src/designer/src/lib/sdk/abstractintegration.h b/src/designer/src/lib/sdk/abstractintegration.h
index f67c4f098..9568d2e92 100644
--- a/src/designer/src/lib/sdk/abstractintegration.h
+++ b/src/designer/src/lib/sdk/abstractintegration.h
@@ -46,14 +46,23 @@
#include <QtCore/QObject>
#include <QtCore/QScopedPointer>
-#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QFlags>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
+class QDesignerFormWindowInterface;
class QDesignerFormEditorInterface;
class QDesignerIntegrationInterfacePrivate;
+class QDesignerResourceBrowserInterface;
+class QVariant;
+class QWidget;
+
+namespace qdesigner_internal {
+class QDesignerIntegrationPrivate;
+}
class QDESIGNER_SDK_EXPORT QDesignerIntegrationInterface: public QObject
{
@@ -62,6 +71,22 @@ class QDESIGNER_SDK_EXPORT QDesignerIntegrationInterface: public QObject
Q_PROPERTY(bool headerLowercase READ isHeaderLowercase WRITE setHeaderLowercase)
public:
+ enum ResourceFileWatcherBehaviour
+ {
+ NoResourceFileWatcher,
+ ReloadResourceFileSilently,
+ PromptToReloadResourceFile // Default
+ };
+
+ enum FeatureFlag
+ {
+ ResourceEditorFeature = 0x1,
+ SlotNavigationFeature = 0x2,
+ DefaultWidgetActionFeature = 0x4,
+ DefaultFeature = ResourceEditorFeature | DefaultWidgetActionFeature
+ };
+ Q_DECLARE_FLAGS(Feature, FeatureFlag)
+
QDesignerIntegrationInterface(QDesignerFormEditorInterface *core, QObject *parent = 0);
virtual ~QDesignerIntegrationInterface();
@@ -69,14 +94,97 @@ public:
virtual QWidget *containerWindow(QWidget *widget) const = 0;
+ // Create a resource browser specific to integration. Language integration takes precedence
+ virtual QDesignerResourceBrowserInterface *createResourceBrowser(QWidget *parent = 0) = 0;
+ virtual QString headerSuffix() const = 0;
+ virtual void setHeaderSuffix(const QString &headerSuffix) = 0;
+
+ virtual bool isHeaderLowercase() const = 0;
+ virtual void setHeaderLowercase(bool headerLowerCase) = 0;
+
+ virtual Feature features() const = 0;
+ bool hasFeature(Feature f) const;
+
+ virtual ResourceFileWatcherBehaviour resourceFileWatcherBehaviour() const = 0;
+ virtual void setResourceFileWatcherBehaviour(ResourceFileWatcherBehaviour behaviour) = 0;
+
+ virtual QString contextHelpId() const = 0;
+
+ void emitObjectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object,
+ const QString &newName, const QString &oldName);
+ void emitNavigateToSlot(const QString &objectName, const QString &signalSignature, const QStringList &parameterNames);
+ void emitNavigateToSlot(const QString &slotSignature);
+ void emitHelpRequested(const QString &manual, const QString &document);
+
+Q_SIGNALS:
+ void propertyChanged(QDesignerFormWindowInterface *formWindow, const QString &name, const QVariant &value);
+ void objectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object, const QString &newName, const QString &oldName);
+ void helpRequested(const QString &manual, const QString &document);
+
+ void navigateToSlot(const QString &objectName, const QString &signalSignature, const QStringList &parameterNames);
+ void navigateToSlot(const QString &slotSignature);
+
+public Q_SLOTS:
+ virtual void setFeatures(Feature f) = 0;
+ virtual void updateProperty(const QString &name, const QVariant &value, bool enableSubPropertyHandling) = 0;
+ virtual void updateProperty(const QString &name, const QVariant &value) = 0;
+ // Additional signals of designer property editor
+ virtual void resetProperty(const QString &name) = 0;
+ virtual void addDynamicProperty(const QString &name, const QVariant &value) = 0;
+ virtual void removeDynamicProperty(const QString &name) = 0;
+
+ virtual void updateActiveFormWindow(QDesignerFormWindowInterface *formWindow) = 0;
+ virtual void setupFormWindow(QDesignerFormWindowInterface *formWindow) = 0;
+ virtual void updateSelection() = 0;
+ virtual void updateCustomWidgetPlugins() = 0;
+
+private:
+ QScopedPointer<QDesignerIntegrationInterfacePrivate> d;
+};
+
+class QDESIGNER_SDK_EXPORT QDesignerIntegration: public QDesignerIntegrationInterface
+{
+ Q_OBJECT
+public:
+ explicit QDesignerIntegration(QDesignerFormEditorInterface *core, QObject *parent = 0);
+ virtual ~QDesignerIntegration();
+
QString headerSuffix() const;
void setHeaderSuffix(const QString &headerSuffix);
bool isHeaderLowercase() const;
void setHeaderLowercase(bool headerLowerCase);
+ Feature features() const;
+ virtual void setFeatures(Feature f);
+
+ ResourceFileWatcherBehaviour resourceFileWatcherBehaviour() const;
+ void setResourceFileWatcherBehaviour(ResourceFileWatcherBehaviour behaviour);
+
+ virtual QWidget *containerWindow(QWidget *widget) const;
+
+ // Load plugins into widget database and factory.
+ static void initializePlugins(QDesignerFormEditorInterface *formEditor);
+
+ // Create a resource browser specific to integration. Language integration takes precedence
+ virtual QDesignerResourceBrowserInterface *createResourceBrowser(QWidget *parent = 0);
+
+ virtual QString contextHelpId() const;
+
+ virtual void updateProperty(const QString &name, const QVariant &value, bool enableSubPropertyHandling);
+ virtual void updateProperty(const QString &name, const QVariant &value);
+ // Additional signals of designer property editor
+ virtual void resetProperty(const QString &name);
+ virtual void addDynamicProperty(const QString &name, const QVariant &value);
+ virtual void removeDynamicProperty(const QString &name);
+
+ virtual void updateActiveFormWindow(QDesignerFormWindowInterface *formWindow);
+ virtual void setupFormWindow(QDesignerFormWindowInterface *formWindow);
+ virtual void updateSelection();
+ virtual void updateCustomWidgetPlugins();
+
private:
- QScopedPointer<QDesignerIntegrationInterfacePrivate> d;
+ QScopedPointer<qdesigner_internal::QDesignerIntegrationPrivate> d;
};
QT_END_NAMESPACE
diff --git a/src/designer/src/lib/shared/formwindowbase.cpp b/src/designer/src/lib/shared/formwindowbase.cpp
index 7c87eaf59..ca81b5ed1 100644
--- a/src/designer/src/lib/shared/formwindowbase.cpp
+++ b/src/designer/src/lib/shared/formwindowbase.cpp
@@ -57,6 +57,7 @@
#include <QtDesigner/QDesignerContainerExtension>
#include <QtDesigner/QExtensionManager>
#include <QtDesigner/QDesignerTaskMenuExtension>
+#include <QtDesigner/QDesignerIntegrationInterface>
#include <QtCore/qdebug.h>
#include <QtCore/QList>
@@ -119,6 +120,8 @@ FormWindowBase::FormWindowBase(QDesignerFormEditorInterface *core, QWidget *pare
syncGridFeature();
m_d->m_pixmapCache = new DesignerPixmapCache(this);
m_d->m_iconCache = new DesignerIconCache(m_d->m_pixmapCache, this);
+ if (core->integration()->hasFeature(QDesignerIntegrationInterface::DefaultWidgetActionFeature))
+ connect(this, SIGNAL(activated(QWidget*)), this, SLOT(triggerDefaultAction(QWidget*)));
}
FormWindowBase::~FormWindowBase()
@@ -484,11 +487,6 @@ void FormWindowBase::triggerDefaultAction(QWidget *widget)
QTimer::singleShot(0, action, SIGNAL(triggered()));
}
-void FormWindowBase::setupDefaultAction(QDesignerFormWindowInterface *fw)
-{
- QObject::connect(fw, SIGNAL(activated(QWidget*)), fw, SLOT(triggerDefaultAction(QWidget*)));
-}
-
QString FormWindowBase::fileContents() const
{
const bool oldValue = QSimpleResource::setWarningsEnabled(false);
diff --git a/src/designer/src/lib/shared/formwindowbase_p.h b/src/designer/src/lib/shared/formwindowbase_p.h
index f0fb2e204..62136a62d 100644
--- a/src/designer/src/lib/shared/formwindowbase_p.h
+++ b/src/designer/src/lib/shared/formwindowbase_p.h
@@ -182,10 +182,6 @@ public:
void setLineTerminatorMode(LineTerminatorMode mode);
LineTerminatorMode lineTerminatorMode() const;
- // Connect the 'activated' (doubleclicked) signal of the form window to a
- // slot triggering the default action (of the task menu)
- static void setupDefaultAction(QDesignerFormWindowInterface *fw);
-
public slots:
void resourceSetActivated(QtResourceSet *resourceSet, bool resourceSetChanged);
diff --git a/src/designer/src/lib/shared/iconselector.cpp b/src/designer/src/lib/shared/iconselector.cpp
index 0d6e3e0e8..10b5c9714 100644
--- a/src/designer/src/lib/shared/iconselector.cpp
+++ b/src/designer/src/lib/shared/iconselector.cpp
@@ -44,14 +44,13 @@
#include "qtresourcemodel_p.h"
#include "qtresourceview_p.h"
#include "iconloader_p.h"
-#include "qdesigner_integration_p.h"
#include "formwindowbase_p.h"
#include <abstractdialoggui_p.h>
-#include <qdesigner_integration_p.h>
#include <QtDesigner/QDesignerFormEditorInterface>
#include <QtDesigner/QDesignerResourceBrowserInterface>
#include <QtDesigner/QDesignerLanguageExtension>
+#include <QtDesigner/QDesignerIntegrationInterface>
#include <QtDesigner/QExtensionManager>
#include <QtGui/QToolButton>
@@ -178,9 +177,8 @@ LanguageResourceDialog* LanguageResourceDialog::create(QDesignerFormEditorInterf
if (QDesignerLanguageExtension *lang = qt_extension<QDesignerLanguageExtension *>(core->extensionManager(), core))
if (QDesignerResourceBrowserInterface *rb = lang->createResourceBrowser(0))
return new LanguageResourceDialog(rb, parent);
- if (QDesignerIntegration *di = qobject_cast<QDesignerIntegration*>(core->integration()))
- if (QDesignerResourceBrowserInterface *rb = di->createResourceBrowser(0))
- return new LanguageResourceDialog(rb, parent);
+ if (QDesignerResourceBrowserInterface *rb = core->integration()->createResourceBrowser(0))
+ return new LanguageResourceDialog(rb, parent);
return 0;
}
@@ -303,10 +301,7 @@ QString IconSelector::choosePixmapResource(QDesignerFormEditorInterface *core, Q
delete ldlg;
} else {
QtResourceViewDialog dlg(core, parent);
-
- QDesignerIntegration *designerIntegration = qobject_cast<QDesignerIntegration *>(core->integration());
- if (designerIntegration)
- dlg.setResourceEditingEnabled(designerIntegration->isResourceEditingEnabled());
+ dlg.setResourceEditingEnabled(core->integration()->hasFeature(QDesignerIntegration::ResourceEditorFeature));
dlg.selectResource(oldPath);
if (dlg.exec() == QDialog::Accepted)
diff --git a/src/designer/src/lib/shared/plugindialog.cpp b/src/designer/src/lib/shared/plugindialog.cpp
index 9b1212b39..c4cdccf77 100644
--- a/src/designer/src/lib/shared/plugindialog.cpp
+++ b/src/designer/src/lib/shared/plugindialog.cpp
@@ -42,9 +42,9 @@
#include "plugindialog_p.h"
#include "pluginmanager_p.h"
-#include "qdesigner_integration_p.h"
#include <QtDesigner/QDesignerFormEditorInterface>
+#include <QtDesigner/QDesignerIntegrationInterface>
#include <QtDesigner/QDesignerCustomWidgetCollectionInterface>
#include <QtDesigner/QDesignerWidgetDataBaseInterface>
@@ -85,14 +85,13 @@ PluginDialog::PluginDialog(QDesignerFormEditorInterface *core, QWidget *parent)
setWindowTitle(tr("Plugin Information"));
populateTreeWidget();
- if (qobject_cast<qdesigner_internal::QDesignerIntegration *>(m_core->integration())) {
- QPushButton *updateButton = new QPushButton(tr("Refresh"));
- const QString tooltip = tr("Scan for newly installed custom widget plugins.");
- updateButton->setToolTip(tooltip);
- updateButton->setWhatsThis(tooltip);
- connect(updateButton, SIGNAL(clicked()), this, SLOT(updateCustomWidgetPlugins()));
- ui.buttonBox->addButton(updateButton, QDialogButtonBox::ActionRole);
- }
+ QPushButton *updateButton = new QPushButton(tr("Refresh"));
+ const QString tooltip = tr("Scan for newly installed custom widget plugins.");
+ updateButton->setToolTip(tooltip);
+ updateButton->setWhatsThis(tooltip);
+ connect(updateButton, SIGNAL(clicked()), this, SLOT(updateCustomWidgetPlugins()));
+ ui.buttonBox->addButton(updateButton, QDialogButtonBox::ActionRole);
+
}
void PluginDialog::populateTreeWidget()
@@ -188,18 +187,16 @@ void PluginDialog::setItem(QTreeWidgetItem *pluginItem, const QString &name,
void PluginDialog::updateCustomWidgetPlugins()
{
- if (qdesigner_internal::QDesignerIntegration *integration = qobject_cast<qdesigner_internal::QDesignerIntegration *>(m_core->integration())) {
- const int before = m_core->widgetDataBase()->count();
- integration->updateCustomWidgetPlugins();
- const int after = m_core->widgetDataBase()->count();
- if (after > before) {
- ui.message->setText(tr("New custom widget plugins have been found."));
- ui.message->show();
- } else {
- ui.message->setText(QString());
- }
- populateTreeWidget();
+ const int before = m_core->widgetDataBase()->count();
+ m_core->integration()->updateCustomWidgetPlugins();
+ const int after = m_core->widgetDataBase()->count();
+ if (after > before) {
+ ui.message->setText(tr("New custom widget plugins have been found."));
+ ui.message->show();
+ } else {
+ ui.message->setText(QString());
}
+ populateTreeWidget();
}
}
diff --git a/src/designer/src/lib/shared/qdesigner_integration.cpp b/src/designer/src/lib/shared/qdesigner_integration.cpp
deleted file mode 100644
index 7470bbf80..000000000
--- a/src/designer/src/lib/shared/qdesigner_integration.cpp
+++ /dev/null
@@ -1,496 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
-** this package.
-**
-** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdesigner_integration_p.h"
-#include "qdesigner_propertycommand_p.h"
-#include "qdesigner_propertyeditor_p.h"
-#include "qdesigner_objectinspector_p.h"
-#include "widgetdatabase_p.h"
-#include "pluginmanager_p.h"
-#include "widgetfactory_p.h"
-#include "qdesigner_widgetbox_p.h"
-#include "qtgradientmanager.h"
-#include "qtgradientutils.h"
-#include "qtresourcemodel_p.h"
-
-// sdk
-#include <QtDesigner/QDesignerFormEditorInterface>
-#include <QtDesigner/QDesignerFormWindowInterface>
-#include <QtDesigner/QDesignerFormWindowManagerInterface>
-#include <QtDesigner/QDesignerFormWindowCursorInterface>
-#include <QtDesigner/QDesignerActionEditorInterface>
-#include <QtDesigner/QDesignerWidgetBoxInterface>
-#include <QtDesigner/QExtensionManager>
-#include <QtDesigner/QDesignerResourceBrowserInterface>
-#include <QtDesigner/QDesignerPropertySheetExtension>
-
-#include <QtCore/QVariant>
-#include <QtCore/QFile>
-#include <QtCore/QDir>
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace qdesigner_internal {
-
-// ---------------- DesignerIntegrationPrivate
-class QDesignerIntegrationPrivate {
-public:
- QDesignerIntegrationPrivate()
- : m_gradientManager(0),
- m_fileWatcherBehaviour(QDesignerIntegration::PromptAndReload),
- m_resourceEditingEnabled(true),
- m_slotNavigationEnabled(false)
- {}
-
- QString m_gradientsPath;
- QtGradientManager *m_gradientManager;
- QDesignerIntegration::ResourceFileWatcherBehaviour m_fileWatcherBehaviour;
- bool m_resourceEditingEnabled;
- bool m_slotNavigationEnabled;
-};
-
-// -------------- QDesignerIntegration
-// As of 4.4, the header will be distributed with the Eclipse plugin.
-
-QDesignerIntegration::QDesignerIntegration(QDesignerFormEditorInterface *core, QObject *parent) :
- QDesignerIntegrationInterface(core, parent),
- m_d(new QDesignerIntegrationPrivate)
-{
- initialize();
-}
-
-QDesignerIntegration::~QDesignerIntegration()
-{
- QFile f(m_d->m_gradientsPath);
- if (f.open(QIODevice::WriteOnly)) {
- f.write(QtGradientUtils::saveState(m_d->m_gradientManager).toUtf8());
- f.close();
- }
- delete m_d;
-}
-
-void QDesignerIntegration::initialize()
-{
- //
- // integrate the `Form Editor component'
- //
-
- // Extensions
- if (QDesignerPropertyEditor *designerPropertyEditor= qobject_cast<QDesignerPropertyEditor *>(core()->propertyEditor())) {
- connect(designerPropertyEditor, SIGNAL(propertyValueChanged(QString,QVariant,bool)), this, SLOT(updateProperty(QString,QVariant,bool)));
- connect(designerPropertyEditor, SIGNAL(resetProperty(QString)), this, SLOT(resetProperty(QString)));
- connect(designerPropertyEditor, SIGNAL(addDynamicProperty(QString,QVariant)),
- this, SLOT(addDynamicProperty(QString,QVariant)));
- connect(designerPropertyEditor, SIGNAL(removeDynamicProperty(QString)),
- this, SLOT(removeDynamicProperty(QString)));
- } else {
- connect(core()->propertyEditor(), SIGNAL(propertyChanged(QString,QVariant)),
- this, SLOT(updatePropertyPrivate(QString,QVariant)));
- }
-
- connect(core()->formWindowManager(), SIGNAL(formWindowAdded(QDesignerFormWindowInterface*)),
- this, SLOT(setupFormWindow(QDesignerFormWindowInterface*)));
-
- connect(core()->formWindowManager(), SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)),
- this, SLOT(updateActiveFormWindow(QDesignerFormWindowInterface*)));
-
- m_d->m_gradientManager = new QtGradientManager(this);
- core()->setGradientManager(m_d->m_gradientManager);
-
- QString designerFolder = QDir::homePath();
- designerFolder += QDir::separator();
- designerFolder += QLatin1String(".designer");
- m_d->m_gradientsPath = designerFolder;
- m_d->m_gradientsPath += QDir::separator();
- m_d->m_gradientsPath += QLatin1String("gradients.xml");
-
- QFile f(m_d->m_gradientsPath);
- if (f.open(QIODevice::ReadOnly)) {
- QtGradientUtils::restoreState(m_d->m_gradientManager, QString::fromAscii(f.readAll()));
- f.close();
- } else {
- QFile defaultGradients(QLatin1String(":/trolltech/designer/defaultgradients.xml"));
- if (defaultGradients.open(QIODevice::ReadOnly)) {
- QtGradientUtils::restoreState(m_d->m_gradientManager, QString::fromAscii(defaultGradients.readAll()));
- defaultGradients.close();
- }
- }
-
- if (WidgetDataBase *widgetDataBase = qobject_cast<WidgetDataBase*>(core()->widgetDataBase()))
- widgetDataBase->grabStandardWidgetBoxIcons();
-}
-
-void QDesignerIntegration::updateProperty(const QString &name, const QVariant &value, bool enableSubPropertyHandling)
-{
- QDesignerFormWindowInterface *formWindow = core()->formWindowManager()->activeFormWindow();
- if (!formWindow)
- return;
-
- Selection selection;
- getSelection(selection);
- if (selection.empty())
- return;
-
- SetPropertyCommand *cmd = new SetPropertyCommand(formWindow);
- // find a reference object to compare to and to find the right group
- if (cmd->init(selection.selection(), name, value, propertyEditorObject(), enableSubPropertyHandling)) {
- formWindow->commandHistory()->push(cmd);
- } else {
- delete cmd;
- qDebug() << "Unable to set property " << name << '.';
- }
-
- emit propertyChanged(formWindow, name, value);
-}
-
-void QDesignerIntegration::updatePropertyPrivate(const QString &name, const QVariant &value)
-{
- updateProperty(name, value, true);
-}
-
-void QDesignerIntegration::resetProperty(const QString &name)
-{
- QDesignerFormWindowInterface *formWindow = core()->formWindowManager()->activeFormWindow();
- if (!formWindow)
- return;
-
- Selection selection;
- getSelection(selection);
- if (selection.empty())
- return;
-
-
- ResetPropertyCommand *cmd = new ResetPropertyCommand(formWindow);
- // find a reference object to find the right group
- if (cmd->init(selection.selection(), name, propertyEditorObject())) {
- formWindow->commandHistory()->push(cmd);
- } else {
- delete cmd;
- qDebug() << "** WARNING Unable to reset property " << name << '.';
- }
-}
-
-void QDesignerIntegration::addDynamicProperty(const QString &name, const QVariant &value)
-{
- QDesignerFormWindowInterface *formWindow = core()->formWindowManager()->activeFormWindow();
- if (!formWindow)
- return;
-
- Selection selection;
- getSelection(selection);
- if (selection.empty())
- return;
-
- AddDynamicPropertyCommand *cmd = new AddDynamicPropertyCommand(formWindow);
- if (cmd->init(selection.selection(), propertyEditorObject(), name, value)) {
- formWindow->commandHistory()->push(cmd);
- } else {
- delete cmd;
- qDebug() << "** WARNING Unable to add dynamic property " << name << '.';
- }
-}
-
-void QDesignerIntegration::removeDynamicProperty(const QString &name)
-{
- QDesignerFormWindowInterface *formWindow = core()->formWindowManager()->activeFormWindow();
- if (!formWindow)
- return;
-
- Selection selection;
- getSelection(selection);
- if (selection.empty())
- return;
-
- RemoveDynamicPropertyCommand *cmd = new RemoveDynamicPropertyCommand(formWindow);
- if (cmd->init(selection.selection(), propertyEditorObject(), name)) {
- formWindow->commandHistory()->push(cmd);
- } else {
- delete cmd;
- qDebug() << "** WARNING Unable to remove dynamic property " << name << '.';
- }
-
-}
-
-
-void QDesignerIntegration::updateActiveFormWindow(QDesignerFormWindowInterface *formWindow)
-{
- Q_UNUSED(formWindow);
- updateSelection();
-}
-
-void QDesignerIntegration::setupFormWindow(QDesignerFormWindowInterface *formWindow)
-{
- connect(formWindow, SIGNAL(selectionChanged()), this, SLOT(updateSelection()));
- connect(formWindow, SIGNAL(activated(QWidget*)), this, SLOT(activateWidget(QWidget*)));
-}
-
-void QDesignerIntegration::updateGeometry()
-{
-}
-
-void QDesignerIntegration::updateSelection()
-{
- QDesignerFormWindowInterface *formWindow = core()->formWindowManager()->activeFormWindow();
- QWidget *selection = 0;
-
- if (formWindow) {
- selection = formWindow->cursor()->current();
- }
-
- if (QDesignerActionEditorInterface *actionEditor = core()->actionEditor())
- actionEditor->setFormWindow(formWindow);
-
- if (QDesignerPropertyEditorInterface *propertyEditor = core()->propertyEditor())
- propertyEditor->setObject(selection);
-
- if (QDesignerObjectInspectorInterface *objectInspector = core()->objectInspector())
- objectInspector->setFormWindow(formWindow);
-
-}
-
-void QDesignerIntegration::activateWidget(QWidget *widget)
-{
- Q_UNUSED(widget);
-}
-
-QWidget *QDesignerIntegration::containerWindow(QWidget *widget) const
-{
- // Find the parent window to apply a geometry to.
- while (widget) {
- if (widget->isWindow())
- break;
- if (!qstrcmp(widget->metaObject()->className(), "QMdiSubWindow"))
- break;
-
- widget = widget->parentWidget();
- }
-
- return widget;
-}
-
-void QDesignerIntegration::getSelection(Selection &s)
-{
- // Get multiselection from object inspector
- if (QDesignerObjectInspector *designerObjectInspector = qobject_cast<QDesignerObjectInspector *>(core()->objectInspector())) {
- designerObjectInspector->getSelection(s);
- // Action editor puts actions that are not on the form yet
- // into the property editor only.
- if (s.empty())
- if (QObject *object = core()->propertyEditor()->object())
- s.objects.push_back(object);
-
- } else {
- // Just in case someone plugs in an old-style object inspector: Emulate selection
- s.clear();
- QDesignerFormWindowInterface *formWindow = core()->formWindowManager()->activeFormWindow();
- if (!formWindow)
- return;
-
- QObject *object = core()->propertyEditor()->object();
- if (object->isWidgetType()) {
- QWidget *widget = static_cast<QWidget*>(object);
- QDesignerFormWindowCursorInterface *cursor = formWindow->cursor();
- if (cursor->isWidgetSelected(widget)) {
- s.managed.push_back(widget);
- } else {
- s.unmanaged.push_back(widget);
- }
- } else {
- s.objects.push_back(object);
- }
- }
-}
-
-QObject *QDesignerIntegration::propertyEditorObject()
-{
- QDesignerPropertyEditorInterface *propertyEditor = core()->propertyEditor();
- if (!propertyEditor)
- return 0;
- return propertyEditor->object();
-}
-
-// Load plugins into widget database and factory.
-void QDesignerIntegration::initializePlugins(QDesignerFormEditorInterface *formEditor)
-{
- // load the plugins
- WidgetDataBase *widgetDataBase = qobject_cast<WidgetDataBase*>(formEditor->widgetDataBase());
- if (widgetDataBase) {
- widgetDataBase->loadPlugins();
- }
-
- if (WidgetFactory *widgetFactory = qobject_cast<WidgetFactory*>(formEditor->widgetFactory())) {
- widgetFactory->loadPlugins();
- }
-
- if (widgetDataBase) {
- widgetDataBase->grabDefaultPropertyValues();
- }
-}
-
-void QDesignerIntegration::updateCustomWidgetPlugins()
-{
- QDesignerFormEditorInterface *formEditor = core();
- if (QDesignerPluginManager *pm = formEditor->pluginManager())
- pm->registerNewPlugins();
-
- initializePlugins(formEditor);
-
- // Do not just reload the last file as the WidgetBox merges the compiled-in resources
- // and $HOME/.designer/widgetbox.xml. This would also double the scratchpad.
- if (QDesignerWidgetBox *wb = qobject_cast<QDesignerWidgetBox*>(formEditor->widgetBox())) {
- const QDesignerWidgetBox::LoadMode oldLoadMode = wb->loadMode();
- wb->setLoadMode(QDesignerWidgetBox::LoadCustomWidgetsOnly);
- wb->load();
- wb->setLoadMode(oldLoadMode);
- }
-}
-
-void QDesignerIntegration::emitObjectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object, const QString &newName, const QString &oldName)
-{
- emit objectNameChanged(formWindow, object, newName, oldName);
-}
-
-void QDesignerIntegration::emitNavigateToSlot(const QString &objectName,
- const QString &signalSignature,
- const QStringList &parameterNames)
-{
- emit navigateToSlot(objectName, signalSignature, parameterNames);
-}
-
-void QDesignerIntegration::emitNavigateToSlot(const QString &slotSignature)
-{
- emit navigateToSlot(slotSignature);
-}
-
-void QDesignerIntegration::requestHelp(const QDesignerFormEditorInterface *core, const QString &manual, const QString &document)
-{
- if (QDesignerIntegration *di = qobject_cast<QDesignerIntegration *>(core->integration()))
- emit di->helpRequested(manual, document);
-}
-
-QDesignerResourceBrowserInterface *QDesignerIntegration::createResourceBrowser(QWidget *)
-{
- return 0;
-}
-
-void QDesignerIntegration::setResourceFileWatcherBehaviour(ResourceFileWatcherBehaviour behaviour)
-{
- m_d->m_fileWatcherBehaviour = behaviour;
- core()->resourceModel()->setWatcherEnabled(behaviour != QDesignerIntegration::NoWatcher);
-}
-
-QDesignerIntegration::ResourceFileWatcherBehaviour QDesignerIntegration::resourceFileWatcherBehaviour() const
-{
- return m_d->m_fileWatcherBehaviour;
-}
-
-void QDesignerIntegration::setResourceEditingEnabled(bool enable)
-{
- m_d->m_resourceEditingEnabled = enable;
-}
-
-bool QDesignerIntegration::isResourceEditingEnabled() const
-{
- return m_d->m_resourceEditingEnabled;
-}
-
-void QDesignerIntegration::setSlotNavigationEnabled(bool enable)
-{
- m_d->m_slotNavigationEnabled = enable;
-}
-
-bool QDesignerIntegration::isSlotNavigationEnabled() const
-{
- return m_d->m_slotNavigationEnabled;
-}
-
-static QString fixHelpClassName(const QString &className)
-{
- // ### generalize using the Widget Data Base
- if (className == QLatin1String("Line"))
- return QLatin1String("QFrame");
- if (className == QLatin1String("Spacer"))
- return QLatin1String("QSpacerItem");
- if (className == QLatin1String("QLayoutWidget"))
- return QLatin1String("QLayout");
- return className;
-}
-
-// Return class in which the property is defined
-static QString classForProperty(QDesignerFormEditorInterface *core,
- QObject *object,
- const QString &property)
-{
- if (const QDesignerPropertySheetExtension *ps = qt_extension<QDesignerPropertySheetExtension *>(core->extensionManager(), object)) {
- const int index = ps->indexOf(property);
- if (index >= 0)
- return ps->propertyGroup(index);
- }
- return QString();
-}
-
-QString QDesignerIntegration::contextHelpId() const
-{
- QObject *currentObject = core()->propertyEditor()->object();
- if (!currentObject)
- return QString();
- // Return a help index id consisting of "class::property"
- QString className;
- QString currentPropertyName = core()->propertyEditor()->currentPropertyName();
- if (!currentPropertyName.isEmpty())
- className = classForProperty(core(), currentObject, currentPropertyName);
- if (className.isEmpty()) {
- currentPropertyName.clear(); // We hit on some fake property.
- className = WidgetFactory::classNameOf(core(), currentObject);
- }
- QString helpId = fixHelpClassName(className);
- if (!currentPropertyName.isEmpty()) {
- helpId += QLatin1String("::");
- helpId += currentPropertyName;
- }
- return helpId;
-}
-
-} // namespace qdesigner_internal
-
-QT_END_NAMESPACE
diff --git a/src/designer/src/lib/shared/qdesigner_integration_p.h b/src/designer/src/lib/shared/qdesigner_integration_p.h
deleted file mode 100644
index f4fdff7db..000000000
--- a/src/designer/src/lib/shared/qdesigner_integration_p.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
-** this package.
-**
-** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@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_INTEGRATION_H
-#define QDESIGNER_INTEGRATION_H
-
-#include "shared_global_p.h"
-#include <QtDesigner/QDesignerIntegrationInterface>
-
-#include <QtCore/QObject>
-
-QT_BEGIN_NAMESPACE
-
-class QDesignerFormEditorInterface;
-class QDesignerFormWindowInterface;
-class QDesignerResourceBrowserInterface;
-
-class QVariant;
-class QWidget;
-
-namespace qdesigner_internal {
-
-struct Selection;
-class QDesignerIntegrationPrivate;
-
-class QDESIGNER_SHARED_EXPORT QDesignerIntegration: public QDesignerIntegrationInterface
-{
- Q_OBJECT
-public:
- explicit QDesignerIntegration(QDesignerFormEditorInterface *core, QObject *parent = 0);
- virtual ~QDesignerIntegration();
-
- static void requestHelp(const QDesignerFormEditorInterface *core, const QString &manual, const QString &document);
-
- virtual QWidget *containerWindow(QWidget *widget) const;
-
- // Load plugins into widget database and factory.
- static void initializePlugins(QDesignerFormEditorInterface *formEditor);
- void emitObjectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object,
- const QString &newName, const QString &oldName);
- void emitNavigateToSlot(const QString &objectName, const QString &signalSignature, const QStringList &parameterNames);
- void emitNavigateToSlot(const QString &slotSignature);
-
- // Create a resource browser specific to integration. Language integration takes precedence
- virtual QDesignerResourceBrowserInterface *createResourceBrowser(QWidget *parent = 0);
-
- enum ResourceFileWatcherBehaviour {
- NoWatcher,
- ReloadSilently,
- PromptAndReload
- };
-
- ResourceFileWatcherBehaviour resourceFileWatcherBehaviour() const;
- bool isResourceEditingEnabled() const;
- bool isSlotNavigationEnabled() const;
-
- QString contextHelpId() const;
-
-protected:
-
- void setResourceFileWatcherBehaviour(ResourceFileWatcherBehaviour behaviour); // PromptAndReload by default
- void setResourceEditingEnabled(bool enable); // true by default
- void setSlotNavigationEnabled(bool enable); // false by default
-
-signals:
- void propertyChanged(QDesignerFormWindowInterface *formWindow, const QString &name, const QVariant &value);
- void objectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object, const QString &newName, const QString &oldName);
- void helpRequested(const QString &manual, const QString &document);
-
- void navigateToSlot(const QString &objectName, const QString &signalSignature, const QStringList &parameterNames);
- void navigateToSlot(const QString &slotSignature);
-
-public slots:
- virtual void updateProperty(const QString &name, const QVariant &value, bool enableSubPropertyHandling);
- // Additional signals of designer property editor
- virtual void resetProperty(const QString &name);
- virtual void addDynamicProperty(const QString &name, const QVariant &value);
- virtual void removeDynamicProperty(const QString &name);
-
- virtual void updateActiveFormWindow(QDesignerFormWindowInterface *formWindow);
- virtual void setupFormWindow(QDesignerFormWindowInterface *formWindow);
- virtual void updateSelection();
- virtual void updateGeometry();
- virtual void activateWidget(QWidget *widget);
-
- void updateCustomWidgetPlugins();
-
-private slots:
- void updatePropertyPrivate(const QString &name, const QVariant &value);
-
-private:
- void initialize();
- void getSelection(Selection &s);
- QObject *propertyEditorObject();
-
- QDesignerIntegrationPrivate *m_d;
-};
-
-} // namespace qdesigner_internal
-
-QT_END_NAMESPACE
-
-#endif // QDESIGNER_INTEGRATION_H
diff --git a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp
index dfe053189..c145f0d2d 100644
--- a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp
+++ b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp
@@ -43,11 +43,11 @@
#include "qdesigner_utils_p.h"
#include "dynamicpropertysheet.h"
#include "qdesigner_propertyeditor_p.h"
-#include "qdesigner_integration_p.h"
#include "spacer_widget_p.h"
#include "qdesigner_propertysheet_p.h"
#include <QtDesigner/QDesignerFormEditorInterface>
+#include <QtDesigner/QDesignerIntegrationInterface>
#include <QtDesigner/QDesignerFormWindowInterface>
#include <QtDesigner/QDesignerFormWindowCursorInterface>
#include <QtDesigner/QDesignerDynamicPropertySheetExtension>
diff --git a/src/designer/src/lib/shared/qdesigner_propertycommand_p.h b/src/designer/src/lib/shared/qdesigner_propertycommand_p.h
index 0dc1825fe..9d72b0487 100644
--- a/src/designer/src/lib/shared/qdesigner_propertycommand_p.h
+++ b/src/designer/src/lib/shared/qdesigner_propertycommand_p.h
@@ -64,11 +64,10 @@ QT_BEGIN_NAMESPACE
class QDesignerFormWindowInterface;
class QDesignerPropertySheetExtension;
+class QDesignerIntegration;
namespace qdesigner_internal {
-class QDesignerIntegration;
-
enum SpecialProperty {
SP_None, SP_ObjectName, SP_LayoutName, SP_SpacerName,SP_WindowTitle,
SP_MinimumSize, SP_MaximumSize, SP_Geometry, SP_Icon, SP_CurrentTabName, SP_CurrentItemName, SP_CurrentPageName,
diff --git a/src/designer/src/lib/shared/qdesigner_taskmenu.cpp b/src/designer/src/lib/shared/qdesigner_taskmenu.cpp
index 5a9ace4b9..d6aef71ef 100644
--- a/src/designer/src/lib/shared/qdesigner_taskmenu.cpp
+++ b/src/designer/src/lib/shared/qdesigner_taskmenu.cpp
@@ -59,7 +59,6 @@
#include "qdesigner_utils_p.h"
#include "qdesigner_objectinspector_p.h"
#include "morphmenu_p.h"
-#include "qdesigner_integration_p.h"
#include "formlayoutmenu_p.h"
#include "ui_selectsignaldialog.h"
#include "widgetfactory_p.h"
@@ -73,6 +72,7 @@
#include <QtDesigner/QDesignerPropertySheetExtension>
#include <QtDesigner/QDesignerFormEditorInterface>
#include <QtDesigner/QDesignerLanguageExtension>
+#include <QtDesigner/QDesignerIntegrationInterface>
#include <QtDesigner/QExtensionManager>
#include <QtGui/QAction>
@@ -121,10 +121,6 @@ static inline QAction *createSeparatorHelper(QObject *parent) {
return rc;
}
-static inline qdesigner_internal::QDesignerIntegration *integration(const QDesignerFormEditorInterface *core) {
- return qobject_cast<qdesigner_internal::QDesignerIntegration *>(core->integration());
-}
-
static QString objName(const QDesignerFormEditorInterface *core, QObject *object) {
QDesignerPropertySheetExtension *sheet
= qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), object);
@@ -701,9 +697,7 @@ static QString declaredInClass(const QDesignerMetaObjectInterface *metaObject, c
bool QDesignerTaskMenu::isSlotNavigationEnabled(const QDesignerFormEditorInterface *core)
{
- if (QDesignerIntegration *integr = integration(core))
- return integr->isSlotNavigationEnabled();
- return false;
+ return core->integration()->hasFeature(QDesignerIntegration::SlotNavigationFeature);
}
void QDesignerTaskMenu::slotNavigateToSlot()
@@ -720,8 +714,6 @@ void QDesignerTaskMenu::navigateToSlot(QDesignerFormEditorInterface *core,
const QString objectName = objName(core, object);
QMap<QString, QMap<QString, QStringList> > classToSignalList;
- QDesignerIntegration *integr = integration(core);
-
// "real" signals
if (const QDesignerMetaObjectInterface *metaObject = core->introspection()->metaObject(object)) {
const int methodCount = metaObject->methodCount();
@@ -801,7 +793,7 @@ void QDesignerTaskMenu::navigateToSlot(QDesignerFormEditorInterface *core,
const QStringList parameterNames = qvariant_cast<QStringList>(selectedItem->data(0, Qt::UserRole));
// TODO: Check whether signal is connected to slot
- integr->emitNavigateToSlot(objectName, signalSignature, parameterNames);
+ core->integration()->emitNavigateToSlot(objectName, signalSignature, parameterNames);
}
}
diff --git a/src/designer/src/lib/shared/shared.pri b/src/designer/src/lib/shared/shared.pri
index 0d145172e..9cba7d7bf 100644
--- a/src/designer/src/lib/shared/shared.pri
+++ b/src/designer/src/lib/shared/shared.pri
@@ -42,7 +42,6 @@ HEADERS += \
$$PWD/qdesigner_membersheet_p.h \
$$PWD/qdesigner_propertyeditor_p.h \
$$PWD/qdesigner_objectinspector_p.h \
- $$PWD/qdesigner_integration_p.h \
$$PWD/invisible_widget_p.h \
$$PWD/qlayout_widget_p.h \
$$PWD/sheet_delegate_p.h \
@@ -126,7 +125,6 @@ SOURCES += \
$$PWD/qdesigner_membersheet.cpp \
$$PWD/qdesigner_propertyeditor.cpp \
$$PWD/qdesigner_objectinspector.cpp \
- $$PWD/qdesigner_integration.cpp \
$$PWD/qdesigner_dnditem.cpp \
$$PWD/qsimpleresource.cpp \
$$PWD/invisible_widget.cpp \
diff --git a/src/designer/src/lib/shared/stylesheeteditor.cpp b/src/designer/src/lib/shared/stylesheeteditor.cpp
index ee5fea41e..72e7c10b8 100644
--- a/src/designer/src/lib/shared/stylesheeteditor.cpp
+++ b/src/designer/src/lib/shared/stylesheeteditor.cpp
@@ -45,7 +45,6 @@
#include "qtgradientmanager.h"
#include "qtgradientviewdialog.h"
#include "qtgradientutils.h"
-#include "qdesigner_integration_p.h"
#include "qdesigner_utils_p.h"
#include "abstractsettings_p.h"
@@ -53,6 +52,7 @@
#include <QtDesigner/QDesignerFormWindowCursorInterface>
#include <QtDesigner/QDesignerFormEditorInterface>
#include <QtDesigner/QDesignerPropertySheetExtension>
+#include <QtDesigner/QDesignerIntegrationInterface>
#include <QtDesigner/QExtensionManager>
#include <QtCore/QSignalMapper>
@@ -331,8 +331,8 @@ void StyleSheetEditorDialog::insertCssProperty(const QString &name, const QStrin
void StyleSheetEditorDialog::slotRequestHelp()
{
- QDesignerIntegration::requestHelp(m_core, QLatin1String("qt"),
- QLatin1String("stylesheet-reference.html"));
+ m_core->integration()->emitHelpRequested(QLatin1String("qt"),
+ QLatin1String("stylesheet-reference.html"));
}
QDialogButtonBox * StyleSheetEditorDialog::buttonBox() const