2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-07-06 11:58:06 +02: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
|
2011-07-06 11:58:06 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-07-06 11:58:06 +02: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.
|
2011-07-06 11:58:06 +02: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
|
2011-07-06 11:58:06 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-07-06 11:58:06 +02:00
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
#include "qmljscodestylepreferencesfactory.h"
|
2011-05-25 08:50:01 +02:00
|
|
|
#include "qmljscodestylesettingspage.h"
|
|
|
|
|
#include "qmljstoolsconstants.h"
|
2011-08-05 09:59:28 +02:00
|
|
|
#include "qmljsindenter.h"
|
2011-08-16 10:45:23 +02:00
|
|
|
#include <texteditor/simplecodestylepreferences.h>
|
|
|
|
|
#include <texteditor/snippets/isnippetprovider.h>
|
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
#include <qmljseditor/qmljseditorconstants.h>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QLayout>
|
2011-05-25 08:50:01 +02:00
|
|
|
|
|
|
|
|
using namespace QmlJSTools;
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
static const char *defaultPreviewText =
|
|
|
|
|
"import QtQuick 1.0\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"Rectangle {\n"
|
|
|
|
|
" width: 360\n"
|
|
|
|
|
" height: 360\n"
|
|
|
|
|
" Text {\n"
|
|
|
|
|
" anchors.centerIn: parent\n"
|
|
|
|
|
" text: \"Hello World\"\n"
|
|
|
|
|
" }\n"
|
|
|
|
|
" MouseArea {\n"
|
|
|
|
|
" anchors.fill: parent\n"
|
|
|
|
|
" onClicked: {\n"
|
|
|
|
|
" Qt.quit();\n"
|
|
|
|
|
" }\n"
|
|
|
|
|
" }\n"
|
|
|
|
|
"}\n";
|
|
|
|
|
|
2011-05-25 08:50:01 +02:00
|
|
|
QmlJSCodeStylePreferencesFactory::QmlJSCodeStylePreferencesFactory()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-21 21:47:17 +02:00
|
|
|
Core::Id QmlJSCodeStylePreferencesFactory::languageId()
|
2011-05-25 08:50:01 +02:00
|
|
|
{
|
|
|
|
|
return Constants::QML_JS_SETTINGS_ID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QmlJSCodeStylePreferencesFactory::displayName()
|
|
|
|
|
{
|
2012-11-21 21:47:17 +02:00
|
|
|
return QLatin1String(Constants::QML_JS_SETTINGS_NAME);
|
2011-05-25 08:50:01 +02:00
|
|
|
}
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
TextEditor::ICodeStylePreferences *QmlJSCodeStylePreferencesFactory::createCodeStyle() const
|
2011-05-25 08:50:01 +02:00
|
|
|
{
|
2011-08-16 10:45:23 +02:00
|
|
|
return new TextEditor::SimpleCodeStylePreferences();
|
2011-05-25 08:50:01 +02:00
|
|
|
}
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
QWidget *QmlJSCodeStylePreferencesFactory::createEditor(TextEditor::ICodeStylePreferences *preferences,
|
2011-05-25 08:50:01 +02:00
|
|
|
QWidget *parent) const
|
|
|
|
|
{
|
|
|
|
|
Internal::QmlJSCodeStylePreferencesWidget *widget = new Internal::QmlJSCodeStylePreferencesWidget(parent);
|
|
|
|
|
widget->layout()->setMargin(0);
|
2011-08-16 10:45:23 +02:00
|
|
|
widget->setPreferences(preferences);
|
2011-05-25 08:50:01 +02:00
|
|
|
return widget;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-05 09:59:28 +02:00
|
|
|
TextEditor::Indenter *QmlJSCodeStylePreferencesFactory::createIndenter() const
|
|
|
|
|
{
|
|
|
|
|
return new QmlJSEditor::Internal::Indenter();
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
TextEditor::ISnippetProvider *QmlJSCodeStylePreferencesFactory::snippetProvider() const
|
|
|
|
|
{
|
|
|
|
|
const QList<TextEditor::ISnippetProvider *> &providers =
|
2012-06-18 11:34:15 +02:00
|
|
|
ExtensionSystem::PluginManager::getObjects<TextEditor::ISnippetProvider>();
|
2011-08-16 10:45:23 +02:00
|
|
|
foreach (TextEditor::ISnippetProvider *provider, providers)
|
|
|
|
|
if (provider->groupId() == QLatin1String(QmlJSEditor::Constants::QML_SNIPPETS_GROUP_ID))
|
|
|
|
|
return provider;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QmlJSCodeStylePreferencesFactory::previewText() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String(defaultPreviewText);
|
|
|
|
|
}
|
|
|
|
|
|