aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/cppcodestylesettingspage.h
blob: 2a8bce064c843faec74f5016dd39e4e96dbadc85 (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
// 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 "cppcodestylesettings.h"

#include <coreplugin/dialogs/ioptionspage.h>
#include <texteditor/icodestylepreferencesfactory.h>
#include <texteditor/tabsettings.h>

#include <QWidget>
#include <QPointer>

namespace TextEditor {
    class FontSettings;
    class SnippetEditorWidget;
    class CodeStyleEditor;
    class CodeStyleEditorWidget;
}

namespace CppEditor {
class CppCodeStylePreferences;

namespace Internal {

class CppCodeStylePreferencesWidgetPrivate;

class CppCodeStylePreferencesWidget : public TextEditor::CodeStyleEditorWidget
{
    Q_OBJECT
public:
    explicit CppCodeStylePreferencesWidget(QWidget *parent = nullptr);
    ~CppCodeStylePreferencesWidget() override;

    void setCodeStyle(CppCodeStylePreferences *codeStylePreferences);
    void addTab(TextEditor::CodeStyleEditorWidget *page, QString tabName);
    void apply() override;
    void finish() override;

private:
    void decorateEditors(const TextEditor::FontSettings &fontSettings);
    void setVisualizeWhitespace(bool on);
    void slotTabSettingsChanged(const TextEditor::TabSettings &settings);
    void slotCodeStyleSettingsChanged();
    void updatePreview();
    void setTabSettings(const TextEditor::TabSettings &settings);
    TextEditor::TabSettings tabSettings() const;
    void setCodeStyleSettings(const CppCodeStyleSettings &settings, bool preview = true);
    void slotCurrentPreferencesChanged(TextEditor::ICodeStylePreferences *, bool preview = true);

    CppCodeStyleSettings cppCodeStyleSettings() const;

    CppCodeStylePreferences *m_preferences = nullptr;
    CppCodeStylePreferencesWidgetPrivate *d = nullptr;
    CppCodeStyleSettings m_originalCppCodeStyleSettings;
    TextEditor::TabSettings m_originalTabSettings;
    bool m_blockUpdates = false;
    friend class CppCodeStylePreferencesWidgetPrivate;
signals:
    void codeStyleSettingsChanged(const CppEditor::CppCodeStyleSettings &);
    void tabSettingsChanged(const TextEditor::TabSettings &);
    void applyEmitted();
    void finishEmitted();
};

void setupCppCodeStyleSettings();

} // namespace Internal
} // namespace CppEditor