Commit b0d093b0 authored by Friedemann Kleint's avatar Friedemann Kleint Committed by Kai Koehne

Designer: Compilation with Qt 5.

Test the new Qt Designer integration interfaces.

Change-Id: I8364167d5be3e7c361b192318b0bba7fb70d0f2f
Reviewed-on: http://codereview.qt.nokia.com/9Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent 0d3d38ec
......@@ -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 \
......
......@@ -35,7 +35,12 @@
#include "formeditorw.h"
#include <QtDesigner/QDesignerFormEditorInterface>
#include "qt_private/qdesigner_integration_p.h"
#if QT_VERSION >= 0x050000
# include <QtDesigner/QDesignerIntegration>
#else
# include "qt_private/qdesigner_integration_p.h"
#endif
#include <QtGui/QWidget>
#include <QtCore/QDebug>
......@@ -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<const qdesigner_internal::QDesignerIntegration*>(core->integration()))
helpId = integration->contextHelpId();
if (debug)
qDebug() << "DesignerContext::contextHelpId" << m_widget << helpId;
return helpId;
#endif
}
} // namespace Internal
......
......@@ -63,14 +63,18 @@
#include <utils/qtcassert.h>
#include <QtDesigner/QDesignerFormEditorPluginInterface>
#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 <QtDesigner/QDesignerFormEditorInterface>
#include <QtDesigner/QDesignerComponents>
#if QT_VERSION >= 0x050000
# include <QtDesigner/QDesignerFormWindowManagerInterface>
#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 <QtDesigner/QDesignerWidgetBoxInterface>
#include <QtDesigner/abstractobjectinspector.h>
#include <QtDesigner/QDesignerPropertyEditorInterface>
......@@ -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<QWidget *>(m_core->editorManager()));
m_formeditor->setSettingsManager(new SettingsManager());
#if QT_VERSION >= 0x050000
m_fwm = m_formeditor->formWindowManager();
#else
m_fwm = qobject_cast<qdesigner_internal::QDesignerFormWindowManager*>(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<QObject*> 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<QDesignerFormEditorPluginInterface*>(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<qdesigner_internal::FormWindowBase *>(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;
......
......@@ -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;
......
......@@ -34,7 +34,11 @@
#include "formeditorw.h"
#include "designerconstants.h"
#include "qt_private/abstractnewformwidget_p.h"
#if QT_VERSION >= 0x050000
# include <QtDesigner/QDesignerNewFormWidgetInterface>
#else
# include "qt_private/abstractnewformwidget_p.h"
#endif
#include <QtCore/QDebug>
#include <QtCore/QXmlStreamReader>
......
......@@ -34,7 +34,6 @@
#include "formwindowfile.h"
#include "designerconstants.h"
#include "resourcehandler.h"
#include "qt_private/formwindowbase_p.h"
#include "designerxmleditor.h"
#include <widgethost.h>
......@@ -48,7 +47,12 @@
#include <utils/qtcassert.h>
#include <utils/fileutils.h>
#include <QtDesigner/QDesignerFormWindowInterface>
#if QT_VERSION >= 0x050000
# include <QtDesigner/QDesignerFormWindowInterface>
# include <QtCore/QBuffer>
#else
# include "qt_private/formwindowbase_p.h"
#endif
#include <QtCore/QDebug>
#include <QtCore/QFileInfo>
......@@ -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<const qdesigner_internal::FormWindowBase *>(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()
......
......@@ -41,7 +41,9 @@
#include <QtDesigner/QDesignerFormWindowInterface>
#include <QtDesigner/QDesignerFormWindowManagerInterface>
#include <QtDesigner/QDesignerFormEditorInterface>
#include "qt_private/qsimpleresource_p.h"
#if QT_VERSION < 0x050000
# include "qt_private/qsimpleresource_p.h"
#endif
#include <QtGui/QMessageBox>
#include <QtGui/QMainWindow>
......@@ -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;
......
......@@ -89,12 +89,24 @@ static QString msgClassNotFound(const QString &uiClassName, const QList<Document
}
QtCreatorIntegration::QtCreatorIntegration(QDesignerFormEditorInterface *core, FormEditorW *parent) :
qdesigner_internal::QDesignerIntegration(core, ::qobject_cast<QObject*>(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
......
......@@ -35,7 +35,11 @@
#include <cplusplus/ModelManagerInterface.h>
#include "qt_private/qdesigner_integration_p.h"
#if QT_VERSION >= 0x050000
# include <QtDesigner/QDesignerIntegration>
#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);
......
......@@ -39,8 +39,12 @@
#include <projectexplorer/project.h>
#include <projectexplorer/session.h>
#include "qt_private/formwindowbase_p.h"
#include "qt_private/qtresourcemodel_p.h"
#if QT_VERSION >= 0x050000
# include <QtDesigner/QDesignerFormWindowInterface>
#else
# include "qt_private/formwindowbase_p.h"
# include "qt_private/qtresourcemodel_p.h"
#endif
#include <utils/qtcassert.h>
......@@ -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.";
}
......
......@@ -37,9 +37,13 @@
#include <QtCore/QStringList>
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;
......
......@@ -33,7 +33,11 @@
#ifndef SETTINGSMANAGER_H
#define SETTINGSMANAGER_H
#include "qt_private/abstractsettings_p.h"
#if QT_VERSION >= 0x050000
# include <QtDesigner/QDesignerSettingsInterface>
#else
# include "qt_private/abstractsettings_p.h"
#endif
namespace Designer {
namespace Internal {
......
......@@ -35,7 +35,11 @@
#include "formeditorw.h"
#include <extensionsystem/pluginmanager.h>
#include "qt_private/abstractoptionspage_p.h"
#if QT_VERSION >= 0x050000
# include <QtDesigner/QDesignerOptionsPageInterface>
#else
# include "qt_private/abstractoptionspage_p.h"
#endif
#include <QtCore/QCoreApplication>
#include <QtGui/QIcon>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment