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? 失败 - - - - - - + + + + + + Error 错误 @@ -1284,39 +1284,39 @@ Are you really want to continue? 无法写入文件"%1" - + Save As 另存为 - + The text to be copied exceeds count limit! 要复制的内容超过了行数限制! - + The text to be copied exceeds character limit! 要复制的内容超过了字符数限制! - + The text to be cut exceeds count limit! 要剪切的内容超过了行数限制! - + The text to be cut exceeds character limit! 要剪切的内容超过了字符数限制! - + Print Document 打印文档 - - - + + + Ctrl+click for more info Ctrl+单击以获取更多信息 @@ -1325,27 +1325,27 @@ Are you really want to continue? 未找到符号'%1'! - + astyle not found 找不到astyle程序 - + Can't find astyle in "%1". 找不到astyle程序"%1". - + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Readonly 只读 @@ -4199,7 +4199,7 @@ Are you really want to continue? - + New Problem Set 新建试题集 @@ -4218,14 +4218,14 @@ Are you really want to continue? - + Save Problem Set 保存试题集 - + Load Problem Set 载入试题集 @@ -5172,7 +5172,7 @@ Are you really want to continue? - + Problem Set %1 试题集%1 @@ -5452,7 +5452,7 @@ Are you really want to continue? - + Do you want to save it? 需要保存吗? @@ -5476,7 +5476,7 @@ Are you really want to continue? - + Save Error 保存失败 @@ -5546,71 +5546,87 @@ Are you really want to continue? 你真的要删除它吗? - + + Change working folder + 改变工作文件夹 + + + + File '%1' is not in the current working folder. + File '%1' is not in the current working folder + 文件'%1'不在当前工作文件夹中。 + + + + Do you want to change working folder to '%1'? + 是否将工作文件夹改设为'%1'? + + + Can't Commit 无法提交 - + Git needs user info to commit. Git需要用信息进行提交。 - + Choose Working Folder 选择工作文件夹 - - + + Header Exists 头文件已存在 - - + + Header file "%1" already exists! 头文件"%1"已存在! - + Source Exists 源文件已存在! - + Source file "%1" already exists! 源文件"%1"已存在! - + Can't commit! 无法提交! - + The following files are in conflicting: 下列文件处于冲突状态,请解决后重新添加和提交: - + Commit Message 提交信息 - + Commit Message: 提交信息: - + Commit Failed 提交失败 - + Commit message shouldn't be empty! 提交信息不能为空! @@ -5715,29 +5731,29 @@ Are you really want to continue? HTML文件 (*.html) - + The current problem set is not empty. 当前的试题集不是空的。 - + Problem %1 试题%1 - - + + Problem Set Files (*.pbs) 试题集文件 (*.pbs) - + Load Error 载入失败 - + Problem Case %1 试题案例%1 @@ -7994,7 +8010,7 @@ Are you really want to continue? 自动链接 - + @@ -8070,15 +8086,15 @@ Are you really want to continue? 杂项 - - + + Program Runner 程序运行 - + Problem Set 试题集 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);