forked from qt-creator/qt-creator
"Qml JS Code Style" is wrong (consistent would probably be "QML/JS Code Style"), and since this is already with "Qt Quick > Code Style" with another group box titled "Tabs and Indentation", it is also weird (the other group box is also about the QML/JS code style). Change-Id: I61d5f273b91aebf95f0e5f5913e160195dcd7a11 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
60 lines
1.5 KiB
C++
60 lines
1.5 KiB
C++
// Copyright (C) 2016 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
#include "qmljscodestylesettingswidget.h"
|
|
#include "qmljscodestylesettings.h"
|
|
#include "qmljstoolstr.h"
|
|
|
|
#include <utils/layoutbuilder.h>
|
|
|
|
#include <QSpinBox>
|
|
#include <QTextStream>
|
|
|
|
namespace QmlJSTools {
|
|
|
|
QmlJSCodeStyleSettingsWidget::QmlJSCodeStyleSettingsWidget(QWidget *parent)
|
|
: QWidget(parent)
|
|
{
|
|
m_lineLengthSpinBox = new QSpinBox;
|
|
m_lineLengthSpinBox->setMinimum(0);
|
|
m_lineLengthSpinBox->setMaximum(999);
|
|
|
|
using namespace Layouting;
|
|
// clang-format off
|
|
Column {
|
|
Group {
|
|
title(Tr::tr("Other")),
|
|
Form {
|
|
Tr::tr("&Line length:"), m_lineLengthSpinBox, br,
|
|
}
|
|
},
|
|
noMargin
|
|
}.attachTo(this);
|
|
// clang-format on
|
|
|
|
connect(m_lineLengthSpinBox, &QSpinBox::valueChanged,
|
|
this, &QmlJSCodeStyleSettingsWidget::slotSettingsChanged);
|
|
}
|
|
|
|
void QmlJSCodeStyleSettingsWidget::setCodeStyleSettings(const QmlJSCodeStyleSettings& s)
|
|
{
|
|
QSignalBlocker blocker(this);
|
|
m_lineLengthSpinBox->setValue(s.lineLength);
|
|
}
|
|
|
|
QmlJSCodeStyleSettings QmlJSCodeStyleSettingsWidget::codeStyleSettings() const
|
|
{
|
|
QmlJSCodeStyleSettings set;
|
|
|
|
set.lineLength = m_lineLengthSpinBox->value();
|
|
|
|
return set;
|
|
}
|
|
|
|
void QmlJSCodeStyleSettingsWidget::slotSettingsChanged()
|
|
{
|
|
emit settingsChanged(codeStyleSettings());
|
|
}
|
|
|
|
} // namespace TextEditor
|