2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** Contact: Qt Software Information (qt-info@nokia.com)
|
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
|
** contact the sales department at qt-sales@nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "formeditorplugin.h"
|
|
|
|
|
#include "formeditorfactory.h"
|
|
|
|
|
#include "formeditorw.h"
|
|
|
|
|
#include "formwizard.h"
|
|
|
|
|
|
|
|
|
|
#ifdef CPP_ENABLED
|
|
|
|
|
# include "formclasswizard.h"
|
|
|
|
|
# include <cppeditor/cppeditorconstants.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "designerconstants.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/mimedatabase.h>
|
|
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/uniqueidmanager.h>
|
|
|
|
|
|
2009-01-19 12:39:20 +01:00
|
|
|
#include <QtCore/QtPlugin>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
|
|
|
|
|
#ifdef CPP_ENABLED
|
|
|
|
|
# include <QtGui/QAction>
|
|
|
|
|
# include <QtGui/QWizard>
|
|
|
|
|
# include <QtGui/QMainWindow>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
using namespace Designer::Internal;
|
|
|
|
|
using namespace Designer::Constants;
|
|
|
|
|
|
|
|
|
|
FormEditorPlugin::FormEditorPlugin() :
|
|
|
|
|
m_factory(0),
|
|
|
|
|
m_formWizard(0),
|
|
|
|
|
m_formClassWizard(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FormEditorPlugin::~FormEditorPlugin()
|
|
|
|
|
{
|
|
|
|
|
if (m_factory)
|
|
|
|
|
removeObject(m_factory);
|
|
|
|
|
if (m_formWizard)
|
|
|
|
|
removeObject(m_formWizard);
|
|
|
|
|
if (m_formClassWizard)
|
|
|
|
|
removeObject(m_formClassWizard);
|
|
|
|
|
delete m_factory;
|
|
|
|
|
delete m_formWizard;
|
|
|
|
|
delete m_formClassWizard;
|
|
|
|
|
FormEditorW::deleteInstance();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// INHERITED FROM ExtensionSystem::Plugin
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////
|
2009-01-20 11:52:04 +01:00
|
|
|
bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-01-20 11:52:04 +01:00
|
|
|
Q_UNUSED(arguments);
|
|
|
|
|
Q_UNUSED(error);
|
|
|
|
|
|
|
|
|
|
Core::ICore *core = Core::ICore::instance();
|
|
|
|
|
if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/formeditor/Designer.mimetypes.xml"), error))
|
2008-12-02 12:01:29 +01:00
|
|
|
return false;
|
|
|
|
|
|
2009-01-20 11:52:04 +01:00
|
|
|
if (!initializeTemplates(error))
|
2008-12-02 12:01:29 +01:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
const int uid = core->uniqueIDManager()->uniqueIdentifier(QLatin1String(C_FORMEDITOR));
|
|
|
|
|
const QList<int> context = QList<int>() << uid;
|
|
|
|
|
|
2009-01-20 17:14:00 +01:00
|
|
|
m_factory = new FormEditorFactory;
|
2008-12-02 12:01:29 +01:00
|
|
|
addObject(m_factory);
|
|
|
|
|
|
2009-03-24 16:49:36 +01:00
|
|
|
FormEditorW::ensureInitStage(FormEditorW::RegisterPlugins);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-20 11:52:04 +01:00
|
|
|
error->clear();
|
2008-12-02 12:01:29 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FormEditorPlugin::extensionsInitialized()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// PRIVATE methods
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
|
2009-01-20 11:52:04 +01:00
|
|
|
bool FormEditorPlugin::initializeTemplates(QString *error)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-01-20 11:52:04 +01:00
|
|
|
Q_UNUSED(error);
|
2008-12-02 12:01:29 +01:00
|
|
|
FormWizard::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard);
|
|
|
|
|
wizardParameters.setCategory(QLatin1String("Qt"));
|
|
|
|
|
wizardParameters.setTrCategory(tr("Qt"));
|
|
|
|
|
const QString formFileType = QLatin1String(Constants::FORM_FILE_TYPE);
|
|
|
|
|
wizardParameters.setName(tr("Qt Designer Form"));
|
|
|
|
|
wizardParameters.setDescription(tr("This creates a new Qt Designer form file."));
|
2009-01-20 15:31:33 +01:00
|
|
|
m_formWizard = new FormWizard(wizardParameters, this);
|
2008-12-02 12:01:29 +01:00
|
|
|
addObject(m_formWizard);
|
|
|
|
|
|
|
|
|
|
#ifdef CPP_ENABLED
|
|
|
|
|
wizardParameters.setKind(Core::IWizard::ClassWizard);
|
|
|
|
|
wizardParameters.setName(tr("Qt Designer Form Class"));
|
|
|
|
|
wizardParameters.setDescription(tr("This creates a new Qt Designer form class."));
|
2009-01-20 15:31:33 +01:00
|
|
|
m_formClassWizard = new FormClassWizard(wizardParameters, this);
|
2008-12-02 12:01:29 +01:00
|
|
|
addObject(m_formClassWizard);
|
|
|
|
|
#endif
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_EXPORT_PLUGIN(FormEditorPlugin)
|