diff options
8 files changed, 397 insertions, 339 deletions
diff --git a/src/designer/src/components/formeditor/formwindow.cpp b/src/designer/src/components/formeditor/formwindow.cpp index 3fb18aa31..e39e36cee 100644 --- a/src/designer/src/components/formeditor/formwindow.cpp +++ b/src/designer/src/components/formeditor/formwindow.cpp @@ -2277,38 +2277,38 @@ QMenu *FormWindow::createPopupMenu(QWidget *w) QToolBoxHelper::addToolBoxContextMenuActions(toolBox, popup); } - if (manager->actionLower()->isEnabled()) { - popup->addAction(manager->actionLower()); - popup->addAction(manager->actionRaise()); + if (manager->action(QDesignerFormWindowManagerInterface::LowerAction)->isEnabled()) { + popup->addAction(manager->action(QDesignerFormWindowManagerInterface::LowerAction)); + popup->addAction(manager->action(QDesignerFormWindowManagerInterface::RaiseAction)); popup->addSeparator(); } - popup->addAction(manager->actionCut()); - popup->addAction(manager->actionCopy()); + popup->addAction(manager->action(QDesignerFormWindowManagerInterface::CutAction)); + popup->addAction(manager->action(QDesignerFormWindowManagerInterface::CopyAction)); } - popup->addAction(manager->actionPaste()); + popup->addAction(manager->action(QDesignerFormWindowManagerInterface::PasteAction)); if (QAction *selectAncestorAction = createSelectAncestorSubMenu(w)) popup->addAction(selectAncestorAction); - popup->addAction(manager->actionSelectAll()); + popup->addAction(manager->action(QDesignerFormWindowManagerInterface::SelectAllAction)); if (!isFormWindow) { - popup->addAction(manager->actionDelete()); + popup->addAction(manager->action(QDesignerFormWindowManagerInterface::DeleteAction)); } popup->addSeparator(); QMenu *layoutMenu = popup->addMenu(tr("Lay out")); - layoutMenu->addAction(manager->actionAdjustSize()); - layoutMenu->addAction(manager->actionHorizontalLayout()); - layoutMenu->addAction(manager->actionVerticalLayout()); + layoutMenu->addAction(manager->action(QDesignerFormWindowManagerInterface::AdjustSizeAction)); + layoutMenu->addAction(manager->action(QDesignerFormWindowManagerInterface::HorizontalLayoutAction)); + layoutMenu->addAction(manager->action(QDesignerFormWindowManagerInterface::VerticalLayoutAction)); if (!isFormWindow) { - layoutMenu->addAction(manager->actionSplitHorizontal()); - layoutMenu->addAction(manager->actionSplitVertical()); + layoutMenu->addAction(manager->action(QDesignerFormWindowManagerInterface::SplitHorizontalAction)); + layoutMenu->addAction(manager->action(QDesignerFormWindowManagerInterface::SplitVerticalAction)); } - layoutMenu->addAction(manager->actionGridLayout()); - layoutMenu->addAction(manager->actionFormLayout()); - layoutMenu->addAction(manager->actionBreakLayout()); - layoutMenu->addAction(manager->actionSimplifyLayout()); + layoutMenu->addAction(manager->action(QDesignerFormWindowManagerInterface::GridLayoutAction)); + layoutMenu->addAction(manager->action(QDesignerFormWindowManagerInterface::FormLayoutAction)); + layoutMenu->addAction(manager->action(QDesignerFormWindowManagerInterface::BreakLayoutAction)); + layoutMenu->addAction(manager->action(QDesignerFormWindowManagerInterface::SimplifyLayoutAction)); return popup; } diff --git a/src/designer/src/components/formeditor/formwindowmanager.cpp b/src/designer/src/components/formeditor/formwindowmanager.cpp index 1d662b27c..e58fdaf66 100644 --- a/src/designer/src/components/formeditor/formwindowmanager.cpp +++ b/src/designer/src/components/formeditor/formwindowmanager.cpp @@ -446,15 +446,14 @@ void FormWindowManager::setupActions() connect(m_actionVerticalLayout, SIGNAL(triggered()), this, SLOT(createLayout())); QIcon formIcon = QIcon::fromTheme("designer-form-layout", createIconSet(QLatin1String("editform.png"))); - QAction *actionFormLayout = new QAction(formIcon, tr("Lay Out in a &Form Layout"), this); - actionFormLayout->setObjectName(QLatin1String("__qt_form_layout_action")); - actionFormLayout->setShortcut(Qt::CTRL + Qt::Key_6); - actionFormLayout->setStatusTip(tr("Lays out the selected widgets in a form layout")); - actionFormLayout->setWhatsThis(whatsThisFrom(QLatin1String("Layout|Lay Out in a Form"))); - actionFormLayout->setData(LayoutInfo::Form); - actionFormLayout->setEnabled(false); - setActionFormLayout(actionFormLayout); - connect(actionFormLayout, SIGNAL(triggered()), this, SLOT(createLayout())); + m_actionFormLayout = new QAction(formIcon, tr("Lay Out in a &Form Layout"), this); + m_actionFormLayout->setObjectName(QLatin1String("__qt_form_layout_action")); + m_actionFormLayout->setShortcut(Qt::CTRL + Qt::Key_6); + m_actionFormLayout->setStatusTip(tr("Lays out the selected widgets in a form layout")); + m_actionFormLayout->setWhatsThis(whatsThisFrom(QLatin1String("Layout|Lay Out in a Form"))); + m_actionFormLayout->setData(LayoutInfo::Form); + m_actionFormLayout->setEnabled(false); + connect(m_actionFormLayout, SIGNAL(triggered()), this, SLOT(createLayout())); m_actionGridLayout = new QAction(createIconSet(QLatin1String("editgrid.png")), tr("Lay Out in a &Grid"), this); m_actionGridLayout->setObjectName(QLatin1String("__qt_grid_layout_action")); @@ -494,20 +493,19 @@ void FormWindowManager::setupActions() connect(m_actionBreakLayout, SIGNAL(triggered()), this, SLOT(slotActionBreakLayoutActivated())); m_actionBreakLayout->setEnabled(false); - QAction *simplifyLayoutAction = new QAction(tr("Si&mplify Grid Layout"), this); - simplifyLayoutAction->setObjectName(QLatin1String("__qt_simplify_layout_action")); - simplifyLayoutAction->setStatusTip(tr("Removes empty columns and rows")); - simplifyLayoutAction->setWhatsThis(whatsThisFrom(QLatin1String("Layout|Simplify Layout"))); - connect(simplifyLayoutAction, SIGNAL(triggered()), this, SLOT(slotActionSimplifyLayoutActivated())); - simplifyLayoutAction->setEnabled(false); - setActionSimplifyLayout(simplifyLayoutAction); + m_actionSimplifyLayout = new QAction(tr("Si&mplify Grid Layout"), this); + m_actionSimplifyLayout->setObjectName(QLatin1String("__qt_simplify_layout_action")); + m_actionSimplifyLayout->setStatusTip(tr("Removes empty columns and rows")); + m_actionSimplifyLayout->setWhatsThis(whatsThisFrom(QLatin1String("Layout|Simplify Layout"))); + connect(m_actionSimplifyLayout, SIGNAL(triggered()), this, SLOT(slotActionSimplifyLayoutActivated())); + m_actionSimplifyLayout->setEnabled(false); m_actionDefaultPreview = new QAction(tr("&Preview..."), this); m_actionDefaultPreview->setObjectName(QLatin1String("__qt_default_preview_action")); m_actionDefaultPreview->setStatusTip(tr("Preview current form")); m_actionDefaultPreview->setWhatsThis(whatsThisFrom(QLatin1String("Form|Preview"))); connect(m_actionDefaultPreview, SIGNAL(triggered()), - this, SLOT(slotActionDefaultPreviewActivated())); + this, SLOT(showPreview())); m_undoGroup = new QUndoGroup(this); @@ -669,7 +667,7 @@ void FormWindowManager::slotActionSelectAllActivated() m_activeFormWindow->selectAll(); } -void FormWindowManager::slotActionDefaultPreviewActivated() +void FormWindowManager::showPreview() { slotActionGroupPreviewInStyle(QString(), -1); } @@ -884,7 +882,7 @@ void FormWindowManager::slotUpdateActions() QLayout *widgetLayout = LayoutInfo::internalLayout(widget); QLayout *managedLayout = LayoutInfo::managedLayout(m_core, widgetLayout); - // We don't touch a layout createds by a custom widget + // We don't touch a layout created by a custom widget if (widgetLayout && !managedLayout) break; @@ -930,11 +928,11 @@ void FormWindowManager::slotUpdateActions() m_actionVerticalLayout->setEnabled(layoutAvailable || canMorphIntoVBoxLayout); m_actionSplitHorizontal->setEnabled(layoutAvailable && !layoutContainer); m_actionSplitVertical->setEnabled(layoutAvailable && !layoutContainer); - actionFormLayout()->setEnabled(layoutAvailable || canMorphIntoFormLayout); + m_actionFormLayout->setEnabled(layoutAvailable || canMorphIntoFormLayout); m_actionGridLayout->setEnabled(layoutAvailable || canMorphIntoGridLayout); m_actionBreakLayout->setEnabled(breakAvailable); - actionSimplifyLayout()->setEnabled(simplifyAvailable); + m_actionSimplifyLayout->setEnabled(simplifyAvailable); m_actionShowFormWindowSettingsDialog->setEnabled(m_activeFormWindow != 0); } @@ -946,37 +944,16 @@ QDesignerFormWindowInterface *FormWindowManager::createFormWindow(QWidget *paren return formWindow; } -QPixmap FormWindowManager::createPreviewPixmap(QString *errorMessage) +QPixmap FormWindowManager::createPreviewPixmap() const { - QPixmap pixmap; - QDesignerFormWindowInterface *fw = activeFormWindow(); + const QDesignerFormWindowInterface *fw = activeFormWindow(); if (!fw) - return pixmap; - - pixmap = m_previewManager->createPreviewPixmap(fw, QString(), errorMessage); - return pixmap; -} - -QAction *FormWindowManager::actionUndo() const -{ - return m_actionUndo; -} - -QAction *FormWindowManager::actionRedo() const -{ - return m_actionRedo; -} - -QActionGroup *FormWindowManager::actionGroupPreviewInStyle() const -{ - if (m_actionGroupPreviewInStyle == 0) { - // Wish we could make the 'this' pointer mutable ;-) - QObject *parent = const_cast<FormWindowManager*>(this); - m_actionGroupPreviewInStyle = new PreviewActionGroup(m_core, parent); - connect(m_actionGroupPreviewInStyle, SIGNAL(preview(QString,int)), - this, SLOT(slotActionGroupPreviewInStyle(QString,int))); - } - return m_actionGroupPreviewInStyle; + return QPixmap(); + QString errorMessage; + const QPixmap pix = m_previewManager->createPreviewPixmap(fw, QString(), &errorMessage); + if (pix.isNull() && !errorMessage.isEmpty()) + qWarning("Preview pixmap creation failed: %s", qPrintable(errorMessage)); + return pix; } void FormWindowManager::deviceProfilesChanged() @@ -997,11 +974,6 @@ QUndoGroup *FormWindowManager::undoGroup() const return m_undoGroup; } -QAction *FormWindowManager::actionShowFormWindowSettingsDialog() const -{ - return m_actionShowFormWindowSettingsDialog; -} - void FormWindowManager::slotActionShowFormWindowSettingsDialog() { QDesignerFormWindowInterface *fw = activeFormWindow(); @@ -1031,6 +1003,71 @@ void FormWindowManager::slotActionShowFormWindowSettingsDialog() delete settingsDialog; } +QAction *FormWindowManager::action(Action action) const +{ + switch (action) { + case QDesignerFormWindowManagerInterface::CutAction: + return m_actionCut; + case QDesignerFormWindowManagerInterface::CopyAction: + return m_actionCopy; + case QDesignerFormWindowManagerInterface::PasteAction: + return m_actionPaste; + case QDesignerFormWindowManagerInterface::DeleteAction: + return m_actionDelete; + case QDesignerFormWindowManagerInterface::SelectAllAction: + return m_actionSelectAll; + case QDesignerFormWindowManagerInterface::LowerAction: + return m_actionLower; + case QDesignerFormWindowManagerInterface::RaiseAction: + return m_actionRaise; + case QDesignerFormWindowManagerInterface::UndoAction: + return m_actionUndo; + case QDesignerFormWindowManagerInterface::RedoAction: + return m_actionRedo; + case QDesignerFormWindowManagerInterface::HorizontalLayoutAction: + return m_actionHorizontalLayout; + case QDesignerFormWindowManagerInterface::VerticalLayoutAction: + return m_actionVerticalLayout; + case QDesignerFormWindowManagerInterface::SplitHorizontalAction: + return m_actionSplitHorizontal; + case QDesignerFormWindowManagerInterface::SplitVerticalAction: + return m_actionSplitVertical; + case QDesignerFormWindowManagerInterface::GridLayoutAction: + return m_actionGridLayout; + case QDesignerFormWindowManagerInterface::FormLayoutAction: + return m_actionFormLayout; + case QDesignerFormWindowManagerInterface::BreakLayoutAction: + return m_actionBreakLayout; + case QDesignerFormWindowManagerInterface::AdjustSizeAction: + return m_actionAdjustSize; + case QDesignerFormWindowManagerInterface::SimplifyLayoutAction: + return m_actionSimplifyLayout; + case QDesignerFormWindowManagerInterface::DefaultPreviewAction: + return m_actionDefaultPreview; + case QDesignerFormWindowManagerInterface::FormWindowSettingsDialogAction: + return m_actionShowFormWindowSettingsDialog; + } + qWarning("FormWindowManager::action: Unhanded enumeration value %d", action); + return 0; +} + +QActionGroup *FormWindowManager::actionGroup(ActionGroup actionGroup) const +{ + switch (actionGroup) { + case QDesignerFormWindowManagerInterface::StyledPreviewActionGroup: + if (m_actionGroupPreviewInStyle == 0) { + // Wish we could make the 'this' pointer mutable ;-) + QObject *parent = const_cast<FormWindowManager*>(this); + m_actionGroupPreviewInStyle = new PreviewActionGroup(m_core, parent); + connect(m_actionGroupPreviewInStyle, SIGNAL(preview(QString,int)), + this, SLOT(slotActionGroupPreviewInStyle(QString,int))); + } + return m_actionGroupPreviewInStyle; + } + qWarning("FormWindowManager::actionGroup: Unhanded enumeration value %d", actionGroup); + return 0; +} + } QT_END_NAMESPACE diff --git a/src/designer/src/components/formeditor/formwindowmanager.h b/src/designer/src/components/formeditor/formwindowmanager.h index dfd421522..78ea9145a 100644 --- a/src/designer/src/components/formeditor/formwindowmanager.h +++ b/src/designer/src/components/formeditor/formwindowmanager.h @@ -75,27 +75,8 @@ public: virtual QDesignerFormEditorInterface *core() const; - inline QAction *actionCut() const { return m_actionCut; } - inline QAction *actionCopy() const { return m_actionCopy; } - inline QAction *actionPaste() const { return m_actionPaste; } - inline QAction *actionDelete() const { return m_actionDelete; } - inline QAction *actionSelectAll() const { return m_actionSelectAll; } - inline QAction *actionLower() const { return m_actionLower; } - inline QAction *actionRaise() const { return m_actionRaise; } - QAction *actionUndo() const; - QAction *actionRedo() const; - - inline QAction *actionHorizontalLayout() const { return m_actionHorizontalLayout; } - inline QAction *actionVerticalLayout() const { return m_actionVerticalLayout; } - inline QAction *actionSplitHorizontal() const { return m_actionSplitHorizontal; } - inline QAction *actionSplitVertical() const { return m_actionSplitVertical; } - inline QAction *actionGridLayout() const { return m_actionGridLayout; } - inline QAction *actionBreakLayout() const { return m_actionBreakLayout; } - inline QAction *actionAdjustSize() const { return m_actionAdjustSize; } - - inline QAction *actionDefaultPreview() const { return m_actionDefaultPreview; } - QActionGroup *actionGroupPreviewInStyle() const; - virtual QAction *actionShowFormWindowSettingsDialog() const; + virtual QAction *action(Action action) const; + virtual QActionGroup *actionGroup(ActionGroup actionGroup) const; QDesignerFormWindowInterface *activeFormWindow() const; @@ -104,7 +85,7 @@ public: QDesignerFormWindowInterface *createFormWindow(QWidget *parentWidget = 0, Qt::WindowFlags flags = 0); - QPixmap createPreviewPixmap(QString *errorMessage); + QPixmap createPreviewPixmap() const; bool eventFilter(QObject *o, QEvent *e); @@ -133,7 +114,7 @@ private slots: void slotActionBreakLayoutActivated(); void slotActionAdjustSizeActivated(); void slotActionSimplifyLayoutActivated(); - void slotActionDefaultPreviewActivated(); + void showPreview(); void slotActionGroupPreviewInStyle(const QString &style, int deviceProfileIndex); void slotActionShowFormWindowSettingsDialog(); @@ -171,10 +152,12 @@ private: // layout actions QAction *m_actionHorizontalLayout; QAction *m_actionVerticalLayout; + QAction *m_actionFormLayout; QAction *m_actionSplitHorizontal; QAction *m_actionSplitVertical; QAction *m_actionGridLayout; QAction *m_actionBreakLayout; + QAction *m_actionSimplifyLayout; QAction *m_actionAdjustSize; // preview actions QAction *m_actionDefaultPreview; diff --git a/src/designer/src/designer/qdesigner_actions.cpp b/src/designer/src/designer/qdesigner_actions.cpp index 8b76294f1..323205000 100644 --- a/src/designer/src/designer/qdesigner_actions.cpp +++ b/src/designer/src/designer/qdesigner_actions.cpp @@ -216,8 +216,8 @@ QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench) qdesigner_internal::QDesignerFormWindowManager *ifwm = qobject_cast<qdesigner_internal::QDesignerFormWindowManager *>(m_core->formWindowManager()); Q_ASSERT(ifwm); m_previewManager = ifwm->previewManager(); - m_previewFormAction = ifwm->actionDefaultPreview(); - m_styleActions = ifwm->actionGroupPreviewInStyle(); + m_previewFormAction = ifwm->action(QDesignerFormWindowManagerInterface::DefaultPreviewAction); + m_styleActions = ifwm->actionGroup(QDesignerFormWindowManagerInterface::StyledPreviewActionGroup); connect(ifwm, SIGNAL(formWindowSettingsChanged(QDesignerFormWindowInterface*)), this, SLOT(formWindowSettingsChanged(QDesignerFormWindowInterface*))); @@ -304,32 +304,32 @@ QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench) // // edit actions // - QAction *undoAction = formWindowManager->actionUndo(); + QAction *undoAction = formWindowManager->action(QDesignerFormWindowManagerInterface::UndoAction); undoAction->setObjectName(QLatin1String("__qt_undo_action")); undoAction->setShortcut(QKeySequence::Undo); m_editActions->addAction(undoAction); - QAction *redoAction = formWindowManager->actionRedo(); + QAction *redoAction = formWindowManager->action(QDesignerFormWindowManagerInterface::RedoAction); redoAction->setObjectName(QLatin1String("__qt_redo_action")); redoAction->setShortcut(QKeySequence::Redo); m_editActions->addAction(redoAction); m_editActions->addAction(createSeparator(this)); - m_editActions->addAction(formWindowManager->actionCut()); - m_editActions->addAction(formWindowManager->actionCopy()); - m_editActions->addAction(formWindowManager->actionPaste()); - m_editActions->addAction(formWindowManager->actionDelete()); + m_editActions->addAction(formWindowManager->action(QDesignerFormWindowManagerInterface::CutAction)); + m_editActions->addAction(formWindowManager->action(QDesignerFormWindowManagerInterface::CopyAction)); + m_editActions->addAction(formWindowManager->action(QDesignerFormWindowManagerInterface::PasteAction)); + m_editActions->addAction(formWindowManager->action(QDesignerFormWindowManagerInterface::DeleteAction)); - m_editActions->addAction(formWindowManager->actionSelectAll()); + m_editActions->addAction(formWindowManager->action(QDesignerFormWindowManagerInterface::SelectAllAction)); m_editActions->addAction(createSeparator(this)); - m_editActions->addAction(formWindowManager->actionLower()); - m_editActions->addAction(formWindowManager->actionRaise()); + m_editActions->addAction(formWindowManager->action(QDesignerFormWindowManagerInterface::LowerAction)); + m_editActions->addAction(formWindowManager->action(QDesignerFormWindowManagerInterface::RaiseAction)); - formWindowManager->actionLower()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); - formWindowManager->actionRaise()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->action(QDesignerFormWindowManagerInterface::LowerAction)->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->action(QDesignerFormWindowManagerInterface::RaiseAction)->setProperty(QDesignerActions::defaultToolbarPropertyName, true); // // edit mode actions @@ -376,25 +376,25 @@ QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench) // form actions // - m_formActions->addAction(formWindowManager->actionHorizontalLayout()); - m_formActions->addAction(formWindowManager->actionVerticalLayout()); - m_formActions->addAction(formWindowManager->actionSplitHorizontal()); - m_formActions->addAction(formWindowManager->actionSplitVertical()); - m_formActions->addAction(formWindowManager->actionGridLayout()); - m_formActions->addAction(formWindowManager->actionFormLayout()); - m_formActions->addAction(formWindowManager->actionBreakLayout()); - m_formActions->addAction(formWindowManager->actionAdjustSize()); - m_formActions->addAction(formWindowManager->actionSimplifyLayout()); + m_formActions->addAction(formWindowManager->action(QDesignerFormWindowManagerInterface::HorizontalLayoutAction)); + m_formActions->addAction(formWindowManager->action(QDesignerFormWindowManagerInterface::VerticalLayoutAction)); + m_formActions->addAction(formWindowManager->action(QDesignerFormWindowManagerInterface::SplitHorizontalAction)); + m_formActions->addAction(formWindowManager->action(QDesignerFormWindowManagerInterface::SplitVerticalAction)); + m_formActions->addAction(formWindowManager->action(QDesignerFormWindowManagerInterface::GridLayoutAction)); + m_formActions->addAction(formWindowManager->action(QDesignerFormWindowManagerInterface::FormLayoutAction)); + m_formActions->addAction(formWindowManager->action(QDesignerFormWindowManagerInterface::BreakLayoutAction)); + m_formActions->addAction(formWindowManager->action(QDesignerFormWindowManagerInterface::AdjustSizeAction)); + m_formActions->addAction(formWindowManager->action(QDesignerFormWindowManagerInterface::SimplifyLayoutAction)); m_formActions->addAction(createSeparator(this)); - formWindowManager->actionHorizontalLayout()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); - formWindowManager->actionVerticalLayout()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); - formWindowManager->actionSplitHorizontal()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); - formWindowManager->actionSplitVertical()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); - formWindowManager->actionGridLayout()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); - formWindowManager->actionFormLayout()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); - formWindowManager->actionBreakLayout()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); - formWindowManager->actionAdjustSize()->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->action(QDesignerFormWindowManagerInterface::HorizontalLayoutAction)->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->action(QDesignerFormWindowManagerInterface::VerticalLayoutAction)->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->action(QDesignerFormWindowManagerInterface::SplitHorizontalAction)->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->action(QDesignerFormWindowManagerInterface::SplitVerticalAction)->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->action(QDesignerFormWindowManagerInterface::GridLayoutAction)->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->action(QDesignerFormWindowManagerInterface::FormLayoutAction)->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->action(QDesignerFormWindowManagerInterface::BreakLayoutAction)->setProperty(QDesignerActions::defaultToolbarPropertyName, true); + formWindowManager->action(QDesignerFormWindowManagerInterface::AdjustSizeAction)->setProperty(QDesignerActions::defaultToolbarPropertyName, true); m_previewFormAction->setShortcut(tr("CTRL+R")); m_formActions->addAction(m_previewFormAction); @@ -408,7 +408,7 @@ QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench) m_formActions->addAction(createSeparator(this)); - m_formActions->addAction(ifwm->actionShowFormWindowSettingsDialog()); + m_formActions->addAction(ifwm->action(QDesignerFormWindowManagerInterface::FormWindowSettingsDialogAction)); // // window actions // @@ -469,7 +469,7 @@ QActionGroup *QDesignerActions::createHelpActions() QAction *aboutPluginsAction = new QAction(tr("About Plugins"), this); aboutPluginsAction->setObjectName(QLatin1String("__qt_about_plugins_action")); aboutPluginsAction->setMenuRole(QAction::ApplicationSpecificRole); - connect(aboutPluginsAction, SIGNAL(triggered()), m_core->formWindowManager(), SLOT(aboutPlugins())); + connect(aboutPluginsAction, SIGNAL(triggered()), m_core->formWindowManager(), SLOT(showPluginDialog())); helpActions->addAction(aboutPluginsAction); QAction *aboutDesignerAction = new QAction(tr("About Qt Designer"), this); diff --git a/src/designer/src/lib/sdk/abstractformwindowmanager.cpp b/src/designer/src/lib/sdk/abstractformwindowmanager.cpp index 867acbce9..20eced143 100644 --- a/src/designer/src/lib/sdk/abstractformwindowmanager.cpp +++ b/src/designer/src/lib/sdk/abstractformwindowmanager.cpp @@ -97,29 +97,52 @@ QT_BEGIN_NAMESPACE \sa QDesignerFormEditorInterface, QDesignerFormWindowInterface */ -// ------------- QDesignerFormWindowManagerInterfacePrivate +/*! + \enum QDesignerFormWindowManagerInterface::Action -class QDesignerFormWindowManagerInterfacePrivate -{ -public: - QDesignerFormWindowManagerInterfacePrivate(); - QAction *m_simplifyLayoutAction; - QAction *m_formLayoutAction; -}; - -QDesignerFormWindowManagerInterfacePrivate::QDesignerFormWindowManagerInterfacePrivate() : - m_simplifyLayoutAction(0), - m_formLayoutAction(0) -{ -} + Specifies an action of \QD. + + \sa action() + + \since 5.0 + \value CutAction Clipboard Cut + \value CopyAction Clipboard Copy + \value PasteAction Clipboard Paste + \value DeleteAction Clipboard Delete + \value SelectAllAction Select All + \value LowerAction Lower current widget + \value RaiseAction Raise current widget + \value UndoAction Undo + \value RedoAction Redo + \value HorizontalLayoutAction Lay out using QHBoxLayout + \value VerticalLayoutAction Lay out using QVBoxLayout + \value SplitHorizontalAction Lay out in horizontal QSplitter + \value SplitVerticalAction Lay out in vertical QSplitter + \value GridLayoutAction Lay out using QGridLayout + \value FormLayoutAction Lay out using QFormLayout + \value BreakLayoutAction Break existing layout + \value AdjustSizeAction Adjust size + \value SimplifyLayoutAction Simplify QGridLayout or QFormLayout + \value DefaultPreviewAction Create a preview in default style + \value FormWindowSettingsDialogAction Show dialog with form settings +*/ + +/*! + \enum QDesignerFormWindowManagerInterface::ActionGroup + + Specifies an action group of \QD. + + \sa actionGroup() + \since 5.0 + \value StyledPreviewActionGroup Action group containing styled preview actions +*/ /*! Constructs an interface with the given \a parent for the form window manager. */ QDesignerFormWindowManagerInterface::QDesignerFormWindowManagerInterface(QObject *parent) - : QObject(parent), d(new QDesignerFormWindowManagerInterfacePrivate) - + : QObject(parent) { } @@ -135,10 +158,13 @@ QDesignerFormWindowManagerInterface::~QDesignerFormWindowManagerInterface() returns the original action. \sa QAction + \obsolete + + Use action() instead. */ QAction *QDesignerFormWindowManagerInterface::actionCut() const { - return 0; + return action(CutAction); } /*! @@ -146,10 +172,13 @@ QAction *QDesignerFormWindowManagerInterface::actionCut() const function returns the original action. \sa QAction + \obsolete + + Use action() instead. */ QAction *QDesignerFormWindowManagerInterface::actionCopy() const { - return 0; + return action(CopyAction); } /*! @@ -157,10 +186,13 @@ QAction *QDesignerFormWindowManagerInterface::actionCopy() const function returns the original action. \sa QAction + \obsolete + + Use action() instead. */ QAction *QDesignerFormWindowManagerInterface::actionPaste() const { - return 0; + return action(PasteAction); } /*! @@ -168,10 +200,13 @@ QAction *QDesignerFormWindowManagerInterface::actionPaste() const returns the original action. \sa QAction + \obsolete + + Use action() instead. */ QAction *QDesignerFormWindowManagerInterface::actionDelete() const { - return 0; + return action(DeleteAction); } /*! @@ -179,10 +214,13 @@ QAction *QDesignerFormWindowManagerInterface::actionDelete() const function returns the original action. \sa QAction + \obsolete + + Use action() instead. */ QAction *QDesignerFormWindowManagerInterface::actionSelectAll() const { - return 0; + return action(SelectAllAction); } /*! @@ -191,10 +229,14 @@ QAction *QDesignerFormWindowManagerInterface::actionSelectAll() const action. \sa QAction + \obsolete + + Use action() instead. */ + QAction *QDesignerFormWindowManagerInterface::actionLower() const { - return 0; + return action(LowerAction); } /*! @@ -203,10 +245,13 @@ QAction *QDesignerFormWindowManagerInterface::actionLower() const action. \sa QAction + \obsolete + + Use action() instead. */ QAction *QDesignerFormWindowManagerInterface::actionRaise() const { - return 0; + return action(RaiseAction); } /*! @@ -215,10 +260,13 @@ QAction *QDesignerFormWindowManagerInterface::actionRaise() const the original action. \sa QAction + \obsolete + + Use action() instead. */ QAction *QDesignerFormWindowManagerInterface::actionHorizontalLayout() const { - return 0; + return action(HorizontalLayoutAction); } /*! @@ -227,10 +275,13 @@ QAction *QDesignerFormWindowManagerInterface::actionHorizontalLayout() const original action. \sa QAction + \obsolete + + Use action() instead. */ QAction *QDesignerFormWindowManagerInterface::actionVerticalLayout() const { - return 0; + return action(VerticalLayoutAction); } /*! @@ -238,10 +289,13 @@ QAction *QDesignerFormWindowManagerInterface::actionVerticalLayout() const action. The function returns the original action. \sa QAction + \obsolete + + Use action() instead. */ QAction *QDesignerFormWindowManagerInterface::actionSplitHorizontal() const { - return 0; + return action(SplitHorizontalAction); } /*! @@ -249,10 +303,13 @@ QAction *QDesignerFormWindowManagerInterface::actionSplitHorizontal() const action. The function returns the original action. \sa QAction + \obsolete + + Use action() instead. */ QAction *QDesignerFormWindowManagerInterface::actionSplitVertical() const { - return 0; + return action(SplitVerticalAction); } /*! @@ -261,35 +318,29 @@ QAction *QDesignerFormWindowManagerInterface::actionSplitVertical() const original action. \sa QAction + \obsolete + + Use action() instead. */ QAction *QDesignerFormWindowManagerInterface::actionGridLayout() const { - return 0; + return action(GridLayoutAction); } /*! Allows you to intervene and control \QD's "form layout" action. The function returns the original action. -FormWindowManagerPrivateMap *fwmpm = g_FormWindowManagerPrivateMap(); \sa QAction + \sa QAction \since 4.4 -*/ - -QAction *QDesignerFormWindowManagerInterface::actionFormLayout() const -{ - return d->m_formLayoutAction; -} - -/*! - Sets the "form layout" action to \a action. + \obsolete - \internal - \since 4.4 + Use action() instead. */ -void QDesignerFormWindowManagerInterface::setActionFormLayout(QAction *action) +QAction *QDesignerFormWindowManagerInterface::actionFormLayout() const { - d->m_formLayoutAction = action; + return action(FormLayoutAction); } /*! @@ -297,10 +348,13 @@ void QDesignerFormWindowManagerInterface::setActionFormLayout(QAction *action) function returns the original action. \sa QAction + \obsolete + + Use action() instead. */ QAction *QDesignerFormWindowManagerInterface::actionBreakLayout() const { - return 0; + return action(BreakLayoutAction); } /*! @@ -308,10 +362,13 @@ QAction *QDesignerFormWindowManagerInterface::actionBreakLayout() const function returns the original action. \sa QAction + \obsolete + + Use action() instead. */ QAction *QDesignerFormWindowManagerInterface::actionAdjustSize() const { - return 0; + return action(AdjustSizeAction); } /*! @@ -320,96 +377,65 @@ QAction *QDesignerFormWindowManagerInterface::actionAdjustSize() const \sa QAction \since 4.4 -*/ - -QAction *QDesignerFormWindowManagerInterface::actionSimplifyLayout() const -{ - return d->m_simplifyLayoutAction; -} - -/*! - Sets the "simplify layout" action to \a action. + \obsolete - \internal - \since 4.4 + Use action() instead. */ -void QDesignerFormWindowManagerInterface::setActionSimplifyLayout(QAction *action) +QAction *QDesignerFormWindowManagerInterface::actionSimplifyLayout() const { - d->m_simplifyLayoutAction = action; + return action(SimplifyLayoutAction); } /*! + \fn virtual QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::activeFormWindow() const Returns the currently active form window in \QD's workspace. \sa setActiveFormWindow(), removeFormWindow() */ -QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::activeFormWindow() const -{ - return 0; -} /*! + \fn virtual QDesignerFormEditorInterface *QDesignerFormWindowManagerInterface::core() const Returns a pointer to \QD's current QDesignerFormEditorInterface object. */ -QDesignerFormEditorInterface *QDesignerFormWindowManagerInterface::core() const -{ - return 0; -} /*! + \fn virtual void QDesignerFormWindowManagerInterface::addFormWindow(QDesignerFormWindowInterface *formWindow) Adds the given \a formWindow to the collection of windows that \QD's form window manager maintains. \sa formWindowAdded() */ -void QDesignerFormWindowManagerInterface::addFormWindow(QDesignerFormWindowInterface *formWindow) -{ - Q_UNUSED(formWindow); -} /*! + \n virtual void QDesignerFormWindowManagerInterface::removeFormWindow(QDesignerFormWindowInterface *formWindow) Removes the given \a formWindow from the collection of windows that \QD's form window manager maintains. \sa formWindow(), formWindowRemoved() */ -void QDesignerFormWindowManagerInterface::removeFormWindow(QDesignerFormWindowInterface *formWindow) -{ - Q_UNUSED(formWindow); -} /*! + \fn virtual void QDesignerFormWindowManagerInterface::setActiveFormWindow(QDesignerFormWindowInterface *formWindow) Sets the given \a formWindow to be the currently active form window in \QD's workspace. \sa activeFormWindow(), activeFormWindowChanged() */ -void QDesignerFormWindowManagerInterface::setActiveFormWindow(QDesignerFormWindowInterface *formWindow) -{ - Q_UNUSED(formWindow); -} /*! + \fn int QDesignerFormWindowManagerInterface::formWindowCount() const Returns the number of form windows maintained by \QD's form window manager. */ -int QDesignerFormWindowManagerInterface::formWindowCount() const -{ - return 0; -} /*! + \fn QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::formWindow(int index) Returns the form window at the given \a index. \sa setActiveFormWindow(), removeFormWindow() */ -QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::formWindow(int index) const -{ - Q_UNUSED(index); - return 0; -} /*! \fn QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::createFormWindow(QWidget *parent, Qt::WindowFlags flags) @@ -419,22 +445,19 @@ QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::formWindow(in \sa addFormWindow() */ -QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::createFormWindow(QWidget *parentWidget, Qt::WindowFlags flags) -{ - Q_UNUSED(parentWidget); - Q_UNUSED(flags); - return 0; -} /*! Allows you to intervene and control \QD's "undo" action. The function returns the original action. \sa QAction + \obsolete + + Use action() instead. */ QAction *QDesignerFormWindowManagerInterface::actionUndo() const { - return 0; + return action(UndoAction); } /*! @@ -442,10 +465,13 @@ QAction *QDesignerFormWindowManagerInterface::actionUndo() const function returns the original action. \sa QAction + \obsolete + + Use action() instead. */ QAction *QDesignerFormWindowManagerInterface::actionRedo() const { - return 0; + return action(RedoAction); } /*! @@ -459,6 +485,15 @@ QAction *QDesignerFormWindowManagerInterface::actionRedo() const */ /*! + \fn void QDesignerFormWindowManagerInterface::formWindowSettingsChanged(QDesignerFormWindowInterface *formWindow) + + This signal is emitted when the settings of the form window change. It can be used to update + window titles, etc. accordingly. + + \sa FormWindowSettingsDialogAction +*/ + +/*! \fn void QDesignerFormWindowManagerInterface::formWindowRemoved(QDesignerFormWindowInterface *formWindow) This signal is emitted when a form window is removed from the @@ -484,4 +519,48 @@ QAction *QDesignerFormWindowManagerInterface::actionRedo() const \internal */ +/*! + \fn virtual QAction QDesignerFormWindowManagerInterface::action(Action action) const + + Returns the action specified by the enumeration value \a action. + + Obsoletes the action accessors of Qt 4.X. + + \since 5.0 +*/ + +/*! + \fn virtual QActionGroup *QDesignerFormWindowManagerInterface::actionGroup(ActionGroup actionGroup) const + + Returns the action group specified by the enumeration value \a actionGroup. + + \since 5.0 +*/ + +/*! + \fn virtual void QDesignerFormWindowManagerInterface::showPreview() + + Show a preview of the current form using the default parameters. + + \since 5.0 + \sa closeAllPreviews() +*/ + +/*! + \fn virtual void QDesignerFormWindowManagerInterface::closeAllPreviews() + + Close all currently open previews. + + \since 5.0 + \sa showPreview() +*/ + +/*! + \fn virtual void QDesignerFormWindowManagerInterface::showPluginDialog() + + Opens a dialog showing the plugins loaded by \QD's and its plugin load failures. + + \since 5.0 +*/ + QT_END_NAMESPACE diff --git a/src/designer/src/lib/sdk/abstractformwindowmanager.h b/src/designer/src/lib/sdk/abstractformwindowmanager.h index 60b12a3f6..90e37a336 100644 --- a/src/designer/src/lib/sdk/abstractformwindowmanager.h +++ b/src/designer/src/lib/sdk/abstractformwindowmanager.h @@ -52,69 +52,107 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -class QAction; -class QActionGroup; class QDesignerFormEditorInterface; -class DomUI; -class QWidget; class QDesignerDnDItemInterface; -class QDesignerFormWindowManagerInterfacePrivate; +class QWidget; +class QPixmap; +class QAction; +class QActionGroup; class QDESIGNER_SDK_EXPORT QDesignerFormWindowManagerInterface: public QObject { Q_OBJECT public: - QDesignerFormWindowManagerInterface(QObject *parent = 0); + explicit QDesignerFormWindowManagerInterface(QObject *parent = 0); virtual ~QDesignerFormWindowManagerInterface(); - virtual QAction *actionCut() const; - virtual QAction *actionCopy() const; - virtual QAction *actionPaste() const; - virtual QAction *actionDelete() const; - virtual QAction *actionSelectAll() const; - virtual QAction *actionLower() const; - virtual QAction *actionRaise() const; - virtual QAction *actionUndo() const; - virtual QAction *actionRedo() const; - - virtual QAction *actionHorizontalLayout() const; - virtual QAction *actionVerticalLayout() const; - virtual QAction *actionSplitHorizontal() const; - virtual QAction *actionSplitVertical() const; - virtual QAction *actionGridLayout() const; + enum Action + { + CutAction = 100, + CopyAction, + PasteAction, + DeleteAction, + SelectAllAction, + + LowerAction = 200, + RaiseAction, + + UndoAction = 300, + RedoAction, + + HorizontalLayoutAction = 400, + VerticalLayoutAction, + SplitHorizontalAction, + SplitVerticalAction, + GridLayoutAction, + FormLayoutAction, + BreakLayoutAction, + AdjustSizeAction, + SimplifyLayoutAction, + + DefaultPreviewAction = 500, + + FormWindowSettingsDialogAction = 600 + }; + + enum ActionGroup + { + StyledPreviewActionGroup = 100 + }; + + virtual QAction *action(Action action) const = 0; + virtual QActionGroup *actionGroup(ActionGroup actionGroup) const = 0; + + QAction *actionCut() const; + QAction *actionCopy() const; + QAction *actionPaste() const; + QAction *actionDelete() const; + QAction *actionSelectAll() const; + QAction *actionLower() const; + QAction *actionRaise() const; + QAction *actionUndo() const; + QAction *actionRedo() const; + + QAction *actionHorizontalLayout() const; + QAction *actionVerticalLayout() const; + QAction *actionSplitHorizontal() const; + QAction *actionSplitVertical() const; + QAction *actionGridLayout() const; QAction *actionFormLayout() const; - virtual QAction *actionBreakLayout() const; - virtual QAction *actionAdjustSize() const; + QAction *actionBreakLayout() const; + QAction *actionAdjustSize() const; QAction *actionSimplifyLayout() const; - virtual QDesignerFormWindowInterface *activeFormWindow() const; + virtual QDesignerFormWindowInterface *activeFormWindow() const = 0; - virtual int formWindowCount() const; - virtual QDesignerFormWindowInterface *formWindow(int index) const; + virtual int formWindowCount() const = 0; + virtual QDesignerFormWindowInterface *formWindow(int index) const = 0; - virtual QDesignerFormWindowInterface *createFormWindow(QWidget *parentWidget = 0, Qt::WindowFlags flags = 0); + virtual QDesignerFormWindowInterface *createFormWindow(QWidget *parentWidget = 0, Qt::WindowFlags flags = 0) = 0; - virtual QDesignerFormEditorInterface *core() const; + virtual QDesignerFormEditorInterface *core() const = 0; virtual void dragItems(const QList<QDesignerDnDItemInterface*> &item_list) = 0; + virtual QPixmap createPreviewPixmap() const = 0; + Q_SIGNALS: void formWindowAdded(QDesignerFormWindowInterface *formWindow); void formWindowRemoved(QDesignerFormWindowInterface *formWindow); void activeFormWindowChanged(QDesignerFormWindowInterface *formWindow); + void formWindowSettingsChanged(QDesignerFormWindowInterface *fw); public Q_SLOTS: - virtual void addFormWindow(QDesignerFormWindowInterface *formWindow); - virtual void removeFormWindow(QDesignerFormWindowInterface *formWindow); - virtual void setActiveFormWindow(QDesignerFormWindowInterface *formWindow); - -protected: - void setActionFormLayout(QAction *action); - void setActionSimplifyLayout(QAction *action); + virtual void addFormWindow(QDesignerFormWindowInterface *formWindow) = 0; + virtual void removeFormWindow(QDesignerFormWindowInterface *formWindow) = 0; + virtual void setActiveFormWindow(QDesignerFormWindowInterface *formWindow) = 0; + virtual void showPreview() = 0; + virtual void closeAllPreviews() = 0; + virtual void showPluginDialog() = 0; private: - QScopedPointer<QDesignerFormWindowManagerInterfacePrivate> d; + QScopedPointer<int> d; }; QT_END_NAMESPACE diff --git a/src/designer/src/lib/shared/qdesigner_formwindowmanager.cpp b/src/designer/src/lib/shared/qdesigner_formwindowmanager.cpp index 1521e146e..14bdfde18 100644 --- a/src/designer/src/lib/shared/qdesigner_formwindowmanager.cpp +++ b/src/designer/src/lib/shared/qdesigner_formwindowmanager.cpp @@ -70,50 +70,6 @@ QDesignerFormWindowManager::~QDesignerFormWindowManager() } /*! - Allows you to intervene and control \QD's form "Preview" action. The - function returns the original action. - - \since 4.5 - */ -QAction *QDesignerFormWindowManager::actionDefaultPreview() const -{ - return 0; -} - -/*! - Allows you to intervene and control \QD's form "Preview in" style action. The - function returns the original list of actions. - - The method calls PreviewManager::createStyleActionGroup() internally. - - \since 4.5 - */ -QActionGroup *QDesignerFormWindowManager::actionGroupPreviewInStyle() const -{ - return 0; -} - -/*! - \fn QPixmap QDesignerFormWindowManager::createPreviewPixmap(QString *errorMessage) - - Creates a pixmap representing the preview of the currently active form. - - The method calls PreviewManager::createPreviewPixmap() internally. - - \since 4.5 - */ - - -/*! - \fn QPixmap QDesignerFormWindowManager::closeAllPreviews() - - Closes all preview windows generated by actionDefaultPreview, actionGroupPreviewInStyle - and the corresponding methods in PreviewManager. - - \since 4.5 - */ - -/*! \fn PreviewManager *QDesignerFormWindowManager::previewManager() Accesses the previewmanager implementation. @@ -122,31 +78,7 @@ QActionGroup *QDesignerFormWindowManager::actionGroupPreviewInStyle() const \internal */ -/*! - \fn QAction *QDesignerFormWindowManager::actionShowFormWindowSettingsDialog() const; - - Allows you to intervene and control \QD's form "Form Settings" action. The - function returns the original action. - - \since 4.5 - \internal - */ - -QAction *QDesignerFormWindowManager::actionShowFormWindowSettingsDialog() const -{ - return 0; -} - -/*! - \fn void QDesignerFormWindowManager::aboutPlugins() - - Pops up an "About plugins" dialog. - - \since 4.5 - \internal - */ - -void QDesignerFormWindowManager::aboutPlugins() +void QDesignerFormWindowManager::showPluginDialog() { PluginDialog dlg(core(), core()->topLevel()); dlg.exec(); @@ -161,7 +93,7 @@ void QDesignerFormWindowManager::aboutPlugins() \since 4.5 \internal - */ +*/ QT_END_NAMESPACE diff --git a/src/designer/src/lib/shared/qdesigner_formwindowmanager_p.h b/src/designer/src/lib/shared/qdesigner_formwindowmanager_p.h index 43c9149fc..835e71b22 100644 --- a/src/designer/src/lib/shared/qdesigner_formwindowmanager_p.h +++ b/src/designer/src/lib/shared/qdesigner_formwindowmanager_p.h @@ -73,20 +73,9 @@ public: explicit QDesignerFormWindowManager(QObject *parent = 0); virtual ~QDesignerFormWindowManager(); - virtual QAction *actionDefaultPreview() const; - virtual QActionGroup *actionGroupPreviewInStyle() const; - virtual QAction *actionShowFormWindowSettingsDialog() const; - - virtual QPixmap createPreviewPixmap(QString *errorMessage) = 0; - virtual PreviewManager *previewManager() const = 0; -Q_SIGNALS: - void formWindowSettingsChanged(QDesignerFormWindowInterface *fw); - -public Q_SLOTS: - virtual void closeAllPreviews() = 0; - void aboutPlugins(); + virtual void showPluginDialog(); private: void *m_unused; |