diff --git a/NEWS.md b/NEWS.md index 57cf32f6..605cdb47 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,6 +11,7 @@ Version 0.7.0 - enhancement: autosave/load bookmarks - enhancement: autosave/load breakpoints - enhancement: autosave/load watches + - implement: files view Version 0.6.8 - enhancement: add link to cppreference in the help menu diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.qm b/RedPandaIDE/RedPandaIDE_zh_CN.qm index 2c684e08..688a619c 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 b6f68db0..af623a65 100644 --- a/RedPandaIDE/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts @@ -2801,40 +2801,40 @@ Are you really want to continue? 小熊猫C++ - - + + Issues 编译器 - + Compile Log 编译日志 - + File 文件 - + Tools 工具 - - + + Run 运行 - + Edit 编辑 - + Project 项目 @@ -2849,90 +2849,91 @@ Are you really want to continue? 结构 + Files - 文件 + 文件 Resource 资源 - - - - + + + + Debug 调试 - + Evaluate: 求值 - + Debug Console 调试主控台 - + Call Stack 调用栈 - + Breakpoints 断点 - + Locals 本地变量 - - + + Search 查找 - + History: 历史: - + Search Again 重新查找 - + Replace with: 替换为: - + Replace 替换 - + Close 关闭 - + Execute 运行 - - + + Code 代码 - + Window 窗口 @@ -2945,721 +2946,732 @@ Are you really want to continue? 工具栏2 - + New 新建 - + Ctrl+N Ctrl+N - + Open... 打开... - + Ctrl+O Ctrl+O - + Save 保存 - + Ctrl+S Ctrl+S - + Save As... 另存为... - + Save As 另存为 - + Save All 全部保存 - + Ctrl+Shift+S Ctrl+Shift+S - + Options 选项 - - - - - - - + + + + + + + Compile 编译 - + F9 F9 - + F10 F10 - + Undo 恢复 - + Ctrl+Z Ctrl+Z - + Redo 重做 - + Ctrl+Y Ctrl+Y - + Cut 剪切 - + Ctrl+X Ctrl+X - - + + Copy 复制 - + Ctrl+C Ctrl+C - - + + Paste 粘贴 - + Ctrl+V Ctrl+V - - + + Select All 选择全部 - + Ctrl+A Ctrl+A - + Indent 缩进 - + UnIndent 取消缩进 - + Toggle Comment 切换注释 - + Ctrl+/ Ctrl+/ - + Collapse All 全部收起 - + Uncollapse All 全部展开 - + Encode in ANSI 使用ANSI编码 - + Encode in UTF-8 使用UTF-8编码 - + Auto Detect 自动检测 - + Convert to ANSI 转换为ANSI编码 - + Convert to UTF-8 转换为UTF-8编码 - - + + Compile & Run 编译运行 - + F11 F11 - - + + Rebuild All 全部重编译 - + F12 F12 - + Stop Execution 停止执行 - + F6 F6 - + F5 F5 - + Step Over 单步跳过 - + F7 F7 - + Step Into 单步进入 - + Memory 内存 - + Address Expression: Address: 地址表达式: - + Cancel 取消 - + TODO TODO - + Bookmark 书签 - + Help 帮助 - + Refactor 重构 - + Main 主工具栏 - + Compiler Set 编译器配置集 - - + + New Source File 新建源代码文件 - + Tab Tab - + Shift+Tab Shift+Tab - + F8 F8 - + Step Out 单步跳出 - + Ctrl+F8 Ctrl+F8 - + Run To Cursor 执行到光标处 - + Ctrl+F5 Ctrl+F5 - + Continue 继续执行 - + F4 F4 - + Add Watch... 添加监视 - + View CPU Window... 打开CPU信息窗口... - + Exit 退出 - + Find... 查找... - + Ctrl+F Ctrl+F - + Find in Files... 在文件中查找... - + Ctrl+Shift+F Ctrl+Shift+F - + Replace... 替换 - + Ctrl+R Ctrl+R - + Find Next 查找下一个 - + F3 F3 - + Find Previous 查找前一个 - + Shift+F3 Shift+F3 - + Remove Watch 删除监视 - - + + Remove All 清除全部监视 - + Modify Watch... 修改监视值 - + Reformat Code 对代码重新排版 - + Ctrl+Shift+A Ctrl+Shift+A - + Go back 前一次编辑位置 - + Ctrl+Alt+Left Ctrl+Alt+Left - + Forward 后一次编辑位置 - + Ctrl+Alt+Right Ctrl+Alt+Right - + Ctrl+W Ctrl+W - + Close All 全部关闭 - + Ctrl+Shift+W Ctrl+Shift+W - + Maximize Editor 最大化编辑器 - + Ctrl+F11 Ctrl+F11 - + Next 下一窗口 - + Ctrl+Tab Ctrl+Tab - + Previous 前一窗口 - + Ctrl+Shift+Tab Ctrl+Shift+Tab - + Toggle breakpoint 切换断点 - + Ctrl+F4 Ctrl+F4 - - + + Clear all breakpoints 删除所有断点 - + Breakpoint property... 设置断点条件... - + Goto Declaration 跳转到声明处 - + Goto Definition 跳转到定义处 - + Find references 查找符号的引用 - + Open containing folder 打开所在的文件夹 - + Ctrl+B Ctrl+B - + Open a terminal here 打开命令行窗口 - + File Properties... 文件属性... - + Close Project 关闭项目 - + Project options 项目属性 - + New Project... 新建项目... - + New File 新建项目文件 - + Add to project... 添加到项目... - + Remove from project 从项目删除 - + View Makefile 查看Makefile - + Clean 清理构建文件 - + Open Folder in Explorer 在浏览器中打开 - + Open In Terminal 在终端中打开 - + About 关于 - - + + Rename Symbol 重命名符号 - + Shift+F6 Shift+F6 - + Print... 打印... - + Ctrl+P Ctrl+P - - + + Export As RTF 导出为RTF - - + + Export As HTML 导出为HTML - + Move To Other View 移动到其他视图 - + Ctrl+M Ctrl+M - + C/C++ Reference C/C++参考 - + EGE Manual EGE图形库手册 - + Add Bookmark 添加书签 - + Remove Bookmark 删除书签 - + Modify Bookmark Description 修改书签说明 - + + Locate in Files View + 在文件视图中定位 + + + + + Open Folder + 打开文件夹 + + + File Encoding 文件编码 - + Recent Files 文件历史 - - - - - - + + + + + + Debugging 正在调试 - - - - - - + + + + + + Running 正在运行 - - - - - - + + + + + + Compiling 正在编译 @@ -3668,510 +3680,543 @@ Are you really want to continue? 行:%1 列:%2 已选择:%3 总行数:%4 总长度:%5 - + Line:%1 Col:%2 Selected:%3 Lines:%4 Length:%5 Line: %1 Col: %2 Selected: %3 Lines: %4 Length: %5 行: %1 列: %2 已选择 :%3 总行数: %4 总长度: %5 - + Read Only 只读 - + Insert 插入 - + Overwrite 覆写 - + Close project 关闭项目 - + Are you sure you want to close %1? 你确定要关闭'%1'吗? - - + + Confirm 确认 - - - + + + Source file is not compiled. 源文件尚未编译。 - - + + Compile now? 现在编译? - - - + + + Source file is more recent than executable. 源文件比可执行程序新。 - + Recompile now? 重新编译? - + No compiler set 无编译器设置 - + No compiler set is configured. 没有配置编译器设置。 - + Can't start debugging. 无法启动调试器 - - + + Enable debugging 启用调试参数 - - + + You have not enabled debugging info (-g3) and/or stripped it from the executable (-s) in Compiler Options.<BR /><BR />Do you want to correct this now? 当前编译设置中未启用调试选项(-g3),或启用了信息剥除选项(-s)<br /><br/>是否纠正这一问题? - + Project not built 项目尚未构建 - + Project hasn't been built. Build it now? 项目尚未构建。是否构建? - + Host applcation missing 宿主程序不存在 - + DLL project needs a host application to run. 动态链接库(DLL)需要一个宿主程序来运行。 - + But it's missing. 但它不存在。 - + Host application not exists 宿主程序不存在 - + Host application file '%1' doesn't exist. 宿主程序'%1'不存在。 - + Recompile? 重新编译? - - + + Save last open info error 保存上次打开信息失败 - + Can't remove old last open information file '%1' 无法删除旧上次打开信息文件'%1' - + Can't save last open info file '%1' 无法保存上次打开信息文件'%1' - + Load last open info error 载入上次打开信息失败 - + Can't load last open info file '%1' 无法载入上次打开信息文件'%1' - + Copy all 全部复制 - - + + Clear 清除 - + Export 导出 - + Insert Snippet 插入代码段 - + Remove 删除 - + Modify Description 修改描述 - - - + + + Bookmark Description 书签描述 - - - + + + Description: 描述: - + Show debug logs in the debug console 在调试主控台中显示调试器输出 - + Remove this search 清除这次搜索 - + Clear all searches 删除所有搜索 - + Breakpoint condition... 断点条件... - + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Remove all breakpoints 清除所有断点 - + Rename File 重命名文件 - - + + Add Folder 添加文件夹 - + New folder 新文件夹 - + Folder name: 文件夹: - + Rename Folder 重命名 - + Remove Folder 删除文件夹 - + Sort By Type 按类型排序 - + Sort alphabetically 按名称排序 - + Show inherited members 显示继承的成员 - + Goto declaration 跳转到声明处 - + Goto definition 跳转到定义处 - + + Open in Editor + 在编辑器中打开 + + + + Open in External Program + 使用外部程序打开 + + + + Open in Terminal + 在终端中打开 + + + + Open in Windows Explorer + 在Windows浏览器中打开 + + + Character sets 字符集 - + %1 files autosaved 已自动保存%1个文件 - + Save project 保存项目 - + The project '%1' has modifications. 项目'%1'有改动。 - + Do you want to save it? 需要保存吗? - + + + + Save Error + 保存失败 + + + Do you really want to clear all breakpoints in this file? 您真的要清除该文件的所有断点吗? - + New project 新建项目 - + Close %1 and start new project? 关闭'%1'以打开新项目? - + Folder not exist 文件夹不存在 - + Folder '%1' doesn't exist. Create it now? 文件夹'%1'不存在。是否创建? - + Can't create folder 无法创建文件夹 - + Failed to create folder '%1'. 创建文件夹'%1'失败。 - + Save new project as - + Red panda Dev-C++ project file (*.dev) 小熊猫Dev-C++项目文件 (*.dev) - + New project fail 新建项目失败 - + Can't assign project template 无法使用模板创建项目 - + Add to project 添加到项目 - + Rename Error 重命名出错 - + Symbol '%1' is defined in system header. 符号'%1'在系统头文件中定义,无法修改。 - + New Name 新名称 - - + + Replace Error 替换出错 - + Can't open file '%1' for replace! 无法打开文件'%1'进行替换! - + Contents has changed since last search! 内容和上次查找时不一致。 - + Rich Text Format Files (*.rtf) RTF格式文件 (*.rtf) - + HTML Files (*.html) HTML文件 (*.html) - - - - - - - - - + + + + + + + + + + + + + + + Error 错误 - + Recent Projects 项目历史 - + File '%1' was changed. 磁盘文件'%1'已被修改。 - + Reload its content from disk? 是否重新读取它的内容? - + File '%1' was removed. 磁盘文件'%1'已被删除。 - + Keep it open? 是否保持它在小熊猫C++中打开的编辑窗口? - + Open 打开 - + Compile Failed 编译失败 - + Run Failed 运行失败 - - + + Confirm Convertion 确认转换 - - + + The editing file will be saved using %1 encoding. <br />This operation can't be reverted. <br />Are you sure to continue? 当前编辑器中的文件将会使用%1编码保存。<br />这项操作无法被撤回。<br />你确定要继续吗? - + New Watch Expression 新监视表达式 - + Enter Watch Expression (it is recommended to use 'this->' for class members): 输入监视表达式 - + Parsing file %1 of %2: "%3" (%1/%2)正在解析文件"%3" - - + + Done parsing %1 files in %2 seconds 完成%1个文件的解析,用时%2秒 - + (%1 files per second) (每秒%1个文件) @@ -6129,6 +6174,19 @@ Are you really want to continue? 本页中有尚未保存的设置修改,是否保存后再切换到其他页? + + SettingsWidget + + + Load Error + 载入失败 + + + + Save Error + 保存失败 + + ShortcutManager diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index c9b50505..16840631 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -495,6 +495,7 @@ void Editor::focusInEvent(QFocusEvent *event) this, &SynEdit::invalidate); } + pMainWindow->updateAppTitle(); pMainWindow->updateEditorActions(); pMainWindow->updateStatusbarForLineCol(); pMainWindow->updateForStatusbarModeInfo(); @@ -511,7 +512,6 @@ void Editor::focusOutEvent(QFocusEvent *event) &SynEdit::invalidate); } //pMainWindow->updateClassBrowserForEditor(nullptr); - pMainWindow->updateEditorActions(); pMainWindow->updateStatusbarForLineCol(); pMainWindow->updateForStatusbarModeInfo(); pMainWindow->functionTip()->hide(); diff --git a/RedPandaIDE/editorlist.cpp b/RedPandaIDE/editorlist.cpp index abccd915..f3bdb504 100644 --- a/RedPandaIDE/editorlist.cpp +++ b/RedPandaIDE/editorlist.cpp @@ -153,6 +153,9 @@ bool EditorList::closeEditor(Editor* editor, bool transferFocus, bool force) { editor = getEditor(); pMainWindow->updateClassBrowserForEditor(editor); } + if (pageCount()==0) { + pMainWindow->updateAppTitle(); + } return true; } @@ -283,6 +286,7 @@ bool EditorList::closeAll(bool force) { return false; } } + pMainWindow->updateAppTitle(); return true; } diff --git a/RedPandaIDE/images/newlook24/046-Locate.png b/RedPandaIDE/images/newlook24/046-Locate.png index 06f161b4..f09ed6a1 100644 Binary files a/RedPandaIDE/images/newlook24/046-Locate.png and b/RedPandaIDE/images/newlook24/046-Locate.png differ diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index e575fe78..ec9ab757 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -207,10 +207,14 @@ MainWindow::MainWindow(QWidget *parent) ui->searchView,&QTreeView::expandAll); ui->replacePanel->setVisible(false); - + //files view ui->treeFiles->setModel(&mFileSystemModel); - mFileSystemModel.setRootPath(pSettings->environment().currentFolder()); - ui->treeFiles->setRootIndex(mFileSystemModel.index(pSettings->environment().currentFolder())); + mFileSystemModel.setReadOnly(true); + setFilesViewRoot(pSettings->environment().currentFolder()); + for (int i=1;itreeFiles->hideColumn(i); + } + //class browser ui->classBrowser->setModel(&mClassBrowserModel); @@ -322,6 +326,8 @@ void MainWindow::updateEditorActions() ui->actionAdd_bookmark->setEnabled(false); ui->actionRemove_Bookmark->setEnabled(false); ui->actionModify_Bookmark_Description->setEnabled(false); + + ui->actionLocate_in_Files_View->setEnabled(false); } else { ui->actionAuto_Detect->setEnabled(true); ui->actionEncode_in_ANSI->setEnabled(true); @@ -362,6 +368,8 @@ void MainWindow::updateEditorActions() ui->actionAdd_bookmark->setEnabled(e->lines()->count()>0 && !e->hasBookmark(line)); ui->actionRemove_Bookmark->setEnabled(e->hasBookmark(line)); ui->actionModify_Bookmark_Description->setEnabled(e->hasBookmark(line)); + + ui->actionLocate_in_Files_View->setEnabled(!e->isNew()); } updateCompileActions(); @@ -2047,33 +2055,113 @@ void MainWindow::buildContextMenus() //toolbar for class browser mClassBrowserToolbar = new QWidget(); - QVBoxLayout* layout = dynamic_cast( ui->tabStructure->layout()); - layout->insertWidget(0,mClassBrowserToolbar); - QHBoxLayout* hlayout = new QHBoxLayout(); - hlayout->setContentsMargins(2,2,2,2); - mClassBrowserToolbar->setLayout(hlayout); - QToolButton * toolButton; - toolButton = new QToolButton; - toolButton->setDefaultAction(mClassBrowser_Sort_By_Type); - hlayout->addWidget(toolButton); - toolButton = new QToolButton; - toolButton->setDefaultAction(mClassBrowser_Sort_By_Name); - hlayout->addWidget(toolButton); - QFrame * vLine = new QFrame(); - vLine->setFrameShape(QFrame::VLine); - vLine->setFrameShadow(QFrame::Sunken); - hlayout->addWidget(vLine); - toolButton = new QToolButton; - toolButton->setDefaultAction(mClassBrowser_Show_Inherited); - hlayout->addWidget(toolButton); - hlayout->addStretch(); + { + QVBoxLayout* layout = dynamic_cast( ui->tabStructure->layout()); + layout->insertWidget(0,mClassBrowserToolbar); + QHBoxLayout* hlayout = new QHBoxLayout(); + hlayout->setContentsMargins(2,2,2,2); + mClassBrowserToolbar->setLayout(hlayout); + QToolButton * toolButton; + toolButton = new QToolButton; + toolButton->setDefaultAction(mClassBrowser_Sort_By_Type); + hlayout->addWidget(toolButton); + toolButton = new QToolButton; + toolButton->setDefaultAction(mClassBrowser_Sort_By_Name); + hlayout->addWidget(toolButton); + QFrame * vLine = new QFrame(); + vLine->setFrameShape(QFrame::VLine); + vLine->setFrameShadow(QFrame::Sunken); + hlayout->addWidget(vLine); + toolButton = new QToolButton; + toolButton->setDefaultAction(mClassBrowser_Show_Inherited); + hlayout->addWidget(toolButton); + hlayout->addStretch(); + } //menu for statusbar mFileEncodingStatus->setContextMenuPolicy(Qt::CustomContextMenu); connect(mFileEncodingStatus,&QWidget::customContextMenuRequested, this, &MainWindow::onFileEncodingContextMenu); - // + //menu for files view + ui->treeFiles->setContextMenuPolicy(Qt::CustomContextMenu); + connect(ui->treeFiles,&QWidget::customContextMenuRequested, + this, &MainWindow::onFilesViewContextMenu); + mFilesView_Open = createActionFor( + tr("Open in Editor"), + ui->treeFiles); + connect(mFilesView_Open, &QAction::triggered, + [this]() { + QString path = mFileSystemModel.filePath(ui->treeFiles->currentIndex()); + if (!path.isEmpty() && QFileInfo(path).isFile()) { + Editor *editor=mEditorList->getEditorByFilename(path); + if (editor) + editor->activate(); + } + }); + mFilesView_OpenWithExternal = createActionFor( + tr("Open in External Program"), + ui->treeFiles); + connect(mFilesView_OpenWithExternal, &QAction::triggered, + [this]() { + QString path = mFileSystemModel.filePath(ui->treeFiles->currentIndex()); + if (!path.isEmpty() && QFileInfo(path).isFile()) { + QDesktopServices::openUrl(QUrl::fromLocalFile(path)); + } + }); + mFilesView_OpenInTerminal = createActionFor( + tr("Open in Terminal"), + ui->treeFiles); + mFilesView_OpenInTerminal->setIcon(ui->actionOpen_Terminal->icon()); + connect(mFilesView_OpenInTerminal, &QAction::triggered, + [this]() { + QString path = mFileSystemModel.filePath(ui->treeFiles->currentIndex()); + if (!path.isEmpty()) { + QFileInfo fileInfo(path); + openShell(fileInfo.path(),"cmd.exe"); + } + }); + mFilesView_OpenInExplorer = createActionFor( + tr("Open in Windows Explorer"), + ui->treeFiles); + mFilesView_OpenInExplorer->setIcon(ui->actionOpen_Containing_Folder->icon()); + connect(mFilesView_OpenInExplorer, &QAction::triggered, + [this]() { + QString path = mFileSystemModel.filePath(ui->treeFiles->currentIndex()); + if (!path.isEmpty()) { + QFileInfo info(path); + if (info.isFile()){ + QDesktopServices::openUrl( + QUrl("file:///"+ + includeTrailingPathDelimiter(info.path()),QUrl::TolerantMode)); + } else if (info.isDir()){ + QDesktopServices::openUrl( + QUrl("file:///"+ + includeTrailingPathDelimiter(path),QUrl::TolerantMode)); + } + } + }); + + //toolbar for files view + mFilesViewToolbar = new QWidget(); + { + QVBoxLayout* layout = dynamic_cast( ui->tabFiles->layout()); + layout->insertWidget(0,mFilesViewToolbar); + QHBoxLayout* hlayout = new QHBoxLayout(); + hlayout->setContentsMargins(2,2,2,2); + mFilesViewToolbar->setLayout(hlayout); + QToolButton * toolButton; + toolButton = new QToolButton; + toolButton->setDefaultAction(ui->actionOpen_Folder); + toolButton->setFixedSize(32,32); + hlayout->addWidget(toolButton); + toolButton = new QToolButton; + toolButton->setDefaultAction(ui->actionLocate_in_Files_View); + toolButton->setFixedSize(32,32); + hlayout->addWidget(toolButton); + hlayout->addStretch(); + } + } void MainWindow::buildEncodingMenu() @@ -2345,6 +2433,26 @@ void MainWindow::onFileEncodingContextMenu(const QPoint &pos) mMenuEncoding->exec(mFileEncodingStatus->mapToGlobal(pos)); } +void MainWindow::onFilesViewContextMenu(const QPoint &pos) +{ + + QMenu menu(this); + menu.addAction(ui->actionOpen_Folder); + menu.addSeparator(); + menu.addAction(mFilesView_Open); + menu.addAction(mFilesView_OpenWithExternal); + menu.addSeparator(); + menu.addAction(mFilesView_OpenInTerminal); + menu.addAction(mFilesView_OpenInExplorer); + QString path = mFileSystemModel.filePath(ui->treeFiles->currentIndex()); + QFileInfo info(path); + mFilesView_Open->setEnabled(info.isFile()); + mFilesView_OpenWithExternal->setEnabled(info.isFile()); + mFilesView_OpenInTerminal->setEnabled(!path.isEmpty()); + mFilesView_OpenInExplorer->setEnabled(!path.isEmpty()); + menu.exec(ui->treeFiles->mapToGlobal(pos)); +} + void MainWindow::onShowInsertCodeSnippetMenu() { mMenuInsertCodeSnippet->clear(); @@ -2407,7 +2515,7 @@ void MainWindow::onEditorContextMenu(const QPoint &pos) menu.addSeparator(); menu.addAction(ui->actionOpen_Containing_Folder); menu.addAction(ui->actionOpen_Terminal); - + menu.addAction(ui->actionLocate_in_Files_View); menu.addSeparator(); menu.addAction(ui->actionReformat_Code); menu.addSeparator(); @@ -2443,6 +2551,7 @@ void MainWindow::onEditorContextMenu(const QPoint &pos) menu.addAction(ui->actionRemove_Bookmark); menu.addAction(ui->actionModify_Bookmark_Description); } + ui->actionLocate_in_Files_View->setEnabled(!editor->isNew()); ui->actionBreakpoint_property->setEnabled(editor->hasBreakpoint(line)); ui->actionAdd_bookmark->setEnabled( line>=0 && editor->lines()->count()>0 @@ -2477,6 +2586,7 @@ void MainWindow::onEditorTabContextMenu(QTabWidget* tabWidget, const QPoint &pos menu.addSeparator(); menu.addAction(ui->actionOpen_Containing_Folder); menu.addAction(ui->actionOpen_Terminal); + menu.addAction(ui->actionLocate_in_Files_View); menu.addSeparator(); menu.addAction(ui->actionMove_To_Other_View); menu.addSeparator(); @@ -2485,7 +2595,10 @@ void MainWindow::onEditorTabContextMenu(QTabWidget* tabWidget, const QPoint &pos tabWidget==ui->EditorTabsRight || tabWidget->count()>1 ); - + Editor * editor = dynamic_cast(tabWidget->widget(index)); + if (editor ) { + ui->actionLocate_in_Files_View->setEnabled(!editor->isNew()); + } menu.exec(tabBar->mapToGlobal(pos)); } @@ -2754,6 +2867,9 @@ void MainWindow::closeEvent(QCloseEvent *event) { settings.setLeftPanelIndex(ui->tabInfos->currentIndex()); settings.setLeftPanelOpenned(mLeftPanelOpenned); settings.save(); + + //save current folder ( for files view ) + pSettings->environment().save(); try { mBookmarkModel->save(includeTrailingPathDelimiter(pSettings->dirs().config()) +DEV_BOOKMARK_FILE); @@ -4343,6 +4459,15 @@ void MainWindow::showSearchReplacePanel(bool show) mSearchResultTreeModel->setSelectable(show); } +void MainWindow::setFilesViewRoot(const QString &path) +{ + mFileSystemModel.setRootPath(path); + ui->treeFiles->setRootIndex(mFileSystemModel.index(path)); + pSettings->environment().setCurrentFolder(path); + ui->txtFilesPath->setText(path); + ui->txtFilesPath->setCursorPosition(1); +} + Ui::MainWindow *MainWindow::mainWidget() const { return ui; @@ -4546,3 +4671,39 @@ void MainWindow::on_actionModify_Bookmark_Description_triggered() } } + +void MainWindow::on_actionLocate_in_Files_View_triggered() +{ + Editor * editor = mEditorList->getEditor(); + if (editor) { + QString fileDir = extractFileDir(editor->filename()); + if (!fileDir.isEmpty()) { + setFilesViewRoot(fileDir); + ui->treeFiles->setCurrentIndex(mFileSystemModel.index(editor->filename())); + } + } +} + + +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(); + } + } +} + + +void MainWindow::on_actionOpen_Folder_triggered() +{ + QString folder = QFileDialog::getExistingDirectory(this,tr("Open Folder"), + pSettings->environment().currentFolder()); + if (!folder.isEmpty()) { + setFilesViewRoot(folder); + } +} + diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 44eb95ce..b34e34e3 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -192,6 +192,7 @@ private: void scanActiveProject(bool parse=false); void includeOrSkipDirs(const QStringList& dirs, bool skip); void showSearchReplacePanel(bool show); + void setFilesViewRoot(const QString& path); private slots: void onAutoSaveTimeout(); @@ -206,6 +207,7 @@ private slots: void onClassBrowserContextMenu(const QPoint& pos); void onDebugConsoleContextMenu(const QPoint& pos); void onFileEncodingContextMenu(const QPoint& pos); + void onFilesViewContextMenu(const QPoint& pos); void onShowInsertCodeSnippetMenu(); @@ -420,6 +422,12 @@ private slots: void on_actionModify_Bookmark_Description_triggered(); + void on_actionLocate_in_Files_View_triggered(); + + void on_treeFiles_doubleClicked(const QModelIndex &index); + + void on_actionOpen_Folder_triggered(); + private: Ui::MainWindow *ui; EditorList *mEditorList; @@ -511,9 +519,6 @@ private: QAction * mFilesView_OpenWithExternal; QAction * mFilesView_OpenInTerminal; QAction * mFilesView_OpenInExplorer; - QAction * mFilesView_OnlyShowDevFiles; - QAction * mFilesView_LocateCurrent; - QWidget * mFilesViewToolbar; //action for debug console diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 1666e1fa..5474c461 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -85,7 +85,7 @@ QTabWidget::West - 2 + 3 true @@ -213,6 +213,9 @@ Files + + 0 + 0 @@ -226,7 +229,24 @@ 0 - + + + true + + + true + + + + + + + QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked + + + QAbstractItemView::DragOnly + + @@ -931,6 +951,7 @@ File + @@ -1965,6 +1986,24 @@ Modify Bookmark Description + + + + :/icons/images/newlook24/046-Locate.png:/icons/images/newlook24/046-Locate.png + + + Locate in Files View + + + + + + :/icons/images/newlook24/053-open.png:/icons/images/newlook24/053-open.png + + + Open Folder + + diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index a43075e0..a9741e88 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -2619,6 +2619,9 @@ void Settings::Environment::doLoad() mInterfaceFontSize = intValue("interface font size",10); mLanguage = stringValue("language", QLocale::system().name()); mCurrentFolder = stringValue("current_folder",QDir::currentPath()); + if (!fileExists(mCurrentFolder)) { + mCurrentFolder = QDir::currentPath(); + } } int Settings::Environment::interfaceFontSize() const diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp index 7c0b4238..5518f23c 100644 --- a/RedPandaIDE/utils.cpp +++ b/RedPandaIDE/utils.cpp @@ -748,7 +748,7 @@ QString parseMacros(const QString &s) QString result = s; Editor *e = pMainWindow->editorList()->getEditor(); - result.replace("", QDir().absolutePath()); + result.replace("", QDir::currentPath()); result.replace("", pSettings->dirs().executable()); result.replace("", DEVCPP_VERSION); result.replace("", pSettings->dirs().app());