- 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
This commit is contained in:
royqh1979@gmail.com 2021-11-17 10:55:18 +08:00
parent d2821ac7f2
commit 01d7335ba2
3 changed files with 50 additions and 38 deletions

View File

@ -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 Version 0.8.11 For Dev-C++ 7 Beta
- fix: text color for cpu info dialog not correctly setted - fix: text color for cpu info dialog not correctly setted

View File

@ -420,7 +420,7 @@ void Project::saveAll()
void Project::saveLayout() void Project::saveLayout()
{ {
QSettings layIni(changeFileExt(mFilename, "layout"),QSettings::IniFormat); SimpleIni layIni;
QStringList sl; QStringList sl;
// Write list of open project files // Write list of open project files
for (int i=0;i<pMainWindow->editorList()->pageCount();i++) { for (int i=0;i<pMainWindow->editorList()->pageCount();i++) {
@ -428,39 +428,37 @@ void Project::saveLayout()
if (e && e->inProject()) if (e && e->inProject())
sl.append(QString("%1").arg(indexInUnits(e))); sl.append(QString("%1").arg(indexInUnits(e)));
} }
layIni.beginGroup("Editors"); layIni.SetValue("Editors","Order",sl.join(",").toUtf8());
layIni.setValue("Order",sl.join(","));
Editor *e, *e2; Editor *e, *e2;
// Remember what files were visible // Remember what files were visible
pMainWindow->editorList()->getVisibleEditors(e, e2); pMainWindow->editorList()->getVisibleEditors(e, e2);
if (e) if (e)
layIni.setValue("Focused", indexInUnits(e)); layIni.SetLongValue("Editors","Focused", indexInUnits(e));
layIni.endGroup();
// save editor info // save editor info
for (int i=0;i<mUnits.count();i++) { for (int i=0;i<mUnits.count();i++) {
layIni.beginGroup(QString("Editor_%1").arg(i)); QByteArray groupName = QString("Editor_%1").arg(i).toUtf8();
PProjectUnit unit = mUnits[i]; PProjectUnit unit = mUnits[i];
Editor* editor = unit->editor(); Editor* editor = unit->editor();
if (editor) { if (editor) {
layIni.setValue("CursorCol", editor->caretX()); layIni.SetLongValue(groupName,"CursorCol", editor->caretX());
layIni.setValue("CursorRow", editor->caretY()); layIni.SetLongValue(groupName,"CursorRow", editor->caretY());
layIni.setValue("TopLine", editor->topLine()); layIni.SetLongValue(groupName,"TopLine", editor->topLine());
layIni.setValue("LeftChar", editor->leftChar()); layIni.SetLongValue(groupName,"LeftChar", editor->leftChar());
} }
layIni.endGroup();
// remove old data from project file // remove old data from project file
SimpleIni ini; SimpleIni ini;
ini.LoadFile(mFilename.toLocal8Bit()); ini.LoadFile(filename().toLocal8Bit());
QByteArray groupName = toByteArray(QString("Unit%1").arg(i+1)); groupName = toByteArray(QString("Unit%1").arg(i+1));
ini.Delete(groupName,"Open"); ini.Delete(groupName,"Open");
ini.Delete(groupName,"Top"); ini.Delete(groupName,"Top");
ini.Delete(groupName,"CursorCol"); ini.Delete(groupName,"CursorCol");
ini.Delete(groupName,"CursorRow"); ini.Delete(groupName,"CursorRow");
ini.Delete(groupName,"TopLine"); ini.Delete(groupName,"TopLine");
ini.Delete(groupName,"LeftChar"); 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) void Project::saveUnitAs(int i, const QString &sFileName, bool syncEditor)
@ -500,20 +498,22 @@ void Project::saveUnitLayout(Editor *e, int index)
{ {
if (!e) if (!e)
return; return;
QSettings layIni = QSettings(changeFileExt(filename(), "layout")); SimpleIni layIni;
layIni.beginGroup(QString("Editor_%1").arg(index)); QByteArray groupName = (QString("Editor_%1").arg(index)).toUtf8();
layIni.setValue("CursorCol", e->caretX()); layIni.SetLongValue(groupName,"CursorCol", e->caretX());
layIni.setValue("CursorRow", e->caretY()); layIni.SetLongValue(groupName,"CursorRow", e->caretY());
layIni.setValue("TopLine", e->topLine()); layIni.SetLongValue(groupName,"TopLine", e->topLine());
layIni.setValue("LeftChar", e->leftChar()); layIni.SetLongValue(groupName,"LeftChar", e->leftChar());
layIni.endGroup(); layIni.SaveFile((changeFileExt(filename(), "layout")).toLocal8Bit());
} }
bool Project::saveUnits() bool Project::saveUnits()
{ {
int count = 0; int count = 0;
SimpleIni ini; 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++) { for (int idx = 0; idx < mUnits.count(); idx++) {
PProjectUnit unit = mUnits[idx]; PProjectUnit unit = mUnits[idx];
bool rd_only = false; bool rd_only = false;
@ -1302,12 +1302,13 @@ QString Project::listUnitStr(const QChar &separator)
void Project::loadLayout() void Project::loadLayout()
{ {
QSettings layIni = QSettings(changeFileExt(filename(), "layout"),QSettings::IniFormat); SimpleIni layIni;
layIni.beginGroup("Editors"); SI_Error error = layIni.LoadFile(changeFileExt(filename(), "layout").toLocal8Bit());
int topLeft = layIni.value("Focused", -1).toInt(); if (error!=SI_OK)
return;
int topLeft = layIni.GetLongValue("Editors","Focused",1);
//TopRight := layIni.ReadInteger('Editors', 'FocusedRight', -1); //TopRight := layIni.ReadInteger('Editors', 'FocusedRight', -1);
QString temp =layIni.value("Order", "").toString(); QString temp =layIni.GetValue("Editors","Order", "");
layIni.endGroup();
QStringList sl = temp.split(",",Qt::SkipEmptyParts); QStringList sl = temp.split(",",Qt::SkipEmptyParts);
foreach (const QString& s,sl) { foreach (const QString& s,sl) {
@ -1320,7 +1321,6 @@ void Project::loadLayout()
if (topLeft>=0 && topLeft<mUnits.count() && mUnits[topLeft]->editor()) { if (topLeft>=0 && topLeft<mUnits.count() && mUnits[topLeft]->editor()) {
mUnits[topLeft]->editor()->activate(); mUnits[topLeft]->editor()->activate();
} }
} }
void Project::loadOptions(SimpleIni& ini) void Project::loadOptions(SimpleIni& ini)
@ -1456,13 +1456,16 @@ void Project::loadUnitLayout(Editor *e, int index)
{ {
if (!e) if (!e)
return; return;
QSettings layIni(changeFileExt(filename(), "layout"), QSettings::IniFormat); SimpleIni layIni;
layIni.beginGroup(QString("Editor_%1").arg(index)); SI_Error error;
e->setCaretY(layIni.value("CursorRow",1).toInt()); error = layIni.LoadFile(changeFileExt(filename(), "layout").toLocal8Bit());
e->setCaretX(layIni.value("CursorCol",1).toInt()); if (error != SI_Error::SI_OK)
e->setTopLine(layIni.value("TopLine",1).toInt()); return;
e->setLeftChar(layIni.value("LeftChar",1).toInt()); QByteArray groupName = (QString("Editor_%1").arg(index)).toUtf8();
layIni.endGroup(); 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() PCppParser Project::cppParser()

View File

@ -108,7 +108,9 @@ PSynEditKeyStroke SynEditKeyStrokes::findCommand(SynEditorCommand command)
PSynEditKeyStroke SynEditKeyStrokes::findKeycode(int key, Qt::KeyboardModifiers modifiers) PSynEditKeyStroke SynEditKeyStrokes::findKeycode(int key, Qt::KeyboardModifiers modifiers)
{ {
for (PSynEditKeyStroke& keyStroke:mList) { 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 keyStroke;
} }
return PSynEditKeyStroke(); return PSynEditKeyStroke();
@ -118,8 +120,10 @@ PSynEditKeyStroke SynEditKeyStrokes::findKeycode2(int key, Qt::KeyboardModifiers
int key2, Qt::KeyboardModifiers modifiers2) int key2, Qt::KeyboardModifiers modifiers2)
{ {
for (PSynEditKeyStroke& keyStroke:mList) { for (PSynEditKeyStroke& keyStroke:mList) {
if (keyStroke->key() == key && keyStroke->keyModifiers()==modifiers && keyStroke->key2()==key2 if (keyStroke->key() == key
&& keyStroke->keyModifiers2() ==modifiers2) && keyStroke->keyModifiers()==(modifiers & ~ Qt::KeypadModifier)
&& keyStroke->key2()==key2
&& keyStroke->keyModifiers2()== (modifiers2 & ~ Qt::KeypadModifier))
return keyStroke; return keyStroke;
} }
return PSynEditKeyStroke(); return PSynEditKeyStroke();