From 01d7335ba290922c90a3122ed6543b97952fd9fa Mon Sep 17 00:00:00 2001 From: "royqh1979@gmail.com" Date: Wed, 17 Nov 2021 10:55:18 +0800 Subject: [PATCH] - fix: control keys in the numpad doesn't work in the editor - fix: project layout infos are wrongly saved to registry - fix: project layout infos are not correctly saved/loaded --- NEWS.md | 5 ++ RedPandaIDE/project.cpp | 73 +++++++++++++++-------------- RedPandaIDE/qsynedit/KeyStrokes.cpp | 10 ++-- 3 files changed, 50 insertions(+), 38 deletions(-) diff --git a/NEWS.md b/NEWS.md index 1f61e99a..d6e99929 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +Version 0.8.12 For Dev-C++ 7 Beta + - fix: control keys in the numpad doesn't work in the editor + - fix: project layout infos are wrongly saved to registry + - fix: project layout infos are not correctly saved/loaded + Version 0.8.11 For Dev-C++ 7 Beta - fix: text color for cpu info dialog not correctly setted diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index 3e55b7a3..e6b76395 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -420,7 +420,7 @@ void Project::saveAll() void Project::saveLayout() { - QSettings layIni(changeFileExt(mFilename, "layout"),QSettings::IniFormat); + SimpleIni layIni; QStringList sl; // Write list of open project files for (int i=0;ieditorList()->pageCount();i++) { @@ -428,39 +428,37 @@ void Project::saveLayout() if (e && e->inProject()) sl.append(QString("%1").arg(indexInUnits(e))); } - layIni.beginGroup("Editors"); - layIni.setValue("Order",sl.join(",")); + layIni.SetValue("Editors","Order",sl.join(",").toUtf8()); Editor *e, *e2; // Remember what files were visible pMainWindow->editorList()->getVisibleEditors(e, e2); if (e) - layIni.setValue("Focused", indexInUnits(e)); - layIni.endGroup(); + layIni.SetLongValue("Editors","Focused", indexInUnits(e)); // save editor info for (int i=0;ieditor(); if (editor) { - layIni.setValue("CursorCol", editor->caretX()); - layIni.setValue("CursorRow", editor->caretY()); - layIni.setValue("TopLine", editor->topLine()); - layIni.setValue("LeftChar", editor->leftChar()); + layIni.SetLongValue(groupName,"CursorCol", editor->caretX()); + layIni.SetLongValue(groupName,"CursorRow", editor->caretY()); + layIni.SetLongValue(groupName,"TopLine", editor->topLine()); + layIni.SetLongValue(groupName,"LeftChar", editor->leftChar()); } - layIni.endGroup(); // remove old data from project file SimpleIni ini; - ini.LoadFile(mFilename.toLocal8Bit()); - QByteArray groupName = toByteArray(QString("Unit%1").arg(i+1)); + ini.LoadFile(filename().toLocal8Bit()); + groupName = toByteArray(QString("Unit%1").arg(i+1)); ini.Delete(groupName,"Open"); ini.Delete(groupName,"Top"); ini.Delete(groupName,"CursorCol"); ini.Delete(groupName,"CursorRow"); ini.Delete(groupName,"TopLine"); ini.Delete(groupName,"LeftChar"); - ini.SaveFile(mFilename.toLocal8Bit()); + ini.SaveFile(filename().toLocal8Bit()); } + layIni.SaveFile(changeFileExt(filename(), "layout").toLocal8Bit()); } void Project::saveUnitAs(int i, const QString &sFileName, bool syncEditor) @@ -500,20 +498,22 @@ void Project::saveUnitLayout(Editor *e, int index) { if (!e) return; - QSettings layIni = QSettings(changeFileExt(filename(), "layout")); - layIni.beginGroup(QString("Editor_%1").arg(index)); - layIni.setValue("CursorCol", e->caretX()); - layIni.setValue("CursorRow", e->caretY()); - layIni.setValue("TopLine", e->topLine()); - layIni.setValue("LeftChar", e->leftChar()); - layIni.endGroup(); + SimpleIni layIni; + QByteArray groupName = (QString("Editor_%1").arg(index)).toUtf8(); + layIni.SetLongValue(groupName,"CursorCol", e->caretX()); + layIni.SetLongValue(groupName,"CursorRow", e->caretY()); + layIni.SetLongValue(groupName,"TopLine", e->topLine()); + layIni.SetLongValue(groupName,"LeftChar", e->leftChar()); + layIni.SaveFile((changeFileExt(filename(), "layout")).toLocal8Bit()); } bool Project::saveUnits() { int count = 0; SimpleIni ini; - ini.LoadFile(mFilename.toLocal8Bit()); + SI_Error error = ini.LoadFile(mFilename.toLocal8Bit()); + if (error != SI_Error::SI_OK) + return false; for (int idx = 0; idx < mUnits.count(); idx++) { PProjectUnit unit = mUnits[idx]; bool rd_only = false; @@ -1302,12 +1302,13 @@ QString Project::listUnitStr(const QChar &separator) void Project::loadLayout() { - QSettings layIni = QSettings(changeFileExt(filename(), "layout"),QSettings::IniFormat); - layIni.beginGroup("Editors"); - int topLeft = layIni.value("Focused", -1).toInt(); + SimpleIni layIni; + SI_Error error = layIni.LoadFile(changeFileExt(filename(), "layout").toLocal8Bit()); + if (error!=SI_OK) + return; + int topLeft = layIni.GetLongValue("Editors","Focused",1); //TopRight := layIni.ReadInteger('Editors', 'FocusedRight', -1); - QString temp =layIni.value("Order", "").toString(); - layIni.endGroup(); + QString temp =layIni.GetValue("Editors","Order", ""); QStringList sl = temp.split(",",Qt::SkipEmptyParts); foreach (const QString& s,sl) { @@ -1320,7 +1321,6 @@ void Project::loadLayout() if (topLeft>=0 && topLefteditor()) { mUnits[topLeft]->editor()->activate(); } - } void Project::loadOptions(SimpleIni& ini) @@ -1456,13 +1456,16 @@ void Project::loadUnitLayout(Editor *e, int index) { if (!e) return; - QSettings layIni(changeFileExt(filename(), "layout"), QSettings::IniFormat); - layIni.beginGroup(QString("Editor_%1").arg(index)); - e->setCaretY(layIni.value("CursorRow",1).toInt()); - e->setCaretX(layIni.value("CursorCol",1).toInt()); - e->setTopLine(layIni.value("TopLine",1).toInt()); - e->setLeftChar(layIni.value("LeftChar",1).toInt()); - layIni.endGroup(); + SimpleIni layIni; + SI_Error error; + error = layIni.LoadFile(changeFileExt(filename(), "layout").toLocal8Bit()); + if (error != SI_Error::SI_OK) + return; + QByteArray groupName = (QString("Editor_%1").arg(index)).toUtf8(); + e->setCaretY(layIni.GetLongValue(groupName,"CursorRow",1)); + e->setCaretX(layIni.GetLongValue(groupName,"CursorCol",1)); + e->setTopLine(layIni.GetLongValue(groupName,"TopLine",1)); + e->setLeftChar(layIni.GetLongValue(groupName,"LeftChar",1)); } PCppParser Project::cppParser() diff --git a/RedPandaIDE/qsynedit/KeyStrokes.cpp b/RedPandaIDE/qsynedit/KeyStrokes.cpp index a9151463..6c8a2b35 100644 --- a/RedPandaIDE/qsynedit/KeyStrokes.cpp +++ b/RedPandaIDE/qsynedit/KeyStrokes.cpp @@ -108,7 +108,9 @@ PSynEditKeyStroke SynEditKeyStrokes::findCommand(SynEditorCommand command) PSynEditKeyStroke SynEditKeyStrokes::findKeycode(int key, Qt::KeyboardModifiers modifiers) { for (PSynEditKeyStroke& keyStroke:mList) { - if (keyStroke->key() == key && keyStroke->keyModifiers()==modifiers && keyStroke->key2()==0) + if (keyStroke->key() == key + && keyStroke->keyModifiers() == (modifiers & ~ Qt::KeypadModifier) + && keyStroke->key2()==0) return keyStroke; } return PSynEditKeyStroke(); @@ -118,8 +120,10 @@ PSynEditKeyStroke SynEditKeyStrokes::findKeycode2(int key, Qt::KeyboardModifiers int key2, Qt::KeyboardModifiers modifiers2) { for (PSynEditKeyStroke& keyStroke:mList) { - if (keyStroke->key() == key && keyStroke->keyModifiers()==modifiers && keyStroke->key2()==key2 - && keyStroke->keyModifiers2() ==modifiers2) + if (keyStroke->key() == key + && keyStroke->keyModifiers()==(modifiers & ~ Qt::KeypadModifier) + && keyStroke->key2()==key2 + && keyStroke->keyModifiers2()== (modifiers2 & ~ Qt::KeypadModifier)) return keyStroke; } return PSynEditKeyStroke();