qmlprojectplugin.cpp 4.25 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** 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
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15 16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22 23 24 25
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
29 30 31

#include "qmlprojectplugin.h"
#include "qmlprojectmanager.h"
32
#include "qmlproject.h"
Kai Koehne's avatar
Kai Koehne committed
33 34
#include "qmlprojectrunconfigurationfactory.h"
#include "qmlprojectruncontrol.h"
35
#include "qmlapplicationwizard.h"
36
#include "fileformat/qmlprojectfileformat.h"
37

38
#include <coreplugin/fileiconprovider.h>
39 40 41
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>

42 43
#include <qtsupport/qtsupportconstants.h>

44
#include <QtPlugin>
45

46 47 48
#include <QApplication>
#include <QMessageBox>
#include <QPushButton>
49

Kai Koehne's avatar
Kai Koehne committed
50
namespace QmlProjectManager {
51

52
QmlProjectPlugin::QmlProjectPlugin()
53 54 55 56 57 58 59 60 61 62
{ }

QmlProjectPlugin::~QmlProjectPlugin()
{
}

bool QmlProjectPlugin::initialize(const QStringList &, QString *errorMessage)
{
    using namespace Core;

hjk's avatar
hjk committed
63
    Core::MimeDatabase *mimeDB = Core::ICore::mimeDatabase();
64

Orgad Shaneh's avatar
Orgad Shaneh committed
65
    const QLatin1String mimetypesXml(":/qmlproject/QmlProjectManager.mimetypes.xml");
66 67 68 69

    if (! mimeDB->addMimeTypes(mimetypesXml, errorMessage))
        return false;

70
    Internal::Manager *manager = new Internal::Manager;
71 72

    addAutoReleasedObject(manager);
Kai Koehne's avatar
Kai Koehne committed
73
    addAutoReleasedObject(new Internal::QmlProjectRunConfigurationFactory);
74
    addAutoReleasedObject(new Internal::QmlProjectRunControlFactory);
75

76 77

    Internal::QmlApplicationWizard::createInstances(this);
78 79 80

    QmlProjectFileFormat::registerDeclarativeTypes();

81
    Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance();
82 83
    iconProvider->registerIconOverlayForSuffix(QIcon(QLatin1String(":/qmlproject/images/qmlproject.png")),
                                               QLatin1String("qmlproject"));
84 85 86 87
    return true;
}

void QmlProjectPlugin::extensionsInitialized()
88 89
{
}
90

91 92 93
void QmlProjectPlugin::showQmlObserverToolWarning()
{
    QMessageBox dialog(QApplication::activeWindow());
94
    QPushButton *qtPref = dialog.addButton(tr("Open Qt Versions"),
95
                                           QMessageBox::ActionRole);
96
    dialog.addButton(QMessageBox::Cancel);
97 98
    dialog.setDefaultButton(qtPref);
    dialog.setWindowTitle(tr("QML Observer Missing"));
99
    dialog.setText(tr("QML Observer could not be found for this Qt version."));
100 101
    dialog.setInformativeText(tr(
                                  "QML Observer is used to offer debugging features for "
102 103 104 105
                                  "Qt Quick UI projects in the Qt 4.7 series.\n\n"
                                  "To compile QML Observer, go to the Qt Versions page, "
                                  "select the current Qt version, "
                                  "and click Build in the Helpers section."));
106 107
    dialog.exec();
    if (dialog.clickedButton() == qtPref) {
hjk's avatar
hjk committed
108
        Core::ICore::showOptionsDialog(
hjk's avatar
hjk committed
109 110
                    ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY,
                    QtSupport::Constants::QTVERSION_SETTINGS_PAGE_ID);
111 112 113
    }
}

Kai Koehne's avatar
Kai Koehne committed
114 115
} // namespace QmlProjectManager

116
Q_EXPORT_PLUGIN(QmlProjectManager::QmlProjectPlugin)