- 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
- fix: text color for cpu info dialog not correctly setted

View File

@ -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;i<pMainWindow->editorList()->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;i<mUnits.count();i++) {
layIni.beginGroup(QString("Editor_%1").arg(i));
QByteArray groupName = QString("Editor_%1").arg(i).toUtf8();
PProjectUnit unit = mUnits[i];
Editor* editor = unit->editor();
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 && topLeft<mUnits.count() && mUnits[topLeft]->editor()) {
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()

View File

@ -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();