Commit 37f9cabf authored by Tobias Hunger's avatar Tobias Hunger

JsonWizard: Make the form page available to the JsonWizard

Change-Id: I86d8a199b1c3ed973b32335d14a9cd7e0d23fdbf
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 869c7770
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "formeditorplugin.h" #include "formeditorplugin.h"
#include "formeditorfactory.h" #include "formeditorfactory.h"
#include "formeditorw.h" #include "formeditorw.h"
#include "formtemplatewizardpage.h"
#include "formwindoweditor.h" #include "formwindoweditor.h"
#include "formwizard.h" #include "formwizard.h"
...@@ -49,6 +50,7 @@ ...@@ -49,6 +50,7 @@
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/designmode.h> #include <coreplugin/designmode.h>
#include <cpptools/cpptoolsconstants.h> #include <cpptools/cpptoolsconstants.h>
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
#include <QApplication> #include <QApplication>
#include <QDebug> #include <QDebug>
...@@ -84,6 +86,7 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error) ...@@ -84,6 +86,7 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
initializeTemplates(); initializeTemplates();
ProjectExplorer::JsonWizardFactory::registerPageFactory(new Internal::FormPageFactory);
addAutoReleasedObject(new FormEditorFactory); addAutoReleasedObject(new FormEditorFactory);
addAutoReleasedObject(new SettingsPageProvider); addAutoReleasedObject(new SettingsPageProvider);
addAutoReleasedObject(new QtDesignerFormClassCodeGenerator); addAutoReleasedObject(new QtDesignerFormClassCodeGenerator);
......
...@@ -31,8 +31,12 @@ ...@@ -31,8 +31,12 @@
#include "formtemplatewizardpage.h" #include "formtemplatewizardpage.h"
#include "formeditorw.h" #include "formeditorw.h"
#include <projectexplorer/jsonwizard/jsonwizardpagefactory.h>
#include <utils/qtcassert.h>
#include <utils/wizard.h> #include <utils/wizard.h>
#include <QCoreApplication>
#include <QDesignerNewFormWidgetInterface> #include <QDesignerNewFormWidgetInterface>
#include <QDebug> #include <QDebug>
#include <QXmlStreamReader> #include <QXmlStreamReader>
...@@ -48,10 +52,39 @@ ...@@ -48,10 +52,39 @@
namespace Designer { namespace Designer {
namespace Internal { namespace Internal {
FormPageFactory::FormPageFactory()
{
setTypeIdsSuffix(QLatin1String("Form"));
}
Utils::WizardPage *FormPageFactory::create(ProjectExplorer::JsonWizard *wizard, Core::Id typeId,
const QVariant &data)
{
Q_UNUSED(wizard);
Q_UNUSED(data);
QTC_ASSERT(canCreate(typeId), return 0);
FormTemplateWizardPage *page = new FormTemplateWizardPage;
return page;
}
bool FormPageFactory::validateData(Core::Id typeId, const QVariant &data, QString *errorMessage)
{
QTC_ASSERT(canCreate(typeId), return false);
if (!data.isNull() && (data.type() != QVariant::Map || !data.toMap().isEmpty())) {
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard",
"\"data\" for a \"Form\" page needs to be unset or an empty object.");
return false;
}
return true;
}
// ----------------- FormTemplateWizardPage // ----------------- FormTemplateWizardPage
FormTemplateWizardPage::FormTemplateWizardPage(QWidget * parent) : FormTemplateWizardPage::FormTemplateWizardPage(QWidget * parent) :
QWizardPage(parent), Utils::WizardPage(parent),
m_newFormWidget(QDesignerNewFormWidgetInterface::createNewFormWidget(FormEditorW::designerEditor())), m_newFormWidget(QDesignerNewFormWidgetInterface::createNewFormWidget(FormEditorW::designerEditor())),
m_templateSelected(m_newFormWidget->hasCurrentTemplate()) m_templateSelected(m_newFormWidget->hasCurrentTemplate())
{ {
...@@ -89,6 +122,7 @@ bool FormTemplateWizardPage::validatePage() ...@@ -89,6 +122,7 @@ bool FormTemplateWizardPage::validatePage()
QMessageBox::critical(this, tr("%1 - Error").arg(title()), errorMessage); QMessageBox::critical(this, tr("%1 - Error").arg(title()), errorMessage);
return false; return false;
} }
wizard()->setProperty("FormContents", m_templateContents.replace(QLatin1Char('\n'), QLatin1String("\\n")));
return true; return true;
} }
......
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
#ifndef FORMTEMPLATEWIZARDPAGE_H #ifndef FORMTEMPLATEWIZARDPAGE_H
#define FORMTEMPLATEWIZARDPAGE_H #define FORMTEMPLATEWIZARDPAGE_H
#include <QWizardPage> #include <projectexplorer/jsonwizard/jsonwizardpagefactory.h>
#include <utils/wizardpage.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QDesignerNewFormWidgetInterface; class QDesignerNewFormWidgetInterface;
...@@ -40,10 +42,22 @@ QT_END_NAMESPACE ...@@ -40,10 +42,22 @@ QT_END_NAMESPACE
namespace Designer { namespace Designer {
namespace Internal { namespace Internal {
class FormPageFactory : public ProjectExplorer::JsonWizardPageFactory
{
public:
FormPageFactory();
Utils::WizardPage *create(ProjectExplorer::JsonWizard *wizard, Core::Id typeId, const QVariant &data);
bool validateData(Core::Id typeId, const QVariant &data, QString *errorMessage);
};
// A wizard page embedding Qt Designer's QDesignerNewFormWidgetInterface // A wizard page embedding Qt Designer's QDesignerNewFormWidgetInterface
// widget. // widget.
class FormTemplateWizardPage : public QWizardPage // Sets FormContents property.
class FormTemplateWizardPage : public Utils::WizardPage
{ {
Q_OBJECT Q_OBJECT
......
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