- fix: crash when create non C/C++ source file in project
- fix: can't open text project file in the editor - change: when create non-text project file, don't auto open it
This commit is contained in:
parent
5ba802c0ee
commit
9b09b4263f
3
NEWS.md
3
NEWS.md
|
@ -1,6 +1,9 @@
|
||||||
Red Panda C++ Version 1.4
|
Red Panda C++ Version 1.4
|
||||||
|
|
||||||
- fix: "Encode in UTF-8" is not correctly checked, when the editor is openned using UTF-8 encoding.
|
- fix: "Encode in UTF-8" is not correctly checked, when the editor is openned using UTF-8 encoding.
|
||||||
|
- fix: crash when create non C/C++ source file in project
|
||||||
|
- fix: can't open text project file in the editor
|
||||||
|
- change: when create non-text project file, don't auto open it
|
||||||
|
|
||||||
Red Panda C++ Version 1.3
|
Red Panda C++ Version 1.3
|
||||||
|
|
||||||
|
|
|
@ -6179,7 +6179,7 @@ void MainWindow::newProjectUnitFile()
|
||||||
newProjectUnitDialog.setSuffix("c");
|
newProjectUnitDialog.setSuffix("c");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
newProjectUnitDialog.setSuffix("");
|
newProjectUnitDialog.setSuffix("txt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QString folder = mProject->fileSystemNodeFolderPath(pNode);
|
QString folder = mProject->fileSystemNodeFolderPath(pNode);
|
||||||
|
@ -6221,9 +6221,10 @@ void MainWindow::newProjectUnitFile()
|
||||||
mProject->saveAll();
|
mProject->saveAll();
|
||||||
updateProjectView();
|
updateProjectView();
|
||||||
idx = mProject->units().count()-1;
|
idx = mProject->units().count()-1;
|
||||||
Editor * editor = mProject->openUnit(idx);
|
Editor * editor = mProject->openUnit(idx, false);
|
||||||
//editor->setUseCppSyntax(mProject->options().useGPP);
|
//editor->setUseCppSyntax(mProject->options().useGPP);
|
||||||
//editor->setModified(true);
|
//editor->setModified(true);
|
||||||
|
if (editor)
|
||||||
editor->activate();
|
editor->activate();
|
||||||
QString branch;
|
QString branch;
|
||||||
if (pSettings->vcs().gitOk() && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
|
if (pSettings->vcs().gitOk() && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
|
||||||
|
|
|
@ -309,7 +309,7 @@ PProjectUnit Project::newUnit(PProjectModelNode parentNode, const QString& custo
|
||||||
return newUnit;
|
return newUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
Editor *Project::openUnit(int index)
|
Editor *Project::openUnit(int index, bool forceOpen)
|
||||||
{
|
{
|
||||||
if ((index < 0) || (index >= mUnits.count()))
|
if ((index < 0) || (index >= mUnits.count()))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -318,11 +318,8 @@ Editor *Project::openUnit(int index)
|
||||||
|
|
||||||
if (!unit->fileName().isEmpty() && fileExists(unit->fileName())) {
|
if (!unit->fileName().isEmpty() && fileExists(unit->fileName())) {
|
||||||
if (getFileType(unit->fileName())==FileType::Other) {
|
if (getFileType(unit->fileName())==FileType::Other) {
|
||||||
QMimeDatabase db;
|
if (forceOpen)
|
||||||
QMimeType mimeType=db.mimeTypeForFile(unit->fileName());
|
|
||||||
if (!mimeType.isValid() || !mimeType.name().startsWith("text/")) {
|
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(unit->fileName()));
|
QDesktopServices::openUrl(QUrl::fromLocalFile(unit->fileName()));
|
||||||
}
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ public:
|
||||||
int indexInUnits(const Editor* editor) const;
|
int indexInUnits(const Editor* editor) const;
|
||||||
PProjectUnit newUnit(PProjectModelNode parentNode,
|
PProjectUnit newUnit(PProjectModelNode parentNode,
|
||||||
const QString& customFileName="");
|
const QString& customFileName="");
|
||||||
Editor* openUnit(int index);
|
Editor* openUnit(int index, bool forceOpen=true);
|
||||||
Editor* unitEditor(const PProjectUnit& unit) const;
|
Editor* unitEditor(const PProjectUnit& unit) const;
|
||||||
Editor* unitEditor(const ProjectUnit* unit) const;
|
Editor* unitEditor(const ProjectUnit* unit) const;
|
||||||
Editor* unitEditor(int index) const {
|
Editor* unitEditor(int index) const {
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "compiler/executablerunner.h"
|
#include "compiler/executablerunner.h"
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
#include <QMimeDatabase>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -276,6 +277,11 @@ FileType getFileType(const QString &filename)
|
||||||
if (filename.endsWith(".dat",PATH_SENSITIVITY)) {
|
if (filename.endsWith(".dat",PATH_SENSITIVITY)) {
|
||||||
return FileType::Text;
|
return FileType::Text;
|
||||||
}
|
}
|
||||||
|
QMimeDatabase db;
|
||||||
|
QMimeType mimeType=db.mimeTypeForFile(filename);
|
||||||
|
if (mimeType.isValid() && mimeType.name().startsWith("text/")) {
|
||||||
|
return FileType::Text;
|
||||||
|
}
|
||||||
return FileType::Other;
|
return FileType::Other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue