diff --git a/src/plugins/texteditor/CMakeLists.txt b/src/plugins/texteditor/CMakeLists.txt index ace544e578b..737ce0023ae 100644 --- a/src/plugins/texteditor/CMakeLists.txt +++ b/src/plugins/texteditor/CMakeLists.txt @@ -49,7 +49,7 @@ add_qtc_plugin(TextEditor command.cpp command.h commentssettings.cpp commentssettings.h completionsettings.cpp completionsettings.h - completionsettingspage.cpp completionsettingspage.h completionsettingspage.ui + completionsettingspage.cpp completionsettingspage.h displaysettings.cpp displaysettings.h displaysettingspage.cpp displaysettingspage.h displaysettingspage.ui extraencodingsettings.cpp extraencodingsettings.h diff --git a/src/plugins/texteditor/completionsettingspage.cpp b/src/plugins/texteditor/completionsettingspage.cpp index c9652aaee26..5194d325b00 100644 --- a/src/plugins/texteditor/completionsettingspage.cpp +++ b/src/plugins/texteditor/completionsettingspage.cpp @@ -27,15 +27,28 @@ #include "texteditorsettings.h" #include "texteditorconstants.h" -#include "ui_completionsettingspage.h" #include #include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace CppEditor; +using namespace Utils; namespace TextEditor { namespace Internal { @@ -55,19 +68,132 @@ private: void settingsFromUi(CompletionSettings &completion, CommentsSettings &comment) const; CompletionSettingsPage *m_owner = nullptr; - Ui::CompletionSettingsPage m_ui; + + QComboBox *m_caseSensitivity; + QComboBox *m_completionTrigger; + QSpinBox *m_thresholdSpinBox; + QSpinBox *m_automaticProposalTimeoutSpinBox; + QCheckBox *m_partiallyComplete; + QCheckBox *m_autoSplitStrings; + QCheckBox *m_insertBrackets; + QCheckBox *m_insertQuotes; + QCheckBox *m_surroundBrackets; + QCheckBox *m_spaceAfterFunctionName; + QCheckBox *m_surroundQuotes; + QCheckBox *m_animateAutoComplete; + QCheckBox *m_highlightAutoComplete; + QCheckBox *m_skipAutoComplete; + QCheckBox *m_removeAutoComplete; + QCheckBox *m_overwriteClosingChars; + QCheckBox *m_enableDoxygenCheckBox; + QCheckBox *m_generateBriefCheckBox; + QCheckBox *m_leadingAsterisksCheckBox; }; CompletionSettingsPageWidget::CompletionSettingsPageWidget(CompletionSettingsPage *owner) : m_owner(owner) { - m_ui.setupUi(this); + resize(823, 756); - connect(m_ui.completionTrigger, QOverload::of(&QComboBox::currentIndexChanged), - this, [this] { + m_caseSensitivity = new QComboBox; + m_caseSensitivity->addItem(tr("Full")); + m_caseSensitivity->addItem(tr("None")); + m_caseSensitivity->addItem(tr("First Letter")); + + auto caseSensitivityLabel = new QLabel(tr("&Case-sensitivity:")); + caseSensitivityLabel->setBuddy(m_caseSensitivity); + + m_completionTrigger = new QComboBox; + m_completionTrigger->addItem(tr("Manually")); + m_completionTrigger->addItem(tr("When Triggered")); + m_completionTrigger->addItem(tr("Always")); + + auto completionTriggerLabel = new QLabel(tr("Activate completion:")); + + auto automaticProposalTimeoutLabel = new QLabel(tr("Timeout in ms:")); + + m_automaticProposalTimeoutSpinBox = new QSpinBox; + m_automaticProposalTimeoutSpinBox->setMaximum(2000); + m_automaticProposalTimeoutSpinBox->setSingleStep(50); + m_automaticProposalTimeoutSpinBox->setValue(400); + + auto thresholdLabel = new QLabel(tr("Character threshold:")); + + m_thresholdSpinBox = new QSpinBox; + m_thresholdSpinBox->setMinimum(1); + + m_partiallyComplete = new QCheckBox(tr("Autocomplete common &prefix")); + m_partiallyComplete->setToolTip(tr("Inserts the common prefix of available completion items.")); + m_partiallyComplete->setChecked(true); + + m_autoSplitStrings = new QCheckBox(tr("Automatically split strings")); + m_autoSplitStrings->setToolTip( + tr("Splits a string into two lines by adding an end quote at the cursor position " + "when you press Enter and a start quote to the next line, before the rest " + "of the string.\n\n" + "In addition, Shift+Enter inserts an escape character at the cursor position " + "and moves the rest of the string to the next line.")); + + m_insertBrackets = new QCheckBox(tr("Insert opening or closing brackets")); + m_insertBrackets->setChecked(true); + + m_insertQuotes = new QCheckBox(tr("Insert closing quote")); + m_insertQuotes->setChecked(true); + + m_surroundBrackets = new QCheckBox(tr("Surround text selection with brackets")); + m_surroundBrackets->setChecked(true); + m_surroundBrackets->setToolTip( + tr("When typing a matching bracket and there is a text selection, instead of " + "removing the selection, surrounds it with the corresponding characters.")); + + m_spaceAfterFunctionName = new QCheckBox(tr("Insert &space after function name")); + m_spaceAfterFunctionName->setEnabled(true); + + m_surroundQuotes = new QCheckBox(tr("Surround text selection with quotes")); + m_surroundQuotes->setChecked(true); + m_surroundQuotes->setToolTip( + tr("When typing a matching quote and there is a text selection, instead of " + "removing the selection, surrounds it with the corresponding characters.")); + + m_animateAutoComplete = new QCheckBox(tr("Animate automatically inserted text")); + m_animateAutoComplete->setChecked(true); + m_animateAutoComplete->setToolTip(tr("Show a visual hint when for example a brace or a quote " + "is automatically inserted by the editor.")); + + m_highlightAutoComplete = new QCheckBox(tr("Highlight automatically inserted text")); + m_highlightAutoComplete->setChecked(true); + + m_skipAutoComplete = new QCheckBox(tr("Skip automatically inserted character when typing")); + m_skipAutoComplete->setToolTip(tr("Skip automatically inserted character if re-typed manually " + "after completion or by pressing tab.")); + m_skipAutoComplete->setChecked(true); + + m_removeAutoComplete = new QCheckBox(tr("Remove automatically inserted text on backspace")); + m_removeAutoComplete->setChecked(true); + m_removeAutoComplete->setToolTip(tr("Remove the automatically inserted character if the trigger " + "is deleted by backspace after the completion.")); + + m_overwriteClosingChars = new QCheckBox(tr("Overwrite closing punctuation")); + m_overwriteClosingChars->setToolTip(tr("Automatically overwrite closing parentheses and quotes.")); + + m_enableDoxygenCheckBox = new QCheckBox(tr("Enable Doxygen blocks")); + m_enableDoxygenCheckBox->setToolTip(tr("Automatically creates a Doxygen comment upon pressing " + "enter after a '/**', '/*!', '//!' or '///'.")); + + m_generateBriefCheckBox = new QCheckBox(tr("Generate brief description")); + m_generateBriefCheckBox->setToolTip(tr("Generates a brief command with an initial " + "description for the corresponding declaration.")); + + m_leadingAsterisksCheckBox = new QCheckBox(tr("Add leading asterisks")); + m_leadingAsterisksCheckBox->setToolTip( + tr("Adds leading asterisks when continuing C/C++ \"/*\", Qt \"/*!\" " + "and Java \"/**\" style comments on new lines.")); + + connect(m_completionTrigger, &QComboBox::currentIndexChanged, + this, [this, automaticProposalTimeoutLabel] { const bool enableTimeoutWidgets = completionTrigger() == AutomaticCompletion; - m_ui.automaticProposalTimeoutLabel->setEnabled(enableTimeoutWidgets); - m_ui.automaticProposalTimeoutSpinBox->setEnabled(enableTimeoutWidgets); + automaticProposalTimeoutLabel->setEnabled(enableTimeoutWidgets); + m_automaticProposalTimeoutSpinBox->setEnabled(enableTimeoutWidgets); }); int caseSensitivityIndex = 0; @@ -96,31 +222,81 @@ CompletionSettingsPageWidget::CompletionSettingsPageWidget(CompletionSettingsPag break; } - m_ui.caseSensitivity->setCurrentIndex(caseSensitivityIndex); - m_ui.completionTrigger->setCurrentIndex(completionTriggerIndex); - m_ui.automaticProposalTimeoutSpinBox + m_caseSensitivity->setCurrentIndex(caseSensitivityIndex); + m_completionTrigger->setCurrentIndex(completionTriggerIndex); + m_automaticProposalTimeoutSpinBox ->setValue(m_owner->m_completionSettings.m_automaticProposalTimeoutInMs); - m_ui.thresholdSpinBox->setValue(m_owner->m_completionSettings.m_characterThreshold); - m_ui.insertBrackets->setChecked(m_owner->m_completionSettings.m_autoInsertBrackets); - m_ui.surroundBrackets->setChecked(m_owner->m_completionSettings.m_surroundingAutoBrackets); - m_ui.insertQuotes->setChecked(m_owner->m_completionSettings.m_autoInsertQuotes); - m_ui.surroundQuotes->setChecked(m_owner->m_completionSettings.m_surroundingAutoQuotes); - m_ui.partiallyComplete->setChecked(m_owner->m_completionSettings.m_partiallyComplete); - m_ui.spaceAfterFunctionName->setChecked(m_owner->m_completionSettings.m_spaceAfterFunctionName); - m_ui.autoSplitStrings->setChecked(m_owner->m_completionSettings.m_autoSplitStrings); - m_ui.animateAutoComplete->setChecked(m_owner->m_completionSettings.m_animateAutoComplete); - m_ui.overwriteClosingChars->setChecked(m_owner->m_completionSettings.m_overwriteClosingChars); - m_ui.highlightAutoComplete->setChecked(m_owner->m_completionSettings.m_highlightAutoComplete); - m_ui.skipAutoComplete->setChecked(m_owner->m_completionSettings.m_skipAutoCompletedText); - m_ui.removeAutoComplete->setChecked(m_owner->m_completionSettings.m_autoRemove); + m_thresholdSpinBox->setValue(m_owner->m_completionSettings.m_characterThreshold); + m_insertBrackets->setChecked(m_owner->m_completionSettings.m_autoInsertBrackets); + m_surroundBrackets->setChecked(m_owner->m_completionSettings.m_surroundingAutoBrackets); + m_insertQuotes->setChecked(m_owner->m_completionSettings.m_autoInsertQuotes); + m_surroundQuotes->setChecked(m_owner->m_completionSettings.m_surroundingAutoQuotes); + m_partiallyComplete->setChecked(m_owner->m_completionSettings.m_partiallyComplete); + m_spaceAfterFunctionName->setChecked(m_owner->m_completionSettings.m_spaceAfterFunctionName); + m_autoSplitStrings->setChecked(m_owner->m_completionSettings.m_autoSplitStrings); + m_animateAutoComplete->setChecked(m_owner->m_completionSettings.m_animateAutoComplete); + m_overwriteClosingChars->setChecked(m_owner->m_completionSettings.m_overwriteClosingChars); + m_highlightAutoComplete->setChecked(m_owner->m_completionSettings.m_highlightAutoComplete); + m_skipAutoComplete->setChecked(m_owner->m_completionSettings.m_skipAutoCompletedText); + m_removeAutoComplete->setChecked(m_owner->m_completionSettings.m_autoRemove); - m_ui.enableDoxygenCheckBox->setChecked(m_owner->m_commentsSettings.m_enableDoxygen); - m_ui.generateBriefCheckBox->setChecked(m_owner->m_commentsSettings.m_generateBrief); - m_ui.leadingAsterisksCheckBox->setChecked(m_owner->m_commentsSettings.m_leadingAsterisks); + m_enableDoxygenCheckBox->setChecked(m_owner->m_commentsSettings.m_enableDoxygen); + m_generateBriefCheckBox->setChecked(m_owner->m_commentsSettings.m_generateBrief); + m_leadingAsterisksCheckBox->setChecked(m_owner->m_commentsSettings.m_leadingAsterisks); - m_ui.generateBriefCheckBox->setEnabled(m_ui.enableDoxygenCheckBox->isChecked()); - m_ui.skipAutoComplete->setEnabled(m_ui.highlightAutoComplete->isChecked()); - m_ui.removeAutoComplete->setEnabled(m_ui.highlightAutoComplete->isChecked()); + m_generateBriefCheckBox->setEnabled(m_enableDoxygenCheckBox->isChecked()); + m_skipAutoComplete->setEnabled(m_highlightAutoComplete->isChecked()); + m_removeAutoComplete->setEnabled(m_highlightAutoComplete->isChecked()); + + using namespace Layouting; + auto indent = [](QWidget *widget) { return Row { Space(30), widget }; }; + + Column { + Group { + title(tr("Behavior")), + Form { + caseSensitivityLabel, m_caseSensitivity, st, br, + completionTriggerLabel, m_completionTrigger, st, br, + automaticProposalTimeoutLabel, m_automaticProposalTimeoutSpinBox, st, br, + thresholdLabel, m_thresholdSpinBox, st, br, + Span(2, m_partiallyComplete), br, + Span(2, m_autoSplitStrings), br, + } + }, + Group { + title(tr("&Automatically insert matching characters")), + Row { + Column { + m_insertBrackets, + m_surroundBrackets, + m_spaceAfterFunctionName, + m_highlightAutoComplete, + indent(m_skipAutoComplete), + indent(m_removeAutoComplete) + }, + Column { + m_insertQuotes, + m_surroundQuotes, + m_animateAutoComplete, + m_overwriteClosingChars, + st, + } + } + }, + Group { + title(tr("Documentation Comments")), + Column { + m_enableDoxygenCheckBox, + indent(m_generateBriefCheckBox), + m_leadingAsterisksCheckBox + } + }, + st + }.attachTo(this); + + connect(m_enableDoxygenCheckBox, &QCheckBox::toggled, m_generateBriefCheckBox, &QCheckBox::setEnabled); + connect(m_highlightAutoComplete, &QCheckBox::toggled, m_skipAutoComplete, &QCheckBox::setEnabled); + connect(m_highlightAutoComplete, &QCheckBox::toggled, m_removeAutoComplete, &QCheckBox::setEnabled); } void CompletionSettingsPageWidget::apply() @@ -145,7 +321,7 @@ void CompletionSettingsPageWidget::apply() CaseSensitivity CompletionSettingsPageWidget::caseSensitivity() const { - switch (m_ui.caseSensitivity->currentIndex()) { + switch (m_caseSensitivity->currentIndex()) { case 0: // Full return TextEditor::CaseSensitive; case 1: // None @@ -157,7 +333,7 @@ CaseSensitivity CompletionSettingsPageWidget::caseSensitivity() const CompletionTrigger CompletionSettingsPageWidget::completionTrigger() const { - switch (m_ui.completionTrigger->currentIndex()) { + switch (m_completionTrigger->currentIndex()) { case 0: return TextEditor::ManualCompletion; case 1: @@ -173,32 +349,32 @@ void CompletionSettingsPageWidget::settingsFromUi(CompletionSettings &completion completion.m_caseSensitivity = caseSensitivity(); completion.m_completionTrigger = completionTrigger(); completion.m_automaticProposalTimeoutInMs - = m_ui.automaticProposalTimeoutSpinBox->value(); - completion.m_characterThreshold = m_ui.thresholdSpinBox->value(); - completion.m_autoInsertBrackets = m_ui.insertBrackets->isChecked(); - completion.m_surroundingAutoBrackets = m_ui.surroundBrackets->isChecked(); - completion.m_autoInsertQuotes = m_ui.insertQuotes->isChecked(); - completion.m_surroundingAutoQuotes = m_ui.surroundQuotes->isChecked(); - completion.m_partiallyComplete = m_ui.partiallyComplete->isChecked(); - completion.m_spaceAfterFunctionName = m_ui.spaceAfterFunctionName->isChecked(); - completion.m_autoSplitStrings = m_ui.autoSplitStrings->isChecked(); - completion.m_animateAutoComplete = m_ui.animateAutoComplete->isChecked(); - completion.m_overwriteClosingChars = m_ui.overwriteClosingChars->isChecked(); - completion.m_highlightAutoComplete = m_ui.highlightAutoComplete->isChecked(); - completion.m_skipAutoCompletedText = m_ui.skipAutoComplete->isChecked(); - completion.m_autoRemove = m_ui.removeAutoComplete->isChecked(); + = m_automaticProposalTimeoutSpinBox->value(); + completion.m_characterThreshold = m_thresholdSpinBox->value(); + completion.m_autoInsertBrackets = m_insertBrackets->isChecked(); + completion.m_surroundingAutoBrackets = m_surroundBrackets->isChecked(); + completion.m_autoInsertQuotes = m_insertQuotes->isChecked(); + completion.m_surroundingAutoQuotes = m_surroundQuotes->isChecked(); + completion.m_partiallyComplete = m_partiallyComplete->isChecked(); + completion.m_spaceAfterFunctionName = m_spaceAfterFunctionName->isChecked(); + completion.m_autoSplitStrings = m_autoSplitStrings->isChecked(); + completion.m_animateAutoComplete = m_animateAutoComplete->isChecked(); + completion.m_overwriteClosingChars = m_overwriteClosingChars->isChecked(); + completion.m_highlightAutoComplete = m_highlightAutoComplete->isChecked(); + completion.m_skipAutoCompletedText = m_skipAutoComplete->isChecked(); + completion.m_autoRemove = m_removeAutoComplete->isChecked(); - comment.m_enableDoxygen = m_ui.enableDoxygenCheckBox->isChecked(); - comment.m_generateBrief = m_ui.generateBriefCheckBox->isChecked(); - comment.m_leadingAsterisks = m_ui.leadingAsterisksCheckBox->isChecked(); + comment.m_enableDoxygen = m_enableDoxygenCheckBox->isChecked(); + comment.m_generateBrief = m_generateBriefCheckBox->isChecked(); + comment.m_leadingAsterisks = m_leadingAsterisksCheckBox->isChecked(); } -const CompletionSettings &CompletionSettingsPage::completionSettings() +const CompletionSettings &CompletionSettingsPage::completionSettings() const { return m_completionSettings; } -const CommentsSettings &CompletionSettingsPage::commentsSettings() +const CommentsSettings &CompletionSettingsPage::commentsSettings() const { return m_commentsSettings; } diff --git a/src/plugins/texteditor/completionsettingspage.h b/src/plugins/texteditor/completionsettingspage.h index f06076d414c..d202757c6ea 100644 --- a/src/plugins/texteditor/completionsettingspage.h +++ b/src/plugins/texteditor/completionsettingspage.h @@ -38,8 +38,8 @@ class CompletionSettingsPage : public Core::IOptionsPage public: CompletionSettingsPage(); - const CompletionSettings & completionSettings(); - const CommentsSettings & commentsSettings(); + const CompletionSettings &completionSettings() const; + const CommentsSettings &commentsSettings() const; private: friend class CompletionSettingsPageWidget; diff --git a/src/plugins/texteditor/completionsettingspage.ui b/src/plugins/texteditor/completionsettingspage.ui deleted file mode 100644 index 16d1fc47ec5..00000000000 --- a/src/plugins/texteditor/completionsettingspage.ui +++ /dev/null @@ -1,523 +0,0 @@ - - - TextEditor::Internal::CompletionSettingsPage - - - - 0 - 0 - 823 - 756 - - - - - - - Behavior - - - - - - - - &Case-sensitivity: - - - caseSensitivity - - - - - - - - - - 0 - 0 - - - - - Full - - - - - None - - - - - First Letter - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Activate completion: - - - - - - - - - - Manually - - - - - When Triggered - - - - - Always - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Timeout in ms: - - - - - - - - - 2000 - - - 50 - - - 400 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Character threshold: - - - - - - - - - 1 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Inserts the common prefix of available completion items. - - - Autocomplete common &prefix - - - true - - - - - - - Splits a string into two lines by adding an end quote at the cursor position when you press Enter and a start quote to the next line, before the rest of the string. - -In addition, Shift+Enter inserts an escape character at the cursor position and moves the rest of the string to the next line. - - - Automatically split strings - - - - - - - - - - - - &Automatically insert matching characters - - - - - - Insert opening or closing brackets - - - true - - - - - - - Insert closing quote - - - true - - - - - - - When typing a matching bracket and there is a text selection, instead of removing the selection, surrounds it with the corresponding characters. - - - Surround text selection with brackets - - - true - - - - - - - true - - - Insert &space after function name - - - - - - - When typing a matching quote and there is a text selection, instead of removing the selection, surrounds it with the corresponding characters. - - - Surround text selection with quotes - - - true - - - - - - - Show a visual hint when for example a brace or a quote is automatically inserted by the editor. - - - Animate automatically inserted text - - - true - - - - - - - Highlight automatically inserted text - - - true - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 30 - 20 - - - - - - - - Skip automatically inserted character if re-typed manually after completion or by pressing tab. - - - Skip automatically inserted character when typing - - - true - - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 30 - 20 - - - - - - - - Remove the automatically inserted character if the trigger is deleted by backspace after the completion. - - - Remove automatically inserted text on backspace - - - true - - - - - - - - - Automatically overwrite closing parentheses and quotes. - - - Overwrite closing punctuation - - - - - - - - - - Documentation Comments - - - - - - Automatically creates a Doxygen comment upon pressing enter after a '/**', '/*!', '//!' or '///'. - - - Enable Doxygen blocks - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 30 - 20 - - - - - - - - Generates a <i>brief</i> command with an initial description for the corresponding declaration. - - - Generate brief description - - - - - - - - - Adds leading asterisks when continuing C/C++ "/*", Qt "/*!" and Java "/**" style comments on new lines. - - - Add leading asterisks - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - caseSensitivity - completionTrigger - automaticProposalTimeoutSpinBox - partiallyComplete - autoSplitStrings - insertBrackets - insertQuotes - surroundBrackets - surroundQuotes - spaceAfterFunctionName - animateAutoComplete - highlightAutoComplete - skipAutoComplete - removeAutoComplete - enableDoxygenCheckBox - generateBriefCheckBox - leadingAsterisksCheckBox - - - - - enableDoxygenCheckBox - toggled(bool) - generateBriefCheckBox - setEnabled(bool) - - - 216 - 411 - - - 378 - 438 - - - - - highlightAutoComplete - toggled(bool) - skipAutoComplete - setEnabled(bool) - - - 176 - 277 - - - 186 - 306 - - - - - highlightAutoComplete - toggled(bool) - removeAutoComplete - setEnabled(bool) - - - 223 - 275 - - - 226 - 333 - - - - - diff --git a/src/plugins/texteditor/texteditor.qbs b/src/plugins/texteditor/texteditor.qbs index 9532c095576..c96ada6a84d 100644 --- a/src/plugins/texteditor/texteditor.qbs +++ b/src/plugins/texteditor/texteditor.qbs @@ -58,7 +58,6 @@ Project { "completionsettings.h", "completionsettingspage.cpp", "completionsettingspage.h", - "completionsettingspage.ui", "displaysettings.cpp", "displaysettings.h", "displaysettingspage.cpp",