summaryrefslogtreecommitdiff
path: root/src/plugins/clangformat/clangformatconfigwidget.h
blob: 755aabd85e36326bdfd207d39f02fb02057a8e01 (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
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <cppeditor/cppcodestylesettingspage.h>

#include <memory>

namespace ProjectExplorer { class Project; }
namespace CppEditor { class CppCodeStyleSettings; }

namespace ClangFormat {

class ClangFormatConfigWidget : public CppEditor::CppCodeStyleWidget
{
    Q_OBJECT

public:
    explicit ClangFormatConfigWidget(TextEditor::ICodeStylePreferences *codeStyle,
                                     ProjectExplorer::Project *project = nullptr,
                                     QWidget *parent = nullptr);
    ~ClangFormatConfigWidget() override;
    void apply() override;
    void finish() override;
    void setCodeStyleSettings(const CppEditor::CppCodeStyleSettings &settings) override;
    void setTabSettings(const TextEditor::TabSettings &settings) override;
    void synchronize() override;

private:
    bool eventFilter(QObject *object, QEvent *event) override;

    Utils::FilePath globalPath();
    Utils::FilePath projectPath();
    void createStyleFileIfNeeded(bool isGlobal);
    void showOrHideWidgets();
    void initChecksAndPreview();
    void connectChecks();

    void fillTable();
    std::string readFile(const QString &path);
    void saveChanges(QObject *sender);

    void updatePreview();
    void slotCodeStyleChanged(TextEditor::ICodeStylePreferences *currentPreferences);

    class Private;
    Private * const d;
};

} // ClangFormat