- fix: project's icon setting is not correctly saved

- fix: project's type setting won't be saved
  - fix: If project's compiler set is not the same with the default compiler set, auto openned project's file will use wrong compiler set to do syntax check.
  - fix: open a project file through "File"->"Open" will not correctly connect it with the project internally
This commit is contained in:
Roy Qu 2022-01-13 16:47:48 +08:00
parent bab728e792
commit 0875d15d67
8 changed files with 70 additions and 43 deletions

View File

@ -17,6 +17,10 @@ Red Panda C++ Version 0.13.2
- fix: caret dispears when at '\t' under Windows 7
- enhancement: ctrl+up/down scrolls in the editor
- enhancement: add "wrap around" option to find/replace
- fix: project's icon setting is not correctly saved
- fix: project's type setting won't be saved
- fix: If project's compiler set is not the same with the default compiler set, auto openned project's file will use wrong compiler set to do syntax check.
- fix: open a project file through "File"->"Open" will not correctly connect it with the project internally
Red Panda C++ Version 0.13.1
- enhancement: suppoort localization info in project templates

View File

@ -975,8 +975,9 @@ void MainWindow::openFile(const QString &filename, QTabWidget* page)
}
try {
pSettings->history().removeFile(filename);
bool inProject = (mProject && mProject->isProjectUnit(filename));
editor = mEditorList->newEditor(filename,ENCODING_AUTO_DETECT,
false, false, page);
inProject, false, page);
editor->activate();
this->updateForEncodingInfo();
} catch (FileError e) {
@ -984,7 +985,7 @@ void MainWindow::openFile(const QString &filename, QTabWidget* page)
}
}
void MainWindow::openProject(const QString &filename)
void MainWindow::openProject(const QString &filename, bool openFiles)
{
if (!fileExists(filename)) {
return;
@ -1029,12 +1030,11 @@ void MainWindow::openProject(const QString &filename)
// if not devData.ShowLeftPages then
// actProjectManager.Execute;
//checkForDllProfiling();
updateAppTitle();
updateCompilerSet();
//parse the project
// UpdateClassBrowsing;
scanActiveProject(true);
if (openFiles)
mProject->doAutoOpen();
//update editor's inproject flag
@ -1054,6 +1054,8 @@ void MainWindow::openProject(const QString &filename)
if (e) {
checkSyntaxInBack(e);
}
updateAppTitle();
updateCompilerSet();
updateClassBrowserForEditor(e);
}
updateForEncodingInfo();
@ -1985,8 +1987,12 @@ void MainWindow::loadLastOpens()
QMessageBox::Ok);
return;
}
Editor * focusedEditor = nullptr;
QString projectFilename = QString::fromLocal8Bit((lastOpenIni.GetValue("LastOpens", "Project","")));
int count = lastOpenIni.GetLongValue("LastOpens","Count",0);
if (fileExists(projectFilename)) {
openProject(projectFilename, false);
}
Editor * focusedEditor = nullptr;
for (int i=0;i<count;i++) {
QByteArray sectionName = QString("Editor_%1").arg(i).toLocal8Bit();
QString editorFilename = QString::fromLocal8Bit(lastOpenIni.GetValue(sectionName,"FileName",""));
@ -1999,7 +2005,8 @@ void MainWindow::loadLastOpens()
page = mEditorList->leftPageWidget();
else
page = mEditorList->rightPageWidget();
Editor * editor = mEditorList->newEditor(editorFilename,ENCODING_AUTO_DETECT,false,false,page);
bool inProject = (mProject && mProject->isProjectUnit(editorFilename));
Editor * editor = mEditorList->newEditor(editorFilename,ENCODING_AUTO_DETECT,inProject,false,page);
if (!editor)
continue;
BufferCoord pos;
@ -2016,10 +2023,7 @@ void MainWindow::loadLastOpens()
focusedEditor = editor;
pSettings->history().removeFile(editorFilename);
}
QString projectFilename = QString::fromLocal8Bit((lastOpenIni.GetValue("LastOpens", "Project","")));
if (fileExists(projectFilename)) {
openProject(projectFilename);
} else {
if (count>0) {
updateEditorActions();
updateForEncodingInfo();
}

View File

@ -177,7 +177,7 @@ public:
const PBookmarkModel &bookmarkModel() const;
void openFile(const QString& filename, QTabWidget* page=nullptr);
void openProject(const QString& filename);
void openProject(const QString& filename, bool openFiles = true);
void changeOptions(const QString& widgetName=QString(), const QString& groupName=QString());
bool openningFiles() const;

View File

@ -564,6 +564,15 @@ bool Project::saveUnits()
return true;
}
bool Project::isProjectUnit(const QString &filename)
{
foreach(const PProjectUnit& unit, mUnits) {
if (QString::compare(unit->fileName(),filename, PATH_SENSITIVITY)==0)
return true;
}
return false;
}
void Project::setCompilerOption(const QString &optionString, char value)
{
if (mOptions.compilerSet<0 || mOptions.compilerSet>=pSettings->compilerSets().size()) {
@ -1211,20 +1220,6 @@ void Project::createFolderNodes()
void Project::doAutoOpen()
{
//todo:
// case devData.AutoOpen of
// 0: begin
// for i := 0 to pred(fUnits.Count) do
// OpenUnit(i); // Open all
// if fUnits.Count > 0 then
// fUnits[0].Editor.Activate; // Show first
// end;
// 1:
// if fUnits.Count > 0 then
// OpenUnit(0).Activate; // Open and show first
// 2:
// LoadLayout; // Open previous selection
// end;
loadLayout();
}

View File

@ -184,6 +184,7 @@ public:
void saveUnitAs(int i, const QString& sFileName, bool syncEditor = true); // save single [UnitX]
void saveUnitLayout(Editor* e, int index); // save single [UnitX] cursor positions
bool saveUnits();
bool isProjectUnit(const QString& filename);
void setCompilerOption(const QString& optionString, char value);
void sortUnitsByPriority();
void sortUnitsByAlpha();

View File

@ -42,7 +42,7 @@ ProjectGeneralWidget::~ProjectGeneralWidget()
void ProjectGeneralWidget::refreshIcon()
{
QPixmap icon(mIconPath);
ui->lblICon->setPixmap(icon);
ui->lbIcon->setPixmap(icon);
}
void ProjectGeneralWidget::doLoad()
@ -103,10 +103,11 @@ void ProjectGeneralWidget::doSave()
project->options().useGPP = ui->cbDefaultCpp->isChecked();
project->options().supportXPThemes = ui->cbSupportXPTheme->isChecked();
if (mIconPath.isEmpty()
|| !ui->lblICon->pixmap() || ui->lblICon->pixmap()->isNull()) {
|| !ui->lbIcon->pixmap() || ui->lbIcon->pixmap()->isNull()) {
project->options().icon = "";
} else {
QString iconPath = changeFileExt(project->filename(),"ico");
if (iconPath!=mIconPath) {
if (QFile(iconPath).exists()) {
if (!QFile::remove(iconPath)) {
QMessageBox::critical(this,
@ -121,6 +122,7 @@ void ProjectGeneralWidget::doSave()
mIconPath = iconPath;
refreshIcon();
}
}
project->saveOptions();
}
@ -130,7 +132,7 @@ void ProjectGeneralWidget::on_btnBrowse_clicked()
QString fileName = QFileDialog::getOpenFileName(this,
tr("Select icon file"),
pSettings->dirs().appDir(),
tr("Icon Files (*.ico)"));
tr("Image Files (*.ico *.png *.jpg)"));
if (!fileName.isEmpty()) {
mIconPath = fileName;
QPixmap icon(mIconPath);
@ -144,7 +146,7 @@ void ProjectGeneralWidget::on_btnBrowse_clicked()
void ProjectGeneralWidget::on_btnRemove_clicked()
{
mIconPath = "";
ui->lblICon->setPixmap(QPixmap());
ui->lbIcon->setPixmap(QPixmap());
ui->btnRemove->setEnabled(!mIconPath.isEmpty());
setSettingsChanged();
}

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>685</width>
<width>687</width>
<height>639</height>
</rect>
</property>
@ -114,7 +114,7 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="lblICon">
<widget class="QLabel" name="lbIcon">
<property name="minimumSize">
<size>
<width>128</width>

View File

@ -24,6 +24,7 @@
#include <QListView>
#include <QMessageBox>
#include <QPlainTextEdit>
#include <QListWidget>
#include <QRadioButton>
#include <QSpinBox>
#include "../widgets/coloredit.h"
@ -121,6 +122,9 @@ void SettingsWidget::connectInputs()
for (QAbstractItemView* p: findChildren<QAbstractItemView*>()) {
connectAbstractItemView(p);
}
for (QListWidget* p:findChildren<QListWidget*>()) {
connect(p, QOverload<int>::of(&QListWidget::currentRowChanged) ,this, &SettingsWidget::setSettingsChanged);
}
for (QGroupBox* p: findChildren<QGroupBox*>()) {
connect(p, &QGroupBox::toggled,this, &SettingsWidget::setSettingsChanged);
}
@ -135,15 +139,32 @@ void SettingsWidget::disconnectInputs()
for (QCheckBox* p:findChildren<QCheckBox*>()) {
disconnect(p, &QCheckBox::stateChanged, this, &SettingsWidget::setSettingsChanged);
}
for (QRadioButton* p:findChildren<QRadioButton*>()) {
disconnect(p, &QRadioButton::toggled, this, &SettingsWidget::setSettingsChanged);
}
for (QPlainTextEdit* p:findChildren<QPlainTextEdit*>()) {
disconnect(p, &QPlainTextEdit::textChanged, this, &SettingsWidget::setSettingsChanged);
}
for (QSpinBox* p:findChildren<QSpinBox*>()) {
disconnect(p, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsWidget::setSettingsChanged);
}
for (ColorEdit* p:findChildren<ColorEdit*>()) {
disconnect(p, &ColorEdit::colorChanged, this, &SettingsWidget::setSettingsChanged);
}
for (QComboBox* p: findChildren<QComboBox*>()) {
disconnect(p, QOverload<int>::of(&QComboBox::currentIndexChanged) ,this, &SettingsWidget::setSettingsChanged);
}
for (QAbstractItemView* p: findChildren<QAbstractItemView*>()) {
disconnectAbstractItemView(p);
}
for (QListWidget* p:findChildren<QListWidget*>()) {
disconnect(p, QOverload<int>::of(&QListWidget::currentRowChanged) ,this, &SettingsWidget::setSettingsChanged);
}
for (QGroupBox* p: findChildren<QGroupBox*>()) {
disconnect(p, &QGroupBox::toggled,this, &SettingsWidget::setSettingsChanged);
}
}
const QString &SettingsWidget::group()