diff --git a/NEWS.md b/NEWS.md index b2524987..d91c8f2a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,7 @@ Version 0.6.7 - adjust: the max value of the debug console's vertical scrollbar. - fix: shfit+click not correctly set selection's end - fix: ctrl+home/end not correctly set cursor to start/end of the editor + - enhancement: click the encoding info in the statusbar will show encoding menu Version 0.6.6 - fix: crash when create new file diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 3ecceff8..8a7f39f4 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -115,6 +115,7 @@ SOURCES += \ widgets/functiontooltipwidget.cpp \ widgets/headercompletionpopup.cpp \ widgets/issuestable.cpp \ + widgets/labelwithmenu.cpp \ widgets/macroinfomodel.cpp \ widgets/newprojectdialog.cpp \ widgets/qconsole.cpp \ @@ -226,6 +227,7 @@ HEADERS += \ widgets/functiontooltipwidget.h \ widgets/headercompletionpopup.h \ widgets/issuestable.h \ + widgets/labelwithmenu.h \ widgets/macroinfomodel.h \ widgets/newprojectdialog.h \ widgets/qconsole.h \ diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.qm b/RedPandaIDE/RedPandaIDE_zh_CN.qm index d1bae071..c156fffc 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 6890f7eb..1ef27b88 100644 --- a/RedPandaIDE/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts @@ -82,17 +82,17 @@ BacktraceModel - + Function 函数 - + Filename 文件名 - + Line @@ -100,17 +100,17 @@ BreakpointModel - + Filename 文件名 - + Line - + Condition 条件 @@ -836,68 +836,68 @@ Are you really want to continue? Debugger - + No compiler set 无编译器设置 - + No compiler set is configured. 没有配置编译器设置。 - + Can't start debugging. 无法启动调试器 - + Debugger path error 调试路径错误 - + Debugger's path "%1" contains non-ascii characters. 调试路径"%1"中包含非ASCII字符(如,中文字符) - + This prevents it from executing. 这会导致调试器无法启动。 - + Debugger not exists 找不到调试器 - + Can''t find debugger in : "%1" 找不到调试器程序"%1" - - + + Execute to evaluate 执行以求值 - + Not found in current context 不在当前语境中 - + Compile 编译 - + Source file is more recent than executable. 源文件比程序文件新。 - + Recompile? 重新编译? @@ -2686,7 +2686,7 @@ Are you really want to continue? - + Issues 编译器 @@ -2889,8 +2889,8 @@ Are you really want to continue? - - + + Compile 编译 @@ -3334,7 +3334,7 @@ Are you really want to continue? - + Clear all breakpoints 删除所有断点 @@ -3435,7 +3435,7 @@ Are you really want to continue? - + Rename Symbol 重命名符号 @@ -3456,13 +3456,13 @@ Are you really want to continue? - + Export As RTF 导出为RTF - + Export As HTML 导出为HTML @@ -3474,10 +3474,10 @@ Are you really want to continue? Ctrl+M - + Ctrl+M - + File Encoding 文件编码 @@ -3522,8 +3522,9 @@ Are you really want to continue? - Line:%1 Col:%2 Selected:%3 Lines:%4 Length:%5 - 行:%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 @@ -3690,6 +3691,11 @@ Are you really want to continue? Export 导出 + + + Insert Snippet + 插入代码段 + Show debug logs in the debug console @@ -3782,141 +3788,141 @@ Are you really want to continue? 跳转到定义处 - + Character sets 字符集 - + %1 files autosaved 已自动保存%1个文件 - + Save project 保存项目 - + The project '%1' has modifications. 项目'%1'有改动。 - + Do you want to save it? 需要保存吗? - + 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 错误 @@ -3926,75 +3932,75 @@ Are you really want to continue? 项目历史 - + 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个文件) @@ -5400,17 +5406,17 @@ Are you really want to continue? RegisterModel - + Register 寄存器 - + Value(Hex) 值(HEX) - + Value(Dec) 值(DEC) @@ -6238,12 +6244,12 @@ Are you really want to continue? WatchModel - + Expression 表达式 - + Value diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index c72e4b15..bb0e2abf 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -57,7 +57,7 @@ MainWindow::MainWindow(QWidget *parent) ui->setupUi(this); // status bar mFileInfoStatus=new QLabel(); - mFileEncodingStatus = new QLabel(); + mFileEncodingStatus = new LabelWithMenu(); mFileModeStatus = new QLabel(); mFileInfoStatus->setStyleSheet("margin-left:10px; margin-right:10px"); mFileEncodingStatus->setStyleSheet("margin-left:10px; margin-right:10px"); @@ -119,7 +119,7 @@ MainWindow::MainWindow(QWidget *parent) rebuildOpenedFileHisotryMenu(); mMenuInsertCodeSnippet = new QMenu(); - mMenuInsertCodeSnippet->setTitle("Insert Snippet"); + mMenuInsertCodeSnippet->setTitle(tr("Insert Snippet")); ui->menuCode->insertMenu(ui->actionReformat_Code,mMenuInsertCodeSnippet); ui->menuCode->insertSeparator(ui->actionReformat_Code); connect(mMenuInsertCodeSnippet,&QMenu::aboutToShow, @@ -686,11 +686,11 @@ void MainWindow::updateStatusbarForLineCol() if (e!=nullptr) { int col = e->charToColumn(e->caretY(),e->caretX()); QString msg = tr("Line:%1 Col:%2 Selected:%3 Lines:%4 Length:%5") - .arg(e->caretY(),4) - .arg(col,3) - .arg(e->selText().length(),6) - .arg(e->lines()->count(),4) - .arg(e->lines()->getTextLength(),6); + .arg(e->caretY()) + .arg(col) + .arg(e->selText().length()) + .arg(e->lines()->count()) + .arg(e->lines()->getTextLength()); mFileInfoStatus->setText(msg); } else { mFileInfoStatus->setText(""); @@ -1930,6 +1930,11 @@ void MainWindow::buildContextMenus() toolButton->setDefaultAction(mClassBrowser_Show_Inherited); hlayout->addWidget(toolButton); hlayout->addStretch(); + + //menu for statusbar + mFileEncodingStatus->setContextMenuPolicy(Qt::CustomContextMenu); + connect(mFileEncodingStatus,&QWidget::customContextMenuRequested, + this, &MainWindow::onFileEncodingContextMenu); } void MainWindow::buildEncodingMenu() @@ -2185,6 +2190,11 @@ void MainWindow::onDebugConsoleContextMenu(const QPoint &pos) menu.exec(ui->debugConsole->mapToGlobal(pos)); } +void MainWindow::onFileEncodingContextMenu(const QPoint &pos) +{ + mMenuEncoding->exec(mFileEncodingStatus->mapToGlobal(pos)); +} + void MainWindow::onShowInsertCodeSnippetMenu() { mMenuInsertCodeSnippet->clear(); diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 28338060..872b7c6a 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -15,6 +15,7 @@ #include "codesnippetsmanager.h" #include "todoparser.h" #include "toolsmanager.h" +#include "widgets/labelwithmenu.h" QT_BEGIN_NAMESPACE @@ -199,6 +200,7 @@ private slots: void onProjectViewContextMenu(const QPoint& pos); void onClassBrowserContextMenu(const QPoint& pos); void onDebugConsoleContextMenu(const QPoint& pos); + void onFileEncodingContextMenu(const QPoint& pos); void onShowInsertCodeSnippetMenu(); @@ -405,7 +407,7 @@ private: Ui::MainWindow *ui; EditorList *mEditorList; QLabel *mFileInfoStatus; - QLabel *mFileEncodingStatus; + LabelWithMenu *mFileEncodingStatus; QLabel *mFileModeStatus; QMenu *mMenuEncoding; QMenu *mMenuExport; diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index e6161fe4..6cfc87ac 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -283,7 +283,7 @@ QTabWidget::South - 1 + 2 @@ -388,16 +388,16 @@ - 2 + 0 - 2 + 0 - 2 + 0 - 2 + 0 diff --git a/RedPandaIDE/resources/codesnippets.json b/RedPandaIDE/resources/codesnippets.json index 81d2ce8f..af572a91 100644 --- a/RedPandaIDE/resources/codesnippets.json +++ b/RedPandaIDE/resources/codesnippets.json @@ -61,5 +61,19 @@ "description": "", "prefix": "function()", "section": -1 + }, + { + "caption": "Comment Header", + "code": "/**\r\n * @file %REPL_BEGIN%%REPL_END% \r\n * @brief: %INSERT%\r\n * @version: %INSERT% \r\n * @copyright: %INSERT%\r\n * @author: %INSERT%\r\n * @date: \r\n * \r\n **/", + "description": "", + "prefix": "", + "section": 0 + }, + { + "caption": "Date/Time", + "code": "", + "description": "", + "prefix": "", + "section": 0 } ] diff --git a/RedPandaIDE/widgets/labelwithmenu.cpp b/RedPandaIDE/widgets/labelwithmenu.cpp new file mode 100644 index 00000000..79ace327 --- /dev/null +++ b/RedPandaIDE/widgets/labelwithmenu.cpp @@ -0,0 +1,18 @@ +#include "labelwithmenu.h" + +#include +#include +#include + +LabelWithMenu::LabelWithMenu(QWidget* parent):QLabel(parent) +{ + +} + +void LabelWithMenu::mousePressEvent(QMouseEvent *event) +{ + QContextMenuEvent *e = new QContextMenuEvent(QContextMenuEvent::Reason::Mouse, + event->pos()); + QApplication::instance()->postEvent(this,e); + event->accept(); +} diff --git a/RedPandaIDE/widgets/labelwithmenu.h b/RedPandaIDE/widgets/labelwithmenu.h new file mode 100644 index 00000000..0d1d4e86 --- /dev/null +++ b/RedPandaIDE/widgets/labelwithmenu.h @@ -0,0 +1,17 @@ +#ifndef LABELWITHMENU_H +#define LABELWITHMENU_H + +#include + +class LabelWithMenu : public QLabel +{ + Q_OBJECT +public: + explicit LabelWithMenu(QWidget* parent = nullptr); + + // QWidget interface +protected: + void mousePressEvent(QMouseEvent *event) override; +}; + +#endif // LABELWITHMENU_H