2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2014-05-02 17:38:42 +02:00
|
|
|
#ifndef IWIZARDFACTORY_H
|
|
|
|
|
#define IWIZARDFACTORY_H
|
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; }
|
2014-05-30 13:21:48 +02:00
|
|
|
WizardKind kind() const { return m_kind; }
|
|
|
|
|
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; }
|
|
|
|
|
FeatureSet requiredFeatures() const { return m_requiredFeatures; }
|
|
|
|
|
WizardFlags flags() const { return m_flags; }
|
|
|
|
|
|
2015-05-18 17:45:04 +02:00
|
|
|
void setId(const Id id) { m_id = id; }
|
2014-05-30 13:21:48 +02:00
|
|
|
void setWizardKind(WizardKind kind) { m_kind = kind; }
|
|
|
|
|
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; }
|
|
|
|
|
void setRequiredFeatures(const FeatureSet &featureSet) { m_requiredFeatures = featureSet; }
|
|
|
|
|
void addRequiredFeature(const Feature &feature) { m_requiredFeatures |= feature; }
|
|
|
|
|
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-05-29 16:17:51 +02:00
|
|
|
virtual Utils::Wizard *runWizard(const QString &path, QWidget *parent, const QString &platform,
|
|
|
|
|
const QVariantMap &variables);
|
2009-05-11 13:34:58 +02:00
|
|
|
|
2015-05-27 15:44:11 +02:00
|
|
|
virtual bool isAvailable(const QString &platformName) const;
|
2012-02-08 17:25:35 +01:00
|
|
|
QStringList 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();
|
2009-05-11 13:34:58 +02:00
|
|
|
// Utility to find all registered wizards of a certain kind
|
2014-05-02 17:38:42 +02:00
|
|
|
static QList<IWizardFactory*> wizardFactoriesOfKind(WizardKind kind);
|
2012-02-08 17:25:35 +01:00
|
|
|
static QStringList allAvailablePlatforms();
|
|
|
|
|
static QString displayNameForPlatform(const QString &string);
|
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:
|
2014-11-16 10:52:41 +02:00
|
|
|
FeatureSet pluginFeatures() const;
|
2015-05-27 15:29:27 +02:00
|
|
|
FeatureSet availableFeatures(const QString &platformName) const;
|
2014-08-27 13:03:32 +02:00
|
|
|
|
2015-05-29 16:17:51 +02:00
|
|
|
virtual Utils::Wizard *runWizardImpl(const QString &path, QWidget *parent, const QString &platform,
|
|
|
|
|
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-09-22 15:08:35 +02:00
|
|
|
Id m_id;
|
|
|
|
|
FeatureSet m_requiredFeatures;
|
2015-09-23 20:34:04 +03:00
|
|
|
WizardKind m_kind = FileWizard;
|
2015-09-22 15:08:35 +02:00
|
|
|
WizardFlags m_flags = 0;
|
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)
|
2010-01-14 14:14:39 +01:00
|
|
|
|
2014-05-02 17:38:42 +02:00
|
|
|
#endif // IWIZARDFACTORY_H
|