- fix: project files' charset settings doesn't work correctly

This commit is contained in:
royqh1979@gmail.com 2022-01-24 09:24:43 +08:00
parent d9f36ae3cd
commit 722d02d688
4 changed files with 14 additions and 4 deletions

View File

@ -16,6 +16,7 @@ Red Panda C++ Version 0.13.3
- fix: Undo in the editor will lose line indents when no highlighter is assigned (the editing file is a not c/cpp source file);
- enhancement: highlighter for GLSL (OpenGL Shading Language)
- add a new template for raylib shader apps
- fix: project files' charset settings doesn't work correctly
Red Panda C++ Version 0.13.2
- fix: "delete and exit" button in the environtment / folder option page doesn't work correctly

View File

@ -394,6 +394,8 @@ const QByteArray& Editor::encodingOption() const noexcept{
return mEncodingOption;
}
void Editor::setEncodingOption(const QByteArray& encoding) noexcept{
if (mEncodingOption == encoding)
return;
mEncodingOption = encoding;
if (!isNew())
loadFile();

View File

@ -980,7 +980,8 @@ void MainWindow::openFile(const QString &filename, QTabWidget* page)
unit = mProject->findUnitByFilename(filename);
}
bool inProject = (mProject && unit);
editor = mEditorList->newEditor(filename,ENCODING_AUTO_DETECT,
QByteArray encoding = unit ? unit->encoding() : ENCODING_AUTO_DETECT;
editor = mEditorList->newEditor(filename,encoding,
inProject, false, page);
if (mProject) {
mProject->associateEditorToUnit(editor,unit);
@ -2011,7 +2012,8 @@ void MainWindow::loadLastOpens()
unit = mProject->findUnitByFilename(editorFilename);
}
bool inProject = (mProject && unit);
Editor * editor = mEditorList->newEditor(editorFilename,ENCODING_AUTO_DETECT,inProject,false,page);
QByteArray encoding = unit ? unit->encoding() : ENCODING_AUTO_DETECT;
Editor * editor = mEditorList->newEditor(editorFilename, encoding, inProject,false,page);
if (mProject) {
mProject->associateEditorToUnit(editor,unit);
}

View File

@ -1760,7 +1760,12 @@ const QByteArray &ProjectUnit::encoding() const
void ProjectUnit::setEncoding(const QByteArray &newEncoding)
{
mEncoding = newEncoding;
if (mEncoding != newEncoding) {
if (mEditor) {
mEditor->setEncodingOption(newEncoding);
}
mEncoding = newEncoding;
}
}
bool ProjectUnit::modified() const