2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/core_global.h>
|
2013-09-20 15:12:44 +02:00
|
|
|
#include <coreplugin/featureprovider.h>
|
2012-01-18 13:50:14 +01:00
|
|
|
|
2013-09-20 15:12:44 +02:00
|
|
|
#include <QIcon>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QObject>
|
2014-08-27 13:03:32 +02:00
|
|
|
#include <QString>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-05-22 17:16:36 +02:00
|
|
|
#include <functional>
|
|
|
|
|
|
2015-05-19 15:09:51 +02:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QAction)
|
|
|
|
|
|
2015-05-29 16:17:51 +02:00
|
|
|
namespace Utils { class Wizard; }
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace Core {
|
|
|
|
|
|
2014-07-29 16:39:03 +02:00
|
|
|
namespace Internal { class CorePlugin; }
|
|
|
|
|
|
2014-05-02 17:38:42 +02:00
|
|
|
class CORE_EXPORT IWizardFactory
|
2008-12-02 12:01:29 +01:00
|
|
|
: public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2010-01-14 14:14:39 +01:00
|
|
|
enum WizardKind {
|
|
|
|
|
FileWizard = 0x01,
|
2015-05-19 11:44:04 +02:00
|
|
|
ProjectWizard = 0x02
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
2012-02-08 17:25:35 +01:00
|
|
|
enum WizardFlag {
|
2012-03-19 16:12:51 +01:00
|
|
|
PlatformIndependent = 0x01,
|
|
|
|
|
ForceCapitalLetterForFileName = 0x02
|
2012-02-08 17:25:35 +01:00
|
|
|
};
|
|
|
|
|
Q_DECLARE_FLAGS(WizardFlags, WizardFlag)
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-05-18 17:45:04 +02:00
|
|
|
Id id() const { return m_id; }
|
2015-12-11 13:48:50 +01:00
|
|
|
WizardKind kind() const { return m_supportedProjectTypes.isEmpty() ? FileWizard : ProjectWizard; }
|
2014-05-30 13:21:48 +02:00
|
|
|
QIcon icon() const { return m_icon; }
|
|
|
|
|
QString description() const { return m_description; }
|
|
|
|
|
QString displayName() const { return m_displayName; }
|
|
|
|
|
QString category() const { return m_category; }
|
|
|
|
|
QString displayCategory() const { return m_displayCategory; }
|
|
|
|
|
QString descriptionImage() const { return m_descriptionImage; }
|
2015-11-27 11:31:35 +01:00
|
|
|
QSet<Id> requiredFeatures() const { return m_requiredFeatures; }
|
2014-05-30 13:21:48 +02:00
|
|
|
WizardFlags flags() const { return m_flags; }
|
2015-12-11 13:48:50 +01:00
|
|
|
QSet<Id> supportedProjectTypes() const { return m_supportedProjectTypes; }
|
2014-05-30 13:21:48 +02:00
|
|
|
|
2015-05-18 17:45:04 +02:00
|
|
|
void setId(const Id id) { m_id = id; }
|
2015-12-11 13:48:50 +01:00
|
|
|
void setSupportedProjectTypes(const QSet<Id> &projectTypes) { m_supportedProjectTypes = projectTypes; }
|
2014-05-30 13:21:48 +02:00
|
|
|
void setIcon(const QIcon &icon) { m_icon = icon; }
|
|
|
|
|
void setDescription(const QString &description) { m_description = description; }
|
|
|
|
|
void setDisplayName(const QString &displayName) { m_displayName = displayName; }
|
|
|
|
|
void setCategory(const QString &category) { m_category = category; }
|
|
|
|
|
void setDisplayCategory(const QString &displayCategory) { m_displayCategory = displayCategory; }
|
|
|
|
|
void setDescriptionImage(const QString &descriptionImage) { m_descriptionImage = descriptionImage; }
|
2015-11-27 11:31:35 +01:00
|
|
|
void setRequiredFeatures(const QSet<Id> &featureSet) { m_requiredFeatures = featureSet; }
|
|
|
|
|
void addRequiredFeature(const Id &feature) { m_requiredFeatures |= feature; }
|
2014-05-30 13:21:48 +02:00
|
|
|
void setFlags(WizardFlags flags) { m_flags = flags; }
|
2012-01-18 13:50:14 +01:00
|
|
|
|
2015-05-19 15:09:51 +02:00
|
|
|
QString runPath(const QString &defaultPath);
|
|
|
|
|
|
2015-05-29 15:55:49 +02:00
|
|
|
// Does bookkeeping and the calls runWizardImpl. Please implement that.
|
2015-11-27 12:07:56 +01:00
|
|
|
virtual Utils::Wizard *runWizard(const QString &path, QWidget *parent, Id platform,
|
2015-05-29 16:17:51 +02:00
|
|
|
const QVariantMap &variables);
|
2009-05-11 13:34:58 +02:00
|
|
|
|
2015-11-27 12:07:56 +01:00
|
|
|
virtual bool isAvailable(Id platformId) const;
|
|
|
|
|
QSet<Id> supportedPlatforms() const;
|
2012-01-18 13:50:14 +01:00
|
|
|
|
2015-05-22 17:16:36 +02:00
|
|
|
typedef std::function<QList<IWizardFactory *>()> FactoryCreator;
|
|
|
|
|
static void registerFactoryCreator(const FactoryCreator &creator);
|
|
|
|
|
|
2009-05-11 13:34:58 +02:00
|
|
|
// Utility to find all registered wizards
|
2014-05-02 17:38:42 +02:00
|
|
|
static QList<IWizardFactory*> allWizardFactories();
|
2015-11-27 12:07:56 +01:00
|
|
|
static QSet<Id> allAvailablePlatforms();
|
|
|
|
|
static QString displayNameForPlatform(Id i);
|
2013-09-20 15:12:44 +02:00
|
|
|
|
2014-07-29 16:39:03 +02:00
|
|
|
static void registerFeatureProvider(IFeatureProvider *provider);
|
|
|
|
|
|
2015-05-29 15:55:49 +02:00
|
|
|
static bool isWizardRunning();
|
|
|
|
|
|
2015-09-23 15:22:02 +02:00
|
|
|
static void requestNewItemDialog(const QString &title,
|
|
|
|
|
const QList<IWizardFactory *> &factories,
|
|
|
|
|
const QString &defaultLocation,
|
|
|
|
|
const QVariantMap &extraVariables);
|
|
|
|
|
|
2014-08-27 13:03:32 +02:00
|
|
|
protected:
|
2015-11-27 11:31:35 +01:00
|
|
|
QSet<Id> pluginFeatures() const;
|
2015-11-27 12:07:56 +01:00
|
|
|
QSet<Id> availableFeatures(Id platformId) const;
|
2014-08-27 13:03:32 +02:00
|
|
|
|
2015-11-27 12:07:56 +01:00
|
|
|
virtual Utils::Wizard *runWizardImpl(const QString &path, QWidget *parent, Id platform,
|
2015-05-29 16:17:51 +02:00
|
|
|
const QVariantMap &variables) = 0;
|
2015-05-29 15:55:49 +02:00
|
|
|
|
2013-09-20 15:12:44 +02:00
|
|
|
private:
|
2015-05-22 17:16:36 +02:00
|
|
|
static void initialize();
|
2014-07-29 16:39:03 +02:00
|
|
|
static void destroyFeatureProvider();
|
|
|
|
|
|
2015-05-19 15:09:51 +02:00
|
|
|
static void clearWizardFactories();
|
|
|
|
|
|
|
|
|
|
QAction *m_action = 0;
|
2014-05-30 13:21:48 +02:00
|
|
|
QIcon m_icon;
|
|
|
|
|
QString m_description;
|
|
|
|
|
QString m_displayName;
|
|
|
|
|
QString m_category;
|
|
|
|
|
QString m_displayCategory;
|
|
|
|
|
QString m_descriptionImage;
|
2015-11-27 11:31:35 +01:00
|
|
|
QSet<Id> m_requiredFeatures;
|
2015-12-11 13:48:50 +01:00
|
|
|
QSet<Id> m_supportedProjectTypes;
|
2015-09-22 15:08:35 +02:00
|
|
|
WizardFlags m_flags = 0;
|
2015-12-11 13:48:50 +01:00
|
|
|
Id m_id;
|
2014-07-29 16:39:03 +02:00
|
|
|
|
|
|
|
|
friend class Internal::CorePlugin;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
} // namespace Core
|
|
|
|
|
|
2014-05-02 17:38:42 +02:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IWizardFactory::WizardFlags)
|