diff --git a/NEWS.md b/NEWS.md
index b9300a12..e67be16f 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,6 +1,11 @@
Version 0.8.10 For Dev-C++ 7 Beta
- fix: Shouldn't update auto link settings, if the header name to be modified is unchanged
- fix: add unit to project not correctly set new unit file's encoding
+ - fix: correctly set encoding for the new added project unit file
+ - fix: if there's a project openned, new file should ask user if he want to add the new file to the project
+ - fix: when adding a file openned in the editor to the project, properties of it are not correctly setted.
+ - enhancement: when remove a file from the project, also ask if user want to remove it from disk
+ - fix: double click a project's .dev file in the Files panel should load the project
Version 0.8.9 For Dev-C++ 7 Beta
- fix: text color of labels in statusbar not correctly updated when change theme
diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.qm b/RedPandaIDE/RedPandaIDE_zh_CN.qm
index 0587e6c1..a8bb9e70 100644
Binary files a/RedPandaIDE/RedPandaIDE_zh_CN.qm and b/RedPandaIDE/RedPandaIDE_zh_CN.qm differ
diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.ts b/RedPandaIDE/RedPandaIDE_zh_CN.ts
index 875cf2d7..0103efed 100644
--- a/RedPandaIDE/RedPandaIDE_zh_CN.ts
+++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts
@@ -82,12 +82,12 @@
链接参数
-
+
头文件已存在
-
+
头文件已存在。
@@ -2857,11 +2857,11 @@ Are you really want to continue?
-
-
-
-
-
+
+
+
+
+
编译器
@@ -3269,7 +3269,7 @@ Are you really want to continue?
-
+
新建试题集
@@ -3288,14 +3288,14 @@ Are you really want to continue?
-
+
保存试题集
-
+
载入试题集
@@ -3630,7 +3630,7 @@ Are you really want to continue?
-
+
删除所有断点
@@ -3731,7 +3731,7 @@ Are you really want to continue?
-
+
重命名符号
@@ -3752,13 +3752,13 @@ Are you really want to continue?
-
+
导出为RTF
-
+
导出为HTML
@@ -3824,7 +3824,7 @@ Are you really want to continue?
-
+
打开文件夹
@@ -4055,7 +4055,7 @@ Are you really want to continue?
-
+
试题集%1
@@ -4122,15 +4122,15 @@ Are you really want to continue?
-
-
+
+
书签描述
-
-
+
+
描述:
@@ -4294,183 +4294,203 @@ Are you really want to continue?
-
+
需要保存吗?
-
-
-
-
+
+
+ 新建项目文件?
+
+
+
+
+ 您是否要将新建的文件加入项目?
+
+
+
+
+
+
保存失败
-
+
改变项目编译器配置集
-
+
改变项目的编译器配置集会导致所有的自定义编译器选项被重置。
-
+
你真的想要做那些吗?
-
+
您真的要清除该文件的所有断点吗?
-
+
新建项目
-
+
关闭'%1'以打开新项目?
-
+
文件夹不存在
-
+
文件夹'%1'不存在。是否创建?
-
+
无法创建文件夹
-
+
创建文件夹'%1'失败。
-
+
-
+
小熊猫Dev-C++项目文件 (*.dev)
-
+
新建项目失败
-
+
无法使用模板创建项目
-
+
+
+ 删除文件
+
+
+
+
+ 同时从硬盘上删除文件?
+
+
+
无标题
-
+
新的项目文件名
-
+
文件名:
-
+
文件已存在!
-
+
文件'%1'已经存在!
-
+
添加到项目
-
+
重命名出错
-
+
符号'%1'在系统头文件中定义,无法修改。
-
+
新名称
-
-
+
+
替换出错
-
+
无法打开文件'%1'进行替换!
-
+
内容和上次查找时不一致。
-
+
RTF格式文件 (*.rtf)
-
+
HTML文件 (*.html)
-
+
当前的试题集不是空的。
-
+
试题%1
-
-
+
+
试题集文件 (*.pbs)
-
+
载入失败
-
+
试题案例%1
@@ -4485,11 +4505,11 @@ Are you really want to continue?
-
-
-
-
-
+
+
+
+
+
错误
@@ -4519,55 +4539,55 @@ Are you really want to continue?
是否保持它在小熊猫C++中打开的编辑窗口?
-
+
打开
-
+
编译失败
-
+
运行失败
-
-
+
+
确认转换
-
-
+
+
当前编辑器中的文件将会使用%1编码保存。<br />这项操作无法被撤回。<br />你确定要继续吗?
-
+
新监视表达式
-
+
输入监视表达式
-
+
(%1/%2)正在解析文件"%3"
-
-
+
+
完成%1个文件的解析,用时%2秒
-
+
(每秒%1个文件)
@@ -4695,77 +4715,77 @@ Are you really want to continue?
无标题
-
+
无法保存文件
-
+
无法保存文件'%1'.
-
+
载入文件错误
-
+
文件已存在
-
+
文件'%1'已在项目中
-
+
项目已升级
-
+
已成功将项目升级到新的格式
-
+
旧项目文件备份在'%1'。
-
+
设置需要更新
-
+
Dev-C++的编译器设置格式已发生改变。
-
+
请在项目 >> 项目属性 >> 编译器设置中修改您的设置并保存您的项目
-
+
未找到编译器
-
+
您为该项目设置的编译器不存在。
-
+
它将会被全局编译器设置代替。
-
+
使用小熊猫Dev-C++编辑器开发
@@ -5156,24 +5176,24 @@ Are you really want to continue?
ProjectModel
-
+
文件已存在
-
+
文件'%1'已存在。是否删除?
-
-
+
+
删除失败
-
-
+
+
无法删除文件'%1'
@@ -6483,7 +6503,7 @@ Are you really want to continue?
自动链接
-
+
@@ -6559,7 +6579,7 @@ Are you really want to continue?
杂项
-
+
diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp
index abbce54d..58eb48a6 100644
--- a/RedPandaIDE/mainwindow.cpp
+++ b/RedPandaIDE/mainwindow.cpp
@@ -3211,6 +3211,15 @@ CPUDialog *MainWindow::cpuDialog() const
void MainWindow::on_actionNew_triggered()
{
+ if (mProject) {
+ if (QMessageBox::question(this,
+ tr("New Project File?"),
+ tr("Do you want to add the new file to the project?"),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
+ newProjectUnitFile();
+ return;
+ }
+ }
newEditor();
}
@@ -4654,46 +4663,7 @@ void MainWindow::on_actionSaveAll_triggered()
void MainWindow::on_actionProject_New_File_triggered()
{
- int idx = -1;
- if (!mProject)
- return;
- QModelIndex current = ui->projectView->currentIndex();
- FolderNode * node = nullptr;
- if (current.isValid()) {
- node = static_cast(current.internalPointer());
- }
- QString newFileName;
- do {
- newFileName = tr("untitled")+QString("%1").arg(getNewFileNumber());
- if (mProject->options().useGPP) {
- newFileName+=".cpp";
- } else {
- newFileName+=".c";
- }
- } while (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName)));
-
- newFileName = QInputDialog::getText(
- this,
- tr("New Project File Name"),
- tr("File Name:"),
- QLineEdit::Normal,
- newFileName);
- if (newFileName.isEmpty())
- return;
- if (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName))) {
- QMessageBox::critical(this,tr("File Already Exists!"),
- tr("File '%1' already exists!").arg(newFileName));
- return;
- }
- PProjectUnit newUnit = mProject->newUnit(
- mProject->pointerToNode(node),newFileName);
- idx = mProject->units().count()-1;
- mProject->saveUnits();
- updateProjectView();
- Editor * editor = mProject->openUnit(idx);
- //editor->setUseCppSyntax(mProject->options().useGPP);
- //editor->setModified(true);
- editor->activate();
+ newProjectUnitFile();
}
@@ -4742,9 +4712,14 @@ void MainWindow::on_actionRemove_from_project_triggered()
continue;
selected.insert(folderNode->unitIndex);
};
+
+ bool removeFile = (QMessageBox::question(this,tr("Remove file"),
+ tr("Remove the file from disk?"),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes);
+
for (int i=mProject->units().count()-1;i>=0;i--) {
if (selected.contains(i)) {
- mProject->removeEditor(i,true);
+ mProject->removeUnit(i,true,removeFile);
}
}
@@ -4952,6 +4927,50 @@ void MainWindow::prepareTabMessagesData()
mTabMessagesData[widget]=info;
}
}
+
+void MainWindow::newProjectUnitFile()
+{
+ if (!mProject)
+ return;
+ int idx = -1;
+ QModelIndex current = ui->projectView->currentIndex();
+ FolderNode * node = nullptr;
+ if (current.isValid()) {
+ node = static_cast(current.internalPointer());
+ }
+ QString newFileName;
+ do {
+ newFileName = tr("untitled")+QString("%1").arg(getNewFileNumber());
+ if (mProject->options().useGPP) {
+ newFileName+=".cpp";
+ } else {
+ newFileName+=".c";
+ }
+ } while (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName)));
+
+ newFileName = QInputDialog::getText(
+ this,
+ tr("New Project File Name"),
+ tr("File Name:"),
+ QLineEdit::Normal,
+ newFileName);
+ if (newFileName.isEmpty())
+ return;
+ if (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName))) {
+ QMessageBox::critical(this,tr("File Already Exists!"),
+ tr("File '%1' already exists!").arg(newFileName));
+ return;
+ }
+ PProjectUnit newUnit = mProject->newUnit(
+ mProject->pointerToNode(node),newFileName);
+ idx = mProject->units().count()-1;
+ mProject->saveUnits();
+ updateProjectView();
+ Editor * editor = mProject->openUnit(idx);
+ //editor->setUseCppSyntax(mProject->options().useGPP);
+ //editor->setModified(true);
+ editor->activate();
+}
void MainWindow::on_EditorTabsLeft_currentChanged(int)
{
Editor * editor = mEditorList->getEditor(-1,ui->EditorTabsLeft);
@@ -5383,9 +5402,10 @@ void MainWindow::on_treeFiles_doubleClicked(const QModelIndex &index)
QString filepath = mFileSystemModel.filePath(index);
QFileInfo file(filepath);
if (file.isFile()) {
- Editor * editor = mEditorList->getEditorByFilename(filepath);
- if (editor) {
- editor->activate();
+ if (getFileType(filepath)==FileType::Project) {
+ openProject(filepath);
+ } else {
+ openFile(filepath);
}
}
}
diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h
index 03a9b403..c11f45b7 100644
--- a/RedPandaIDE/mainwindow.h
+++ b/RedPandaIDE/mainwindow.h
@@ -226,6 +226,7 @@ private:
void showHideMessagesTab(QWidget *widget, bool show);
void prepareTabInfosData();
void prepareTabMessagesData();
+ void newProjectUnitFile();
private slots:
void onAutoSaveTimeout();
diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui
index 507115f3..70747547 100644
--- a/RedPandaIDE/mainwindow.ui
+++ b/RedPandaIDE/mainwindow.ui
@@ -85,7 +85,7 @@
QTabWidget::West
- 1
+ 3
true
diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp
index fc228a73..3e55b7a3 100644
--- a/RedPandaIDE/project.cpp
+++ b/RedPandaIDE/project.cpp
@@ -340,7 +340,7 @@ void Project::rebuildNodes()
emit nodesChanged();
}
-bool Project::removeEditor(int index, bool doClose)
+bool Project::removeUnit(int index, bool doClose , bool removeFile)
{
mModel.beginUpdate();
auto action = finally([this]{
@@ -357,6 +357,10 @@ bool Project::removeEditor(int index, bool doClose)
return false;
}
+ if (removeFile) {
+ QFile::remove(unit->fileName());
+ }
+
//if not fUnits.GetItem(index).fNew then
PFolderNode node = unit->node();
PFolderNode parent = node->parent.lock();
@@ -788,10 +792,17 @@ PProjectUnit Project::addUnit(const QString &inFileName, PFolderNode parentNode,
newUnit = std::make_shared(this);
// Set all properties
- newUnit->setEncoding(toByteArray(mOptions.encoding));
newUnit->setFileName(QDir(directory()).filePath(inFileName));
newUnit->setNew(false);
- newUnit->setEditor(nullptr);
+ Editor * e= pMainWindow->editorList()->getOpenedEditorByFilename(newUnit->fileName());
+ if (e) {
+ newUnit->setEditor(e);
+ newUnit->setEncoding(e->encodingOption());
+ e->setInProject(true);
+ } else {
+ newUnit->setEditor(nullptr);
+ newUnit->setEncoding(ENCODING_AUTO_DETECT);
+ }
newUnit->setFolder(getFolderPath(parentNode));
newUnit->setNode(makeNewFileNode(extractFileName(newUnit->fileName()), false, parentNode));
newUnit->node()->unitIndex = mUnits.count();
@@ -1515,7 +1526,7 @@ void Project::removeFolderRecurse(PFolderNode node)
} else if (childNode->unitIndex >= 0 && childNode->level > 0) {
// Remove editor in folder from project
int editorIndex = childNode->unitIndex;
- if (!removeEditor(editorIndex,true))
+ if (!removeUnit(editorIndex,true))
return;
}
}
@@ -1920,7 +1931,7 @@ bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, int
// Remove it from the current project...
int projindex = mProject->indexInUnits(newName);
if (projindex>=0) {
- mProject->removeEditor(projindex,false);
+ mProject->removeUnit(projindex,false);
}
// All references to the file are removed. Delete the file from disk
diff --git a/RedPandaIDE/project.h b/RedPandaIDE/project.h
index 3c37f000..e5f6f392 100644
--- a/RedPandaIDE/project.h
+++ b/RedPandaIDE/project.h
@@ -148,7 +148,7 @@ public:
const QString& customFileName="");
Editor* openUnit(int index);
void rebuildNodes();
- bool removeEditor(int index, bool doClose);
+ bool removeUnit(int index, bool doClose, bool removeFile = false);
bool removeFolder(PFolderNode node);
void resetParserProjectFiles();
void saveAll(); // save [Project] and all [UnitX]