2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2022-04-02 12:15:26 +02:00
|
|
|
|
|
|
|
|
#include "qmljscodestylesettingswidget.h"
|
2022-04-07 21:56:10 +02:00
|
|
|
|
2022-04-02 12:15:26 +02:00
|
|
|
#include "qmljscodestylesettings.h"
|
|
|
|
|
|
2022-08-16 17:16:47 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
|
|
|
|
|
|
|
|
|
#include <QSpinBox>
|
2022-04-02 12:15:26 +02:00
|
|
|
#include <QTextStream>
|
|
|
|
|
|
|
|
|
|
namespace QmlJSTools {
|
|
|
|
|
|
2022-08-16 17:16:47 +02:00
|
|
|
QmlJSCodeStyleSettingsWidget::QmlJSCodeStyleSettingsWidget(QWidget *parent)
|
|
|
|
|
: QWidget(parent)
|
2022-04-02 12:15:26 +02:00
|
|
|
{
|
2022-08-16 17:16:47 +02:00
|
|
|
m_lineLengthSpinBox = new QSpinBox;
|
|
|
|
|
m_lineLengthSpinBox->setMinimum(0);
|
|
|
|
|
m_lineLengthSpinBox->setMaximum(999);
|
|
|
|
|
|
|
|
|
|
using namespace Utils::Layouting;
|
|
|
|
|
Column {
|
|
|
|
|
Group {
|
|
|
|
|
title(tr("Qml JS Code Style")),
|
|
|
|
|
Form {
|
|
|
|
|
tr("&Line length:"), m_lineLengthSpinBox, br,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}.attachTo(this, WithoutMargins);
|
|
|
|
|
|
|
|
|
|
connect(m_lineLengthSpinBox, &QSpinBox::valueChanged,
|
2022-04-02 12:15:26 +02:00
|
|
|
this, &QmlJSCodeStyleSettingsWidget::slotSettingsChanged);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlJSCodeStyleSettingsWidget::setCodeStyleSettings(const QmlJSCodeStyleSettings& s)
|
|
|
|
|
{
|
|
|
|
|
QSignalBlocker blocker(this);
|
2022-08-16 17:16:47 +02:00
|
|
|
m_lineLengthSpinBox->setValue(s.lineLength);
|
2022-04-02 12:15:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlJSCodeStyleSettings QmlJSCodeStyleSettingsWidget::codeStyleSettings() const
|
|
|
|
|
{
|
|
|
|
|
QmlJSCodeStyleSettings set;
|
|
|
|
|
|
2022-08-16 17:16:47 +02:00
|
|
|
set.lineLength = m_lineLengthSpinBox->value();
|
2022-04-02 12:15:26 +02:00
|
|
|
|
|
|
|
|
return set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlJSCodeStyleSettingsWidget::slotSettingsChanged()
|
|
|
|
|
{
|
|
|
|
|
emit settingsChanged(codeStyleSettings());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace TextEditor
|