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::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(); }
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 += QStringLiteral("::"); helpId += currentPropertyName; } return helpId; }
bool ToolBarEventFilter::handleMousePressEvent(QMouseEvent *event) { if (event->button() != Qt::LeftButton || withinHandleArea(m_toolBar, event->pos())) return false; if (QDesignerFormWindowInterface *fw = formWindow()) { QDesignerFormEditorInterface *core = fw->core(); // Keep selection in sync fw->clearSelection(false); if (QDesignerObjectInspector *oi = qobject_cast<QDesignerObjectInspector *>(core->objectInspector())) { oi->clearSelection(); oi->selectObject(m_toolBar); } core->propertyEditor()->setObject(m_toolBar); } m_startPosition = m_toolBar->mapFromGlobal(event->globalPos()); event->accept(); return true; }
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); }
void ButtonGroupCommand::breakButtonGroup() { if (debugButtonMenu) qDebug() << "Removing " << m_buttonGroup << " consisting of " << m_buttonList; QDesignerFormWindowInterface *fw = formWindow(); QDesignerFormEditorInterface *core = fw->core(); // Button group was selected, that is, break was invoked via its context menu. Remove it from property editor, select the buttons if (core->propertyEditor()->object() == m_buttonGroup) { fw->clearSelection(false); const ButtonList::const_iterator cend = m_buttonList.constEnd(); for (ButtonList::const_iterator it = m_buttonList.constBegin(); it != cend; ++it) fw->selectWidget(*it, true); } // Now remove and refresh object inspector removeButtonsFromGroup(); // Notify components (for example, signal slot editor) if (qdesigner_internal::FormWindowBase *fwb = qobject_cast<qdesigner_internal::FormWindowBase *>(fw)) fwb->emitObjectRemoved(m_buttonGroup); core->metaDataBase()->remove(m_buttonGroup); core->objectInspector()->setFormWindow(fw); }
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); } }