Пример #1
0
void ActionEditor::slotNewAction()
{
    NewActionDialog dlg(this);
    dlg.setWindowTitle(tr("New action"));

    if (dlg.exec() == QDialog::Accepted) {
        const ActionData actionData = dlg.actionData();
        m_actionView->clearSelection();
        QAction *action = new QAction(formWindow());
        action->setObjectName(actionData.name);
        formWindow()->ensureUniqueObjectName(action);
        action->setText(actionData.text);

        QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), action);
        if (!actionData.toolTip.isEmpty())
            setInitialProperty(sheet, QLatin1String(toolTipPropertyC), actionData.toolTip);

        if (actionData.checkable)
            setInitialProperty(sheet, QLatin1String(checkablePropertyC), QVariant(true));

        if (!actionData.keysequence.value().isEmpty())
            setInitialProperty(sheet, QLatin1String(shortcutPropertyC), QVariant::fromValue(actionData.keysequence));

        sheet->setProperty(sheet->indexOf(QLatin1String(iconPropertyC)), QVariant::fromValue(actionData.icon));

        AddActionCommand *cmd = new AddActionCommand(formWindow());
        cmd->init(action);
        formWindow()->commandHistory()->push(cmd);
    }
}
static PyObject *meth_QDesignerPropertySheetExtension_count(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;
    PyObject *sipOrigSelf = sipSelf;

    {
        QDesignerPropertySheetExtension *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QDesignerPropertySheetExtension, &sipCpp))
        {
            int sipRes;

            if (!sipOrigSelf)
            {
                sipAbstractMethod(sipName_QDesignerPropertySheetExtension, sipName_count);
                return NULL;
            }

            Py_BEGIN_ALLOW_THREADS
            sipRes = sipCpp->count();
            Py_END_ALLOW_THREADS

            return SIPLong_FromLong(sipRes);
        }
    }
static PyObject *meth_QDesignerPropertySheetExtension_setChanged(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;
    PyObject *sipOrigSelf = sipSelf;

    {
        int a0;
        bool a1;
        QDesignerPropertySheetExtension *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "Bib", &sipSelf, sipType_QDesignerPropertySheetExtension, &sipCpp, &a0, &a1))
        {
            if (!sipOrigSelf)
            {
                sipAbstractMethod(sipName_QDesignerPropertySheetExtension, sipName_setChanged);
                return NULL;
            }

            sipCpp->setChanged(a0,a1);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QDesignerPropertySheetExtension, sipName_setChanged, doc_QDesignerPropertySheetExtension_setChanged);

    return NULL;
}
static PyObject *meth_QDesignerPropertySheetExtension_setProperty(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;
    PyObject *sipOrigSelf = sipSelf;

    {
        int a0;
        const QVariant* a1;
        int a1State = 0;
        QDesignerPropertySheetExtension *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BiJ1", &sipSelf, sipType_QDesignerPropertySheetExtension, &sipCpp, &a0, sipType_QVariant, &a1, &a1State))
        {
            if (!sipOrigSelf)
            {
                sipAbstractMethod(sipName_QDesignerPropertySheetExtension, sipName_setProperty);
                return NULL;
            }

            sipCpp->setProperty(a0,*a1);
            sipReleaseType(const_cast<QVariant *>(a1),sipType_QVariant,a1State);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QDesignerPropertySheetExtension, sipName_setProperty, doc_QDesignerPropertySheetExtension_setProperty);

    return NULL;
}
static PyObject *meth_QDesignerPropertySheetExtension_reset(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;
    PyObject *sipOrigSelf = sipSelf;

    {
        int a0;
        QDesignerPropertySheetExtension *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "Bi", &sipSelf, sipType_QDesignerPropertySheetExtension, &sipCpp, &a0))
        {
            bool sipRes;

            if (!sipOrigSelf)
            {
                sipAbstractMethod(sipName_QDesignerPropertySheetExtension, sipName_reset);
                return NULL;
            }

            sipRes = sipCpp->reset(a0);

            return PyBool_FromLong(sipRes);
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QDesignerPropertySheetExtension, sipName_reset, doc_QDesignerPropertySheetExtension_reset);

    return NULL;
}
Пример #6
0
void ActionEditor::editAction(QAction *action)
{
    if (!action)
        return;

    NewActionDialog dlg(this);
    dlg.setWindowTitle(tr("Edit action"));

    ActionData oldActionData;
    QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), action);
    oldActionData.name = action->objectName();
    oldActionData.text = action->text();
    oldActionData.toolTip = textPropertyValue(sheet, QLatin1String(toolTipPropertyC));
    oldActionData.icon = qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC))));
    oldActionData.keysequence = ActionModel::actionShortCut(sheet);
    oldActionData.checkable =  action->isCheckable();
    dlg.setActionData(oldActionData);

    if (!dlg.exec())
        return;

    // figure out changes and whether to start a macro
    const ActionData newActionData = dlg.actionData();
    const unsigned changeMask = newActionData.compare(oldActionData);
    if (changeMask == 0u)
        return;

    const bool severalChanges = (changeMask != ActionData::TextChanged)      && (changeMask != ActionData::NameChanged)
                             && (changeMask != ActionData::ToolTipChanged)   && (changeMask != ActionData::IconChanged)
                             && (changeMask != ActionData::CheckableChanged) && (changeMask != ActionData::KeysequenceChanged);

    QDesignerFormWindowInterface *fw = formWindow();
    QUndoStack *undoStack = fw->commandHistory();
    if (severalChanges)
        fw->beginCommand(QStringLiteral("Edit action"));

    if (changeMask & ActionData::NameChanged)
        undoStack->push(createTextPropertyCommand(QLatin1String(objectNamePropertyC), newActionData.name, action, fw));

    if (changeMask & ActionData::TextChanged)
        undoStack->push(createTextPropertyCommand(QLatin1String(textPropertyC), newActionData.text, action, fw));

    if (changeMask & ActionData::ToolTipChanged)
        undoStack->push(createTextPropertyCommand(QLatin1String(toolTipPropertyC), newActionData.toolTip, action, fw));

    if (changeMask & ActionData::IconChanged)
        undoStack->push(setIconPropertyCommand(newActionData.icon, action, fw));

    if (changeMask & ActionData::CheckableChanged)
        undoStack->push(setPropertyCommand(QLatin1String(checkablePropertyC), newActionData.checkable, false, action, fw));

    if (changeMask & ActionData::KeysequenceChanged)
        undoStack->push(setKeySequencePropertyCommand(newActionData.keysequence, action, fw));

    if (severalChanges)
        fw->endCommand();
}
Пример #7
0
static QString buddy(QLabel *label, QDesignerFormEditorInterface *core)
{
    QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), label);
    if (sheet == 0)
        return QString();
    const int prop_idx = sheet->indexOf(QLatin1String(buddyPropertyC));
    if (prop_idx == -1)
        return QString();
    return sheet->property(prop_idx).toString();
}
Пример #8
0
// shortcut is a fake property, need to retrieve it via property sheet.
static QString actionShortCut(QDesignerFormEditorInterface *core, QAction *action)
{
    QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), action);
    if (!sheet)
        return QString();
    const int index = sheet->indexOf(QLatin1String("shortcut"));
    if (index == -1)
        return QString();
    const QKeySequence keysequence = qvariant_cast<QKeySequence>(sheet->property(index));
    return keysequence.toString();
}
Пример #9
0
void ActionEditor::manageAction(QAction *action)
{
    action->setParent(formWindow()->mainContainer());
    core()->metaDataBase()->add(action);

    if (action->isSeparator() || action->menu() != 0)
        return;

    QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), action);
    sheet->setChanged(sheet->indexOf(QLatin1String(objectNamePropertyC)), true);
    sheet->setChanged(sheet->indexOf(QLatin1String(textPropertyC)), true);
    refreshIconPropertyChanged(action, sheet);

    m_actionView->setCurrentIndex(m_actionView->model()->addAction(action));
    connect(action, SIGNAL(changed()), this, SLOT(slotActionChanged()));
}
Пример #10
0
void ItemViewPropertySheet::initHeaderProperties(QHeaderView *hv, const QString &prefix)
{
    QDesignerPropertySheetExtension *headerSheet = d->m_propertySheet.value(hv);
    Q_ASSERT(headerSheet);
    const QString headerGroupS = QLatin1String(headerGroup);
    foreach (const QString &realPropertyName, d->realPropertyNames()) {
        const int headerIndex = headerSheet->indexOf(realPropertyName);
        Q_ASSERT(headerIndex != -1);
        const QVariant defaultValue = realPropertyName == QLatin1String(visibleProperty) ?
                                      QVariant(true) : headerSheet->property(headerIndex);
        const QString fakePropertyName = d->fakePropertyName(prefix, realPropertyName);
        const int fakeIndex = createFakeProperty(fakePropertyName, defaultValue);
        d->m_propertyIdMap.insert(fakeIndex, Property(headerSheet, headerIndex));
        setAttribute(fakeIndex, true);
        setPropertyGroup(fakeIndex, headerGroupS);
    }
}
Пример #11
0
// --- StyleSheetPropertyEditorDialog
StyleSheetPropertyEditorDialog::StyleSheetPropertyEditorDialog(QWidget *parent,
                                               QDesignerFormWindowInterface *fw,
                                               QWidget *widget):
    StyleSheetEditorDialog(fw->core(), parent),
    m_fw(fw),
    m_widget(widget)
{
    Q_ASSERT(m_fw != 0);

    QPushButton *apply = buttonBox()->addButton(QDialogButtonBox::Apply);
    QObject::connect(apply, SIGNAL(clicked()), this, SLOT(applyStyleSheet()));
    QObject::connect(buttonBox(), SIGNAL(accepted()), this, SLOT(applyStyleSheet()));

    QDesignerPropertySheetExtension *sheet =
            qt_extension<QDesignerPropertySheetExtension*>(m_fw->core()->extensionManager(), m_widget);
    Q_ASSERT(sheet != 0);
    setText(sheet->property(sheet->indexOf(QLatin1String(styleSheetProperty))).toString());
}
Пример #12
0
bool ItemViewPropertySheet::reset(int index)
{
    const FakePropertyMap::iterator it = d->m_propertyIdMap.find(index);
    if (it != d->m_propertyIdMap.end()) {
       QDesignerPropertySheetExtension *headerSheet = it.value().m_sheet;
       const int headerIndex = it.value().m_id;
       const bool resetRC = headerSheet->reset(headerIndex);
       // Resetting for "visible" might fail and the stored default
       // of the Widget database is "false" due to the widget not being
       // visible at the time it was determined. Reset to "true" manually.
       if (!resetRC && headerSheet->propertyName(headerIndex) == QLatin1String(visibleProperty)) {
           headerSheet->setProperty(headerIndex, QVariant(true));
           headerSheet->setChanged(headerIndex, false);
           return true;
       }
       return resetRC;
    } else {
        return QDesignerPropertySheet::reset(index);
    }
}
Пример #13
0
void QtDesignerChild::formGeometryChanged()
{
    // set modified state
    bool loading = property( "loadingFile" ).toBool();
    bool modified = !loading;

    // update property
    QDesignerPropertySheetExtension* sheet = qt_extension<QDesignerPropertySheetExtension*>( mDesignerManager->core()->extensionManager(), mHostWidget->formWindow() );
    QRect geo = sheet->property( sheet->indexOf( "geometry" ) ).toRect();
    geo.moveTopLeft( QPoint( 0, 0 ) );
    delete sheet;
    mDesignerManager->core()->propertyEditor()->setPropertyValue( "geometry", geo, modified );

    // update state
    mHostWidget->formWindow()->setDirty( modified );
    setWindowModified( modified );
    setProperty( "loadingFile", false );

    // emit modified state
    emit modifiedChanged( modified );
    emit contentChanged();
}
static SIP_SSIZE_T slot_QDesignerPropertySheetExtension___len__(PyObject *sipSelf)
{
    QDesignerPropertySheetExtension *sipCpp = reinterpret_cast<QDesignerPropertySheetExtension *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_QDesignerPropertySheetExtension));

    if (!sipCpp)
        return 0;


    {
        {
            SIP_SSIZE_T sipRes = 0;

#line 1 "Auto-generated"
            sipRes = (SIP_SSIZE_T)sipCpp->count();
#line 908 "C:\\Users\\marcus\\Downloads\\PyQt-gpl-5.4\\PyQt-gpl-5.4\\QtDesigner/sipQtDesignerQDesignerPropertySheetExtension.cpp"

            return sipRes;
        }
    }

    return 0;
}
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);
    }
}
Пример #16
0
void LayoutPropertySheet::markChangedStretchProperties(QDesignerFormEditorInterface *core, QLayout *lt, const DomLayout *domLayout)
{
    // While the actual values are applied by the form builder, we still need
    // to mark them as 'changed'.
    QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), lt);
    Q_ASSERT(sheet);
    if (!domLayout->attributeStretch().isEmpty())
        sheet->setChanged(sheet->indexOf(QLatin1String(boxStretchPropertyC)), true);
    if (!domLayout->attributeRowStretch().isEmpty())
        sheet->setChanged(sheet->indexOf(QLatin1String(gridRowStretchPropertyC)), true);
    if (!domLayout->attributeColumnStretch().isEmpty())
        sheet->setChanged(sheet->indexOf(QLatin1String(gridColumnStretchPropertyC)), true);
   if (!domLayout->attributeColumnMinimumWidth().isEmpty())
        sheet->setChanged(sheet->indexOf(QLatin1String(gridColumnMinimumWidthPropertyC)), true);
   if (!domLayout->attributeRowMinimumHeight().isEmpty())
        sheet->setChanged(sheet->indexOf(QLatin1String(gridRowMinimumHeightPropertyC)), true);
}