2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-07-06 11:58:06 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
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
|
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.
|
2011-07-06 11:58:06 +02: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.
|
2011-07-06 11:58:06 +02:00
|
|
|
**
|
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"
|
2018-02-06 15:59:05 +01:00
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
#include <texteditor/simplecodestylepreferences.h>
|
2018-02-06 15:59:05 +01:00
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
#include <qmljseditor/qmljseditorconstants.h>
|
2018-02-06 15:59:05 +01:00
|
|
|
|
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";
|
|
|
|
|
|
2018-11-24 10:22:37 +01:00
|
|
|
QmlJSCodeStylePreferencesFactory::QmlJSCodeStylePreferencesFactory() = default;
|
2011-05-25 08:50:01 +02:00
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
Utils::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
|
|
|
|
|
{
|
2018-11-24 10:22:37 +01:00
|
|
|
auto widget = new Internal::QmlJSCodeStylePreferencesWidget(parent);
|
2019-08-29 10:36:01 +02:00
|
|
|
widget->layout()->setContentsMargins(0, 0, 0, 0);
|
2011-08-16 10:45:23 +02:00
|
|
|
widget->setPreferences(preferences);
|
2011-05-25 08:50:01 +02:00
|
|
|
return widget;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-16 09:37:54 +01:00
|
|
|
TextEditor::Indenter *QmlJSCodeStylePreferencesFactory::createIndenter(QTextDocument *doc) const
|
2011-08-05 09:59:28 +02:00
|
|
|
{
|
2019-01-16 09:37:54 +01:00
|
|
|
return new QmlJSEditor::Internal::Indenter(doc);
|
2011-08-05 09:59:28 +02:00
|
|
|
}
|
|
|
|
|
|
2018-02-06 15:59:05 +01:00
|
|
|
QString QmlJSCodeStylePreferencesFactory::snippetProviderGroupId() const
|
2011-08-16 10:45:23 +02:00
|
|
|
{
|
2018-02-07 09:49:03 +01:00
|
|
|
return QString(QmlJSEditor::Constants::QML_SNIPPETS_GROUP_ID);
|
2011-08-16 10:45:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QmlJSCodeStylePreferencesFactory::previewText() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String(defaultPreviewText);
|
|
|
|
|
}
|
|
|
|
|
|