1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of Qt Creator.
7 **
8 ** Commercial License Usage
9 ** Licensees holding valid commercial Qt licenses may use this file in
10 ** accordance with the commercial license agreement provided with the
11 ** Software or, alternatively, in accordance with the terms contained in
12 ** a written agreement between you and The Qt Company. For licensing terms
13 ** and conditions see https://www.qt.io/terms-conditions. For further
14 ** information use the contact form at https://www.qt.io/contact-us.
15 **
16 ** GNU General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU
18 ** General Public License version 3 as published by the Free Software
19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
20 ** included in the packaging of this file. Please review the following
21 ** information to ensure the GNU General Public License requirements will
22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
23 **
24 ****************************************************************************/
25 
26 #pragma once
27 
28 #include "texteditor_global.h"
29 
30 #include <utils/id.h>
31 
32 #include <QObject>
33 
34 QT_BEGIN_NAMESPACE
35 template <typename Key, typename T>
36 class QMap;
37 QT_END_NAMESPACE
38 
39 namespace TextEditor {
40 
41 class FontSettings;
42 class TypingSettings;
43 class StorageSettings;
44 class BehaviorSettings;
45 class MarginSettings;
46 class DisplaySettings;
47 class CompletionSettings;
48 class HighlighterSettings;
49 class ExtraEncodingSettings;
50 class ICodeStylePreferences;
51 class ICodeStylePreferencesFactory;
52 class CodeStylePool;
53 class CommentsSettings;
54 
55 /**
56  * This class provides a central place for basic text editor settings. These
57  * settings include font settings, tab settings, storage settings, behavior
58  * settings, display settings and completion settings.
59  */
60 class TEXTEDITOR_EXPORT TextEditorSettings : public QObject
61 {
62     Q_OBJECT
63 
64 public:
65     TextEditorSettings();
66     ~TextEditorSettings() override;
67 
68     static TextEditorSettings *instance();
69 
70     static const FontSettings &fontSettings();
71     static const TypingSettings &typingSettings();
72     static const StorageSettings &storageSettings();
73     static const BehaviorSettings &behaviorSettings();
74     static const MarginSettings &marginSettings();
75     static const DisplaySettings &displaySettings();
76     static const CompletionSettings &completionSettings();
77     static const HighlighterSettings &highlighterSettings();
78     static const ExtraEncodingSettings &extraEncodingSettings();
79     static const CommentsSettings &commentsSettings();
80 
81     static ICodeStylePreferencesFactory *codeStyleFactory(Utils::Id languageId);
82     static const QMap<Utils::Id, ICodeStylePreferencesFactory *> &codeStyleFactories();
83     static void registerCodeStyleFactory(ICodeStylePreferencesFactory *codeStyleFactory);
84     static void unregisterCodeStyleFactory(Utils::Id languageId);
85 
86     static CodeStylePool *codeStylePool();
87     static CodeStylePool *codeStylePool(Utils::Id languageId);
88     static void registerCodeStylePool(Utils::Id languageId, CodeStylePool *pool);
89     static void unregisterCodeStylePool(Utils::Id languageId);
90 
91     static ICodeStylePreferences *codeStyle();
92     static ICodeStylePreferences *codeStyle(Utils::Id languageId);
93     static QMap<Utils::Id, ICodeStylePreferences *> codeStyles();
94     static void registerCodeStyle(Utils::Id languageId, ICodeStylePreferences *prefs);
95     static void unregisterCodeStyle(Utils::Id languageId);
96 
97     static void registerMimeTypeForLanguageId(const char *mimeType, Utils::Id languageId);
98     static Utils::Id languageId(const QString &mimeType);
99     static int increaseFontZoom(int step);
100     static void resetFontZoom();
101 
102 signals:
103     void fontSettingsChanged(const TextEditor::FontSettings &);
104     void typingSettingsChanged(const TextEditor::TypingSettings &);
105     void storageSettingsChanged(const TextEditor::StorageSettings &);
106     void behaviorSettingsChanged(const TextEditor::BehaviorSettings &);
107     void marginSettingsChanged(const TextEditor::MarginSettings &);
108     void displaySettingsChanged(const TextEditor::DisplaySettings &);
109     void completionSettingsChanged(const TextEditor::CompletionSettings &);
110     void extraEncodingSettingsChanged(const TextEditor::ExtraEncodingSettings &);
111     void commentsSettingsChanged(const TextEditor::CommentsSettings &);
112 };
113 
114 } // namespace TextEditor
115