* work save: symbol completion settings

This commit is contained in:
royqh1979 2021-06-21 16:25:21 +08:00
parent 08a89abe59
commit bec57498ed
10 changed files with 402 additions and 6 deletions

View File

@ -40,6 +40,7 @@ SOURCES += \
settingsdialog/editorcolorschemewidget.cpp \
settingsdialog/editorfontwidget.cpp \
settingsdialog/editorgeneralwidget.cpp \
settingsdialog/editorsymbolcompletionwidget.cpp \
settingsdialog/environmentappearencewidget.cpp \
settingsdialog/settingsdialog.cpp \
settingsdialog/settingswidget.cpp \
@ -81,6 +82,7 @@ HEADERS += \
settingsdialog/editorcolorschemewidget.h \
settingsdialog/editorfontwidget.h \
settingsdialog/editorgeneralwidget.h \
settingsdialog/editorsymbolcompletionwidget.h \
settingsdialog/environmentappearencewidget.h \
settingsdialog/settingsdialog.h \
settingsdialog/settingswidget.h \
@ -99,6 +101,7 @@ FORMS += \
settingsdialog/editorcolorschemewidget.ui \
settingsdialog/editorfontwidget.ui \
settingsdialog/editorgeneralwidget.ui \
settingsdialog/editorsymbolcompletionwidget.ui \
settingsdialog/environmentappearencewidget.ui \
settingsdialog/settingsdialog.ui

View File

@ -247,6 +247,34 @@ void Editor::focusOutEvent(QFocusEvent *event)
pMainWindow->updateForStatusbarModeInfo();
}
void Editor::keyPressEvent(QKeyEvent *event)
{
bool handled = false;
QString t = event->text();
if (!t.isEmpty()) {
QChar ch = t;
switch (ch.unicode()) {
case '"':
case '\'':
case '(':
case ')':
case '{':
case '}':
case '[':
case ']':
case '<':
case '>':
case ';':
handled = handleSymbolCompletion(ch);
}
}
if (!handled) {
SynEdit::keyPressEvent(event);
} else {
event->accept();
}
}
void Editor::copyToClipboard()
{
if (pSettings->editor().copySizeLimit()) {
@ -403,7 +431,12 @@ void Editor::onStatusChanged(SynStatusChanges changes)
pMainWindow->updateEditorActions();
// mainForm.CaretList.AddCaret(self,fText.CaretY,fText.CaretX);
// mainForm.CaretList.AddCaret(self,fText.CaretY,fText.CaretX);
}
bool Editor::handleSymbolCompletion(QChar ch)
{
}
void Editor::applySettings()

View File

@ -79,6 +79,9 @@ protected slots:
void onModificationChanged(bool status) ;
void onStatusChanged(SynStatusChanges changes);
private:
bool handleSymbolCompletion(QChar ch);
private:
static int newfileCount;
QByteArray mEncodingOption; // the encoding type set by the user
@ -93,6 +96,7 @@ protected:
void wheelEvent(QWheelEvent *event) override;
void focusInEvent(QFocusEvent *event);
void focusOutEvent(QFocusEvent *event);
void keyPressEvent(QKeyEvent *event);
};
#endif // EDITOR_H

View File

@ -293,6 +293,106 @@ void Settings::Editor::setColorScheme(const QString &colorScheme)
mColorScheme = colorScheme;
}
bool Settings::Editor::removeMathcingSymbol() const
{
return mRemoveMathcingSymbol;
}
void Settings::Editor::setRemoveMathcingSymbol(bool removeMathcingSymbol)
{
mRemoveMathcingSymbol = removeMathcingSymbol;
}
bool Settings::Editor::overwriteSymbols() const
{
return mOverwriteSymbols;
}
void Settings::Editor::setOverwriteSymbols(bool overwriteSymbols)
{
mOverwriteSymbols = overwriteSymbols;
}
bool Settings::Editor::completeGlobalInclude() const
{
return mCompleteGlobalInclude;
}
void Settings::Editor::setCompleteGlobalInclude(bool completeGlobalInclude)
{
mCompleteGlobalInclude = completeGlobalInclude;
}
bool Settings::Editor::completeDoubleQuote() const
{
return mCompleteDoubleQuote;
}
void Settings::Editor::setCompleteDoubleQuote(bool completeDoubleQuote)
{
mCompleteDoubleQuote = completeDoubleQuote;
}
bool Settings::Editor::completeSingleQuote() const
{
return mCompleteSingleQuote;
}
void Settings::Editor::setCompleteSingleQuote(bool completeSingleQuote)
{
mCompleteSingleQuote = completeSingleQuote;
}
bool Settings::Editor::completeComment() const
{
return mCompleteComment;
}
void Settings::Editor::setCompleteComment(bool completeComment)
{
mCompleteComment = completeComment;
}
bool Settings::Editor::completeBrace() const
{
return mCompleteBrace;
}
void Settings::Editor::setCompleteBrace(bool completeBrace)
{
mCompleteBrace = completeBrace;
}
bool Settings::Editor::completeBracket() const
{
return mCompleteBracket;
}
void Settings::Editor::setCompleteBracket(bool completeBracket)
{
mCompleteBracket = completeBracket;
}
bool Settings::Editor::completeParenthese() const
{
return mCompleteParenthese;
}
void Settings::Editor::setCompleteParenthese(bool completeParenthese)
{
mCompleteParenthese = completeParenthese;
}
bool Settings::Editor::completeSymbols() const
{
return mCompleteSymbols;
}
void Settings::Editor::setCompleteSymbols(bool completeSymbols)
{
mCompleteSymbols = completeSymbols;
}
QString Settings::Editor::copyHTMLColorScheme() const
{
return mCopyHTMLColorScheme;
@ -610,6 +710,18 @@ void Settings::Editor::doSave()
//color scheme
saveValue("color_scheme", mColorScheme);
//Symbol Completion
saveValue("complete_symbols", mCompleteSymbols);
saveValue("complete_parenthese", mCompleteParenthese);
saveValue("complete_bracket", mCompleteBracket);
saveValue("complete_brace", mCompleteBrace);
saveValue("complete_comment", mCompleteComment);
saveValue("complete_single_quote", mCompleteSingleQuote);
saveValue("complete_double_quote", mCompleteDoubleQuote);
saveValue("complete_global_include", mCompleteGlobalInclude);
saveValue("overwrite_symbols", mOverwriteSymbols);
saveValue("remove_matching_symbols",mRemoveMathcingSymbol);
}
void Settings::Editor::doLoad()
@ -664,13 +776,25 @@ void Settings::Editor::doLoad()
mCopyWithFormatAs = intValue("copy_with_format_as",0);
mCopyRTFUseBackground = boolValue("copy_rtf_use_background",false);
mCopyRTFUseEditorColor = boolValue("copy_rtf_use_editor_color_scheme",true);
mCopyRTFColorScheme = stringValue("copy_rtf_color_scheme","");
mCopyRTFColorScheme = stringValue("copy_rtf_color_scheme","Intellij Classic");
mCopyHTMLUseBackground = boolValue("copy_html_use_background",false);
mCopyHTMLUseEditorColor = boolValue("copy_html_use_editor_color_scheme",true);
mCopyHTMLColorScheme = stringValue("copy_html_color_scheme","");
mCopyHTMLColorScheme = stringValue("copy_html_color_scheme","Intellij Classic");
//color
mColorScheme = stringValue("color_scheme", "VS Code");
//Symbol Completion
mCompleteSymbols = boolValue("complete_symbols",true);
mCompleteParenthese = boolValue("complete_parenthese",true);
mCompleteBracket = boolValue("complete_bracket",true);
mCompleteBrace = boolValue("complete_brace",true);
mCompleteComment = boolValue("complete_comment",true);
mCompleteSingleQuote = boolValue("complete_single_quote",true);
mCompleteDoubleQuote = boolValue("complete_double_quote",true);
mCompleteGlobalInclude = boolValue("complete_global_include",true);
mOverwriteSymbols = boolValue("overwrite_symbols",true);
mRemoveMathcingSymbol = boolValue("remove_matching_symbols",true);
}
SynEditCaretType Settings::Editor::caretForOverwrite() const
@ -1833,7 +1957,7 @@ Settings::Environment::Environment(Settings *settings):_Base(settings, SETTING_E
void Settings::Environment::doLoad()
{
//Appearence
mTheme = stringValue("theme","default");
mTheme = stringValue("theme","dark");
mInterfaceFont = stringValue("interface font","Segoe UI");
mInterfaceFontSize = intValue("interface font size",10);
mLanguage = stringValue("language", QLocale::system().name());

View File

@ -218,6 +218,36 @@ public:
QString colorScheme() const;
void setColorScheme(const QString &colorScheme);
bool completeSymbols() const;
void setCompleteSymbols(bool completeSymbols);
bool completeParenthese() const;
void setCompleteParenthese(bool completeParenthese);
bool completeBracket() const;
void setCompleteBracket(bool completeBracket);
bool completeBrace() const;
void setCompleteBrace(bool completeBrace);
bool completeComment() const;
void setCompleteComment(bool completeComment);
bool completeSingleQuote() const;
void setCompleteSingleQuote(bool completeSingleQuote);
bool completeDoubleQuote() const;
void setCompleteDoubleQuote(bool completeDoubleQuote);
bool completeGlobalInclude() const;
void setCompleteGlobalInclude(bool completeGlobalInclude);
bool overwriteSymbols() const;
void setOverwriteSymbols(bool overwriteSymbols);
bool removeMathcingSymbol() const;
void setRemoveMathcingSymbol(bool removeMathcingSymbol);
private:
QByteArray mDefaultEncoding;
//General
@ -277,6 +307,18 @@ public:
//Color
QString mColorScheme;
//Symbol Completion
bool mCompleteSymbols;
bool mCompleteParenthese;
bool mCompleteBracket;
bool mCompleteBrace;
bool mCompleteComment;
bool mCompleteSingleQuote;
bool mCompleteDoubleQuote;
bool mCompleteGlobalInclude;
bool mOverwriteSymbols;
bool mRemoveMathcingSymbol;
// _Base interface
protected:
void doSave() override;

View File

@ -0,0 +1,14 @@
#include "editorsymbolcompletionwidget.h"
#include "ui_editorsymbolcompletionwidget.h"
EditorSymbolCompletionWidget::EditorSymbolCompletionWidget(const QString& name, const QString& group, QWidget *parent) :
SettingsWidget(name,group,parent),
ui(new Ui::EditorSymbolCompletionWidget)
{
ui->setupUi(this);
}
EditorSymbolCompletionWidget::~EditorSymbolCompletionWidget()
{
delete ui;
}

View File

@ -0,0 +1,28 @@
#ifndef EDITORSYMBOLCOMPLETIONWIDGET_H
#define EDITORSYMBOLCOMPLETIONWIDGET_H
#include <QWidget>
#include "settingswidget.h"
namespace Ui {
class EditorSymbolCompletionWidget;
}
class EditorSymbolCompletionWidget : public SettingsWidget
{
Q_OBJECT
public:
explicit EditorSymbolCompletionWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
~EditorSymbolCompletionWidget();
private:
Ui::EditorSymbolCompletionWidget *ui;
// SettingsWidget interface
protected:
void doLoad();
void doSave();
};
#endif // EDITORSYMBOLCOMPLETIONWIDGET_H

View File

@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EditorSymbolCompletionWidget</class>
<widget class="QWidget" name="EditorSymbolCompletionWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>606</width>
<height>413</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="grpCompleSymbols">
<property name="title">
<string>Complete Symbols</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>GroupBox</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>11</number>
</property>
<property name="topMargin">
<number>11</number>
</property>
<property name="rightMargin">
<number>11</number>
</property>
<property name="bottomMargin">
<number>11</number>
</property>
<item>
<widget class="QCheckBox" name="chkCompleteBrace">
<property name="text">
<string>Complete Braces{}</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkCompleteBracket">
<property name="text">
<string>Complete Brackets []</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkCompleteParenthesis">
<property name="text">
<string>Complete Parenthesis ()</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkCompleteComments">
<property name="text">
<string>Complete Multiline Comments /**/</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkCompleteSingleQuotation">
<property name="text">
<string>Complete Single Quotations ''</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkCompleteDoubleQuotation">
<property name="text">
<string>Complete Double Quotations &quot;&quot;</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkCompleteGlobalInclude">
<property name="text">
<string>Complete #include &lt;&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkSkipMathingSymbols">
<property name="text">
<string>Skip matching symbols while typing</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkRemoveMatchingSymbols">
<property name="text">
<string>Remove matching symbols when delete chars</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -6,6 +6,7 @@
#include "editorfontwidget.h"
#include "editorclipboardwidget.h"
#include "editorcolorschemewidget.h"
#include "editorsymbolcompletionwidget.h"
#include "environmentappearencewidget.h"
#include <QDebug>
#include <QMessageBox>
@ -47,7 +48,9 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
pEditorColorSchemeWidget->init();
addWidget(pEditorColorSchemeWidget);
pEditorSymbolCompletionWidget = new EditorSymbolCompletionWidget(tr("Symbol Completion"),tr("Editor"));
pEditorSymbolCompletionWidget->init();
addWidget(pEditorSymbolCompletionWidget);
ui->widgetsView->expandAll();
//select the first widget of the first group

View File

@ -10,11 +10,12 @@ namespace Ui {
class SettingsDialog;
}
class PCompilerSet;
class CompilerSetOptionWidget;
class EditorGeneralWidget;
class EditorFontWidget;
class EditorClipboardWidget;
class PCompilerSet;
class EditorSymbolCompletionWidget;
class EditorColorSchemeWidget;
class EnvironmentAppearenceWidget;
class SettingsWidget;
@ -52,6 +53,7 @@ private:
EditorClipboardWidget *pEditorClipboardWidget;
EditorColorSchemeWidget *pEditorColorSchemeWidget;
EnvironmentAppearenceWidget* pEnvironmentAppearenceWidget;
EditorSymbolCompletionWidget* pEditorSymbolCompletionWidget;
};
#endif // SETTINGSDIALOG_H