From 55b63a4f95310b32f6a67a85d275734665ba1320 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Mon, 24 Oct 2022 19:23:43 +0800 Subject: [PATCH] - enhancement: refresh project view for git status won't redraw project structure - enhancement: auto save project options after the compilerset option for project resetted - enhancement: "." and ".." in paths of issues not correctly handled - enhancement: auto locate the last opened file in the project view after project creation - enhancement: separate compiler's language standard option for C / C++ - fix: compiler settings not correctly handled when create makefile --- NEWS.md | 3 + RedPandaIDE/compiler/compiler.cpp | 13 +-- RedPandaIDE/compiler/compilerinfo.cpp | 23 ++-- RedPandaIDE/compiler/compilerinfo.h | 2 + RedPandaIDE/mainwindow.cpp | 34 +++++- RedPandaIDE/mainwindow.ui | 3 + RedPandaIDE/settings.cpp | 155 ++++++++++++++++++++++++++ RedPandaIDE/settings.h | 48 ++++++++ 8 files changed, 259 insertions(+), 22 deletions(-) diff --git a/NEWS.md b/NEWS.md index 0433968b..3b0a4cb5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -17,6 +17,9 @@ Red Panda C++ Version 2.0 - enhancement: refresh project view for git status won't redraw project structure - enhancement: auto save project options after the compilerset option for project resetted - enhancement: "." and ".." in paths of issues not correctly handled + - enhancement: auto locate the last opened file in the project view after project creation + - enhancement: separate compiler's language standard option for C / C++ + - fix: compiler settings not correctly handled when create makefile Red Panda C++ Version 1.5 diff --git a/RedPandaIDE/compiler/compiler.cpp b/RedPandaIDE/compiler/compiler.cpp index 5a099c5a..07ab4972 100644 --- a/RedPandaIDE/compiler/compiler.cpp +++ b/RedPandaIDE/compiler/compiler.cpp @@ -113,8 +113,7 @@ QString Compiler::getFileNameFromOutputLine(QString &line) { break; } } - QFileInfo info(temp); - return info.isAbsolute()?cleanPath(temp):absolutePath(mDirectory,temp); + return temp; } int Compiler::getLineNumberFromOutputLine(QString &line) @@ -389,8 +388,9 @@ QString Compiler::getCCompileArguments(bool checkSyntax) if (pOption && pOption->isC && !pOption->isLinker) { if (pOption->choices.isEmpty()) result += " " + pOption->setting; - else - result += " " + pOption->setting + compilerSet()->getCompileOptionValue(key); + else { + result += " " + pOption->setting + compileOptions[key]; + } } } @@ -432,7 +432,7 @@ QString Compiler::getCppCompileArguments(bool checkSyntax) if (pOption->choices.isEmpty()) result += " " + pOption->setting; else - result += " " + pOption->setting + compilerSet()->getCompileOptionValue(key); + result += " " + pOption->setting + compileOptions[key]; } } if (compilerSet()->useCustomCompileParams() && !compilerSet()->customCompileParams().isEmpty()) { @@ -544,11 +544,10 @@ QString Compiler::getLibraryArguments(FileType fileType) if (pOption->choices.isEmpty()) result += " " + pOption->setting; else - result += " " + pOption->setting + compilerSet()->getCompileOptionValue(key); + result += " " + pOption->setting + compileOptions[key]; } } - // Add global compiler linker extras if (compilerSet()->useCustomLinkParams() && !compilerSet()->customLinkParams().isEmpty()) { QStringList params = textToLines(compilerSet()->customLinkParams()); diff --git a/RedPandaIDE/compiler/compilerinfo.cpp b/RedPandaIDE/compiler/compilerinfo.cpp index 0fc6f3da..48805847 100644 --- a/RedPandaIDE/compiler/compilerinfo.cpp +++ b/RedPandaIDE/compiler/compilerinfo.cpp @@ -68,27 +68,30 @@ void CompilerInfo::prepareCompilerOptions() sl.append(QPair("Debug (g)","g")); addOption(CC_CMD_OPT_OPTIMIZE, QObject::tr("Optimization level (-Ox)"), groupName, true, true, false, "-O", sl); - // Language Standards + // C++ Language Standards sl.clear(); - sl.append(QPair("ISO C90","c90")); - sl.append(QPair("ISO C99","c99")); - sl.append(QPair("ISO C11","c11")); - sl.append(QPair("ISO C17","c17")); sl.append(QPair("ISO C++","c++98")); sl.append(QPair("ISO C++11","c++11")); sl.append(QPair("ISO C++14","c++14")); sl.append(QPair("ISO C++17","c++17")); sl.append(QPair("ISO C++20","c++2a")); - sl.append(QPair("GNU C90","gnu90")); - sl.append(QPair("GNU C99","gnu99")); - sl.append(QPair("GNU C11","gnu11")); - sl.append(QPair("GNU C17","gnu17")); sl.append(QPair("GNU C++","gnu++98")); sl.append(QPair("GNU C++11","gnu++11")); sl.append(QPair("GNU C++14","gnu++14")); sl.append(QPair("GNU C++17","gnu++17")); sl.append(QPair("GNU C++20","gnu++2a")); - addOption(CC_CMD_OPT_STD, QObject::tr("Language standard (-std)"), groupName, true, true, false, "-std=", sl); + addOption(CC_CMD_OPT_STD, QObject::tr("C++ Language standard (-std)"), groupName, false, true, false, "-std=", sl); + + sl.clear(); + sl.append(QPair("ISO C90","c90")); + sl.append(QPair("ISO C99","c99")); + sl.append(QPair("ISO C11","c11")); + sl.append(QPair("ISO C17","c17")); + sl.append(QPair("GNU C90","gnu90")); + sl.append(QPair("GNU C99","gnu99")); + sl.append(QPair("GNU C11","gnu11")); + sl.append(QPair("GNU C17","gnu17")); + addOption(C_CMD_OPT_STD, QObject::tr("C Language standard (-std)"), groupName, true, false, false, "-std=", sl); // Optimization for cpu type sl.clear(); diff --git a/RedPandaIDE/compiler/compilerinfo.h b/RedPandaIDE/compiler/compilerinfo.h index 302cb418..0cfbe58b 100644 --- a/RedPandaIDE/compiler/compilerinfo.h +++ b/RedPandaIDE/compiler/compilerinfo.h @@ -9,6 +9,8 @@ #define COMPILER_GCC "GCC" #define COMPILER_GCC_UTF8 "GCC_UTF8" +#define C_CMD_OPT_STD "c_cmd_opt_std" + #define CC_CMD_OPT_ANSI "cc_cmd_opt_ansi" #define CC_CMD_OPT_NO_ASM "cc_cmd_opt_no_asm" #define CC_CMD_OPT_TRADITIONAL_CPP "cc_cmd_opt_traditional_cpp" diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 009de4f3..0e58bd46 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -1383,11 +1383,6 @@ void MainWindow::openProject(const QString &filename, bool openFiles) //stretchExplorerPanel(true); if (openFiles) ui->tabExplorer->setCurrentWidget(ui->tabProject); -// { -// LeftPageControl.ActivePage := LeftProjectSheet; -// fLeftPageControlChanged := False; -// ClassBrowser.TabVisible:= False; -// } // Only update class browser once mClassBrowserModel.beginUpdate(); @@ -6239,6 +6234,17 @@ void MainWindow::on_actionNew_Project_triggered() scanActiveProject(true); Editor* editor = mEditorList->getEditor(); updateClassBrowserForEditor(editor); + if (editor) { + PProjectUnit unit=mProject->findUnit(editor); + if (unit) { + QModelIndex index=mProject->model()->getNodeIndex(unit->node().get()); + index = mProjectProxyModel->mapFromSource(index); + ui->projectView->expand(index); + ui->projectView->setCurrentIndex(index); + } + } + if (pSettings->ui().showProject()) + ui->tabExplorer->setCurrentWidget(ui->tabProject); } pSettings->ui().setNewProjectDialogWidth(dialog.width()); pSettings->ui().setNewProjectDialogHeight(dialog.height()); @@ -6513,6 +6519,16 @@ void MainWindow::showHideMessagesTab(QWidget *widget, bool show) void MainWindow::prepareTabInfosData() { +// QHash tabOrders; +// tabOrders.insert(pSettings->ui().projectOrder(), ui->tabProject); +// tabOrders.insert(pSettings->ui().watchOrder(), ui->tabWatch); +// tabOrders.insert(pSettings->ui().structureOrder(), ui->tabStructure); +// tabOrders.insert(pSettings->ui().filesOrder(), ui->tabFiles); +// tabOrders.insert(pSettings->ui().problemSetOrder(), ui->tabProblemSet); + +// for (int i=1;itabExplorer->count();i++) { QWidget* widget = ui->tabExplorer->widget(i); PTabWidgetInfo info = std::make_shared(); @@ -6525,6 +6541,14 @@ void MainWindow::prepareTabInfosData() void MainWindow::prepareTabMessagesData() { +// QHash tabOrders; +// tabOrders.insert(pSettings->ui().issuesOrder(), ui->tabIssues); +// tabOrders.insert(pSettings->ui().compileLogOrder(), ui->tabToolsOutput); +// tabOrders.insert(pSettings->ui().debugOrder(), ui->tabDebug); +// tabOrders.insert(pSettings->ui().searchOrder(), ui->tabSearch); +// tabOrders.insert(pSettings->ui().TODOOrder(), ui->tabTODO); +// tabOrders.insert(pSettings->ui().bookmarkOrder(), ui->tabBookmark); + for (int i=0;itabMessages->count();i++) { QWidget* widget = ui->tabMessages->widget(i); PTabWidgetInfo info = std::make_shared(); diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 702a410a..70a5961f 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -478,6 +478,9 @@ true + + true + true diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 0d0b33a5..7f251ebd 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -4893,6 +4893,126 @@ void Settings::UI::setDebugPanelIndex(int newDebugPanelIndex) mDebugPanelIndex = newDebugPanelIndex; } +int Settings::UI::problemOrder() const +{ + return mProblemOrder; +} + +void Settings::UI::setProblemOrder(int newProblemOrder) +{ + mProblemOrder = newProblemOrder; +} + +int Settings::UI::bookmarkOrder() const +{ + return mBookmarkOrder; +} + +void Settings::UI::setBookmarkOrder(int newBookmarkOrder) +{ + mBookmarkOrder = newBookmarkOrder; +} + +int Settings::UI::TODOOrder() const +{ + return mTODOOrder; +} + +void Settings::UI::setTODOOrder(int newTODOOrder) +{ + mTODOOrder = newTODOOrder; +} + +int Settings::UI::searchOrder() const +{ + return mSearchOrder; +} + +void Settings::UI::setSearchOrder(int newSearchOrder) +{ + mSearchOrder = newSearchOrder; +} + +int Settings::UI::debugOrder() const +{ + return mDebugOrder; +} + +void Settings::UI::setDebugOrder(int newDebugOrder) +{ + mDebugOrder = newDebugOrder; +} + +int Settings::UI::compileLogOrder() const +{ + return mCompileLogOrder; +} + +void Settings::UI::setCompileLogOrder(int newCompileLogOrder) +{ + mCompileLogOrder = newCompileLogOrder; +} + +int Settings::UI::issuesOrder() const +{ + return mIssuesOrder; +} + +void Settings::UI::setIssuesOrder(int newIssuesOrder) +{ + mIssuesOrder = newIssuesOrder; +} + +int Settings::UI::problemSetOrder() const +{ + return mProblemSetOrder; +} + +void Settings::UI::setProblemSetOrder(int newProblemSetOrder) +{ + mProblemSetOrder = newProblemSetOrder; +} + +int Settings::UI::filesOrder() const +{ + return mFilesOrder; +} + +void Settings::UI::setFilesOrder(int newFilesOrder) +{ + mFilesOrder = newFilesOrder; +} + +int Settings::UI::structureOrder() const +{ + return mStructureOrder; +} + +void Settings::UI::setStructureOrder(int newStructureOrder) +{ + mStructureOrder = newStructureOrder; +} + +int Settings::UI::watchOrder() const +{ + return mWatchOrder; +} + +void Settings::UI::setWatchOrder(int newWatchOrder) +{ + mWatchOrder = newWatchOrder; +} + +int Settings::UI::projectOrder() const +{ + return mProjectOrder; +} + +void Settings::UI::setProjectOrder(int newProjectOrder) +{ + mProjectOrder = newProjectOrder; +} + const QSize &Settings::UI::explorerTabsSize() const { return mExplorerTabsSize; @@ -5188,6 +5308,27 @@ void Settings::UI::doSave() saveValue("show_bookmark", mShowBookmark); saveValue("show_problem", mShowProblem); + saveValue("show_issues", mIssuesOrder); + saveValue("show_compile_log", mShowCompileLog); + saveValue("show_debug", mShowDebug); + saveValue("show_search", mShowSearch); + saveValue("show_todo", mShowTODO); + saveValue("show_bookmark", mShowBookmark); + saveValue("show_problem", mShowProblem); + + saveValue("project_order", mProjectOrder); + saveValue("watch_order", mWatchOrder); + saveValue("structure_order", mStructureOrder); + saveValue("files_order", mFilesOrder); + saveValue("problemset_order", mProblemSetOrder); + saveValue("issues_order", mIssuesOrder); + saveValue("compilelog_order", mCompileLogOrder); + saveValue("debug_order", mDebugOrder); + saveValue("search_order", mSearchOrder); + saveValue("todo_order", mTODOOrder); + saveValue("bookmark_order", mBookmarkOrder); + saveValue("problem_order", mProblemOrder); + //dialogs saveValue("cpu_dialog_width", mCPUDialogWidth); saveValue("cpu_dialog_height", mCPUDialogHeight); @@ -5239,6 +5380,20 @@ void Settings::UI::doLoad() mShowBookmark = boolValue("show_bookmark",true); mShowProblem = boolValue("show_problem",true); + mProjectOrder = intValue("project_order",1); + mWatchOrder = intValue("watch_order",2); + mStructureOrder = intValue("structure_order",3); + mFilesOrder = intValue("files_order",0); + mProblemSetOrder = intValue("problemset_order",4); + + mIssuesOrder = intValue("issues_order",0); + mCompileLogOrder = intValue("compilelog_order",1); + mDebugOrder = intValue("debug_order",2); + mSearchOrder = intValue("search_order",3); + mTODOOrder = intValue("todo_order",4); + mBookmarkOrder = intValue("bookmark_order",5); + mProblemOrder = intValue("problem_order",6); + //dialogs mCPUDialogWidth = intValue("cpu_dialog_width",977*qApp->desktop()->width()/1920); mCPUDialogHeight = intValue("cpu_dialog_height",622*qApp->desktop()->height()/1080); diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h index 7f3388e8..eecf4766 100644 --- a/RedPandaIDE/settings.h +++ b/RedPandaIDE/settings.h @@ -1025,6 +1025,42 @@ public: int debugPanelIndex() const; void setDebugPanelIndex(int newDebugPanelIndex); + int projectOrder() const; + void setProjectOrder(int newProjectOrder); + + int watchOrder() const; + void setWatchOrder(int newWatchOrder); + + int structureOrder() const; + void setStructureOrder(int newStructureOrder); + + int filesOrder() const; + void setFilesOrder(int newFilesOrder); + + int problemSetOrder() const; + void setProblemSetOrder(int newProblemSetOrder); + + int issuesOrder() const; + void setIssuesOrder(int newIssuesOrder); + + int compileLogOrder() const; + void setCompileLogOrder(int newCompileLogOrder); + + int debugOrder() const; + void setDebugOrder(int newDebugOrder); + + int searchOrder() const; + void setSearchOrder(int newSearchOrder); + + int TODOOrder() const; + void setTODOOrder(int newTODOOrder); + + int bookmarkOrder() const; + void setBookmarkOrder(int newBookmarkOrder); + + int problemOrder() const; + void setProblemOrder(int newProblemOrder); + private: QByteArray mMainWindowState; QByteArray mMainWindowGeometry; @@ -1049,6 +1085,11 @@ public: bool mShowStructure; bool mShowFiles; bool mShowProblemSet; + int mProjectOrder; + int mWatchOrder; + int mStructureOrder; + int mFilesOrder; + int mProblemSetOrder; bool mShowIssues; bool mShowCompileLog; @@ -1057,6 +1098,13 @@ public: bool mShowTODO; bool mShowBookmark; bool mShowProblem; + int mIssuesOrder; + int mCompileLogOrder; + int mDebugOrder; + int mSearchOrder; + int mTODOOrder; + int mBookmarkOrder; + int mProblemOrder; //dialogs int mCPUDialogWidth;