2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2010-05-10 18:30:09 +02:00
|
|
|
|
|
|
|
|
#include "completionsettings.h"
|
|
|
|
|
|
2023-09-22 16:15:27 +02:00
|
|
|
#include <utils/qtcsettings.h>
|
2010-05-10 18:30:09 +02:00
|
|
|
|
2023-09-22 16:15:27 +02:00
|
|
|
using namespace Utils;
|
2010-05-10 18:30:09 +02:00
|
|
|
|
2023-09-22 16:15:27 +02:00
|
|
|
namespace TextEditor {
|
2010-05-10 18:30:09 +02:00
|
|
|
|
2023-09-22 16:15:27 +02:00
|
|
|
const char settingsGroup[] = "CppTools/Completion";
|
|
|
|
|
const char caseSensitivityKey[] = "CaseSensitivity";
|
|
|
|
|
const char completionTriggerKey[] = "CompletionTrigger";
|
|
|
|
|
const char automaticProposalTimeoutKey[] = "AutomaticProposalTimeout";
|
|
|
|
|
const char characterThresholdKey[] = "CharacterThreshold";
|
|
|
|
|
const char autoInsertBracesKey[] = "AutoInsertBraces";
|
|
|
|
|
const char surroundingAutoBracketsKey[] = "SurroundingAutoBrackets";
|
|
|
|
|
const char autoInsertQuotesKey[] = "AutoInsertQuotes";
|
|
|
|
|
const char surroundingAutoQuotesKey[] = "SurroundingAutoQuotes";
|
|
|
|
|
const char partiallyCompleteKey[] = "PartiallyComplete";
|
|
|
|
|
const char spaceAfterFunctionNameKey[] = "SpaceAfterFunctionName";
|
|
|
|
|
const char autoSplitStringsKey[] = "AutoSplitStrings";
|
|
|
|
|
const char animateAutoCompleteKey[] = "AnimateAutoComplete";
|
|
|
|
|
const char highlightAutoCompleteKey[] = "HighlightAutoComplete";
|
|
|
|
|
const char skipAutoCompleteKey[] = "SkipAutoComplete";
|
|
|
|
|
const char autoRemoveKey[] = "AutoRemove";
|
|
|
|
|
const char overwriteClosingCharsKey[] = "OverwriteClosingChars";
|
|
|
|
|
|
|
|
|
|
void CompletionSettings::toSettings(QtcSettings *s) const
|
2010-05-10 18:30:09 +02:00
|
|
|
{
|
2016-05-19 12:25:16 +02:00
|
|
|
s->beginGroup(settingsGroup);
|
2016-05-02 09:10:39 +02:00
|
|
|
s->setValue(caseSensitivityKey, (int) m_caseSensitivity);
|
|
|
|
|
s->setValue(completionTriggerKey, (int) m_completionTrigger);
|
|
|
|
|
s->setValue(automaticProposalTimeoutKey, m_automaticProposalTimeoutInMs);
|
2020-08-03 16:19:19 +02:00
|
|
|
s->setValue(characterThresholdKey, m_characterThreshold);
|
2016-05-02 09:10:39 +02:00
|
|
|
s->setValue(autoInsertBracesKey, m_autoInsertBrackets);
|
|
|
|
|
s->setValue(surroundingAutoBracketsKey, m_surroundingAutoBrackets);
|
|
|
|
|
s->setValue(autoInsertQuotesKey, m_autoInsertQuotes);
|
|
|
|
|
s->setValue(surroundingAutoQuotesKey, m_surroundingAutoQuotes);
|
|
|
|
|
s->setValue(partiallyCompleteKey, m_partiallyComplete);
|
|
|
|
|
s->setValue(spaceAfterFunctionNameKey, m_spaceAfterFunctionName);
|
|
|
|
|
s->setValue(autoSplitStringsKey, m_autoSplitStrings);
|
2016-04-28 12:51:34 +02:00
|
|
|
s->setValue(animateAutoCompleteKey, m_animateAutoComplete);
|
2016-06-01 10:19:59 +02:00
|
|
|
s->setValue(highlightAutoCompleteKey, m_highlightAutoComplete);
|
2016-06-10 15:13:38 +02:00
|
|
|
s->setValue(skipAutoCompleteKey, m_skipAutoCompletedText);
|
2016-06-14 08:00:32 +02:00
|
|
|
s->setValue(autoRemoveKey, m_autoRemove);
|
2019-05-15 21:50:28 -07:00
|
|
|
s->setValue(overwriteClosingCharsKey, m_overwriteClosingChars);
|
2010-05-10 18:30:09 +02:00
|
|
|
s->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-22 16:15:27 +02:00
|
|
|
void CompletionSettings::fromSettings(QtcSettings *s)
|
2010-05-10 18:30:09 +02:00
|
|
|
{
|
|
|
|
|
*this = CompletionSettings(); // Assign defaults
|
|
|
|
|
|
2016-05-19 12:25:16 +02:00
|
|
|
s->beginGroup(settingsGroup);
|
2016-05-02 09:10:39 +02:00
|
|
|
m_caseSensitivity = (CaseSensitivity)
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(caseSensitivityKey, m_caseSensitivity).toInt();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_completionTrigger = (CompletionTrigger)
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(completionTriggerKey, m_completionTrigger).toInt();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_automaticProposalTimeoutInMs =
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(automaticProposalTimeoutKey, m_automaticProposalTimeoutInMs).toInt();
|
2020-08-03 16:19:19 +02:00
|
|
|
m_characterThreshold =
|
|
|
|
|
s->value(characterThresholdKey, m_characterThreshold).toInt();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_autoInsertBrackets =
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(autoInsertBracesKey, m_autoInsertBrackets).toBool();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_surroundingAutoBrackets =
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(surroundingAutoBracketsKey, m_surroundingAutoBrackets).toBool();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_autoInsertQuotes =
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(autoInsertQuotesKey, m_autoInsertQuotes).toBool();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_surroundingAutoQuotes =
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(surroundingAutoQuotesKey, m_surroundingAutoQuotes).toBool();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_partiallyComplete =
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(partiallyCompleteKey, m_partiallyComplete).toBool();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_spaceAfterFunctionName =
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(spaceAfterFunctionNameKey, m_spaceAfterFunctionName).toBool();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_autoSplitStrings =
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(autoSplitStringsKey, m_autoSplitStrings).toBool();
|
2016-04-28 12:51:34 +02:00
|
|
|
m_animateAutoComplete =
|
|
|
|
|
s->value(animateAutoCompleteKey, m_animateAutoComplete).toBool();
|
2016-06-01 10:19:59 +02:00
|
|
|
m_highlightAutoComplete =
|
|
|
|
|
s->value(highlightAutoCompleteKey, m_highlightAutoComplete).toBool();
|
2016-06-10 15:13:38 +02:00
|
|
|
m_skipAutoCompletedText =
|
|
|
|
|
s->value(skipAutoCompleteKey, m_skipAutoCompletedText).toBool();
|
2016-06-14 08:00:32 +02:00
|
|
|
m_autoRemove =
|
|
|
|
|
s->value(autoRemoveKey, m_autoRemove).toBool();
|
2019-05-15 21:50:28 -07:00
|
|
|
m_overwriteClosingChars =
|
|
|
|
|
s->value(overwriteClosingCharsKey, m_overwriteClosingChars).toBool();
|
2016-05-19 12:25:16 +02:00
|
|
|
s->endGroup();
|
2010-05-10 18:30:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CompletionSettings::equals(const CompletionSettings &cs) const
|
|
|
|
|
{
|
2016-05-02 09:10:39 +02:00
|
|
|
return m_caseSensitivity == cs.m_caseSensitivity
|
|
|
|
|
&& m_completionTrigger == cs.m_completionTrigger
|
|
|
|
|
&& m_automaticProposalTimeoutInMs == cs.m_automaticProposalTimeoutInMs
|
2020-08-03 16:19:19 +02:00
|
|
|
&& m_characterThreshold == cs.m_characterThreshold
|
2016-05-02 09:10:39 +02:00
|
|
|
&& m_autoInsertBrackets == cs.m_autoInsertBrackets
|
|
|
|
|
&& m_surroundingAutoBrackets == cs.m_surroundingAutoBrackets
|
|
|
|
|
&& m_autoInsertQuotes == cs.m_autoInsertQuotes
|
|
|
|
|
&& m_surroundingAutoQuotes == cs.m_surroundingAutoQuotes
|
|
|
|
|
&& m_partiallyComplete == cs.m_partiallyComplete
|
|
|
|
|
&& m_spaceAfterFunctionName == cs.m_spaceAfterFunctionName
|
|
|
|
|
&& m_autoSplitStrings == cs.m_autoSplitStrings
|
2016-04-28 12:51:34 +02:00
|
|
|
&& m_animateAutoComplete == cs.m_animateAutoComplete
|
2016-06-01 10:19:59 +02:00
|
|
|
&& m_highlightAutoComplete == cs.m_highlightAutoComplete
|
2016-06-10 15:13:38 +02:00
|
|
|
&& m_skipAutoCompletedText == cs.m_skipAutoCompletedText
|
2016-06-14 08:00:32 +02:00
|
|
|
&& m_autoRemove == cs.m_autoRemove
|
2019-05-15 21:50:28 -07:00
|
|
|
&& m_overwriteClosingChars == cs.m_overwriteClosingChars
|
2010-05-10 18:30:09 +02:00
|
|
|
;
|
|
|
|
|
}
|
2023-09-22 16:15:27 +02:00
|
|
|
|
|
|
|
|
} // TextEditor
|