diff --git a/src/plugins/designer/designer.pro b/src/plugins/designer/designer.pro index b6723b83c72..21559fdbea1 100644 --- a/src/plugins/designer/designer.pro +++ b/src/plugins/designer/designer.pro @@ -7,20 +7,26 @@ include(../../shared/designerintegrationv2/designerintegration.pri) include(cpp/cpp.pri) include(designer_dependencies.pri) -# -- figure out shared dir location -!exists($$[QT_INSTALL_HEADERS]/QtDesigner/private/qdesigner_integration_p.h) { - QT_SOURCE_TREE=$$fromfile($$(QTDIR)/.qmake.cache,QT_SOURCE_TREE) - INCLUDEPATH += $$QT_SOURCE_TREE/include +INCLUDEPATH += ../../tools/utils + +minQtVersion(5, 0, 0) { + CONFIG += designer +# -- Fixme: Make tools available + INCLUDEPATH += $$QMAKE_INCDIR_QT/../../qttools/include +} else { + # -- figure out shared dir location + !exists($$[QT_INSTALL_HEADERS]/QtDesigner/private/qdesigner_integration_p.h) { + QT_SOURCE_TREE=$$fromfile($$(QTDIR)/.qmake.cache,QT_SOURCE_TREE) + INCLUDEPATH += $$QT_SOURCE_TREE/include + } + INCLUDEPATH += $$QMAKE_INCDIR_QT/QtDesigner + qtAddLibrary(QtDesigner) } -INCLUDEPATH += $$QMAKE_INCDIR_QT/QtDesigner \ - ../../tools/utils +QT += xml -qtAddLibrary(QtDesigner) qtAddLibrary(QtDesignerComponents) -QT+=xml - HEADERS += formeditorplugin.h \ formeditorfactory.h \ formwindoweditor.h \ diff --git a/src/plugins/designer/designercontext.cpp b/src/plugins/designer/designercontext.cpp index bddb1e9d810..e91f619add6 100644 --- a/src/plugins/designer/designercontext.cpp +++ b/src/plugins/designer/designercontext.cpp @@ -35,7 +35,12 @@ #include "formeditorw.h" #include -#include "qt_private/qdesigner_integration_p.h" + +#if QT_VERSION >= 0x050000 +# include +#else +# include "qt_private/qdesigner_integration_p.h" +#endif #include #include @@ -56,16 +61,18 @@ DesignerContext::DesignerContext(const Core::Context &context, QString DesignerContext::contextHelpId() const { - QString helpId; const QDesignerFormEditorInterface *core = FormEditorW::instance()->designerEditor(); - // Present from Qt 4.5.1 onwards. This will show the class documentation +#if QT_VERSION >= 0x050000 + return core->integration()->contextHelpId(); +#else + QString helpId; + // Present from Qt 4.5.1 onwards. This will show the class documentation // scrolled to the current property. if (const qdesigner_internal::QDesignerIntegration *integration = qobject_cast(core->integration())) helpId = integration->contextHelpId(); - if (debug) - qDebug() << "DesignerContext::contextHelpId" << m_widget << helpId; return helpId; +#endif } } // namespace Internal diff --git a/src/plugins/designer/formeditorw.cpp b/src/plugins/designer/formeditorw.cpp index ce58f190347..7bb9c56c637 100644 --- a/src/plugins/designer/formeditorw.cpp +++ b/src/plugins/designer/formeditorw.cpp @@ -63,14 +63,18 @@ #include #include -#include "qt_private/pluginmanager_p.h" - -#include "qt_private/iconloader_p.h" // createIconSet -#include "qt_private/qdesigner_formwindowmanager_p.h" -#include "qt_private/formwindowbase_p.h" #include #include +#if QT_VERSION >= 0x050000 +# include +#else +# include "qt_private/pluginmanager_p.h" +# include "qt_private/iconloader_p.h" // createIconSet +# include "qt_private/qdesigner_formwindowmanager_p.h" +# include "qt_private/formwindowbase_p.h" +#endif + #include #include #include @@ -117,7 +121,11 @@ static const char settingsGroup[] = "Designer"; static inline QIcon designerIcon(const QString &iconName) { +#if QT_VERSION >= 0x050000 + const QIcon icon = QDesignerFormEditorInterface::createIcon(iconName); +#else const QIcon icon = qdesigner_internal::createIconSet(iconName); +#endif if (icon.isNull()) qWarning() << "Unable to locate " << iconName; return icon; @@ -180,7 +188,11 @@ FormEditorW::FormEditorW() : m_formeditor->setTopLevel(qobject_cast(m_core->editorManager())); m_formeditor->setSettingsManager(new SettingsManager()); +#if QT_VERSION >= 0x050000 + m_fwm = m_formeditor->formWindowManager(); +#else m_fwm = qobject_cast(m_formeditor->formWindowManager()); +#endif QTC_ASSERT(m_fwm, return); m_contexts.add(Designer::Constants::C_FORMEDITOR); @@ -295,7 +307,11 @@ void FormEditorW::fullInit() * This will initialize our TabOrder, Signals and slots and Buddy editors. */ QList plugins = QPluginLoader::staticInstances(); +#if QT_VERSION >= 0x050000 + plugins += m_formeditor->pluginInstances(); +#else plugins += m_formeditor->pluginManager()->instances(); +#endif foreach (QObject *plugin, plugins) { if (QDesignerFormEditorPluginInterface *formEditorPlugin = qobject_cast(plugin)) { if (!formEditorPlugin->isInitialized()) @@ -535,13 +551,22 @@ void FormEditorW::setupActions() // Commands that do not go into the editor toolbar createSeparator(this, am, m_contexts, mformtools, QLatin1String("FormEditor.Menu.Tools.Separator2")); +#if QT_VERSION >= 0x050000 + m_actionPreview = m_fwm->action(QDesignerFormWindowManagerInterface::DefaultPreviewAction); +#else m_actionPreview = m_fwm->actionDefaultPreview(); +#endif QTC_ASSERT(m_actionPreview, return); addToolAction(m_actionPreview, am, m_contexts, QLatin1String("FormEditor.Preview"), mformtools, tr("Alt+Shift+R")); // Preview in style... +#if QT_VERSION >= 0x050000 + m_actionGroupPreviewInStyle = m_fwm->actionGroup(QDesignerFormWindowManagerInterface::StyledPreviewActionGroup); +#else m_actionGroupPreviewInStyle = m_fwm->actionGroupPreviewInStyle(); +#endif + Core::ActionContainer *previewAC = createPreviewStyleMenu(am, m_actionGroupPreviewInStyle); m_previewInStyleMenu = previewAC->menu(); mformtools->addMenu(previewAC); @@ -562,14 +587,24 @@ void FormEditorW::setupActions() tr("Shift+F4")); createSeparator(this, am, m_contexts, mformtools, QLatin1String("FormEditor.Menu.Tools.Separator4")); +#if QT_VERSION >= 0x050000 + QAction *actionFormSettings = m_fwm->action(QDesignerFormWindowManagerInterface::FormWindowSettingsDialogAction); +#else QAction *actionFormSettings = m_fwm->actionShowFormWindowSettingsDialog(); +#endif addToolAction(actionFormSettings, am, m_contexts, QLatin1String("FormEditor.FormSettings"), mformtools); createSeparator(this, am, m_contexts, mformtools, QLatin1String("FormEditor.Menu.Tools.Separator5")); m_actionAboutPlugins = new QAction(tr("About Qt Designer plugins...."), this); addToolAction(m_actionAboutPlugins, am, m_contexts, QLatin1String("FormEditor.AboutPlugins"), mformtools); - connect(m_actionAboutPlugins, SIGNAL(triggered()), m_fwm, SLOT(aboutPlugins())); + connect(m_actionAboutPlugins, SIGNAL(triggered()), m_fwm, +#if QT_VERSION >= 0x050000 + SLOT(showPluginDialog()) +#else + SLOT(aboutPlugins()) +#endif + ); m_actionAboutPlugins->setEnabled(false); // FWM @@ -706,12 +741,18 @@ EditorData FormEditorW::createEditor(QWidget *parent) // Create and associate form and text editor. EditorData data; m_fwm->closeAllPreviews(); +#if QT_VERSION >= 0x050000 + QDesignerFormWindowInterface *form = m_fwm->createFormWindow(0); +#else qdesigner_internal::FormWindowBase *form = qobject_cast(m_fwm->createFormWindow(0)); +#endif QTC_ASSERT(form, return data); connect(form, SIGNAL(toolChanged(int)), this, SLOT(toolChanged(int))); ResourceHandler *resourceHandler = new ResourceHandler(form); +#if QT_VERSION < 0x050000 form->setDesignerGrid(qdesigner_internal::FormWindowBase::defaultDesignerGrid()); qdesigner_internal::FormWindowBase::setupDefaultAction(form); +#endif data.widgetHost = new SharedTools::WidgetHost( /* parent */ 0, form); DesignerXmlEditor *xmlEditor = new DesignerXmlEditor(form, parent); TextEditor::TextEditorSettings::instance()->initializeEditor(xmlEditor); @@ -815,10 +856,13 @@ void FormEditorW::print() const QPrinter::Orientation oldOrientation = m_core->printer()->orientation (); m_core->printer()->setFullPage(false); do { - // Grab the image to be able to a suggest suitable orientation QString errorMessage; +#if QT_VERSION >= 0x050000 + const QPixmap pixmap = m_fwm->createPreviewPixmap(); +#else const QPixmap pixmap = m_fwm->createPreviewPixmap(&errorMessage); +#endif if (pixmap.isNull()) { critical(tr("The image could not be created: %1").arg(errorMessage)); break; diff --git a/src/plugins/designer/formeditorw.h b/src/plugins/designer/formeditorw.h index 67ba660db48..61c27a2bdb7 100644 --- a/src/plugins/designer/formeditorw.h +++ b/src/plugins/designer/formeditorw.h @@ -55,9 +55,13 @@ class QSignalMapper; class QSettings; class QToolBar; +#if QT_VERSION >= 0x050000 +class QDesignerFormWindowManagerInterface; +#else namespace qdesigner_internal { class QDesignerFormWindowManager; } +#endif QT_END_NAMESPACE @@ -172,7 +176,12 @@ private: QDesignerFormEditorInterface *m_formeditor; QDesignerIntegrationInterface *m_integration; + +#if QT_VERSION >= 0x050000 + QDesignerFormWindowManagerInterface *m_fwm; +#else qdesigner_internal::QDesignerFormWindowManager *m_fwm; +#endif Core::ICore *m_core; InitializationStage m_initStage; diff --git a/src/plugins/designer/formtemplatewizardpage.cpp b/src/plugins/designer/formtemplatewizardpage.cpp index 9d2bdc954b1..9385e0ab1f2 100644 --- a/src/plugins/designer/formtemplatewizardpage.cpp +++ b/src/plugins/designer/formtemplatewizardpage.cpp @@ -34,7 +34,11 @@ #include "formeditorw.h" #include "designerconstants.h" -#include "qt_private/abstractnewformwidget_p.h" +#if QT_VERSION >= 0x050000 +# include +#else +# include "qt_private/abstractnewformwidget_p.h" +#endif #include #include diff --git a/src/plugins/designer/formwindoweditor.cpp b/src/plugins/designer/formwindoweditor.cpp index 4117a3b93e7..516795f27ff 100644 --- a/src/plugins/designer/formwindoweditor.cpp +++ b/src/plugins/designer/formwindoweditor.cpp @@ -34,7 +34,6 @@ #include "formwindowfile.h" #include "designerconstants.h" #include "resourcehandler.h" -#include "qt_private/formwindowbase_p.h" #include "designerxmleditor.h" #include @@ -48,7 +47,12 @@ #include #include -#include +#if QT_VERSION >= 0x050000 +# include +# include +#else +# include "qt_private/formwindowbase_p.h" +#endif #include #include @@ -114,12 +118,17 @@ bool FormWindowEditor::createNew(const QString &contents) QApplication::restoreOverrideCursor(); } +#if QT_VERSION >= 0x050000 + const bool success = form->setContents(contents); +#else form->setContents(contents); + const bool success = form->mainContainer() != 0; +#endif if (hasOverrideCursor) QApplication::setOverrideCursor(overrideCursor); - if (form->mainContainer() == 0) + if (!success) return false; syncXmlEditor(contents); @@ -154,11 +163,17 @@ bool FormWindowEditor::open(QString *errorString, const QString &fileName, const return false; form->setFileName(absfileName); - - const QString contents = QString::fromUtf8(reader.data()); - form->setContents(contents); + QByteArray contents = reader.data(); +#if QT_VERSION >= 0x050000 + QBuffer str(&contents); + str.open(QIODevice::ReadOnly); + if (!form->setContents(&str, errorString)) + return false; +#else + form->setContents(QString::fromUtf8(contents)); if (!form->mainContainer()) return false; +#endif form->setDirty(fileName != realFileName); syncXmlEditor(contents); @@ -249,9 +264,16 @@ QWidget *FormWindowEditor::toolBar() QString FormWindowEditor::contents() const { +#if QT_VERSION >= 0x050000 // TODO: No warnings about spacers here + const QDesignerFormWindowInterface *fw = d->m_file.formWindow(); + QTC_ASSERT(fw, return QString()); + return fw->contents(); +#else + // No warnings about spacers here const qdesigner_internal::FormWindowBase *fw = qobject_cast(d->m_file.formWindow()); QTC_ASSERT(fw, return QString()); - return fw->fileContents(); // No warnings about spacers here + return fw->fileContents(); +#endif } TextEditor::BaseTextDocument *FormWindowEditor::textDocument() diff --git a/src/plugins/designer/formwindowfile.cpp b/src/plugins/designer/formwindowfile.cpp index 9d729c9071a..61b30661fe0 100644 --- a/src/plugins/designer/formwindowfile.cpp +++ b/src/plugins/designer/formwindowfile.cpp @@ -41,7 +41,9 @@ #include #include #include -#include "qt_private/qsimpleresource_p.h" +#if QT_VERSION < 0x050000 +# include "qt_private/qsimpleresource_p.h" +#endif #include #include @@ -83,10 +85,13 @@ bool FormWindowFile::save(QString *errorString, const QString &name, bool autoSa const QString oldFormName = m_formWindow->fileName(); if (!autoSave) m_formWindow->setFileName(fi.absoluteFilePath()); - +#if QT_VERSION >= 0x050000 + const bool writeOK = writeFile(actualName, errorString); +#else const bool warningsEnabled = qdesigner_internal::QSimpleResource::setWarningsEnabled(false); const bool writeOK = writeFile(actualName, errorString); qdesigner_internal::QSimpleResource::setWarningsEnabled(warningsEnabled); +#endif m_shouldAutoSave = false; if (autoSave) return writeOK; diff --git a/src/plugins/designer/qtcreatorintegration.cpp b/src/plugins/designer/qtcreatorintegration.cpp index f69b657290c..0d8eeb24c55 100644 --- a/src/plugins/designer/qtcreatorintegration.cpp +++ b/src/plugins/designer/qtcreatorintegration.cpp @@ -89,12 +89,24 @@ static QString msgClassNotFound(const QString &uiClassName, const QList(parent)), +#if QT_VERSION >= 0x050000 + QDesignerIntegration(core, parent), +#else + qdesigner_internal::QDesignerIntegration(core, parent), +#endif m_few(parent) { +#if QT_VERSION >= 0x050000 + setResourceFileWatcherBehaviour(ReloadResourceFileSilently); + Feature f = features(); + f |= SlotNavigationFeature; + f &= ~ResourceEditorFeature; + setFeatures(f); +#else setResourceFileWatcherBehaviour(QDesignerIntegration::ReloadSilently); setResourceEditingEnabled(false); setSlotNavigationEnabled(true); +#endif connect(this, SIGNAL(navigateToSlot(QString, QString, QStringList)), this, SLOT(slotNavigateToSlot(QString, QString, QStringList))); connect(this, SIGNAL(helpRequested(QString,QString)), @@ -115,7 +127,11 @@ void QtCreatorIntegration::updateSelection() { if (const EditorData ed = m_few->activeEditor()) ed.widgetHost->updateFormWindowSelectionHandles(true); +#if QT_VERSION >= 0x050000 + QDesignerIntegration::updateSelection(); +#else qdesigner_internal::QDesignerIntegration::updateSelection(); +#endif } QWidget *QtCreatorIntegration::containerWindow(QWidget * /*widget*/) const diff --git a/src/plugins/designer/qtcreatorintegration.h b/src/plugins/designer/qtcreatorintegration.h index 1b4d714ceb2..402056216f4 100644 --- a/src/plugins/designer/qtcreatorintegration.h +++ b/src/plugins/designer/qtcreatorintegration.h @@ -35,7 +35,11 @@ #include -#include "qt_private/qdesigner_integration_p.h" +#if QT_VERSION >= 0x050000 +# include +#else +# include "qt_private/qdesigner_integration_p.h" +#endif QT_FORWARD_DECLARE_CLASS(QUrl) @@ -44,7 +48,12 @@ namespace Internal { class FormEditorW; -class QtCreatorIntegration : public qdesigner_internal::QDesignerIntegration { +class QtCreatorIntegration : +#if QT_VERSION >= 0x050000 + public QDesignerIntegration { +#else + public qdesigner_internal::QDesignerIntegration { +#endif Q_OBJECT public: explicit QtCreatorIntegration(QDesignerFormEditorInterface *core, FormEditorW *parent = 0); diff --git a/src/plugins/designer/resourcehandler.cpp b/src/plugins/designer/resourcehandler.cpp index 18a2c057fb6..31ed808332e 100644 --- a/src/plugins/designer/resourcehandler.cpp +++ b/src/plugins/designer/resourcehandler.cpp @@ -39,8 +39,12 @@ #include #include -#include "qt_private/formwindowbase_p.h" -#include "qt_private/qtresourcemodel_p.h" +#if QT_VERSION >= 0x050000 +# include +#else +# include "qt_private/formwindowbase_p.h" +# include "qt_private/qtresourcemodel_p.h" +#endif #include @@ -83,7 +87,11 @@ void QrcFilesVisitor::visitFolderNode(FolderNode *folderNode) } // ------------ ResourceHandler +#if QT_VERSION >= 0x050000 +ResourceHandler::ResourceHandler(QDesignerFormWindowInterface *fw) : +#else ResourceHandler::ResourceHandler(qdesigner_internal::FormWindowBase *fw) : +#endif QObject(fw), m_form(fw), m_sessionNode(0), @@ -106,8 +114,11 @@ void ResourceHandler::ensureInitialized() connect(m_sessionWatcher, SIGNAL(foldersAdded()), this, SLOT(updateResources())); connect(m_sessionWatcher, SIGNAL(foldersRemoved()), this, SLOT(updateResources())); m_sessionNode->registerWatcher(m_sessionWatcher); - +#if QT_VERSION >= 0x050000 + m_originalUiQrcPaths = m_form->activeResourceFilePaths(); +#else m_originalUiQrcPaths = m_form->resourceSet()->activeQrcPaths(); +#endif if (Designer::Constants::Internal::debug) qDebug() << "ResourceHandler::ensureInitialized() origPaths=" << m_originalUiQrcPaths; } @@ -142,16 +153,26 @@ void ResourceHandler::updateResources() QrcFilesVisitor qrcVisitor; root->accept(&qrcVisitor); const QStringList projectQrcFiles = qrcVisitor.qrcFiles(); +#if QT_VERSION >= 0x050000 + m_form->activateResourceFilePaths(projectQrcFiles); + m_form->setResourceFileSaveMode(QDesignerFormWindowInterface::SaveOnlyUsedResourceFiles); +#else m_form->resourceSet()->activateQrcPaths(projectQrcFiles); m_form->setSaveResourcesBehaviour(qdesigner_internal::FormWindowBase::SaveOnlyUsedQrcFiles); +#endif if (Designer::Constants::Internal::debug) qDebug() << "ResourceHandler::updateResources()" << fileName << " associated with project" << project->rootProjectNode()->path() << " using project qrc files" << projectQrcFiles.size(); } else { // Use resource file originally used in form +#if QT_VERSION >= 0x050000 + m_form->activateResourceFilePaths(m_originalUiQrcPaths); + m_form->setResourceFileSaveMode(QDesignerFormWindowInterface::SaveAllResourceFiles); +#else m_form->resourceSet()->activateQrcPaths(m_originalUiQrcPaths); m_form->setSaveResourcesBehaviour(qdesigner_internal::FormWindowBase::SaveAll); +#endif if (Designer::Constants::Internal::debug) qDebug() << "ResourceHandler::updateResources()" << fileName << " not associated with project, using loaded qrc files."; } diff --git a/src/plugins/designer/resourcehandler.h b/src/plugins/designer/resourcehandler.h index 1fdec7e381f..ec3ca72a9ed 100644 --- a/src/plugins/designer/resourcehandler.h +++ b/src/plugins/designer/resourcehandler.h @@ -37,9 +37,13 @@ #include QT_BEGIN_NAMESPACE +#if QT_VERSION >= 0x050000 +class QDesignerFormWindowInterface; +#else namespace qdesigner_internal { class FormWindowBase; } +#endif QT_END_NAMESPACE namespace ProjectExplorer { @@ -64,7 +68,11 @@ class ResourceHandler : public QObject { Q_OBJECT public: - explicit ResourceHandler(qdesigner_internal::FormWindowBase *fw); +#if QT_VERSION >= 0x050000 + explicit ResourceHandler(QDesignerFormWindowInterface *fw); +#else + explicit ResourceHandler(qdesigner_internal::FormWindowBase *fw); +#endif virtual ~ResourceHandler(); public slots: @@ -72,9 +80,11 @@ public slots: private: void ensureInitialized(); - +#if QT_VERSION >= 0x050000 + QDesignerFormWindowInterface * const m_form; +#else qdesigner_internal::FormWindowBase * const m_form; - +#endif QStringList m_originalUiQrcPaths; ProjectExplorer::SessionNode *m_sessionNode; ProjectExplorer::NodesWatcher *m_sessionWatcher; diff --git a/src/plugins/designer/settingsmanager.h b/src/plugins/designer/settingsmanager.h index d0f0cb1d63a..faf8a21e083 100644 --- a/src/plugins/designer/settingsmanager.h +++ b/src/plugins/designer/settingsmanager.h @@ -33,7 +33,11 @@ #ifndef SETTINGSMANAGER_H #define SETTINGSMANAGER_H -#include "qt_private/abstractsettings_p.h" +#if QT_VERSION >= 0x050000 +# include +#else +# include "qt_private/abstractsettings_p.h" +#endif namespace Designer { namespace Internal { diff --git a/src/plugins/designer/settingspage.cpp b/src/plugins/designer/settingspage.cpp index f23251dc4ef..a23a5fb712c 100644 --- a/src/plugins/designer/settingspage.cpp +++ b/src/plugins/designer/settingspage.cpp @@ -35,7 +35,11 @@ #include "formeditorw.h" #include -#include "qt_private/abstractoptionspage_p.h" +#if QT_VERSION >= 0x050000 +# include +#else +# include "qt_private/abstractoptionspage_p.h" +#endif #include #include