- fix: Can't correctly set project file's encoding back to 'UTF-8'/'ANSI' in the project options dialog/files setting page.

This commit is contained in:
Roy Qu 2023-01-25 10:28:55 +08:00
parent 0ccec06f33
commit 35e3c9af8d
3 changed files with 8 additions and 2 deletions

View File

@ -16,6 +16,7 @@ Red Panda C++ Version 2.10
- fix: Settings in Options/Tools/General is messed up when switching items in the list. - fix: Settings in Options/Tools/General is messed up when switching items in the list.
- fix: Infos in the status bar not correctly updated when editor closed. - fix: Infos in the status bar not correctly updated when editor closed.
- change: Project's encoding shouldn't be set to "auto detect" - change: Project's encoding shouldn't be set to "auto detect"
- fix: Can't correctly set project file's encoding back to 'UTF-8'/'ANSI' in the project options dialog/files setting page.
Red Panda C++ Version 2.9 Red Panda C++ Version 2.9

View File

@ -529,9 +529,12 @@ const QByteArray& Editor::encodingOption() const noexcept{
return mEncodingOption; return mEncodingOption;
} }
void Editor::setEncodingOption(const QByteArray& encoding) noexcept{ void Editor::setEncodingOption(const QByteArray& encoding) noexcept{
if (mEncodingOption == encoding) QByteArray newEncoding=encoding;
if (mProject && encoding==ENCODING_PROJECT)
newEncoding=mProject->options().encoding;
if (mEncodingOption == newEncoding)
return; return;
mEncodingOption = encoding; mEncodingOption = newEncoding;
if (!isNew()) { if (!isNew()) {
try { try {
loadFile(); loadFile();

View File

@ -270,6 +270,8 @@ void ProjectFilesWidget::on_cbEncodingDetail_currentTextChanged(const QString &)
PProjectUnit unit = currentUnit(); PProjectUnit unit = currentUnit();
if(!unit) if(!unit)
return; return;
if (ui->cbEncodingDetail->currentText().isEmpty())
return;
unit->setEncoding(ui->cbEncodingDetail->currentText().toUtf8()); unit->setEncoding(ui->cbEncodingDetail->currentText().toUtf8());
} }