void QStackedWidgetEventFilter::changeOrder()
{
    QDesignerFormWindowInterface *fw = QDesignerFormWindowInterface::findFormWindow(stackedWidget());

    if (!fw)
        return;

    const QWidgetList oldPages = qdesigner_internal::OrderDialog::pagesOfContainer(fw->core(), stackedWidget());
    const int pageCount = oldPages.size();
    if (pageCount < 2)
        return;

    qdesigner_internal::OrderDialog dlg(fw);
    dlg.setPageList(oldPages);
    if (dlg.exec() == QDialog::Rejected)
        return;

    const QWidgetList newPages = dlg.pageList();
    if (newPages == oldPages)
        return;

    fw->beginCommand(tr("Change Page Order"));
    for(int i=0; i < pageCount; ++i) {
        if (newPages.at(i) == stackedWidget()->widget(i))
            continue;
        qdesigner_internal::MoveStackedWidgetCommand *cmd = new qdesigner_internal::MoveStackedWidgetCommand(fw);
        cmd->init(stackedWidget(), newPages.at(i), i);
        fw->commandHistory()->push(cmd);
    }
    fw->endCommand();
}
Exemple #2
0
void PromotionTaskMenu::slotEditSignalsSlots()
{
    QDesignerFormWindowInterface *fw = formWindow();
    if (!fw)
        return;
    SignalSlotDialog::editPromotedClass(fw->core(), m_widget, fw);
}
// -------------------- NewActionDialog
NewActionDialog::NewActionDialog(ActionEditor *parent) :
    QDialog(parent, Qt::Sheet),
    m_ui(new Ui::NewActionDialog),
    m_actionEditor(parent)
{
    m_ui->setupUi(this);
    
    m_ui->tooltipEditor->setTextPropertyValidationMode(ValidationRichText);
    connect(m_ui->toolTipToolButton, SIGNAL(clicked()), this, SLOT(slotEditToolTip()));

    m_ui->keysequenceResetToolButton->setIcon(createIconSet(QStringLiteral("resetproperty.png")));
    connect(m_ui->keysequenceResetToolButton, SIGNAL(clicked()), this, SLOT(slotResetKeySequence()));

    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
    m_ui->editActionText->setFocus();
    m_auto_update_object_name = true;
    updateButtons();

    QDesignerFormWindowInterface *form = parent->formWindow();
    m_ui->iconSelector->setFormEditor(form->core());
    FormWindowBase *formBase = qobject_cast<FormWindowBase *>(form);

    if (formBase) {
        m_ui->iconSelector->setPixmapCache(formBase->pixmapCache());
        m_ui->iconSelector->setIconCache(formBase->iconCache());
    }
}
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);
    }
}
Exemple #5
0
void PromotionTaskMenu::slotEditPromotedWidgets()
{
    // Global context, show over non-promotable widget
    QDesignerFormWindowInterface *fw = formWindow();
    if (!fw)
        return;
    editPromotedWidgets(fw->core(), fw);
}
Exemple #6
0
void PromotionTaskMenu::slotDemoteFromCustomWidget()
{
    QDesignerFormWindowInterface *fw = formWindow();
    const PromotionSelectionList promotedWidgets = promotionSelectionList(fw);
    Q_ASSERT(!promotedWidgets.empty() && isPromoted(fw->core(), promotedWidgets.front()));

    // ### use the undo stack
    DemoteFromCustomWidgetCommand *cmd = new DemoteFromCustomWidgetCommand(fw);
    cmd->init(promotedWidgets);
    fw->commandHistory()->push(cmd);
}
Exemple #7
0
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);
}
bool DesignerStyleInput::filterEvent(const QEvent* event)
{
    if (event->type()== QEvent::MouseButtonPress)
    {
        QMouseEvent* me = (QMouseEvent *)event;
        if (me->button() == Qt::LeftButton)
        {
            QDesignerFormWindowInterface* formWindow = QDesignerFormWindowInterface::findFormWindow(m_widget);
            formWindow->clearSelection(false);
            formWindow->core()->propertyEditor()->setObject(m_widget);
            formWindow->core()->propertyEditor()->setEnabled(true);
            return true;
        }
        else if (me->button() == Qt::RightButton)
        {
            QList<QAction *> actions;
            actions.append(m_actRemoveStyle);
            QMenu::exec(actions, QCursor::pos());
            return true;
        }
    }
    return true; // Handle all input context events here.
}
void QAxWidgetPropertySheet::updatePropertySheet()
{
    // refresh the property sheet (we are deleting m_currentProperties)
    struct SavedProperties tmp = m_currentProperties;
    QDesignerAxWidget *axw = axWidget();
    QDesignerFormWindowInterface *formWin = QDesignerFormWindowInterface::findFormWindow(axw);
    Q_ASSERT(formWin != 0);
    tmp.widget = axw;
    tmp.clsid = axw->control();
    // Delete the sheets as they cache the meta object and other information
    delete this;
    delete qt_extension<QDesignerMemberSheetExtension *>(formWin->core()->extensionManager(), axw);
    reloadPropertySheet(tmp, formWin);
}
void QDesignerMenuBar::leaveEditMode(LeaveEditMode mode)
{
    m_editor->releaseKeyboard();

    if (mode == Default)
        return;

    if (m_editor->text().isEmpty())
        return;

    QAction *action = 0;

    QDesignerFormWindowInterface *fw = formWindow();
    Q_ASSERT(fw);

    if (m_currentIndex >= 0 && m_currentIndex < realActionCount()) {
        action = safeActionAt(m_currentIndex);
        fw->beginCommand(QApplication::translate("Command", "Change Title"));
    } else {
        fw->beginCommand(QApplication::translate("Command", "Insert Menu"));
        const QString niceObjectName = ActionEditor::actionTextToName(m_editor->text(), QStringLiteral("menu"));
        QMenu *menu = qobject_cast<QMenu*>(fw->core()->widgetFactory()->createWidget(QStringLiteral("QMenu"), this));
        fw->core()->widgetFactory()->initialize(menu);
        menu->setObjectName(niceObjectName);
        menu->setTitle(tr("Menu"));
        fw->ensureUniqueObjectName(menu);
        action = menu->menuAction();
        AddMenuActionCommand *cmd = new AddMenuActionCommand(fw);
        cmd->init(action, m_addMenu, this, this);
        fw->commandHistory()->push(cmd);
    }

    SetPropertyCommand *cmd = new SetPropertyCommand(fw);
    cmd->init(action, QStringLiteral("text"), m_editor->text());
    fw->commandHistory()->push(cmd);
    fw->endCommand();
}
Exemple #11
0
bool ConnectionModel::setData(const QModelIndex &index, const QVariant &data, int)
{
    if (!index.isValid() || !m_editor)
        return false;
    if (data.type() != QVariant::String)
        return false;

    SignalSlotConnection *con = static_cast<SignalSlotConnection*>(m_editor->connection(index.row()));
    QDesignerFormWindowInterface *form = m_editor->formWindow();

    QString s = data.toString();
    switch (index.column()) {
        case 0:
            if (!s.isEmpty() && !objectNameList(form).contains(s))
                s.clear();
            m_editor->setSource(con, s);
            break;
        case 1:
            if (!memberFunctionListContains(form->core(), con->object(CETypes::EndPoint::Source), SignalMember, s))
                s.clear();
            m_editor->setSignal(con, s);
            break;
        case 2:
            if (!s.isEmpty() && !objectNameList(form).contains(s))
                s.clear();
            m_editor->setTarget(con, s);
            break;
        case 3:
            if (!memberFunctionListContains(form->core(), con->object(CETypes::EndPoint::Target), SlotMember, s))
                s.clear();
            m_editor->setSlot(con, s);
            break;
    }

    return true;
}
bool SetControlCommand::apply(const QString &clsid)
{
    if (m_oldClsid == m_newClsid)
        return true;

    QObject *ext = m_formWindow->core()->extensionManager()->extension(m_axWidget, Q_TYPEID(QDesignerPropertySheetExtension));
    QAxWidgetPropertySheet *sheet = qobject_cast<QAxWidgetPropertySheet*>(ext);
    if (!sheet)
        return false;

    const bool hasClsid = !clsid.isEmpty();
    const int index = sheet->indexOf(QLatin1String(QAxWidgetPropertySheet::controlPropertyName));
    if (hasClsid)
        sheet->setProperty(index, clsid);
    else
        sheet->reset(index);
    return true;
}
Exemple #13
0
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;
}
Exemple #14
0
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);
}
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;
}
bool MorphLayoutCommand::init(QWidget *w, int newType)
{
    int oldType;
    QDesignerFormWindowInterface *fw = formWindow();
    if (!canMorph(fw, w, &oldType) || oldType == newType)
        return false;
    m_layoutBase = w;
    m_newType = newType;
    // Find all managed widgets
    m_widgets.clear();
    const QLayout *layout = LayoutInfo::managedLayout(fw->core(), w);
    const int count = layout->count();
    for (int i = 0; i < count ; i++) {
        if (QWidget *w = layout->itemAt(i)->widget())
            if (fw->isManaged(w))
                m_widgets.push_back(w);
    }
    const bool reparentLayoutWidget = false; // leave QLayoutWidget intact
    m_breakLayoutCommand->init(m_widgets, m_layoutBase, reparentLayoutWidget);
    m_layoutCommand->init(m_layoutBase, m_widgets, static_cast<LayoutInfo::Type>(m_newType), m_layoutBase, reparentLayoutWidget);
    setText(formatDescription(core(), m_layoutBase, oldType, newType));
    return true;
}
Exemple #17
0
bool QDesignerWidgetItem::check(const QLayout *layout, QWidget *w, Qt::Orientations *ptrToOrientations)
{
    // Check for form-editor non-containerextension-containers (QFrame, etc)
    // within laid-out form editor widgets. No check for managed() here as we
    // want container pages and widgets in the process of being morphed as
    // well. Avoid nested layouts (as the effective stretch cannot be easily
    // computed and may mess things up). Won't work for Q3 Group boxes.
    if (ptrToOrientations)
        *ptrToOrientations = 0;

    const QObject *layoutParent = layout->parent();
    if (!layoutParent || !layoutParent->isWidgetType() || !WidgetFactory::isFormEditorObject(layoutParent))
        return false;

    QDesignerFormWindowInterface *fw = QDesignerFormWindowInterface::findFormWindow(w);
    if (!fw || !isContainer(fw->core(), w))
        return false;

    // If it is a box, restrict to its orientation
    if (ptrToOrientations)
        *ptrToOrientations = layoutOrientation(layout);

    return true;
}
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);
        }
    }
}