From c5331f059705d966e22b9a993239f961d10f67b3 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Fri, 20 Jan 2023 12:17:04 +0800 Subject: [PATCH] - enhancement: If there is "cppreference.chm" or "cppreference-%locale_name%.chm"(like cppreference-zh_CN.chm) in the redpanda C++'s app folder, open it instead of the cppreference website. --- NEWS.md | 2 ++ RedPandaIDE/mainwindow.cpp | 32 +++++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/NEWS.md b/NEWS.md index 0cc3d964..74534ec1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,6 +9,8 @@ Red Panda C++ Version 2.10 - enhancement: Save project files' real encoding; - enhancement: Use project files' real encoding information when generating the makefile. - fix: If buttons in the options dialog / compiler / compiler set page is pressed, they won't release. + - enhancement: Confirm before remove a compiler set. + - enhancement: If there is "cppreference.chm" or "cppreference-%locale_name%.chm"(like cppreference-zh_CN.chm) in the redpanda C++'s app folder, open it instead of the cppreference website. Red Panda C++ Version 2.9 diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 80831e6c..f13dad96 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -7921,14 +7921,20 @@ void MainWindow::on_actionMove_To_Other_View_triggered() void MainWindow::on_actionC_C_Reference_triggered() { + QFileInfo fileInfo(includeTrailingPathDelimiter(pSettings->dirs().appDir())+ + QString("cppreference-%1.chm").arg(pSettings->environment().language())); + if (fileInfo.exists()) { + QDesktopServices::openUrl(QUrl::fromLocalFile(fileInfo.absoluteFilePath())); + return; + } + fileInfo=QFileInfo(includeTrailingPathDelimiter(pSettings->dirs().appDir())+ + QString("cppreference.chm")); + if (fileInfo.exists()) { + QDesktopServices::openUrl(QUrl::fromLocalFile(fileInfo.absoluteFilePath())); + return; + } if (pSettings->environment().language()=="zh_CN") { - QFileInfo fileInfo(includeTrailingPathDelimiter(pSettings->dirs().appDir())+"cppreference-zh.chm"); - if (fileInfo.exists()) { - QDesktopServices::openUrl(QUrl::fromLocalFile(fileInfo.absoluteFilePath())); - } else { - - QDesktopServices::openUrl(QUrl("https://zh.cppreference.com/w/cpp")); - } + QDesktopServices::openUrl(QUrl("https://zh.cppreference.com/w/cpp")); } else { QDesktopServices::openUrl(QUrl("https://en.cppreference.com/w/cpp")); } @@ -8250,6 +8256,18 @@ void MainWindow::onProblemRunAllCases() void MainWindow::on_actionC_Reference_triggered() { + QFileInfo fileInfo(includeTrailingPathDelimiter(pSettings->dirs().appDir())+ + QString("cppreference-%1.chm").arg(pSettings->environment().language())); + if (fileInfo.exists()) { + QDesktopServices::openUrl(QUrl::fromLocalFile(fileInfo.absoluteFilePath())); + return; + } + fileInfo=QFileInfo(includeTrailingPathDelimiter(pSettings->dirs().appDir())+ + QString("cppreference.chm")); + if (fileInfo.exists()) { + QDesktopServices::openUrl(QUrl::fromLocalFile(fileInfo.absoluteFilePath())); + return; + } if (pSettings->environment().language()=="zh_CN") { QDesktopServices::openUrl(QUrl("https://zh.cppreference.com/w/c")); } else {