2021-12-26 23:18:28 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2021-08-30 16:59:08 +08:00
|
|
|
#include "editorcodecompletionwidget.h"
|
|
|
|
#include "ui_editorcodecompletionwidget.h"
|
|
|
|
#include "../settings.h"
|
2021-09-30 11:20:43 +08:00
|
|
|
#include "../mainwindow.h"
|
|
|
|
#include "../symbolusagemanager.h"
|
2021-08-30 16:59:08 +08:00
|
|
|
|
|
|
|
EditorCodeCompletionWidget::EditorCodeCompletionWidget(const QString& name, const QString& group,
|
|
|
|
QWidget *parent) :
|
|
|
|
SettingsWidget(name,group,parent),
|
|
|
|
ui(new Ui::EditorCodeCompletionWidget)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2023-08-11 13:49:09 +08:00
|
|
|
ui->chkClearWhenEditorHidden->setVisible(false);
|
2021-08-30 16:59:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
EditorCodeCompletionWidget::~EditorCodeCompletionWidget()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorCodeCompletionWidget::doLoad()
|
|
|
|
{
|
|
|
|
ui->grpEnabled->setChecked(pSettings->codeCompletion().enabled());
|
|
|
|
|
|
|
|
ui->chkParseLocalFiles->setChecked(pSettings->codeCompletion().parseLocalHeaders());
|
|
|
|
ui->chkParseSystemFiles->setChecked(pSettings->codeCompletion().parseGlobalHeaders());
|
|
|
|
|
|
|
|
ui->spinWidth->setValue(pSettings->codeCompletion().width());
|
|
|
|
ui->spinHeight->setValue(pSettings->codeCompletion().height());
|
|
|
|
|
|
|
|
ui->chkShowSuggestionWhileTyping->setChecked(pSettings->codeCompletion().showCompletionWhileInput());
|
|
|
|
ui->chkRecordUsage->setChecked(pSettings->codeCompletion().recordUsage());
|
|
|
|
ui->chkSortByScope->setChecked(pSettings->codeCompletion().sortByScope());
|
|
|
|
ui->chkShowKeywords->setChecked(pSettings->codeCompletion().showKeywords());
|
|
|
|
ui->chkIgnoreCases->setChecked(pSettings->codeCompletion().ignoreCase());
|
|
|
|
ui->chkAppendFunc->setChecked(pSettings->codeCompletion().appendFunc());
|
|
|
|
ui->chkShowCodeIns->setChecked(pSettings->codeCompletion().showCodeIns());
|
2023-08-11 13:49:09 +08:00
|
|
|
// ui->chkClearWhenEditorHidden->setChecked(pSettings->codeCompletion().clearWhenEditorHidden());
|
2022-03-01 22:03:54 +08:00
|
|
|
ui->chkHideSymbolsStartWithTwoUnderline->setChecked(pSettings->codeCompletion().hideSymbolsStartsWithTwoUnderLine());
|
|
|
|
ui->chkHideSymbolsStartWithUnderline->setChecked(pSettings->codeCompletion().hideSymbolsStartsWithUnderLine());
|
2022-01-10 21:46:03 +08:00
|
|
|
|
2022-10-27 15:18:57 +08:00
|
|
|
ui->chkEditorShareCodeParser->setChecked(pSettings->codeCompletion().shareParser());
|
2022-01-10 21:46:03 +08:00
|
|
|
ui->spinMinCharRequired->setValue(pSettings->codeCompletion().minCharRequired());
|
2021-08-30 16:59:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorCodeCompletionWidget::doSave()
|
|
|
|
{
|
|
|
|
//font
|
|
|
|
pSettings->codeCompletion().setEnabled(ui->grpEnabled->isChecked());
|
|
|
|
|
|
|
|
pSettings->codeCompletion().setParseLocalHeaders(ui->chkParseLocalFiles->isChecked());
|
|
|
|
pSettings->codeCompletion().setParseGlobalHeaders(ui->chkParseSystemFiles->isChecked());
|
|
|
|
|
|
|
|
pSettings->codeCompletion().setWidth(ui->spinWidth->value());
|
|
|
|
pSettings->codeCompletion().setHeight(ui->spinHeight->value());
|
|
|
|
|
|
|
|
pSettings->codeCompletion().setShowCompletionWhileInput(ui->chkShowSuggestionWhileTyping->isChecked());
|
|
|
|
pSettings->codeCompletion().setRecordUsage(ui->chkRecordUsage->isChecked());
|
|
|
|
pSettings->codeCompletion().setSortByScope(ui->chkSortByScope->isChecked());
|
|
|
|
pSettings->codeCompletion().setShowKeywords(ui->chkShowKeywords->isChecked());
|
|
|
|
pSettings->codeCompletion().setIgnoreCase(ui->chkIgnoreCases->isChecked());
|
|
|
|
pSettings->codeCompletion().setAppendFunc(ui->chkAppendFunc->isChecked());
|
|
|
|
pSettings->codeCompletion().setShowCodeIns(ui->chkShowCodeIns->isChecked());
|
2022-01-10 21:46:03 +08:00
|
|
|
pSettings->codeCompletion().setMinCharRequired(ui->spinMinCharRequired->value());
|
|
|
|
|
2023-08-11 13:49:09 +08:00
|
|
|
//pSettings->codeCompletion().setClearWhenEditorHidden(ui->chkClearWhenEditorHidden->isChecked());
|
2021-08-30 16:59:08 +08:00
|
|
|
|
2022-03-01 22:03:54 +08:00
|
|
|
pSettings->codeCompletion().setHideSymbolsStartsWithTwoUnderLine(ui->chkHideSymbolsStartWithTwoUnderline->isChecked());
|
|
|
|
pSettings->codeCompletion().setHideSymbolsStartsWithUnderLine(ui->chkHideSymbolsStartWithUnderline->isChecked());
|
|
|
|
|
2022-10-27 15:18:57 +08:00
|
|
|
pSettings->codeCompletion().setShareParser(ui->chkEditorShareCodeParser->isChecked());
|
|
|
|
|
2021-08-30 19:52:38 +08:00
|
|
|
pSettings->codeCompletion().save();
|
2021-08-30 16:59:08 +08:00
|
|
|
}
|
|
|
|
|
2021-09-30 11:20:43 +08:00
|
|
|
|
|
|
|
void EditorCodeCompletionWidget::on_btnClearUsageData_clicked()
|
|
|
|
{
|
|
|
|
pMainWindow->symbolUsageManager()->reset();
|
|
|
|
}
|
|
|
|
|