summaryrefslogtreecommitdiff
path: root/src/plugins/qmljstools/qmljscodestylesettingswidget.cpp
blob: 34919f6144fa20303b8d80e51870d2bf94e12ac0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// 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;
    Column {
        Group {
            title(Tr::tr("Qml JS Code Style")),
            Form {
                Tr::tr("&Line length:"), m_lineLengthSpinBox, br,
            }
        },
        noMargin
    }.attachTo(this);

    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