void QDesignerIntegrationPrivate::initialize() { typedef void (QDesignerIntegration::*QDesignerIntegrationUpdatePropertySlot3)(const QString &, const QVariant &, bool); // // integrate the `Form Editor component' // // Extensions QDesignerFormEditorInterface *core = q->core(); if (QDesignerPropertyEditor *designerPropertyEditor= qobject_cast<QDesignerPropertyEditor *>(core->propertyEditor())) { QObject::connect(designerPropertyEditor, &QDesignerPropertyEditor::propertyValueChanged, q, static_cast<QDesignerIntegrationUpdatePropertySlot3>(&QDesignerIntegration::updateProperty)); QObject::connect(designerPropertyEditor, &QDesignerPropertyEditor::resetProperty, q, &QDesignerIntegration::resetProperty); QObject::connect(designerPropertyEditor, &QDesignerPropertyEditor::addDynamicProperty, q, &QDesignerIntegration::addDynamicProperty); QObject::connect(designerPropertyEditor, &QDesignerPropertyEditor::removeDynamicProperty, q, &QDesignerIntegration::removeDynamicProperty); } else { QObject::connect(core->propertyEditor(), SIGNAL(propertyChanged(QString,QVariant)), q, SLOT(updatePropertyPrivate(QString,QVariant))); // ### fixme: VS Integration leftover? } QObject::connect(core->formWindowManager(), &QDesignerFormWindowManagerInterface::formWindowAdded, q, &QDesignerIntegrationInterface::setupFormWindow); QObject::connect(core->formWindowManager(), &QDesignerFormWindowManagerInterface::activeFormWindowChanged, q, &QDesignerIntegrationInterface::updateActiveFormWindow); m_gradientManager = new QtGradientManager(q); core->setGradientManager(m_gradientManager); QString designerFolder = QDir::homePath(); designerFolder += QDir::separator(); designerFolder += QStringLiteral(".designer"); m_gradientsPath = designerFolder; m_gradientsPath += QDir::separator(); m_gradientsPath += QStringLiteral("gradients.xml"); QFile f(m_gradientsPath); if (f.open(QIODevice::ReadOnly)) { QtGradientUtils::restoreState(m_gradientManager, QString::fromLatin1(f.readAll())); f.close(); } else { QFile defaultGradients(QStringLiteral(":/qt-project.org/designer/defaultgradients.xml")); if (defaultGradients.open(QIODevice::ReadOnly)) { QtGradientUtils::restoreState(m_gradientManager, QString::fromLatin1(defaultGradients.readAll())); defaultGradients.close(); } } if (WidgetDataBase *widgetDataBase = qobject_cast<WidgetDataBase*>(core->widgetDataBase())) widgetDataBase->grabStandardWidgetBoxIcons(); }
QT_BEGIN_NAMESPACE QDesignerFormWindow::QDesignerFormWindow(QDesignerFormWindowInterface *editor, QDesignerWorkbench *workbench, QWidget *parent, Qt::WindowFlags flags) : QWidget(parent, flags), m_editor(editor), m_workbench(workbench), m_action(new QAction(this)), m_initialized(false), m_windowTitleInitialized(false) { Q_ASSERT(workbench); setMaximumSize(0xFFF, 0xFFF); QDesignerFormEditorInterface *core = workbench->core(); if (m_editor) { m_editor->setParent(this); } else { m_editor = core->formWindowManager()->createFormWindow(this); } QVBoxLayout *l = new QVBoxLayout(this); l->setMargin(0); l->addWidget(m_editor); m_action->setCheckable(true); connect(m_editor->commandHistory(), SIGNAL(indexChanged(int)), this, SLOT(updateChanged())); connect(m_editor, SIGNAL(geometryChanged()), this, SLOT(geometryChanged())); qdesigner_internal::FormWindowBase::setupDefaultAction(m_editor); }
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); } } }
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); }