blob: a2028dddab51b875fb7e0da420f4080a7d2b6c5a (
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include "qmljstools_global.h"
#include <coreplugin/dialogs/ioptionspage.h>
#include <texteditor/icodestylepreferences.h>
#include <texteditor/codestyleeditor.h>
#include <utils/filepath.h>
#include <utils/store.h>
namespace TextEditor {
class FontSettings;
class TabSettings;
}
QT_BEGIN_NAMESPACE
class QStackedWidget;
QT_END_NAMESPACE
namespace QmlJSTools {
class FormatterSelectionWidget;
class QMLJSTOOLS_EXPORT QmlJSCodeStyleSettings
{
public:
QmlJSCodeStyleSettings();
enum Formatter {
Builtin,
QmlFormat,
Custom
};
int lineLength = 80;
QString qmlformatIniContent;
Formatter formatter = Builtin;
Utils::FilePath customFormatterPath;
QString customFormatterArguments;
void toMap(Utils::Store &map) const;
void fromMap(const Utils::Store &map);
bool equals(const QmlJSCodeStyleSettings &rhs) const;
bool operator==(const QmlJSCodeStyleSettings &s) const { return equals(s); }
bool operator!=(const QmlJSCodeStyleSettings &s) const { return !equals(s); }
static QmlJSCodeStyleSettings currentGlobalCodeStyle();
static TextEditor::TabSettings currentGlobalTabSettings();
static Utils::Id settingsId();
};
using QmlJSCodeStylePreferences = TextEditor::TypedCodeStylePreferences<QmlJSCodeStyleSettings>;
namespace Internal {
class QmlJSCodeStylePreferencesWidget : public TextEditor::CodeStyleEditorWidget
{
Q_OBJECT
public:
explicit QmlJSCodeStylePreferencesWidget(const QString &previewText, QWidget *parent = nullptr);
void setPreferences(QmlJSCodeStylePreferences* preferences);
private:
void decorateEditor(const TextEditor::FontSettings &fontSettings);
void setVisualizeWhitespace(bool on);
void slotSettingsChanged(const QmlJSCodeStyleSettings &);
void slotCurrentPreferencesChanged(TextEditor::ICodeStylePreferences *preferences);
void updatePreview();
void builtInFormatterPreview();
void qmlformatPreview();
void customFormatterPreview();
FormatterSelectionWidget *m_formatterSelectionWidget;
QStackedWidget *m_formatterSettingsStack;
TextEditor::SnippetEditorWidget *m_previewTextEdit;
QmlJSCodeStylePreferences *m_preferences = nullptr;
};
class QmlJSCodeStyleSettingsPage : public Core::IOptionsPage
{
public:
QmlJSCodeStyleSettingsPage();
};
} // namespace Internal
} // namespace QmlJSTools
Q_DECLARE_METATYPE(QmlJSTools::QmlJSCodeStyleSettings)
|