From e1ac9ce48fee656e587523989041221ec04122ef Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 13 May 2011 11:56:29 +0200 Subject: Designer: BC corrections in QDesignerFormWindowInterface. Make active resource file sets and related functions available for IDE project integration. Reviewed-by: Jarek Kobus --- .../src/components/formeditor/formwindow.h | 1 + .../components/formeditor/qdesigner_resource.cpp | 21 +++---- src/designer/src/lib/sdk/abstractformwindow.cpp | 70 ++++++++++++++++++++++ src/designer/src/lib/sdk/abstractformwindow.h | 19 +++++- src/designer/src/lib/sdk/abstractintegration.cpp | 4 +- src/designer/src/lib/shared/formwindowbase.cpp | 8 +-- src/designer/src/lib/shared/formwindowbase_p.h | 15 ++--- .../src/lib/shared/qtresourceeditordialog.cpp | 4 +- src/designer/src/lib/shared/qtresourcemodel.cpp | 12 ++-- src/designer/src/lib/shared/qtresourcemodel_p.h | 4 +- src/designer/src/lib/shared/widgetfactory.cpp | 5 +- 11 files changed, 121 insertions(+), 42 deletions(-) diff --git a/src/designer/src/components/formeditor/formwindow.h b/src/designer/src/components/formeditor/formwindow.h index ff862d863..405a631b4 100644 --- a/src/designer/src/components/formeditor/formwindow.h +++ b/src/designer/src/components/formeditor/formwindow.h @@ -58,6 +58,7 @@ QT_BEGIN_NAMESPACE class QDesignerDnDItemInterface; class QDesignerTaskMenuExtension; class DomConnections; +class DomUI; class QWidget; class QAction; diff --git a/src/designer/src/components/formeditor/qdesigner_resource.cpp b/src/designer/src/components/formeditor/qdesigner_resource.cpp index a79bdf8fd..1627d4275 100644 --- a/src/designer/src/components/formeditor/qdesigner_resource.cpp +++ b/src/designer/src/components/formeditor/qdesigner_resource.cpp @@ -2297,7 +2297,7 @@ void QDesignerResource::createResources(DomResources *resources) QtResourceSet *resourceSet = m_formWindow->resourceSet(); if (resourceSet) { - QStringList oldPaths = resourceSet->activeQrcPaths(); + QStringList oldPaths = resourceSet->activeResourceFilePaths(); QStringList newPaths = oldPaths; QStringListIterator it(paths); while (it.hasNext()) { @@ -2305,7 +2305,7 @@ void QDesignerResource::createResources(DomResources *resources) if (!newPaths.contains(path)) newPaths << path; } - resourceSet->activateQrcPaths(newPaths); + resourceSet->activateResourceFilePaths(newPaths); } else { resourceSet = m_formWindow->core()->resourceModel()->addResourceSet(paths); m_formWindow->setResourceSet(resourceSet); @@ -2317,15 +2317,16 @@ void QDesignerResource::createResources(DomResources *resources) DomResources *QDesignerResource::saveResources() { QStringList paths; - if (m_formWindow->saveResourcesBehaviour() == FormWindowBase::SaveAll) { - QtResourceSet *resourceSet = m_formWindow->resourceSet(); - QList dom_include; - if (resourceSet) - paths = resourceSet->activeQrcPaths(); - } else if (m_formWindow->saveResourcesBehaviour() == FormWindowBase::SaveOnlyUsedQrcFiles) { + switch (m_formWindow->resourceFileSaveMode()) { + case QDesignerFormWindowInterface::SaveAllResourceFiles: + paths = m_formWindow->activeResourceFilePaths(); + break; + case QDesignerFormWindowInterface::SaveOnlyUsedResourceFiles: paths = m_resourceBuilder->usedQrcFiles(); + break; + case QDesignerFormWindowInterface::DontSaveResourceFiles: + break; } - return saveResources(paths); } @@ -2334,7 +2335,7 @@ DomResources *QDesignerResource::saveResources(const QStringList &qrcPaths) QtResourceSet *resourceSet = m_formWindow->resourceSet(); QList dom_include; if (resourceSet) { - const QStringList activePaths = resourceSet->activeQrcPaths(); + const QStringList activePaths = resourceSet->activeResourceFilePaths(); foreach (const QString &path, activePaths) { if (qrcPaths.contains(path)) { DomResource *dom_res = new DomResource; diff --git a/src/designer/src/lib/sdk/abstractformwindow.cpp b/src/designer/src/lib/sdk/abstractformwindow.cpp index 7ea450627..8e37b9f78 100644 --- a/src/designer/src/lib/sdk/abstractformwindow.cpp +++ b/src/designer/src/lib/sdk/abstractformwindow.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "abstractformwindow.h" +#include "qtresourcemodel_p.h" #include @@ -149,6 +150,18 @@ QT_BEGIN_NAMESPACE \sa hasFeature(), features() */ +/*! + \enum QDesignerFormWindowInterface::ResourceFileSaveMode + \since 5.0 + + This enum describes how resource files are saved. + + + \value SaveAllResourceFiles Save all resource files. + \value SaveOnlyUsedResourceFiles Save resource files used by form. + \value DontSaveResourceFiles Do not save resource files. +*/ + /*! Constructs a form window interface with the given \a parent and the specified window \a flags. @@ -244,6 +257,53 @@ QDesignerFormWindowInterface *QDesignerFormWindowInterface::findFormWindow(QObje return 0; } +/*! + \fn virtual QtResourceSet *QDesignerFormWindowInterface::resourceSet() const + + Returns the resource set used by the form window interface. + + \since 5.0 + \internal +*/ + +/*! + \fn virtual void QDesignerFormWindowInterface::setResourceSet(QtResourceSet *resourceSet) + + Sets the resource set used by the form window interface to \a resourceSet. + + \since 5.0 + \internal +*/ + +/*! + Returns the active resource (.qrc) file paths currently loaded in \QD. + \since 5.0 + \sa activateResourceFilePaths() +*/ + +QStringList QDesignerFormWindowInterface::activeResourceFilePaths() const +{ + return resourceSet()->activeResourceFilePaths(); +} + +/*! + Activates the resource (.qrc) file paths \a paths, returning the count of errors in \a errorCount and + error message in \a errorMessages. \QD loads the resources using the QResource class, + making them available for form editing. + + In IDE integrations, a list of the project's resource (.qrc) file can be activated, making + them available to \QD. + + \since 5.0 + \sa activeResourceFilePaths() + \sa QResource +*/ + +void QDesignerFormWindowInterface::activateResourceFilePaths(const QStringList &paths, int *errorCount, QString *errorMessages) +{ + resourceSet()->activateResourceFilePaths(paths, errorCount, errorMessages); +} + /*! \fn virtual QString QDesignerFormWindowInterface::fileName() const @@ -485,6 +545,16 @@ QDesignerFormWindowInterface *QDesignerFormWindowInterface::findFormWindow(QObje Returns the main container widget for the form window. \sa setMainContainer() + \internal +*/ + +/*! + \fn virtual QWidget *QDesignerFormWindowInterface::formContainer() const + + Returns the form the widget containing the main container widget. + + \since 5.0 + \sa mainContainer() */ /*! diff --git a/src/designer/src/lib/sdk/abstractformwindow.h b/src/designer/src/lib/sdk/abstractformwindow.h index 36ce4a54c..cf91864e2 100644 --- a/src/designer/src/lib/sdk/abstractformwindow.h +++ b/src/designer/src/lib/sdk/abstractformwindow.h @@ -53,9 +53,9 @@ QT_BEGIN_NAMESPACE class QDesignerFormEditorInterface; class QDesignerFormWindowCursorInterface; class QDesignerFormWindowToolInterface; -class DomUI; class QUndoStack; class QDir; +class QtResourceSet; class QDESIGNER_SDK_EXPORT QDesignerFormWindowInterface: public QWidget { @@ -70,6 +70,13 @@ public: }; Q_DECLARE_FLAGS(Feature, FeatureFlag) + enum ResourceFileSaveMode + { + SaveAllResourceFiles, + SaveOnlyUsedResourceFiles, + DontSaveResourceFiles + }; + public: QDesignerFormWindowInterface(QWidget *parent = 0, Qt::WindowFlags flags = 0); virtual ~QDesignerFormWindowInterface(); @@ -104,6 +111,14 @@ public: virtual QStringList includeHints() const = 0; virtual void setIncludeHints(const QStringList &includeHints) = 0; + virtual ResourceFileSaveMode resourceFileSaveMode() const = 0; + virtual void setResourceFileSaveMode(ResourceFileSaveMode behaviour) = 0; + + virtual QtResourceSet *resourceSet() const = 0; + virtual void setResourceSet(QtResourceSet *resourceSet) = 0; + + QStringList activeResourceFilePaths() const; + virtual QDesignerFormEditorInterface *core() const; virtual QDesignerFormWindowCursorInterface *cursor() const = 0; @@ -119,6 +134,7 @@ public: virtual QWidget *mainContainer() const = 0; virtual void setMainContainer(QWidget *mainContainer) = 0; + virtual QWidget *formContainer() const = 0; virtual bool isManaged(QWidget *widget) const = 0; @@ -155,6 +171,7 @@ public Q_SLOTS: virtual void setContents(const QString &contents) = 0; virtual void editWidgets() = 0; + void activateResourceFilePaths(const QStringList &paths, int *errorCount = 0, QString *errorMessages = 0); Q_SIGNALS: void mainContainerChanged(QWidget *mainContainer); diff --git a/src/designer/src/lib/sdk/abstractintegration.cpp b/src/designer/src/lib/sdk/abstractintegration.cpp index c222e1966..da9d98f60 100644 --- a/src/designer/src/lib/sdk/abstractintegration.cpp +++ b/src/designer/src/lib/sdk/abstractintegration.cpp @@ -331,7 +331,6 @@ public: QDesignerIntegrationInterface::ResourceFileWatcherBehaviour m_resourceFileWatcherBehaviour; QString m_gradientsPath; QtGradientManager *m_gradientManager; - QDesignerIntegrationInterface::ResourceFileWatcherBehaviour m_fileWatcherBehaviour; }; QDesignerIntegrationPrivate::QDesignerIntegrationPrivate(QDesignerIntegration *qq) : @@ -340,8 +339,7 @@ QDesignerIntegrationPrivate::QDesignerIntegrationPrivate(QDesignerIntegration *q headerLowercase(true), m_features(QDesignerIntegrationInterface::DefaultFeature), m_resourceFileWatcherBehaviour(QDesignerIntegrationInterface::PromptToReloadResourceFile), - m_gradientManager(0), - m_fileWatcherBehaviour(QDesignerIntegrationInterface::PromptToReloadResourceFile) + m_gradientManager(0) { } diff --git a/src/designer/src/lib/shared/formwindowbase.cpp b/src/designer/src/lib/shared/formwindowbase.cpp index ca81b5ed1..83bf05796 100644 --- a/src/designer/src/lib/shared/formwindowbase.cpp +++ b/src/designer/src/lib/shared/formwindowbase.cpp @@ -95,7 +95,7 @@ public: QMap m_reloadablePropertySheets; const DeviceProfile m_deviceProfile; FormWindowBase::LineTerminatorMode m_lineTerminatorMode; - FormWindowBase::SaveResourcesBehaviour m_saveResourcesBehaviour; + FormWindowBase::ResourceFileSaveMode m_saveResourcesBehaviour; }; FormWindowBasePrivate::FormWindowBasePrivate(QDesignerFormEditorInterface *core) : @@ -107,7 +107,7 @@ FormWindowBasePrivate::FormWindowBasePrivate(QDesignerFormEditorInterface *core) m_resourceSet(0), m_deviceProfile(QDesignerSharedSettings(core).currentDeviceProfile()), m_lineTerminatorMode(FormWindowBase::NativeLineTerminator), - m_saveResourcesBehaviour(FormWindowBase::SaveAll) + m_saveResourcesBehaviour(FormWindowBase::SaveAllResourceFiles) { } @@ -302,12 +302,12 @@ bool FormWindowBase::gridVisible() const return m_d->m_grid.visible() && currentTool() == 0; } -FormWindowBase::SaveResourcesBehaviour FormWindowBase::saveResourcesBehaviour() const +FormWindowBase::ResourceFileSaveMode FormWindowBase::resourceFileSaveMode() const { return m_d->m_saveResourcesBehaviour; } -void FormWindowBase::setSaveResourcesBehaviour(SaveResourcesBehaviour behaviour) +void FormWindowBase::setResourceFileSaveMode(ResourceFileSaveMode behaviour) { m_d->m_saveResourcesBehaviour = behaviour; } diff --git a/src/designer/src/lib/shared/formwindowbase_p.h b/src/designer/src/lib/shared/formwindowbase_p.h index 62136a62d..91f6a306d 100644 --- a/src/designer/src/lib/shared/formwindowbase_p.h +++ b/src/designer/src/lib/shared/formwindowbase_p.h @@ -82,7 +82,6 @@ class QDESIGNER_SHARED_EXPORT FormWindowBase: public QDesignerFormWindowInterfac Q_OBJECT public: enum HighlightMode { Restore, Highlight }; - enum SaveResourcesBehaviour { SaveAll, SaveOnlyUsedQrcFiles, DontSaveQrcFiles }; explicit FormWindowBase(QDesignerFormEditorInterface *core, QWidget *parent = 0, Qt::WindowFlags flags = 0); virtual ~FormWindowBase(); @@ -93,12 +92,6 @@ public: // Return contents without warnings. Should be 'contents(bool quiet)' QString fileContents() const; - // Return the widget containing the form. This is used to - // apply embedded design settings to that are inherited (for example font). - // These are meant to be applied to the form only and not to the other editors - // in the widget stack. - virtual QWidget *formContainer() const = 0; - // Deprecated virtual QPoint grid() const; @@ -117,8 +110,8 @@ public: bool gridVisible() const; - SaveResourcesBehaviour saveResourcesBehaviour() const; - void setSaveResourcesBehaviour(SaveResourcesBehaviour behaviour); + virtual ResourceFileSaveMode resourceFileSaveMode() const; + virtual void setResourceFileSaveMode(ResourceFileSaveMode behaviour); static const Grid &defaultDesignerGrid(); static void setDefaultDesignerGrid(const Grid& grid); @@ -153,8 +146,8 @@ public: DesignerPixmapCache *pixmapCache() const; DesignerIconCache *iconCache() const; - QtResourceSet *resourceSet() const; - void setResourceSet(QtResourceSet *resourceSet); + virtual QtResourceSet *resourceSet() const; + virtual void setResourceSet(QtResourceSet *resourceSet); void addReloadableProperty(QDesignerPropertySheet *sheet, int index); void removeReloadableProperty(QDesignerPropertySheet *sheet, int index); void addReloadablePropertySheet(QDesignerPropertySheet *sheet, QObject *object); diff --git a/src/designer/src/lib/shared/qtresourceeditordialog.cpp b/src/designer/src/lib/shared/qtresourceeditordialog.cpp index 9162b097d..59a12de00 100644 --- a/src/designer/src/lib/shared/qtresourceeditordialog.cpp +++ b/src/designer/src/lib/shared/qtresourceeditordialog.cpp @@ -2105,7 +2105,7 @@ void QtResourceEditorDialog::setResourceModel(QtResourceModel *model) // enable qrcBox - QStringList paths = resourceSet->activeQrcPaths(); + QStringList paths = resourceSet->activeResourceFilePaths(); QStringListIterator it(paths); while (it.hasNext()) { const QString path = it.next(); @@ -2198,7 +2198,7 @@ void QtResourceEditorDialog::accept() } else { int errorCount; QString errorMessages; - d_ptr->m_resourceModel->currentResourceSet()->activateQrcPaths(newQrcPaths, &errorCount, &errorMessages); + d_ptr->m_resourceModel->currentResourceSet()->activateResourceFilePaths(newQrcPaths, &errorCount, &errorMessages); if (errorCount) displayResourceFailures(errorMessages, d_ptr->m_dlgGui, this); } diff --git a/src/designer/src/lib/shared/qtresourcemodel.cpp b/src/designer/src/lib/shared/qtresourcemodel.cpp index ca2fb7882..50e67a45c 100644 --- a/src/designer/src/lib/shared/qtresourcemodel.cpp +++ b/src/designer/src/lib/shared/qtresourcemodel.cpp @@ -143,13 +143,13 @@ QtResourceSet::~QtResourceSet() { } -QStringList QtResourceSet::activeQrcPaths() const +QStringList QtResourceSet::activeResourceFilePaths() const { QtResourceSet *that = const_cast(this); return d_ptr->m_resourceModel->d_ptr->m_resourceSetToPaths.value(that); } -void QtResourceSet::activateQrcPaths(const QStringList &paths, int *errorCount, QString *errorMessages) +void QtResourceSet::activateResourceFilePaths(const QStringList &paths, int *errorCount, QString *errorMessages) { d_ptr->m_resourceModel->d_ptr->activate(this, paths, errorCount, errorMessages); } @@ -217,7 +217,7 @@ void QtResourceModelPrivate::registerResourceSet(QtResourceSet *resourceSet) return; // unregister old paths (all because the order of registration is important), later it can be optimized a bit - QStringList toRegister = resourceSet->activeQrcPaths(); + QStringList toRegister = resourceSet->activeResourceFilePaths(); QStringListIterator itRegister(toRegister); while (itRegister.hasNext()) { const QString path = itRegister.next(); @@ -249,7 +249,7 @@ void QtResourceModelPrivate::unregisterResourceSet(QtResourceSet *resourceSet) return; // unregister old paths (all because the order of registration is importans), later it can be optimized a bit - QStringList toUnregister = resourceSet->activeQrcPaths(); + QStringList toUnregister = resourceSet->activeResourceFilePaths(); QStringListIterator itUnregister(toUnregister); while (itUnregister.hasNext()) { const QString path = itUnregister.next(); @@ -283,7 +283,7 @@ void QtResourceModelPrivate::activate(QtResourceSet *resourceSet, const QStringL int generatedCount = 0; bool newResourceSetChanged = false; - if (resourceSet && resourceSet->activeQrcPaths() != newPaths && !m_newlyCreated.contains(resourceSet)) + if (resourceSet && resourceSet->activeResourceFilePaths() != newPaths && !m_newlyCreated.contains(resourceSet)) newResourceSetChanged = true; PathDataMap newPathToData = m_pathToData; @@ -356,7 +356,7 @@ void QtResourceModelPrivate::activate(QtResourceSet *resourceSet, const QStringL QStringList oldActivePaths; if (m_currentResourceSet) - oldActivePaths = m_currentResourceSet->activeQrcPaths(); + oldActivePaths = m_currentResourceSet->activeResourceFilePaths(); const bool needReregister = (oldActivePaths != newPaths) || newResourceSetChanged; diff --git a/src/designer/src/lib/shared/qtresourcemodel_p.h b/src/designer/src/lib/shared/qtresourcemodel_p.h index b1ddcca4a..ca8eadaa7 100644 --- a/src/designer/src/lib/shared/qtresourcemodel_p.h +++ b/src/designer/src/lib/shared/qtresourcemodel_p.h @@ -65,7 +65,7 @@ class QtResourceModel; class QDESIGNER_SHARED_EXPORT QtResourceSet // one instance per one form { public: - QStringList activeQrcPaths() const; + QStringList activeResourceFilePaths() const; // activateQrcPaths(): if this QtResourceSet is active it emits resourceSetActivated(); // otherwise only in case if active QtResource set contains one of @@ -78,7 +78,7 @@ public: // resource set) it is automatically unloaded. The removed file can also be // marked as modified (later when another resource set which contains // removed path is activated will be reloaded) - void activateQrcPaths(const QStringList &paths, int *errorCount = 0, QString *errorMessages = 0); + void activateResourceFilePaths(const QStringList &paths, int *errorCount = 0, QString *errorMessages = 0); bool isModified(const QString &path) const; // for all paths in resource model (redundant here, maybe it should be removed from here) void setModified(const QString &path); // for all paths in resource model (redundant here, maybe it should be removed from here) diff --git a/src/designer/src/lib/shared/widgetfactory.cpp b/src/designer/src/lib/shared/widgetfactory.cpp index ce0883796..400e5b9ef 100644 --- a/src/designer/src/lib/shared/widgetfactory.cpp +++ b/src/designer/src/lib/shared/widgetfactory.cpp @@ -362,9 +362,8 @@ QWidget *WidgetFactory::createWidget(const QString &widgetName, QWidget *parentW if (qt_extension(m_core->extensionManager(), parentWidget)) { w = new QDesignerWidget(fw, parentWidget); } else { - if (const FormWindowBase *fwb = qobject_cast(fw)) - if (parentWidget == fwb->formContainer()) - w = new QDesignerWidget(fw, parentWidget); + if (parentWidget == fw->formContainer()) + w = new QDesignerWidget(fw, parentWidget); } } if (!w) -- cgit v1.2.1 From ed81ec87cd8c1f5d3c61ecdbed12211a7d754082 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 13 May 2011 14:24:57 +0200 Subject: Designer: BC cleanup of QDesignerFormWindowManager. Obsolete the virtual action-accessors causing Qt 4 BC grief by action() taking an enumeration that can be easily extended. Make actions added during Qt 4 development available. Make preview functionality public for IDE integration. Acked-by: Jarek Kobus --- .../src/components/formeditor/formwindow.cpp | 34 +-- .../components/formeditor/formwindowmanager.cpp | 147 +++++++----- .../src/components/formeditor/formwindowmanager.h | 29 +-- src/designer/src/designer/qdesigner_actions.cpp | 64 ++--- .../src/lib/sdk/abstractformwindowmanager.cpp | 267 +++++++++++++-------- .../src/lib/sdk/abstractformwindowmanager.h | 110 ++++++--- .../src/lib/shared/qdesigner_formwindowmanager.cpp | 72 +----- .../src/lib/shared/qdesigner_formwindowmanager_p.h | 13 +- 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(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(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(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); } /*! @@ -458,6 +484,15 @@ QAction *QDesignerFormWindowManagerInterface::actionRedo() const \sa addFormWindow(), setActiveFormWindow() */ +/*! + \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) @@ -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 &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 d; + QScopedPointer 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 @@ -69,50 +69,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() @@ -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; -- cgit v1.2.1