diff --git a/NEWS.md b/NEWS.md
index eba5b67b..9bb7f99f 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,7 @@
Red Panda C++ Version 1.0.0
- fix: calculation for code snippets's tab stop positions is not correct
+ - fix: Refresh files view shouldn'tchange open/save dialog's default folder
+ - enhancement: "locate in files view" will request user's confirmation when change the working folder
Red Panda C++ Version 0.14.5
- fix: the "gnu c++ 20" option in compiler set options is wrong
diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.ts b/RedPandaIDE/RedPandaIDE_zh_CN.ts
index d7cf17cd..2f1b8d6d 100644
--- a/RedPandaIDE/RedPandaIDE_zh_CN.ts
+++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts
@@ -1270,12 +1270,12 @@ Are you really want to continue?
失败
-
-
-
-
-
-
+
+
+
+
+
+
错误
@@ -1284,39 +1284,39 @@ Are you really want to continue?
无法写入文件"%1"
-
+
另存为
-
+
要复制的内容超过了行数限制!
-
+
要复制的内容超过了字符数限制!
-
+
要剪切的内容超过了行数限制!
-
+
要剪切的内容超过了字符数限制!
-
+
打印文档
-
-
-
+
+
+
Ctrl+单击以获取更多信息
@@ -1325,27 +1325,27 @@ Are you really want to continue?
未找到符号'%1'!
-
+
找不到astyle程序
-
+
找不到astyle程序"%1".
-
+
断点条件
-
+
输入当前断点的生效条件:
-
+
只读
@@ -4199,7 +4199,7 @@ Are you really want to continue?
-
+
新建试题集
@@ -4218,14 +4218,14 @@ Are you really want to continue?
-
+
保存试题集
-
+
载入试题集
@@ -5172,7 +5172,7 @@ Are you really want to continue?
-
+
试题集%1
@@ -5452,7 +5452,7 @@ Are you really want to continue?
-
+
需要保存吗?
@@ -5476,7 +5476,7 @@ Are you really want to continue?
-
+
保存失败
@@ -5546,71 +5546,87 @@ Are you really want to continue?
你真的要删除它吗?
-
+
+
+ 改变工作文件夹
+
+
+
+
+ File '%1' is not in the current working folder
+ 文件'%1'不在当前工作文件夹中。
+
+
+
+
+ 是否将工作文件夹改设为'%1'?
+
+
+
无法提交
-
+
Git需要用信息进行提交。
-
+
选择工作文件夹
-
-
+
+
头文件已存在
-
-
+
+
头文件"%1"已存在!
-
+
源文件已存在!
-
+
源文件"%1"已存在!
-
+
无法提交!
-
+
下列文件处于冲突状态,请解决后重新添加和提交:
-
+
提交信息
-
+
提交信息:
-
+
提交失败
-
+
提交信息不能为空!
@@ -5715,29 +5731,29 @@ Are you really want to continue?
HTML文件 (*.html)
-
+
当前的试题集不是空的。
-
+
试题%1
-
-
+
+
试题集文件 (*.pbs)
-
+
载入失败
-
+
试题案例%1
@@ -7994,7 +8010,7 @@ Are you really want to continue?
自动链接
-
+
@@ -8070,15 +8086,15 @@ Are you really want to continue?
杂项
-
-
+
+
程序运行
-
+
试题集
diff --git a/RedPandaIDE/main.cpp b/RedPandaIDE/main.cpp
index b0527047..7d3c83be 100644
--- a/RedPandaIDE/main.cpp
+++ b/RedPandaIDE/main.cpp
@@ -352,9 +352,6 @@ int main(int argc, char *argv[])
QMessageBox::Ok);
}
- //set default open folder
- QDir::setCurrent(pSettings->environment().defaultOpenFolder());
-
MainWindow mainWindow;
pMainWindow = &mainWindow;
if (app.arguments().count()>1) {
@@ -375,6 +372,10 @@ int main(int argc, char *argv[])
setScreenDPI(mainWindow.screen()->logicalDotsPerInch());
#endif
mainWindow.show();
+
+ //reset default open folder
+ QDir::setCurrent(pSettings->environment().defaultOpenFolder());
+
#ifdef Q_OS_WIN
WindowLogoutEventFilter filter;
app.installNativeEventFilter(&filter);
diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp
index ed88b23f..89a04783 100644
--- a/RedPandaIDE/mainwindow.cpp
+++ b/RedPandaIDE/mainwindow.cpp
@@ -5929,14 +5929,15 @@ void MainWindow::showSearchReplacePanel(bool show)
mSearchResultTreeModel->setSelectable(show);
}
-void MainWindow::setFilesViewRoot(const QString &path)
+void MainWindow::setFilesViewRoot(const QString &path, bool setOpenFolder)
{
mFileSystemModelIconProvider.setRootFolder(path);
mFileSystemModel.setIconProvider(&mFileSystemModelIconProvider);
mFileSystemModel.setRootPath(path);
ui->treeFiles->setRootIndex(mFileSystemModel.index(path));
pSettings->environment().setCurrentFolder(path);
- QDir::setCurrent(path);
+ if (setOpenFolder)
+ QDir::setCurrent(path);
int pos = ui->cbFilesPath->findText(path);
if (pos<0) {
ui->cbFilesPath->addItem(mFileSystemModel.iconProvider()->icon(QFileIconProvider::Folder),path);
@@ -6216,15 +6217,30 @@ void MainWindow::on_actionLocate_in_Files_View_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor) {
- QModelIndex index = mFileSystemModel.index(editor->filename());
- if (!index.isValid()) {
+ QFileInfo fileInfo(editor->filename());
+ if (!fileInfo.absoluteFilePath().startsWith(
+ mFileSystemModel.rootDirectory().absolutePath()+"/",
+ PATH_SENSITIVITY
+ )) {
QString fileDir = extractFileDir(editor->filename());
+ if (QMessageBox::question(this,
+ tr("Change working folder"),
+ tr("File '%1' is not in the current working folder.")
+ .arg(extractFileName(editor->filename()))
+ +"
"
+ +tr("Do you want to change working folder to '%1'?")
+ .arg(fileDir),
+ QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::Yes
+ )!=QMessageBox::Yes) {
+ return;
+ }
if (!fileDir.isEmpty())
- setFilesViewRoot(fileDir);
+ setFilesViewRoot(fileDir,true);
else
return;
- index = mFileSystemModel.index(editor->filename());
}
+ QModelIndex index = mFileSystemModel.index(editor->filename());
ui->treeFiles->setCurrentIndex(index);
ui->treeFiles->scrollTo(index, QAbstractItemView::PositionAtCenter);
ui->tabInfos->setCurrentWidget(ui->tabFiles);
@@ -6252,7 +6268,7 @@ void MainWindow::on_actionOpen_Folder_triggered()
QString folder = QFileDialog::getExistingDirectory(this,tr("Choose Working Folder"),
pSettings->environment().currentFolder());
if (!folder.isEmpty()) {
- setFilesViewRoot(folder);
+ setFilesViewRoot(folder,true);
}
}
diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h
index deb30024..e5bf6d48 100644
--- a/RedPandaIDE/mainwindow.h
+++ b/RedPandaIDE/mainwindow.h
@@ -243,7 +243,7 @@ private:
void scanActiveProject(bool parse=false);
void includeOrSkipDirs(const QStringList& dirs, bool skip);
void showSearchReplacePanel(bool show);
- void setFilesViewRoot(const QString& path);
+ void setFilesViewRoot(const QString& path, bool setOpenFolder=false);
void clearIssues();
void doCompileRun(RunType runType);
void updateProblemCaseOutput(POJProblemCase problemCase);