2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-01-04 11:30:14 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2010-01-04 11:30:14 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-01-04 11:30:14 +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
|
|
|
|
|
** 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.
|
2010-01-04 11:30:14 +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
|
|
|
|
|
** 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
|
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
|
|
|
****************************************************************************/
|
2010-01-04 11:30:14 +01:00
|
|
|
|
2009-09-24 12:54:53 +02:00
|
|
|
#include "qmlfilewizard.h"
|
2012-11-13 11:55:29 +01:00
|
|
|
#include "qmljseditorconstants.h"
|
2009-09-24 12:54:53 +02:00
|
|
|
|
2011-10-05 12:09:14 +02:00
|
|
|
#include <qmljstools/qmljstoolsconstants.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QTextStream>
|
2009-09-24 12:54:53 +02:00
|
|
|
|
2010-01-15 17:20:03 +01:00
|
|
|
using namespace QmlJSEditor;
|
2009-09-24 12:54:53 +02:00
|
|
|
|
2013-09-20 15:12:44 +02:00
|
|
|
QmlFileWizard::QmlFileWizard()
|
2009-09-24 12:54:53 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Core::GeneratedFiles QmlFileWizard::generateFilesFromPath(const QString &path,
|
|
|
|
|
const QString &name,
|
|
|
|
|
QString * /*errorMessage*/) const
|
|
|
|
|
|
|
|
|
|
{
|
2011-10-05 12:09:14 +02:00
|
|
|
const QString mimeType = QLatin1String(QmlJSTools::Constants::QML_MIMETYPE);
|
2009-09-24 12:54:53 +02:00
|
|
|
const QString fileName = Core::BaseFileWizard::buildFileName(path, name, preferredSuffix(mimeType));
|
|
|
|
|
|
|
|
|
|
Core::GeneratedFile file(fileName);
|
|
|
|
|
file.setContents(fileContents(fileName));
|
2010-04-16 15:55:32 +02:00
|
|
|
file.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
2009-09-24 12:54:53 +02:00
|
|
|
return Core::GeneratedFiles() << file;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-15 13:08:08 +01:00
|
|
|
QString QmlFileWizard::fileContents(const QString &) const
|
2009-09-24 12:54:53 +02:00
|
|
|
{
|
|
|
|
|
QString contents;
|
|
|
|
|
QTextStream str(&contents);
|
|
|
|
|
|
2013-09-20 15:12:44 +02:00
|
|
|
if (id() == QLatin1String(Constants::WIZARD_QML1FILE))
|
2012-11-13 11:55:29 +01:00
|
|
|
str << QLatin1String("import QtQuick 1.1\n");
|
|
|
|
|
else
|
|
|
|
|
str << QLatin1String("import QtQuick 2.0\n");
|
|
|
|
|
|
2010-11-11 11:39:57 +01:00
|
|
|
// 100:62 is the 'golden ratio'
|
2012-11-13 11:55:29 +01:00
|
|
|
str << QLatin1String("\n")
|
2009-09-24 12:54:53 +02:00
|
|
|
<< QLatin1String("Rectangle {\n")
|
2010-11-11 11:39:57 +01:00
|
|
|
<< QLatin1String(" width: 100\n")
|
|
|
|
|
<< QLatin1String(" height: 62\n")
|
2009-09-24 12:54:53 +02:00
|
|
|
<< QLatin1String("}\n");
|
|
|
|
|
|
|
|
|
|
return contents;
|
|
|
|
|
}
|