From 85686acba79ab2a488c696706992b59deb049054 Mon Sep 17 00:00:00 2001 From: royqh1979 Date: Sat, 18 Sep 2021 22:37:07 +0800 Subject: [PATCH] - done: debug for project - add dll host project option widget --- RedPandaIDE/RedPandaIDE.pro | 3 + RedPandaIDE/debugger.cpp | 2 +- RedPandaIDE/mainwindow.cpp | 28 ++++----- RedPandaIDE/project.cpp | 4 ++ .../settingsdialog/projectdllhostwidget.cpp | 41 +++++++++++++ .../settingsdialog/projectdllhostwidget.h | 30 ++++++++++ .../settingsdialog/projectdllhostwidget.ui | 57 +++++++++++++++++++ RedPandaIDE/settingsdialog/settingsdialog.cpp | 5 ++ 8 files changed, 155 insertions(+), 15 deletions(-) create mode 100644 RedPandaIDE/settingsdialog/projectdllhostwidget.cpp create mode 100644 RedPandaIDE/settingsdialog/projectdllhostwidget.h create mode 100644 RedPandaIDE/settingsdialog/projectdllhostwidget.ui diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index d95ef199..90eafd4a 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -48,6 +48,7 @@ SOURCES += \ settingsdialog/projectcompileparamaterswidget.cpp \ settingsdialog/projectcompilerwidget.cpp \ settingsdialog/projectdirectorieswidget.cpp \ + settingsdialog/projectdllhostwidget.cpp \ settingsdialog/projectfileswidget.cpp \ settingsdialog/projectgeneralwidget.cpp \ settingsdialog/projectmakefilewidget.cpp \ @@ -143,6 +144,7 @@ HEADERS += \ settingsdialog/projectcompileparamaterswidget.h \ settingsdialog/projectcompilerwidget.h \ settingsdialog/projectdirectorieswidget.h \ + settingsdialog/projectdllhostwidget.h \ settingsdialog/projectfileswidget.h \ settingsdialog/projectgeneralwidget.h \ settingsdialog/projectmakefilewidget.h \ @@ -212,6 +214,7 @@ FORMS += \ settingsdialog/projectcompileparamaterswidget.ui \ settingsdialog/projectcompilerwidget.ui \ settingsdialog/projectdirectorieswidget.ui \ + settingsdialog/projectdllhostwidget.ui \ settingsdialog/projectfileswidget.ui \ settingsdialog/projectgeneralwidget.ui \ settingsdialog/projectmakefilewidget.ui \ diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index fae71a01..296241ac 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -1422,7 +1422,7 @@ void DebugReader::run() readed = mProcess->readAll(); buffer += readed; if (getLastAnnotation(buffer) == AnnotationType::TPrompt) { - mOutput = buffer; + mOutput = QString::fromLocal8Bit(buffer); processDebugOutput(); buffer.clear(); mCmdRunning = false; diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 617277af..9edf41c0 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -1013,14 +1013,14 @@ void MainWindow::debug() +tr("But it's missing."), QMessageBox::Ok); return; + } else if (!fileExists(mProject->options().hostApplication)) { + QMessageBox::critical(this, + tr("Host application not exists"), + tr("Host application file '%1' doesn't exist.") + .arg(mProject->options().hostApplication), + QMessageBox::Ok); + return; } - } else if (!fileExists(mProject->options().hostApplication)) { - QMessageBox::critical(this, - tr("Host application not exists"), - tr("Host application file '%1' doesn't exist.") - .arg(mProject->options().hostApplication), - QMessageBox::Ok); - return; } // Reset UI, remove invalid breakpoints prepareDebugger(); @@ -1180,14 +1180,14 @@ void MainWindow::debug() mDebugger->updateDebugInfo(); break; case CompileTarget::Project: -//params := ''; + params = ""; //if fCompiler.UseRunParams then // params := params + ' ' + fProject.Options.CmdLineArgs; //if fCompiler.UseInputFile then // params := params + ' < "' + fCompiler.InputFile + '"'; -//fDebugger.SendCommand('start', params); -//UpdateDebugInfo; + mDebugger->sendCommand("start",params); + mDebugger->updateDebugInfo(); break; } } else { @@ -1209,8 +1209,8 @@ void MainWindow::debug() //if fCompiler.UseInputFile then // params := params + ' < "' + fCompiler.InputFile + '"'; -//fDebugger.SendCommand('run', params); -//UpdateDebugInfo; + mDebugger->sendCommand("run",params); + mDebugger->updateDebugInfo(); break; } } @@ -2468,12 +2468,12 @@ void MainWindow::on_tabMessages_tabBarClicked(int index) } } -void MainWindow::on_tabMessages_currentChanged(int index) +void MainWindow::on_tabMessages_currentChanged(int) { openCloseBottomPanel(true); } -void MainWindow::on_tabMessages_tabBarDoubleClicked(int index) +void MainWindow::on_tabMessages_tabBarDoubleClicked(int ) { } diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index ec55bfa0..81cf86f9 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -613,6 +613,10 @@ bool Project::assignTemplate(const std::shared_ptr aTemplate) } mOptions = aTemplate->options(); + mOptions.compilerSet = pSettings->compilerSets().defaultIndex(); + if (pSettings->compilerSets().defaultSet()) { + mOptions.compilerOptions = pSettings->compilerSets().defaultSet()->iniOptions(); + } mOptions.icon = aTemplate->icon(); // Copy icon to project directory diff --git a/RedPandaIDE/settingsdialog/projectdllhostwidget.cpp b/RedPandaIDE/settingsdialog/projectdllhostwidget.cpp new file mode 100644 index 00000000..83368389 --- /dev/null +++ b/RedPandaIDE/settingsdialog/projectdllhostwidget.cpp @@ -0,0 +1,41 @@ +#include "projectdllhostwidget.h" +#include "ui_projectdllhostwidget.h" +#include "../project.h" +#include "../mainwindow.h" + +#include + +ProjectDLLHostWidget::ProjectDLLHostWidget(const QString &name, const QString &group, QWidget *parent) : + SettingsWidget(name,group,parent), + ui(new Ui::ProjectDLLHostWidget) +{ + ui->setupUi(this); +} + +ProjectDLLHostWidget::~ProjectDLLHostWidget() +{ + delete ui; +} + +void ProjectDLLHostWidget::doLoad() +{ + ui->txtHost->setText(pMainWindow->project()->options().hostApplication); +} + +void ProjectDLLHostWidget::doSave() +{ + pMainWindow->project()->options().hostApplication = ui->txtHost->text(); +} + +void ProjectDLLHostWidget::on_btnBrowse_triggered(QAction *arg1) +{ + QString filename = QFileDialog::getOpenFileName( + this, + tr("Choose host application"), + pMainWindow->project()->directory(), + tr("All files (*.*)")); + if (!filename.isEmpty() && fileExists(filename)) { + ui->txtHost->setText(filename); + } +} + diff --git a/RedPandaIDE/settingsdialog/projectdllhostwidget.h b/RedPandaIDE/settingsdialog/projectdllhostwidget.h new file mode 100644 index 00000000..c34331f8 --- /dev/null +++ b/RedPandaIDE/settingsdialog/projectdllhostwidget.h @@ -0,0 +1,30 @@ +#ifndef PROJECTDLLHOSTWIDGET_H +#define PROJECTDLLHOSTWIDGET_H + +#include +#include "settingswidget.h" + +namespace Ui { +class ProjectDLLHostWidget; +} + +class ProjectDLLHostWidget : public SettingsWidget +{ + Q_OBJECT + +public: + explicit ProjectDLLHostWidget(const QString& name, const QString& group, QWidget *parent = nullptr); + ~ProjectDLLHostWidget(); + +private: + Ui::ProjectDLLHostWidget *ui; + + // SettingsWidget interface +protected: + void doLoad() override; + void doSave() override; +private slots: + void on_btnBrowse_triggered(QAction *arg1); +}; + +#endif // PROJECTDLLHOSTWIDGET_H diff --git a/RedPandaIDE/settingsdialog/projectdllhostwidget.ui b/RedPandaIDE/settingsdialog/projectdllhostwidget.ui new file mode 100644 index 00000000..e88f8e21 --- /dev/null +++ b/RedPandaIDE/settingsdialog/projectdllhostwidget.ui @@ -0,0 +1,57 @@ + + + ProjectDLLHostWidget + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + + + + + :/icons/images/newlook24/053-open.png:/icons/images/newlook24/053-open.png + + + + + + + + + + Host application for DLL: + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + diff --git a/RedPandaIDE/settingsdialog/settingsdialog.cpp b/RedPandaIDE/settingsdialog/settingsdialog.cpp index 1b6bf062..c8131116 100644 --- a/RedPandaIDE/settingsdialog/settingsdialog.cpp +++ b/RedPandaIDE/settingsdialog/settingsdialog.cpp @@ -25,6 +25,7 @@ #include "projectoutputwidget.h" #include "projectmakefilewidget.h" #include "projectversioninfowidget.h" +#include "projectdllhostwidget.h" #include #include #include @@ -189,6 +190,10 @@ PSettingsDialog SettingsDialog::projectOptionDialog() widget->init(); dialog->addWidget(widget); + widget = new ProjectDLLHostWidget(tr("DLL host"),tr("Project")); + widget->init(); + dialog->addWidget(widget); + widget = new ProjectVersionInfoWidget(tr("Version info"),tr("Project")); widget->init(); dialog->addWidget(widget);