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 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)); } } }
bool SignalSlotDialog::editMetaDataBase(QDesignerFormWindowInterface *fw, QObject *object, QWidget *parent, FocusMode mode) { QDesignerFormEditorInterface *core = fw->core(); SignalSlotDialog dlg(core->dialogGui(), parent, mode); dlg.setWindowTitle(tr("Signals/Slots of %1").arg(object->objectName())); SignalSlotDialogData slotData; SignalSlotDialogData signalData; existingMethodsFromMemberSheet(core, object, slotData.m_existingMethods, signalData.m_existingMethods); fakeMethodsFromMetaDataBase(core, object, slotData.m_fakeMethods, signalData.m_fakeMethods); const QStringList oldSlots = slotData.m_fakeMethods; const QStringList oldSignals = signalData.m_fakeMethods; if (dlg.showDialog(slotData, signalData) == QDialog::Rejected) return false; if (oldSlots == slotData.m_fakeMethods && oldSignals == signalData.m_fakeMethods) return false; FakeMethodMetaDBCommand *cmd = new FakeMethodMetaDBCommand(fw); cmd->init(object, oldSlots, oldSignals, slotData.m_fakeMethods, signalData.m_fakeMethods); fw->commandHistory()->push(cmd); return true; }
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; }
void TabOrderEditor::mousePressEvent(QMouseEvent *e) { e->accept(); if (!m_indicator_region.contains(e->pos())) { if (QWidget *child = m_bg_widget->childAt(e->pos())) { QDesignerFormEditorInterface *core = m_form_window->core(); if (core->widgetFactory()->isPassiveInteractor(child)) { QMouseEvent event(QEvent::MouseButtonPress, child->mapFromGlobal(e->globalPos()), e->button(), e->buttons(), e->modifiers()); qApp->sendEvent(child, &event); QMouseEvent event2(QEvent::MouseButtonRelease, child->mapFromGlobal(e->globalPos()), e->button(), e->buttons(), e->modifiers()); qApp->sendEvent(child, &event2); updateBackground(); } } return; } if (e->button() != Qt::LeftButton) return; const int target_index = widgetIndexAt(e->pos()); if (target_index == -1) return; m_beginning = false; if (e->modifiers() & Qt::ControlModifier) { m_current_index = target_index + 1; if (m_current_index >= m_tab_order_list.size()) m_current_index = 0; update(); return; } if (m_current_index == -1) return; m_tab_order_list.swap(target_index, m_current_index); ++m_current_index; if (m_current_index == m_tab_order_list.size()) m_current_index = 0; TabOrderCommand *cmd = new TabOrderCommand(formWindow()); cmd->init(m_tab_order_list); formWindow()->commandHistory()->push(cmd); }
void TabOrderEditor::initTabOrder() { m_tab_order_list.clear(); QDesignerFormEditorInterface *core = formWindow()->core(); if (const QDesignerMetaDataBaseItemInterface *item = core->metaDataBase()->item(formWindow())) { m_tab_order_list = item->tabOrder(); } // Remove any widgets that have been removed form the form for (int i = 0; i < m_tab_order_list.size(); ) { QWidget *w = m_tab_order_list.at(i); if (!formWindow()->mainContainer()->isAncestorOf(w) || skipWidget(w)) m_tab_order_list.removeAt(i); else ++i; } // Append any widgets that are in the form but are not in the tab order QList<QWidget *> childQueue; childQueue.append(formWindow()->mainContainer()); while (!childQueue.isEmpty()) { QWidget *child = childQueue.takeFirst(); childQueue += qvariant_cast<QWidgetList>(child->property("_q_widgetOrder")); if (skipWidget(child)) continue; if (!m_tab_order_list.contains(child)) m_tab_order_list.append(child); } // Just in case we missed some widgets QDesignerFormWindowCursorInterface *cursor = formWindow()->cursor(); for (int i = 0; i < cursor->widgetCount(); ++i) { QWidget *widget = cursor->widget(i); if (skipWidget(widget)) continue; if (!m_tab_order_list.contains(widget)) m_tab_order_list.append(widget); } m_indicator_region = QRegion(); for (int i = 0; i < m_tab_order_list.size(); ++i) { if (m_tab_order_list.at(i)->isVisible()) m_indicator_region |= indicatorRect(i); } if (m_current_index >= m_tab_order_list.size()) m_current_index = m_tab_order_list.size() - 1; if (m_current_index < 0) m_current_index = 0; }
PromotionTaskMenu::PromotionState PromotionTaskMenu::createPromotionActions(QDesignerFormWindowInterface *formWindow) { // clear out old if (!m_promotionActions.empty()) { qDeleteAll(m_promotionActions); m_promotionActions.clear(); } // No promotion of main container if (formWindow->mainContainer() == m_widget) return NotApplicable; // Check for a homogenous selection const PromotionSelectionList promotionSelection = promotionSelectionList(formWindow); if (promotionSelection.empty()) return NoHomogenousSelection; QDesignerFormEditorInterface *core = formWindow->core(); // if it is promoted: demote only. if (isPromoted(formWindow->core(), m_widget)) { const QString label = m_demoteLabel.arg( promotedExtends(core , m_widget)); QAction *demoteAction = new QAction(label, this); connect(demoteAction, SIGNAL(triggered()), this, SLOT(slotDemoteFromCustomWidget())); m_promotionActions.push_back(demoteAction); return CanDemote; } // figure out candidates const QString baseClassName = WidgetFactory::classNameOf(core, m_widget); const WidgetDataBaseItemList candidates = promotionCandidates(core->widgetDataBase(), baseClassName ); if (candidates.empty()) { // Is this thing promotable at all? return QDesignerPromotionDialog::baseClassNames(core->promotion()).contains(baseClassName) ? CanPromote : NotApplicable; } // Set up a signal mapper to associate class names if (!m_promotionMapper) { m_promotionMapper = new QSignalMapper(this); connect(m_promotionMapper, SIGNAL(mapped(QString)), this, SLOT(slotPromoteToCustomWidget(QString))); } QMenu *candidatesMenu = new QMenu(); // Create a sub menu const WidgetDataBaseItemList::const_iterator cend = candidates.constEnd(); // Set up actions and map class names for (WidgetDataBaseItemList::const_iterator it = candidates.constBegin(); it != cend; ++it) { const QString customClassName = (*it)->name(); QAction *action = new QAction((*it)->name(), this); connect(action, SIGNAL(triggered()), m_promotionMapper, SLOT(map())); m_promotionMapper->setMapping(action, customClassName); candidatesMenu->addAction(action); } // Sub menu action QAction *subMenuAction = new QAction(m_promoteLabel, this); subMenuAction->setMenu(candidatesMenu); m_promotionActions.push_back(subMenuAction); return CanPromote; }
bool QDesignerFormWindowCommand::hasLayout(QWidget *widget) const { QDesignerFormEditorInterface *core = formWindow()->core(); if (widget && LayoutInfo::layoutType(core, widget) != LayoutInfo::NoLayout) { const QDesignerMetaDataBaseItemInterface *item = core->metaDataBase()->item(widget); return item != 0; } return false; }
void ButtonGroupCommand::createButtonGroup() { if (debugButtonMenu) qDebug() << "Creating " << m_buttonGroup << " from " << m_buttonList; QDesignerFormWindowInterface *fw = formWindow(); QDesignerFormEditorInterface *core = fw->core(); core->metaDataBase()->add(m_buttonGroup); addButtonsToGroup(); // Make button group visible core->objectInspector()->setFormWindow(fw); }
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 WidgetBoxCategoryModel::addWidget(const QDesignerWidgetBoxInterface::Widget &widget, const QIcon &icon,bool editable) { // build item. Filter on name + class name if it is different and not a layout. QString filter = widget.name(); if (!filter.contains(QLatin1String("Layout")) && m_classNameRegExp.indexIn(widget.domXml()) != -1) { const QString className = m_classNameRegExp.cap(1); if (!filter.contains(className)) filter += className; } WidgetBoxCategoryEntry item(widget, filter, icon, editable); const QDesignerWidgetDataBaseInterface *db = m_core->widgetDataBase(); const int dbIndex = db->indexOfClassName(widget.name()); if (dbIndex != -1) { const QDesignerWidgetDataBaseItemInterface *dbItem = db->item(dbIndex); const QString toolTip = dbItem->toolTip(); if (!toolTip.isEmpty()) item.toolTip = toolTip; const QString whatsThis = dbItem->whatsThis(); if (!whatsThis.isEmpty()) item.whatsThis = whatsThis; } // insert const int row = m_items.size(); beginInsertRows(QModelIndex(), row, row); m_items.push_back(item); endInsertRows(); }
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 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); } }
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 TabOrderEditor::initTabOrder() { m_tab_order_list.clear(); QDesignerFormEditorInterface *core = formWindow()->core(); if (const QDesignerMetaDataBaseItemInterface *item = core->metaDataBase()->item(formWindow())) { m_tab_order_list = item->tabOrder(); } // Remove any widgets that have been removed form the form for (int i = 0; i < m_tab_order_list.size(); ) { QWidget *w = m_tab_order_list.at(i); if (!formWindow()->mainContainer()->isAncestorOf(w) || skipWidget(w)) m_tab_order_list.removeAt(i); else ++i; } // Append any widgets that are in the form but are not in the tab order QDesignerFormWindowCursorInterface *cursor = formWindow()->cursor(); for (int i = 0; i < cursor->widgetCount(); ++i) { QWidget *widget = cursor->widget(i); if (skipWidget(widget)) continue; if (!m_tab_order_list.contains(widget)) m_tab_order_list.append(widget); } m_indicator_region = QRegion(); for (int i = 0; i < m_tab_order_list.size(); ++i) { if (m_tab_order_list.at(i)->isVisible()) m_indicator_region |= indicatorRect(i); } if (m_current_index >= m_tab_order_list.size()) m_current_index = m_tab_order_list.size() - 1; if (m_current_index < 0) m_current_index = 0; }
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 PromotionTaskMenu::slotEditPromoteTo() { Q_ASSERT(m_widget); // Check whether invoked over a promotable widget QDesignerFormWindowInterface *fw = formWindow(); QDesignerFormEditorInterface *core = fw->core(); const QString base_class_name = WidgetFactory::classNameOf(core, m_widget); Q_ASSERT(QDesignerPromotionDialog::baseClassNames(core->promotion()).contains(base_class_name)); // Show over promotable widget QString promoteToClassName; QDialog *promotionEditor = 0; if (QDesignerLanguageExtension *lang = languageExtension(core)) promotionEditor = lang->createPromotionDialog(core, base_class_name, &promoteToClassName, fw); if (!promotionEditor) promotionEditor = new QDesignerPromotionDialog(core, fw, base_class_name, &promoteToClassName); if (promotionEditor->exec() == QDialog::Accepted && !promoteToClassName.isEmpty()) { promoteTo(fw, promoteToClassName); } delete promotionEditor; }
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); }
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; }
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); } }
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; }
PromotionTaskMenu::PromotionSelectionList PromotionTaskMenu::promotionSelectionList(QDesignerFormWindowInterface *formWindow) const { // In multi selection mode, check for a homogenous selection (same class, same promotion state) // and return the list if this is the case. Also make sure m_widget // is the last widget in the list so that it is re-selected as the last // widget by the promotion commands. PromotionSelectionList rc; if (m_mode != ModeSingleWidget) { QDesignerFormEditorInterface *core = formWindow->core(); const QDesignerIntrospectionInterface *intro = core->introspection(); const QString className = intro->metaObject(m_widget)->className(); const bool promoted = isPromoted(formWindow->core(), m_widget); // Just in case someone plugged an old-style Object Inspector if (QDesignerObjectInspector *designerObjectInspector = qobject_cast<QDesignerObjectInspector *>(core->objectInspector())) { Selection s; designerObjectInspector->getSelection(s); // Find objects of similar state const QWidgetList &source = m_mode == ModeManagedMultiSelection ? s.managed : s.unmanaged; const QWidgetList::const_iterator cend = source.constEnd(); for (QWidgetList::const_iterator it = source.constBegin(); it != cend; ++it) { QWidget *w = *it; if (w != m_widget) { // Selection state mismatch if (intro->metaObject(w)->className() != className || isPromoted(core, w) != promoted) return PromotionSelectionList(); rc.push_back(w); } } } } rc.push_back(m_widget); return rc; }
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(); }
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 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 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); } } }