2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2011-07-06 11:58:06 +02:00
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
#include "qmljscodestylepreferencesfactory.h"
|
2022-04-07 21:56:10 +02:00
|
|
|
|
|
|
|
|
#include "qmljscodestylepreferences.h"
|
2011-05-25 08:50:01 +02:00
|
|
|
#include "qmljscodestylesettingspage.h"
|
2011-08-05 09:59:28 +02:00
|
|
|
#include "qmljsindenter.h"
|
2022-04-07 21:56:10 +02:00
|
|
|
#include "qmljstoolsconstants.h"
|
2023-01-13 11:03:09 +01:00
|
|
|
#include "qmljstoolstr.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
|
|
|
|
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()
|
|
|
|
|
{
|
2023-01-13 11:03:09 +01:00
|
|
|
return Tr::tr("Qt Quick");
|
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
|
|
|
{
|
2022-04-02 12:15:26 +02:00
|
|
|
return new QmlJSCodeStylePreferences();
|
2011-05-25 08:50:01 +02:00
|
|
|
}
|
|
|
|
|
|
2022-03-29 15:48:15 +02:00
|
|
|
TextEditor::CodeStyleEditorWidget *QmlJSCodeStylePreferencesFactory::createEditor(
|
|
|
|
|
TextEditor::ICodeStylePreferences *preferences,
|
2022-03-17 12:01:17 +01:00
|
|
|
ProjectExplorer::Project *project,
|
2022-03-29 15:48:15 +02:00
|
|
|
QWidget *parent) const
|
2011-05-25 08:50:01 +02:00
|
|
|
{
|
2022-03-17 12:01:17 +01:00
|
|
|
Q_UNUSED(project)
|
2022-04-02 12:15:26 +02:00
|
|
|
auto qmlJSPreferences = qobject_cast<QmlJSCodeStylePreferences *>(preferences);
|
|
|
|
|
if (!qmlJSPreferences)
|
|
|
|
|
return nullptr;
|
2022-08-16 17:16:47 +02:00
|
|
|
auto widget = new Internal::QmlJSCodeStylePreferencesWidget(this, parent);
|
2022-04-02 12:15:26 +02:00
|
|
|
widget->setPreferences(qmlJSPreferences);
|
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
|
|
|
{
|
2023-12-21 16:47:22 +01:00
|
|
|
return QmlJSEditor::createQmlJsIndenter(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);
|
|
|
|
|
}
|
|
|
|
|
|