From 9c111be41f8762a31c3fc7146064ca726ce01cb2 Mon Sep 17 00:00:00 2001 From: "royqh1979@gmail.com" Date: Mon, 26 Jul 2021 22:29:47 +0800 Subject: [PATCH] work save --- RedPandaIDE/compiler/compilermanager.cpp | 68 ++++++++++++++---------- RedPandaIDE/debugger.cpp | 3 +- RedPandaIDE/mainwindow.cpp | 38 ++++++------- 3 files changed, 62 insertions(+), 47 deletions(-) diff --git a/RedPandaIDE/compiler/compilermanager.cpp b/RedPandaIDE/compiler/compilermanager.cpp index 2e2f55e1..612950d3 100644 --- a/RedPandaIDE/compiler/compilermanager.cpp +++ b/RedPandaIDE/compiler/compilermanager.cpp @@ -6,6 +6,7 @@ #include "executablerunner.h" #include "utils.h" #include "../settings.h" +#include CompilerManager::CompilerManager(QObject *parent) : QObject(parent) { @@ -36,41 +37,54 @@ bool CompilerManager::running() void CompilerManager::compile(const QString& filename, const QByteArray& encoding, bool rebuild, bool silent, bool onlyCheckSyntax) { - QMutexLocker locker(&mCompileMutex); - if (mCompiler!=nullptr) { + if (!pSettings->compilerSets().defaultSet()) { + QMessageBox::critical(pMainWindow, + tr("No compiler set"), + tr("No compiler set is configured.")+tr("Can't start debugging.")); return; } - if (!pSettings->compilerSets().defaultSet()) - return; - mCompileErrorCount = 0; - mCompiler = new FileCompiler(filename,encoding,silent,onlyCheckSyntax); - mCompiler->setRebuild(rebuild); - connect(mCompiler, &Compiler::compileFinished, this ,&CompilerManager::onCompileFinished); - connect(mCompiler, &Compiler::compileIssue, this, &CompilerManager::onCompileIssue); - connect(mCompiler, &Compiler::compileFinished, pMainWindow, &MainWindow::onCompileFinished); - connect(mCompiler, &Compiler::compileOutput, pMainWindow, &MainWindow::onCompileLog); - connect(mCompiler, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue); - connect(mCompiler, &Compiler::compileErrorOccured, pMainWindow, &MainWindow::onCompileErrorOccured); - mCompiler->start(); + { + QMutexLocker locker(&mCompileMutex); + if (mCompiler!=nullptr) { + return; + } + mCompileErrorCount = 0; + mCompiler = new FileCompiler(filename,encoding,silent,onlyCheckSyntax); + mCompiler->setRebuild(rebuild); + connect(mCompiler, &Compiler::compileFinished, this ,&CompilerManager::onCompileFinished); + connect(mCompiler, &Compiler::compileIssue, this, &CompilerManager::onCompileIssue); + connect(mCompiler, &Compiler::compileFinished, pMainWindow, &MainWindow::onCompileFinished); + connect(mCompiler, &Compiler::compileOutput, pMainWindow, &MainWindow::onCompileLog); + connect(mCompiler, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue); + connect(mCompiler, &Compiler::compileErrorOccured, pMainWindow, &MainWindow::onCompileErrorOccured); + mCompiler->start(); + } } void CompilerManager::checkSyntax(const QString &filename, const QString &content) { - QMutexLocker locker(&mBackgroundSyntaxCheckMutex); - if (mBackgroundSyntaxChecker!=nullptr) { + if (!pSettings->compilerSets().defaultSet()) { + QMessageBox::critical(pMainWindow, + tr("No compiler set"), + tr("No compiler set is configured.")+tr("Can't start debugging.")); return; } - if (!pSettings->compilerSets().defaultSet()) - return; - mSyntaxCheckErrorCount = 0; - mBackgroundSyntaxChecker = new StdinCompiler(filename,content,true,true); - connect(mBackgroundSyntaxChecker, &Compiler::compileFinished, this ,&CompilerManager::onSyntaxCheckFinished); - connect(mBackgroundSyntaxChecker, &Compiler::compileIssue, this, &CompilerManager::onSyntaxCheckIssue); - connect(mBackgroundSyntaxChecker, &Compiler::compileFinished, pMainWindow, &MainWindow::onCompileFinished); - connect(mBackgroundSyntaxChecker, &Compiler::compileOutput, pMainWindow, &MainWindow::onCompileLog); - connect(mBackgroundSyntaxChecker, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue); - connect(mBackgroundSyntaxChecker, &Compiler::compileErrorOccured, pMainWindow, &MainWindow::onCompileErrorOccured); - mBackgroundSyntaxChecker->start(); + { + QMutexLocker locker(&mBackgroundSyntaxCheckMutex); + if (mBackgroundSyntaxChecker!=nullptr) { + return; + } + + mSyntaxCheckErrorCount = 0; + mBackgroundSyntaxChecker = new StdinCompiler(filename,content,true,true); + connect(mBackgroundSyntaxChecker, &Compiler::compileFinished, this ,&CompilerManager::onSyntaxCheckFinished); + connect(mBackgroundSyntaxChecker, &Compiler::compileIssue, this, &CompilerManager::onSyntaxCheckIssue); + connect(mBackgroundSyntaxChecker, &Compiler::compileFinished, pMainWindow, &MainWindow::onCompileFinished); + connect(mBackgroundSyntaxChecker, &Compiler::compileOutput, pMainWindow, &MainWindow::onCompileLog); + connect(mBackgroundSyntaxChecker, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue); + connect(mBackgroundSyntaxChecker, &Compiler::compileErrorOccured, pMainWindow, &MainWindow::onCompileErrorOccured); + mBackgroundSyntaxChecker->start(); + } } void CompilerManager::run(const QString &filename, const QString &arguments, const QString &workDir) diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index b8f197e3..63820a61 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -18,8 +18,6 @@ Debugger::Debugger(QObject *parent) : QObject(parent) void Debugger::start() { - mExecuting = true; - Settings::PCompilerSet compilerSet = pSettings->compilerSets().defaultSet(); if (!compilerSet) { QMessageBox::critical(pMainWindow, @@ -27,6 +25,7 @@ void Debugger::start() tr("No compiler set is configured.")+tr("Can't start debugging.")); return; } + mExecuting = true; QString debuggerPath = compilerSet->debugger(); QFile debuggerProgram(debuggerPath); if (!debuggerProgram.exists()) { diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index be4b9af5..bf74b14a 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -247,23 +247,23 @@ void MainWindow::updateAppTitle() else str = e->filename(); if (mDebugger->executing()) { - setWindowTitle(QString("%s - [%s] - %s %s").arg(str).arg(appName) + setWindowTitle(QString("%1 - [%2] - %3 %4").arg(str).arg(appName) .arg(tr("Debugging")).arg(DEVCPP_VERSION)); - app->setApplicationName(QString("%s - [%s] - %s").arg(str).arg(appName) + app->setApplicationName(QString("%1 - [%2] - %3").arg(str).arg(appName) .arg(tr("Debugging"))); } else if (mCompilerManager->running()) { - setWindowTitle(QString("%s - [%s] - %s %s").arg(str).arg(appName) + setWindowTitle(QString("%1 - [%2] - %3 %4").arg(str).arg(appName) .arg(tr("Running")).arg(DEVCPP_VERSION)); - app->setApplicationName(QString("%s - [%s] - %s").arg(str).arg(appName) + app->setApplicationName(QString("%1 - [%2] - %3").arg(str).arg(appName) .arg(tr("Running"))); } else if (mCompilerManager->compiling()) { - setWindowTitle(QString("%s - [%s] - %s %s").arg(str).arg(appName) + setWindowTitle(QString("%1 - [%2] - %3 %4").arg(str).arg(appName) .arg(tr("Compiling")).arg(DEVCPP_VERSION)); - app->setApplicationName(QString("%s - [%s] - %s").arg(str).arg(appName) + app->setApplicationName(QString("%1 - [%2] - %3").arg(str).arg(appName) .arg(tr("Compiling"))); } else { - this->setWindowTitle(QString("%s - %s %s").arg(str).arg(appName).arg(DEVCPP_VERSION)); - app->setApplicationName(QString("%s - %s").arg(str).arg(appName)); + this->setWindowTitle(QString("%1 - %2 %3").arg(str).arg(appName).arg(DEVCPP_VERSION)); + app->setApplicationName(QString("%1 - %2").arg(str).arg(appName)); } } // else if Assigned(fProject) then begin @@ -427,10 +427,11 @@ bool MainWindow::compile(bool rebuild) if (mCompileSuccessionTask) { mCompileSuccessionTask->filename = getCompiledExecutableName(editor->filename()); } - mCompilerManager->compile(editor->filename(),editor->fileEncoding(),rebuild); updateCompileActions(); openCloseMessageSheet(true); ui->tabMessages->setCurrentWidget(ui->tabCompilerOutput); + updateAppTitle(); + mCompilerManager->compile(editor->filename(),editor->fileEncoding(),rebuild); return true; } return false; @@ -441,7 +442,7 @@ void MainWindow::runExecutable(const QString &exeName,const QString &filename) // Check if it exists if (!QFile(exeName).exists()) { if (ui->actionCompile_Run->isEnabled()) { - if (QMessageBox::warning(this,tr("Confirm"), + if (QMessageBox::question(this,tr("Confirm"), tr("Source file is not compiled.") +"

"+tr("Compile now?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { @@ -482,17 +483,12 @@ void MainWindow::runExecutable(const QString &exeName,const QString &filename) // FileToRun := FileToRun; // end; -// if devData.MinOnRun then -// Application.Minimize; -// devExecutor.ExecuteAndWatch(FileToRun, Parameters, ExtractFilePath(fSourceFile), -// True, UseInputFile,InputFile, INFINITE, RunTerminate); -// MainForm.UpdateAppTitle; -// end; - mCompilerManager->run(exeName,"",QFileInfo(exeName).absolutePath()); updateCompileActions(); if (pSettings->executor().minimizeOnRun()) { showMinimized(); } + updateAppTitle(); + mCompilerManager->run(exeName,"",QFileInfo(exeName).absolutePath()); } void MainWindow::runExecutable() @@ -513,8 +509,12 @@ void MainWindow::debug() if (mCompilerManager->compiling()) return; Settings::PCompilerSet compilerSet = pSettings->compilerSets().defaultSet(); - if (!compilerSet) + if (!compilerSet) { + QMessageBox::critical(pMainWindow, + tr("No compiler set"), + tr("No compiler set is configured.")+"
"+tr("Can't start debugging.")); return; + } bool debugEnabled; bool stripEnabled; QString filePath; @@ -1003,6 +1003,7 @@ void MainWindow::onCompileFinished() } mCheckSyntaxInBack=false; updateCompileActions(); + updateAppTitle(); } void MainWindow::onCompileErrorOccured(const QString &reason) @@ -1021,6 +1022,7 @@ void MainWindow::onRunFinished() if (pSettings->executor().minimizeOnRun()) { showNormal(); } + updateAppTitle(); } void MainWindow::on_actionCompile_triggered()