KTextAddons

autocorrectionsettings.h
1/*
2 SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8#include "autocorrectionutils.h"
9#include "textautocorrectioncore_export.h"
10#include <QDebug>
11#include <QSet>
12namespace TextAutoCorrectionCore
13{
14class AutoCorrectionSettingsPrivate;
15class TEXTAUTOCORRECTIONCORE_EXPORT AutoCorrectionSettings
16{
17public:
18 AutoCorrectionSettings();
19 ~AutoCorrectionSettings();
20
21 [[nodiscard]] bool isEnabledAutoCorrection() const;
22 [[nodiscard]] bool isUppercaseFirstCharOfSentence() const;
23 [[nodiscard]] bool isFixTwoUppercaseChars() const;
24 [[nodiscard]] bool isSingleSpaces() const;
25 [[nodiscard]] bool isAutoFractions() const;
26 [[nodiscard]] bool isCapitalizeWeekDays() const;
27 [[nodiscard]] bool isReplaceDoubleQuotes() const;
28 [[nodiscard]] bool isReplaceSingleQuotes() const;
29 [[nodiscard]] bool isAdvancedAutocorrect() const;
30 [[nodiscard]] bool isAutoFormatUrl() const;
31 [[nodiscard]] bool isAutoBoldUnderline() const;
32 [[nodiscard]] bool isSuperScript() const;
33
34 [[nodiscard]] bool isAddNonBreakingSpace() const;
35 [[nodiscard]] bool isReplaceDoubleQuotesByFrenchQuotes() const;
36
37 [[nodiscard]] TextAutoCorrectionCore::AutoCorrectionUtils::TypographicQuotes typographicSingleQuotes() const;
38 [[nodiscard]] TextAutoCorrectionCore::AutoCorrectionUtils::TypographicQuotes typographicDoubleQuotes() const;
39 void setTypographicSingleQuotes(TextAutoCorrectionCore::AutoCorrectionUtils::TypographicQuotes singleQuote);
40 void setTypographicDoubleQuotes(TextAutoCorrectionCore::AutoCorrectionUtils::TypographicQuotes doubleQuote);
41
42 void setAutoFormatUrl(bool b);
43 void setAutoBoldUnderline(bool b);
44 void setSuperScript(bool b);
45 void setAddNonBreakingSpace(bool b);
46 void setCapitalizeWeekDays(bool b);
47 void setReplaceDoubleQuotes(bool b);
48 void setReplaceSingleQuotes(bool b);
49 void setAdvancedAutocorrect(bool b);
50 void setEnabledAutoCorrection(bool b);
51 void setReplaceDoubleQuotesByFrenchQuotes(bool b);
52
53 void readConfig();
54
55 void writeConfig();
56
57 void setAutoFractions(bool newAutoFractions);
58
59 void setSingleSpaces(bool newSingleSpaces);
60
61 void setFixTwoUppercaseChars(bool newFixTwoUppercaseChars);
62
63 void setUppercaseFirstCharOfSentence(bool newUppercaseFirstCharOfSentence);
64
65 void setUpperCaseExceptions(const QSet<QString> &exceptions);
66 void setTwoUpperLetterExceptions(const QSet<QString> &exceptions);
67 [[nodiscard]] QSet<QString> upperCaseExceptions() const;
68 [[nodiscard]] QSet<QString> twoUpperLetterExceptions() const;
69
70 void setLanguage(const QString &lang, bool forceGlobal = false);
71 [[nodiscard]] QString language() const;
72
73 [[nodiscard]] bool isFrenchLanguage() const;
74 void setAutocorrectEntries(const QHash<QString, QString> &entries);
75
76 [[nodiscard]] QHash<QString, QString> autocorrectEntries() const;
77 [[nodiscard]] bool addAutoCorrect(const QString &currentWord, const QString &replaceWord);
78
79 [[nodiscard]] QChar nonBreakingSpace() const;
80 void setNonBreakingSpace(const QChar &newNonBreakingSpace);
81
82 [[nodiscard]] QHash<QString, QString> superScriptEntries() const;
83 void setSuperScriptEntries(const QHash<QString, QString> &newSuperScriptEntries);
84
85 void writeAutoCorrectionFile(const QString &filename = QString());
86 [[nodiscard]] int maxFindStringLength() const;
87
88 [[nodiscard]] int minFindStringLength() const;
89
90 void loadLocalFileName(const QString &localFileName, const QString &fname);
91 void loadGlobalFileName(const QString &fname);
92
93 [[nodiscard]] AutoCorrectionUtils::TypographicQuotes doubleFrenchQuotes() const;
94 void setDoubleFrenchQuotes(const AutoCorrectionUtils::TypographicQuotes &newDoubleFrenchQuotes);
95
96 [[nodiscard]] QString customWritablePath() const;
97 void setCustomWritablePath(const QString &path);
98
99 [[nodiscard]] QString customSystemPath() const;
100 void setCustomSystemPath(const QString &path);
101
102private:
103 TEXTAUTOCORRECTIONCORE_NO_EXPORT void migrateKMailXmlFile();
104 TEXTAUTOCORRECTIONCORE_NO_EXPORT void readAutoCorrectionFile(bool forceGlobal = false);
105 [[nodiscard]] TEXTAUTOCORRECTIONCORE_NO_EXPORT QString containsAutoCorrectionFile(const QString &fileName);
106
107 friend class AutoCorrectionSettingsPrivate;
108 std::unique_ptr<AutoCorrectionSettingsPrivate> const d;
109};
110}
111TEXTAUTOCORRECTIONCORE_EXPORT QDebug operator<<(QDebug d, const TextAutoCorrectionCore::AutoCorrectionSettings &t);
QDebug operator<<(QDebug dbg, const PerceptualColor::MultiSpinBoxSection &value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:19:49 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.