- enhancement: "Toggle readonly" in the Edit menu.

- fix: Error When save project units' encoding settings.
This commit is contained in:
Roy Qu 2023-01-02 16:50:30 +08:00
parent 96f9a898d0
commit 9296877b86
8 changed files with 711 additions and 665 deletions

View File

@ -8,6 +8,8 @@ Red Panda C++ Version 2.8
- fix: Resource compilation items is missing in the auto generated makefile, if the project's icon is removed and re-added.
- fix: Action "Run all problem cases" is triggered twice by one clicked.
- enhancement: "Switch Header/Source" in editor title bar context menu.
- enhancement: "Toggle readonly" in the Edit menu.
- fix: Error When save project units' encoding settings.
Red Panda C++ Version 2.7

View File

@ -571,6 +571,7 @@ void MainWindow::updateEditorActions(const Editor *e)
ui->actionGo_to_Line->setEnabled(false);
ui->actionLocate_in_Files_View->setEnabled(false);
ui->actionToggle_Readonly->setEnabled(false);
} else {
ui->actionAuto_Detect->setEnabled(true);
ui->actionEncode_in_ANSI->setEnabled(true);
@ -626,6 +627,7 @@ void MainWindow::updateEditorActions(const Editor *e)
ui->actionGo_to_Line->setEnabled(true);
ui->actionLocate_in_Files_View->setEnabled(!e->isNew());
ui->actionToggle_Readonly->setEnabled(!e->modified());
}
updateCompileActions(e);
@ -4820,6 +4822,8 @@ void MainWindow::onEditorTabContextMenu(QTabWidget* tabWidget, const QPoint &pos
menu.addAction(ui->actionClose);
menu.addAction(ui->actionClose_All);
menu.addSeparator();
menu.addAction(ui->actionToggle_Readonly);
menu.addSeparator();
menu.addAction(ui->actionOpen_Containing_Folder);
menu.addAction(ui->actionOpen_Terminal);
menu.addAction(ui->actionLocate_in_Files_View);
@ -9218,3 +9222,14 @@ void MainWindow::onExportFPSProblemSet()
}
}
void MainWindow::on_actionToggle_Readonly_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor && !editor->modified()) {
editor->setReadOnly(!editor->readOnly());
editor->updateCaption();
updateEditorActions(editor);
}
}

View File

@ -767,6 +767,8 @@ private slots:
void onExportFPSProblemSet();
void on_actionToggle_Readonly_triggered();
private:
Ui::MainWindow *ui;
EditorList *mEditorList;

View File

@ -200,6 +200,8 @@
<addaction name="actionDelete_to_Word_End"/>
<addaction name="actionDelete_to_BOL"/>
<addaction name="actionDelete_to_EOL"/>
<addaction name="separator"/>
<addaction name="actionToggle_Readonly"/>
</widget>
<widget class="QMenu" name="menuSearch">
<property name="title">
@ -3300,6 +3302,11 @@
<string>Trim trailing spaces</string>
</property>
</action>
<action name="actionToggle_Readonly">
<property name="text">
<string>Toggle Readonly</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -237,9 +237,11 @@ void Project::open()
newUnit->setOverrideBuildCmd(ini.GetBoolValue(groupName,"OverrideBuildCmd", false));
newUnit->setBuildCmd(fromByteArray(ini.GetValue(groupName,"BuildCmd", "")));
QByteArray defaultEncoding = toByteArray(mOptions.encoding);
//Compatibility
if (ini.GetBoolValue(groupName,"DetectEncoding",true)){
defaultEncoding = ENCODING_AUTO_DETECT;
}
newUnit->setEncoding(ini.GetValue(groupName, "FileEncoding",defaultEncoding));
if (QTextCodec::codecForName(newUnit->encoding())==nullptr) {
newUnit->setEncoding(ENCODING_AUTO_DETECT);
@ -758,9 +760,14 @@ bool Project::saveUnits()
ini.SetLongValue(groupName,"Priority", unit->priority());
ini.SetLongValue(groupName,"OverrideBuildCmd", unit->overrideBuildCmd());
ini.SetValue(groupName,"BuildCmd", toByteArray(unit->buildCmd()));
ini.SetLongValue(groupName,"DetectEncoding", unit->encoding()==ENCODING_AUTO_DETECT);
if (unit->encoding() != options().encoding)
//ini.SetLongValue(groupName,"DetectEncoding", unit->encoding()==ENCODING_AUTO_DETECT);
ini.Delete(groupName,"DetectEncoding");
if (unit->encoding() != options().encoding
&& unit->encoding()!=ENCODING_AUTO_DETECT)
ini.SetValue(groupName,"FileEncoding", toByteArray(unit->encoding()));
else
ini.Delete(groupName,"FileEncoding");
}
ini.SetLongValue("Project","UnitCount",count);
ini.SaveFile(mFilename.toLocal8Bit());

View File

@ -4920,6 +4920,10 @@
<source>Choose Expected Output File</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toggle Readonly</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>NewClassDialog</name>

File diff suppressed because it is too large Load Diff

View File

@ -4737,6 +4737,10 @@
<source>Add Problem Case</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Toggle Readonly</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>NewClassDialog</name>