void QDesignerDockWidget::setDocked(bool b) { if (QMainWindow *mainWindow = findMainWindow()) { QDesignerFormEditorInterface *core = formWindow()->core(); QDesignerContainerExtension *c; c = qt_extension<QDesignerContainerExtension*>(core->extensionManager(), mainWindow); if (b && !docked()) { // Dock it // ### undo/redo stack setParent(0); c->addWidget(this); formWindow()->selectWidget(this, formWindow()->cursor()->isWidgetSelected(this)); } else if (!b && docked()) { // Undock it for (int i = 0; i < c->count(); ++i) { if (c->widget(i) == this) { c->remove(i); break; } } // #### restore the position setParent(mainWindow->centralWidget()); show(); formWindow()->selectWidget(this, formWindow()->cursor()->isWidgetSelected(this)); } } }
QDesignerContainerExtension *QDesignerQ3WidgetStack::container() { if (formWindow()) { QDesignerFormEditorInterface *core = formWindow()->core(); return qt_extension<QDesignerContainerExtension*>(core->extensionManager(), this); } return 0; }
QDesignerActionProviderExtension *QDesignerMenuBar::actionProvider() { if (QDesignerFormWindowInterface *fw = formWindow()) { QDesignerFormEditorInterface *core = fw->core(); return qt_extension<QDesignerActionProviderExtension*>(core->extensionManager(), this); } return 0; }
ConnectDialog::WidgetMode ConnectDialog::widgetMode(QWidget *w, QDesignerFormWindowInterface *formWindow) { QDesignerFormEditorInterface *core = formWindow->core(); if (qt_extension<QDesignerLanguageExtension*>(core->extensionManager(), core)) return NormalWidget; if (w == formWindow || formWindow->mainContainer() == w) return MainContainer; if (isPromoted(formWindow->core(), w)) return PromotedWidget; return NormalWidget; }
void TaskMenuInlineEditor::editText() { m_formWindow = QDesignerFormWindowInterface::findFormWindow(m_widget); if (m_formWindow.isNull()) return; m_managed = m_formWindow->isManaged(m_widget); // Close as soon as a different widget is selected connect(m_formWindow, SIGNAL(selectionChanged()), this, SLOT(updateSelection())); // get old value QDesignerFormEditorInterface *core = m_formWindow->core(); const QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), m_widget); const int index = sheet->indexOf(m_property); if (index == -1) return; m_value = qvariant_cast<PropertySheetStringValue>(sheet->property(index)); const QString oldValue = m_value.value(); m_editor = new InPlaceEditor(m_widget, m_vm, m_formWindow, oldValue, editRectangle()); connect(m_editor, SIGNAL(textChanged(QString)), this, SLOT(updateText(QString))); }
void ToolBarEventFilter::adjustDragIndicator(const QPoint &pos) { if (QDesignerFormWindowInterface *fw = formWindow()) { QDesignerFormEditorInterface *core = fw->core(); if (QDesignerActionProviderExtension *a = qt_extension<QDesignerActionProviderExtension*>(core->extensionManager(), m_toolBar)) a->adjustIndicator(pos); } }
void DsgnRibbonStatusBarPlugin::widgetManaged(QWidget* widget) { if (widget->metaObject()->className() == QString("Qtitan::RibbonStatusBar")) { QDesignerFormWindowInterface* formWindow = static_cast<QDesignerFormWindowInterface *>(sender()); QDesignerFormEditorInterface* core = formWindow->core(); QDesignerContainerExtension* container = qt_extension<QDesignerContainerExtension*>(core->extensionManager(), formWindow->mainContainer()); formWindow->unmanageWidget(widget); QUndoStack* stack = formWindow->commandHistory(); if (!stack->isClean()) { //This code check the InsertWidget command on the stack. const QUndoCommand* command = stack->command(stack->index()); if (command->childCount() == 0) return; } if (qobject_cast<QMainWindow *>(formWindow->mainContainer()) == 0) { QMessageBox::critical( formWindow->mainContainer(), tr("Can't add Ribbon StatusBar"), tr("You can add Ribbon StatusBar onto Qtitan::RibbonMainWindow or QMainWindow only.")); widget->deleteLater(); return; } for (int i = 0; i < container->count(); ++i) { QWidget* w = container->widget(i); if (w->metaObject()->className() == QString("Qtitan::RibbonStatusBar") || w->metaObject()->className() == QString("QStatusBar")) { QMessageBox::critical( formWindow->mainContainer(), tr("Can't add Ribbon StatusBar"), tr("Only one instance of the Ribbon StatusBar can be adding to the main form.")); widget->deleteLater(); return; } } container->addWidget(widget); formWindow->core()->metaDataBase()->add(widget); } }
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); } }
void RibbonStyleDsgnPlugin::widgetManaged(QWidget* widget) { QDesignerFormWindowInterface* formWindow = static_cast<QDesignerFormWindowInterface *>(sender()); QDesignerFormEditorInterface* core = formWindow->core(); QDesignerContainerExtension* container = qt_extension<QDesignerContainerExtension*>(core->extensionManager(), formWindow->mainContainer()); if (widget->metaObject()->className() == QString("Qtitan::RibbonStyle")) { formWindow->unmanageWidget(widget); QUndoStack* stack = formWindow->commandHistory(); if (!stack->isClean()) { //This code check the InsertWidget command on the stack. const QUndoCommand* command = stack->command(stack->index()); if (command->childCount() == 0) return; } if (qobject_cast<QMainWindow *>(formWindow->mainContainer()) == 0) { QMessageBox::critical(formWindow->mainContainer(), tr("Can't add Ribbon Style"), tr("You can't drag-drop the style to this QWidget form. The style can be placed only onto the form of QMainWindow successor.")); widget->deleteLater(); return; } QWidget* widgetStyle = Q_NULL; for (int i = 0; i < container->count() && widgetStyle == Q_NULL; ++i) { QWidget* w = container->widget(i); if (w->metaObject()->className() == QString("Qtitan::OfficeStyle") || w->metaObject()->className() == QString("Qtitan::RibbonStyle")) widgetStyle = w; } if (widgetStyle && widgetStyle->metaObject()->className() == QString("Qtitan::RibbonStyle")) { QMessageBox::critical( formWindow->mainContainer(), tr("Can't add Ribbon Style"), tr("Only one instance of the Ribbon Style can be adding to the main form.")); widget->deleteLater(); return; } if (widgetStyle) { g_removeBlock = true; const QString description = tr("Delete '%1'").arg(widgetStyle->objectName()); formWindow->commandHistory()->beginMacro(description); DeleteStyleCommand* cmd = new DeleteStyleCommand(formWindow); cmd->init(widgetStyle); formWindow->commandHistory()->push(cmd); formWindow->commandHistory()->endMacro(); g_removeBlock = false; } container->addWidget(widget); formWindow->core()->metaDataBase()->add(widget); widget->setCursor(Qt::PointingHandCursor); } else if (DesignerMainWindowStyleContainer* styelContainer = dynamic_cast<DesignerMainWindowStyleContainer*>(container)) { if (QMainWindow* mainindow = static_cast<QMainWindow*>(styelContainer->mainWindow())) { if (Qtitan::CommonStyle* currentStyle = qobject_cast<Qtitan::CommonStyle*>(mainindow->style())) ::setChildStyle(widget, currentStyle); } } }
bool DsgnOfficeStyleWidget::event(QEvent* event) { bool res = QWidget::event(event); if (event->type() == QEvent::ParentChange) { if (DsgnOfficeStyle* desStyle = dynamic_cast<DsgnOfficeStyle *>(m_targetStyle)) desStyle->setParentStyle(parentWidget()); } else if (event->type() == QEvent::Hide && isHidden()) { QDesignerFormWindowInterface* formWindow = QDesignerFormWindowInterface::findFormWindow(parentWidget()); QDesignerFormEditorInterface* core = formWindow->core(); QDesignerContainerExtension* container = qt_extension<QDesignerContainerExtension*>(core->extensionManager(), formWindow->mainContainer()); if (container->widget(container->count() - 1) == this) { container->remove(container->count() - 1); core->metaDataBase()->remove(this); formWindow->emitSelectionChanged(); } } return res; }