diff --git a/NEWS.md b/NEWS.md index 187195d0..c1be869a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,11 @@ Version 0.7.8 - fix: current input/expected not correctly applied when save/run problem cases - fix: colors of the syntax issues view are not correctly set using the current color sheme - change: The error color of color scheme "vs code" + - add: "C Reference" in the help menu + - fix: Custom editor colors shouldn't be tested for high contrast with the default background color + - fix: Custom color settings not correctly displayed in the options widget + - enhancement: add hit counts in the search result view + - fix: editor actions' state not correctly updated after close editors. Version 0.7.7 - enhancement: Problem Set diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.ts b/RedPandaIDE/RedPandaIDE_zh_CN.ts index 43a313af..e71fe821 100644 --- a/RedPandaIDE/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts @@ -2828,11 +2828,11 @@ Are you really want to continue? - - - - - + + + + + Issues 编译器 @@ -2842,29 +2842,29 @@ Are you really want to continue? 编译日志 - + File 文件 - + Tools 工具 - - + + Run 运行 - + Edit 编辑 - + Project 项目 @@ -2889,9 +2889,9 @@ Are you really want to continue? - - - + + + Debug 调试 @@ -2922,7 +2922,7 @@ Are you really want to continue? - + Search 查找 @@ -2947,23 +2947,23 @@ Are you really want to continue? 替换 - + Close 关闭 - + Execute 运行 - - + + Code 代码 - + Window 窗口 @@ -2976,263 +2976,263 @@ 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 单步进入 - + Problem Set 试题集 - + New Problem Set 新建试题集 @@ -3251,14 +3251,14 @@ Are you really want to continue? - + Save Problem Set 保存试题集 - + Load Problem Set 载入试题集 @@ -3291,7 +3291,7 @@ Are you really want to continue? - + Problem 试题 @@ -3336,464 +3336,464 @@ Are you really want to continue? 期望输出 - + 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 Watches 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 打开文件夹 - + Running Parameters... 运行参数... - + File Encoding 文件编码 - + Recent Files 文件历史 - - - - - - + + + + + + Debugging 正在调试 - - - - - - + + + + + + Running 正在运行 - - - - - - + + + + + + Compiling 正在编译 @@ -3802,654 +3802,654 @@ 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 插入代码段 - - + + Problem Set %1 试题集%1 - + Listen failed 监听失败 - + Can't listen to port %1 form Competitve Companion. 无法在网络端口"%1"监听Competitive Companion连接。 - + You can turn off competitive companion support in the Problem Set options. 您可以在“试题集”选项卡中关闭监听Competitive Companion选项。 - + Or You can choose a different port number and try again. 或者选择使用其他的网络端口。 - + Red Panda Dev-C++ 小熊猫Dev-C++ - + Remove 删除 - + Remove All Bookmarks 删除全部书签 - + 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 Remove all breakpoints 删除所有断点 - + Remove Breakpoint 删除当前断点 - + 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 保存失败 - + Change Project Compiler Set 改变项目编译器配置集 - + Change the project's compiler set will lose all custom compiler set options. 改变项目的编译器配置集会导致所有的自定义编译器选项被重置。 - + Do you really want to do that? 你真的想要做那些吗? - + 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 无法使用模板创建项目 - + untitled 无标题 - + New Project File Name 新的项目文件名 - + File Name: 文件名: - + File Already Exists! 文件已存在! - + File '%1' already exists! 文件'%1'已经存在! - + 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) - + The current problem set is not empty. 当前的试题集不是空的。 - + Problem %1 试题%1 - - + + Problem Set Files (*.pbs) 试题集文件 (*.pbs) - + Load Error 载入失败 - - + + Problem Case %1 试题案例%1 - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + 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个文件) @@ -6298,7 +6298,7 @@ Are you really want to continue? 自动链接 - + @@ -6374,7 +6374,7 @@ Are you really want to continue? 杂项 - + Program Runner diff --git a/RedPandaIDE/editorlist.cpp b/RedPandaIDE/editorlist.cpp index 82b8c57b..66ed92d0 100644 --- a/RedPandaIDE/editorlist.cpp +++ b/RedPandaIDE/editorlist.cpp @@ -11,7 +11,9 @@ EditorList::EditorList(QTabWidget* leftPageWidget, QTabWidget* rightPageWidget, QSplitter* splitter, - QWidget* panel): + QWidget* panel, + QObject* parent): + QObject(parent), mLayout(LayoutShowType::lstLeft), mLeftPageWidget(leftPageWidget), mRightPageWidget(rightPageWidget), @@ -157,9 +159,7 @@ bool EditorList::closeEditor(Editor* editor, bool transferFocus, bool force) { else pMainWindow->updateClassBrowserForEditor(editor); } - if (pageCount()==0) { - pMainWindow->updateAppTitle(); - } + emit editorClosed(); return true; } @@ -290,7 +290,6 @@ bool EditorList::closeAll(bool force) { return false; } } - pMainWindow->updateAppTitle(); return true; } @@ -301,6 +300,7 @@ void EditorList::forceCloseEditor(Editor *editor) // Force layout update when creating, destroying or moving editors updateLayout(); endUpdate(); + emit editorClosed(); } Editor* EditorList::getOpenedEditorByFilename(QString filename) diff --git a/RedPandaIDE/editorlist.h b/RedPandaIDE/editorlist.h index 1b150275..e4820783 100644 --- a/RedPandaIDE/editorlist.h +++ b/RedPandaIDE/editorlist.h @@ -7,8 +7,9 @@ #include "utils.h" class Editor; -class EditorList +class EditorList : public QObject { + Q_OBJECT public: enum class LayoutShowType{ lstLeft, @@ -19,7 +20,7 @@ public: explicit EditorList(QTabWidget* leftPageWidget, QTabWidget* rightPageWidget, QSplitter* splitter, - QWidget* panel); + QWidget* panel, QObject* parent = nullptr); Editor* newEditor(const QString& filename, const QByteArray& encoding, bool inProject, bool newFile, @@ -59,6 +60,9 @@ public: QTabWidget *rightPageWidget() const; +signals: + void editorClosed(); + private: QTabWidget* getNewEditorPageControl() const; QTabWidget* getFocusedPageControl() const; diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index d6fef451..3532bfa9 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -76,6 +76,8 @@ MainWindow::MainWindow(QWidget *parent) ui->EditorTabsRight, ui->splitterEditorPanel, ui->EditorPanel); + connect(mEditorList, &EditorList::editorClosed, + this, &MainWindow::onEditorClosed); mProject = nullptr; setupActions(); ui->EditorTabsRight->setVisible(false); @@ -447,11 +449,6 @@ void MainWindow::updateCompileActions() || mEditorList->pageCount()>0); } -static bool haveGoodContrast(const QColor& c1, const QColor &c2) { - int lightness1 = c1.lightness(); - int lightness2 = c2.lightness(); - return std::abs(lightness1 - lightness2)>=100; -} void MainWindow::updateEditorColorSchemes() { @@ -466,50 +463,54 @@ void MainWindow::updateEditorColorSchemes() item = pColorManager->getItem(schemeName, SYNS_AttrFunction); QColor baseColor = palette().color(QPalette::Base); - if (item && haveGoodContrast(item->foreground(), baseColor)) { + if (item) { mStatementColors->insert(StatementKind::skFunction,item); mStatementColors->insert(StatementKind::skConstructor,item); mStatementColors->insert(StatementKind::skDestructor,item); } item = pColorManager->getItem(schemeName, SYNS_AttrClass); - if (item && haveGoodContrast(item->foreground(), baseColor)) { + if (item) { mStatementColors->insert(StatementKind::skClass,item); mStatementColors->insert(StatementKind::skTypedef,item); mStatementColors->insert(StatementKind::skAlias,item); } item = pColorManager->getItem(schemeName, SYNS_AttrIdentifier); - if (item && haveGoodContrast(item->foreground(), baseColor)) { + if (item) { mStatementColors->insert(StatementKind::skEnumType,item); mStatementColors->insert(StatementKind::skEnumClassType,item); } item = pColorManager->getItem(schemeName, SYNS_AttrVariable); - if (item && haveGoodContrast(item->foreground(), baseColor)) { + if (item) { mStatementColors->insert(StatementKind::skVariable,item); } item = pColorManager->getItem(schemeName, SYNS_AttrLocalVariable); - if (item && haveGoodContrast(item->foreground(), baseColor)) { + if (item) { mStatementColors->insert(StatementKind::skLocalVariable,item); mStatementColors->insert(StatementKind::skParameter,item); } item = pColorManager->getItem(schemeName, SYNS_AttrGlobalVariable); - if (item && haveGoodContrast(item->foreground(), baseColor)) { + if (item) { mStatementColors->insert(StatementKind::skGlobalVariable,item); } item = pColorManager->getItem(schemeName, SYNS_AttrPreprocessor); - if (item && haveGoodContrast(item->foreground(), baseColor)) { + if (item) { mStatementColors->insert(StatementKind::skPreprocessor,item); mStatementColors->insert(StatementKind::skEnum,item); - mHeaderCompletionPopup->setSuggestionColor(item->foreground()); + if (haveGoodContrast(item->foreground(), baseColor)) { + mHeaderCompletionPopup->setSuggestionColor(item->foreground()); + } else { + mHeaderCompletionPopup->setSuggestionColor(palette().color(QPalette::Text)); + } } else { mHeaderCompletionPopup->setSuggestionColor(palette().color(QPalette::Text)); } item = pColorManager->getItem(schemeName, SYNS_AttrReservedWord); - if (item && haveGoodContrast(item->foreground(), baseColor)) { + if (item) { mStatementColors->insert(StatementKind::skKeyword,item); mStatementColors->insert(StatementKind::skUserCodeSnippet,item); } item = pColorManager->getItem(schemeName, SYNS_AttrString); - if (item && haveGoodContrast(item->foreground(), baseColor)) { + if (item) { mStatementColors->insert(StatementKind::skNamespace,item); mStatementColors->insert(StatementKind::skNamespaceAlias,item); } @@ -1119,7 +1120,7 @@ bool MainWindow::compile(bool rebuild) Editor * editor = mEditorList->getEditor(); if (editor != NULL ) { clearIssues(); - if (editor->modified()) { + if (editor->modified() || editor->isNew()) { if (!editor->save(false,false)) return false; } @@ -1210,7 +1211,7 @@ void MainWindow::runExecutable(RunType runType) } else { Editor * editor = mEditorList->getEditor(); if (editor != NULL ) { - if (editor->modified()) { + if (editor->modified() || editor->isNew()) { if (!editor->save(false,false)) return; } @@ -1342,13 +1343,12 @@ void MainWindow::debug() Editor* e = mEditorList->getEditor(); if (e!=nullptr) { // Did we saved? - if (e->modified()) { + if (e->modified() || e->isNew()) { // if file is modified,save it first if (!e->save(false,false)) return; } - // Did we compiled? filePath = getCompiledExecutableName(e->filename()); debugFile.setFile(filePath); @@ -1386,7 +1386,9 @@ void MainWindow::debug() } break; default: - break; + //don't compile + updateEditorActions(); + return; } updateEditorActions(); @@ -2673,6 +2675,14 @@ void MainWindow::onNewProblemConnection() clientConnection->disconnectFromHost(); } +void MainWindow::onEditorClosed() +{ + if (mQuitting) + return; + updateEditorActions(); + updateAppTitle(); +} + void MainWindow::onShowInsertCodeSnippetMenu() { mMenuInsertCodeSnippet->clear(); @@ -5200,3 +5210,22 @@ void MainWindow::on_btnRunAllProblemCases_clicked() runExecutable(RunType::ProblemCases); } + +void MainWindow::on_actionC_Reference_triggered() +{ + if (pSettings->environment().language()=="zh_CN") { + QDesktopServices::openUrl(QUrl("https://zh.cppreference.com/w/c")); + } else { + QDesktopServices::openUrl(QUrl("https://en.cppreference.com/w/c")); + } +} + + +void MainWindow::on_btnRemoveProblemCase_clicked() +{ + QModelIndex idx = ui->lstProblemCases->currentIndex(); + if (idx.isValid()) { + mOJProblemModel.removeCase(idx.row()); + } +} + diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 2d81878e..2a22961d 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -231,6 +231,7 @@ private slots: void onProblemCaseIndexChanged(const QModelIndex ¤t, const QModelIndex &previous); void onProblemNameChanged(int index); void onNewProblemConnection(); + void onEditorClosed(); void onShowInsertCodeSnippetMenu(); @@ -467,6 +468,10 @@ private slots: void on_btnRunAllProblemCases_clicked(); + void on_actionC_Reference_triggered(); + + void on_btnRemoveProblemCase_clicked(); + private: Ui::MainWindow *ui; EditorList *mEditorList; diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 03595178..6fea2a37 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -497,7 +497,7 @@ QTabWidget::South - 0 + 6 @@ -1460,6 +1460,7 @@ Help + @@ -2350,7 +2351,10 @@ - C/C++ Reference + C++ Reference + + + C++ Reference @@ -2408,6 +2412,11 @@ Running Parameters... + + + C Reference + + diff --git a/RedPandaIDE/systemconsts.h b/RedPandaIDE/systemconsts.h index d448e9e0..e6deb8dd 100644 --- a/RedPandaIDE/systemconsts.h +++ b/RedPandaIDE/systemconsts.h @@ -3,7 +3,7 @@ #include -#define DEVCPP_VERSION "0.7.7" +#define DEVCPP_VERSION "0.7.8" #define APP_SETTSINGS_FILENAME "redpandacpp.ini" #ifdef Q_OS_WIN diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp index e01413a9..cf4ac521 100644 --- a/RedPandaIDE/utils.cpp +++ b/RedPandaIDE/utils.cpp @@ -852,3 +852,9 @@ QByteArray getHTTPBody(const QByteArray& content) { } return ""; } + +bool haveGoodContrast(const QColor& c1, const QColor &c2) { + int lightness1 = c1.lightness(); + int lightness2 = c2.lightness(); + return std::abs(lightness1 - lightness2)>=80; +} diff --git a/RedPandaIDE/utils.h b/RedPandaIDE/utils.h index d6eb0df5..958ea8dd 100644 --- a/RedPandaIDE/utils.h +++ b/RedPandaIDE/utils.h @@ -167,6 +167,7 @@ QString TrimLeft(const QString& s); bool StringIsBlank(const QString& s); int compareFileModifiedTime(const QString& filename1, const QString& filename2); QByteArray getHTTPBody(const QByteArray& content); +bool haveGoodContrast(const QColor& c1, const QColor &c2); //void changeTheme(const QString& themeName); diff --git a/RedPandaIDE/widgets/classbrowser.cpp b/RedPandaIDE/widgets/classbrowser.cpp index 2d4181fd..80c019f8 100644 --- a/RedPandaIDE/widgets/classbrowser.cpp +++ b/RedPandaIDE/widgets/classbrowser.cpp @@ -6,6 +6,7 @@ #include "../mainwindow.h" #include "../settings.h" #include "../colorscheme.h" +#include "../utils.h" ClassBrowserModel::ClassBrowserModel(QObject *parent):QAbstractItemModel(parent) { @@ -140,8 +141,10 @@ QVariant ClassBrowserModel::data(const QModelIndex &index, int role) const kind = StatementKind::skPreprocessor; } PColorSchemeItem item = mColors->value(kind,PColorSchemeItem()); - if (item) { + if (item && haveGoodContrast(item->foreground(), pMainWindow->palette().color(QPalette::Base))) { return item->foreground(); + } else { + return QVariant(); } } return pMainWindow->palette().color(QPalette::Text); diff --git a/RedPandaIDE/widgets/codecompletionpopup.cpp b/RedPandaIDE/widgets/codecompletionpopup.cpp index 0b193e94..79cf2d21 100644 --- a/RedPandaIDE/widgets/codecompletionpopup.cpp +++ b/RedPandaIDE/widgets/codecompletionpopup.cpp @@ -25,7 +25,7 @@ CodeCompletionPopup::CodeCompletionPopup(QWidget *parent) : kind = statement->kind; } PColorSchemeItem item = mColors->value(kind,PColorSchemeItem()); - if (item) { + if (item && haveGoodContrast(item->foreground(),palette().color(QPalette::Base))) { return item->foreground(); } return palette().color(QPalette::Text); diff --git a/RedPandaIDE/widgets/coloredit.cpp b/RedPandaIDE/widgets/coloredit.cpp index 815ef458..7def1e1e 100644 --- a/RedPandaIDE/widgets/coloredit.cpp +++ b/RedPandaIDE/widgets/coloredit.cpp @@ -23,7 +23,7 @@ void ColorEdit::setColor(const QColor &value) mColor=value; emit colorChanged(value); resize(sizeHint()); -// update(); + repaint(); } } diff --git a/RedPandaIDE/widgets/headercompletionpopup.cpp b/RedPandaIDE/widgets/headercompletionpopup.cpp index 5634496f..865ea1ad 100644 --- a/RedPandaIDE/widgets/headercompletionpopup.cpp +++ b/RedPandaIDE/widgets/headercompletionpopup.cpp @@ -236,6 +236,8 @@ bool HeaderCompletionPopup::event(QEvent *event) case QEvent::FontChange: mListView->setFont(font()); break; + default: + break; } return result; } diff --git a/RedPandaIDE/widgets/ojproblemsetmodel.cpp b/RedPandaIDE/widgets/ojproblemsetmodel.cpp index 32abf18e..f2d0c79c 100644 --- a/RedPandaIDE/widgets/ojproblemsetmodel.cpp +++ b/RedPandaIDE/widgets/ojproblemsetmodel.cpp @@ -150,7 +150,7 @@ void OJProblemSetModel::loadFromFile(const QString &fileName) } } -int OJProblemSetModel::rowCount(const QModelIndex &parent) const +int OJProblemSetModel::rowCount(const QModelIndex &) const { return mProblemSet.problems.count(); } diff --git a/RedPandaIDE/widgets/searchresultview.cpp b/RedPandaIDE/widgets/searchresultview.cpp index 5e882e3f..3242b507 100644 --- a/RedPandaIDE/widgets/searchresultview.cpp +++ b/RedPandaIDE/widgets/searchresultview.cpp @@ -208,7 +208,8 @@ QVariant SearchResultTreeModel::data(const QModelIndex &index, int role) const } if (item->parent==nullptr) { //is filename - return item->filename; + return QString("%1(%2)").arg(item->filename) + .arg(item->results.count()); } else { return QString("%1 %2: %3").arg(tr("Line")).arg(item->line) .arg(item->text);