* work save: compile & run
This commit is contained in:
parent
94ae45cca4
commit
effd416389
|
@ -43,6 +43,7 @@ SOURCES += \
|
|||
settingsdialog/editorfontwidget.cpp \
|
||||
settingsdialog/editorgeneralwidget.cpp \
|
||||
settingsdialog/editorsymbolcompletionwidget.cpp \
|
||||
settingsdialog/editorsyntaxcheckwidget.cpp \
|
||||
settingsdialog/environmentappearencewidget.cpp \
|
||||
settingsdialog/settingsdialog.cpp \
|
||||
settingsdialog/settingswidget.cpp \
|
||||
|
@ -87,6 +88,7 @@ HEADERS += \
|
|||
settingsdialog/editorfontwidget.h \
|
||||
settingsdialog/editorgeneralwidget.h \
|
||||
settingsdialog/editorsymbolcompletionwidget.h \
|
||||
settingsdialog/editorsyntaxcheckwidget.h \
|
||||
settingsdialog/environmentappearencewidget.h \
|
||||
settingsdialog/settingsdialog.h \
|
||||
settingsdialog/settingswidget.h \
|
||||
|
@ -106,6 +108,7 @@ FORMS += \
|
|||
settingsdialog/editorfontwidget.ui \
|
||||
settingsdialog/editorgeneralwidget.ui \
|
||||
settingsdialog/editorsymbolcompletionwidget.ui \
|
||||
settingsdialog/editorsyntaxcheckwidget.ui \
|
||||
settingsdialog/environmentappearencewidget.ui \
|
||||
settingsdialog/settingsdialog.ui
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@ Compiler::Compiler(const QString &filename, bool silent, bool onlyCheckSyntax):
|
|||
QThread(),
|
||||
mSilent(silent),
|
||||
mOnlyCheckSyntax(onlyCheckSyntax),
|
||||
mFilename(filename)
|
||||
mFilename(filename),
|
||||
mRebuild(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -24,6 +25,9 @@ void Compiler::run()
|
|||
{
|
||||
emit compileStarted();
|
||||
try {
|
||||
if (mRebuild && !prepareForRebuild()) {
|
||||
throw CompileError(tr("Clean before rebuild failed."));
|
||||
}
|
||||
if (prepareForCompile()){
|
||||
mErrorCount = 0;
|
||||
mWarningCount = 0;
|
||||
|
@ -386,10 +390,11 @@ void Compiler::runCommand(const QString &cmd, const QString &arguments, const Q
|
|||
if (process.state()!=QProcess::Running) {
|
||||
break;
|
||||
}
|
||||
if (mStop || errorOccurred) {
|
||||
process.kill();
|
||||
break;
|
||||
if (mStop) {
|
||||
process.terminate();
|
||||
}
|
||||
if (errorOccurred)
|
||||
break;
|
||||
}
|
||||
if (errorOccurred) {
|
||||
switch (process.error()) {
|
||||
|
@ -397,7 +402,8 @@ void Compiler::runCommand(const QString &cmd, const QString &arguments, const Q
|
|||
throw CompileError(tr("The compiler process failed to start."));
|
||||
break;
|
||||
case QProcess::Crashed:
|
||||
throw CompileError(tr("The compiler process crashed after starting successfully."));
|
||||
if (!mStop)
|
||||
throw CompileError(tr("The compiler process crashed after starting successfully."));
|
||||
break;
|
||||
case QProcess::Timedout:
|
||||
throw CompileError(tr("The last waitFor...() function timed out."));
|
||||
|
@ -414,6 +420,16 @@ void Compiler::runCommand(const QString &cmd, const QString &arguments, const Q
|
|||
}
|
||||
}
|
||||
|
||||
bool Compiler::isRebuild() const
|
||||
{
|
||||
return mRebuild;
|
||||
}
|
||||
|
||||
void Compiler::setRebuild(bool isRebuild)
|
||||
{
|
||||
mRebuild = isRebuild;
|
||||
}
|
||||
|
||||
void Compiler::log(const QString &msg)
|
||||
{
|
||||
emit compileOutput(msg);
|
||||
|
|
|
@ -18,6 +18,9 @@ public:
|
|||
};
|
||||
Compiler(const QString& filename, bool silent,bool onlyCheckSyntax);
|
||||
|
||||
bool isRebuild() const;
|
||||
void setRebuild(bool isRebuild);
|
||||
|
||||
signals:
|
||||
void compileStarted();
|
||||
void compileFinished();
|
||||
|
@ -39,6 +42,7 @@ protected:
|
|||
virtual Settings::PCompilerSet compilerSet() = 0;
|
||||
virtual bool prepareForCompile() = 0;
|
||||
virtual QString pipedText() = 0;
|
||||
virtual bool prepareForRebuild() = 0;
|
||||
virtual QString getCharsetArgument(const QByteArray& encoding);
|
||||
virtual QString getCCompileArguments(bool checkSyntax);
|
||||
virtual QString getCppCompileArguments(bool checkSyntax);
|
||||
|
@ -59,6 +63,7 @@ protected:
|
|||
int mWarningCount;
|
||||
PCompileIssue mLastIssue;
|
||||
QString mFilename;
|
||||
bool mRebuild;
|
||||
|
||||
private:
|
||||
bool mStop;
|
||||
|
|
|
@ -17,22 +17,31 @@ CompilerManager::CompilerManager(QObject *parent) : QObject(parent)
|
|||
|
||||
bool CompilerManager::compiling()
|
||||
{
|
||||
QMutexLocker locker(&mCompileMutex);
|
||||
return mCompiler!=nullptr;
|
||||
}
|
||||
|
||||
bool CompilerManager::backgroundSyntaxChecking()
|
||||
{
|
||||
QMutexLocker locker(&mBackgroundSyntaxCheckMutex);
|
||||
return mBackgroundSyntaxChecker!=nullptr;
|
||||
}
|
||||
|
||||
void CompilerManager::compile(const QString& filename, const QByteArray& encoding, bool silent, bool onlyCheckSyntax)
|
||||
bool CompilerManager::running()
|
||||
{
|
||||
QMutexLocker locker(&compileMutex);
|
||||
QMutexLocker locker(&mRunnerMutex);
|
||||
return mRunner!=nullptr;
|
||||
}
|
||||
|
||||
void CompilerManager::compile(const QString& filename, const QByteArray& encoding, bool rebuild, bool silent, bool onlyCheckSyntax)
|
||||
{
|
||||
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);
|
||||
|
@ -44,7 +53,7 @@ void CompilerManager::compile(const QString& filename, const QByteArray& encodin
|
|||
|
||||
void CompilerManager::checkSyntax(const QString &filename, const QString &content)
|
||||
{
|
||||
QMutexLocker locker(&backgroundSyntaxChekMutex);
|
||||
QMutexLocker locker(&mBackgroundSyntaxCheckMutex);
|
||||
if (mBackgroundSyntaxChecker!=nullptr) {
|
||||
return;
|
||||
}
|
||||
|
@ -61,7 +70,7 @@ void CompilerManager::checkSyntax(const QString &filename, const QString &conten
|
|||
|
||||
void CompilerManager::run(const QString &filename, const QString &arguments, const QString &workDir)
|
||||
{
|
||||
QMutexLocker locker(&runnerMutex);
|
||||
QMutexLocker locker(&mRunnerMutex);
|
||||
if (mRunner!=nullptr) {
|
||||
return;
|
||||
}
|
||||
|
@ -72,9 +81,25 @@ void CompilerManager::run(const QString &filename, const QString &arguments, con
|
|||
mRunner = new ExecutableRunner(filename,arguments,workDir);
|
||||
}
|
||||
connect(mRunner, &ExecutableRunner::terminated, this ,&CompilerManager::onRunnerTerminated);
|
||||
connect(mRunner, &ExecutableRunner::terminated, pMainWindow ,&MainWindow::onRunFinished);
|
||||
connect(mRunner, &ExecutableRunner::runErrorOccurred, pMainWindow ,&MainWindow::onRunErrorOccured);
|
||||
mRunner->start();
|
||||
}
|
||||
|
||||
void CompilerManager::stopRun()
|
||||
{
|
||||
QMutexLocker locker(&mRunnerMutex);
|
||||
if (mRunner!=nullptr)
|
||||
mRunner->stop();
|
||||
}
|
||||
|
||||
void CompilerManager::stopCompile()
|
||||
{
|
||||
QMutexLocker locker(&mCompileMutex);
|
||||
if (mCompiler!=nullptr)
|
||||
mCompiler->stopCompile();
|
||||
}
|
||||
|
||||
bool CompilerManager::canCompile(const QString &filename)
|
||||
{
|
||||
return !compiling();
|
||||
|
@ -82,15 +107,15 @@ bool CompilerManager::canCompile(const QString &filename)
|
|||
|
||||
void CompilerManager::onCompileFinished()
|
||||
{
|
||||
QMutexLocker locker(&compileMutex);
|
||||
QMutexLocker locker(&mCompileMutex);
|
||||
delete mCompiler;
|
||||
mCompiler=nullptr;
|
||||
}
|
||||
|
||||
void CompilerManager::onRunnerTerminated()
|
||||
{
|
||||
QMutexLocker locker(&runnerMutex);
|
||||
qDebug() << "Runner Terminated";
|
||||
QMutexLocker locker(&mRunnerMutex);
|
||||
delete mRunner;
|
||||
mRunner=nullptr;
|
||||
}
|
||||
|
||||
|
@ -101,7 +126,7 @@ void CompilerManager::onCompileIssue(PCompileIssue)
|
|||
|
||||
void CompilerManager::onSyntaxCheckFinished()
|
||||
{
|
||||
QMutexLocker locker(&backgroundSyntaxChekMutex);
|
||||
QMutexLocker locker(&mBackgroundSyntaxCheckMutex);
|
||||
delete mBackgroundSyntaxChecker;
|
||||
mBackgroundSyntaxChecker=nullptr;
|
||||
}
|
||||
|
|
|
@ -16,10 +16,13 @@ public:
|
|||
|
||||
bool compiling();
|
||||
bool backgroundSyntaxChecking();
|
||||
bool running();
|
||||
|
||||
void compile(const QString& filename, const QByteArray& encoding, bool silent=false,bool onlyCheckSyntax=false);
|
||||
void compile(const QString& filename, const QByteArray& encoding, bool rebuild, bool silent=false,bool onlyCheckSyntax=false);
|
||||
void checkSyntax(const QString&filename, const QString& content);
|
||||
void run(const QString& filename, const QString& arguments, const QString& workDir);
|
||||
void stopRun();
|
||||
void stopCompile();
|
||||
bool canCompile(const QString& filename);
|
||||
int compileErrorCount() const;
|
||||
|
||||
|
@ -38,9 +41,9 @@ private:
|
|||
int mSyntaxCheckErrorCount;
|
||||
Compiler* mBackgroundSyntaxChecker;
|
||||
ExecutableRunner* mRunner;
|
||||
QMutex compileMutex;
|
||||
QMutex backgroundSyntaxChekMutex;
|
||||
QMutex runnerMutex;
|
||||
QMutex mCompileMutex;
|
||||
QMutex mBackgroundSyntaxCheckMutex;
|
||||
QMutex mRunnerMutex;
|
||||
};
|
||||
|
||||
class CompileError : public BaseError {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <QProcess>
|
||||
#include <windows.h>
|
||||
#include <QDebug>
|
||||
#include "compilermanager.h"
|
||||
|
||||
ExecutableRunner::ExecutableRunner(const QString &filename, const QString &arguments, const QString &workDir):
|
||||
QThread(),
|
||||
|
@ -24,6 +25,8 @@ void ExecutableRunner::run()
|
|||
emit started();
|
||||
QProcess process;
|
||||
mStop = false;
|
||||
bool errorOccurred = false;
|
||||
|
||||
process.setProgram(mFilename);
|
||||
process.setArguments(QProcess::splitCommand(mArguments));
|
||||
process.setWorkingDirectory(mWorkDir);
|
||||
|
@ -31,8 +34,12 @@ void ExecutableRunner::run()
|
|||
args->flags |= CREATE_NEW_CONSOLE;
|
||||
args->startupInfo -> dwFlags &= ~STARTF_USESTDHANDLES;
|
||||
});
|
||||
qDebug() << mFilename;
|
||||
qDebug() << QProcess::splitCommand(mArguments);
|
||||
process.connect(&process, &QProcess::errorOccurred,
|
||||
[&](){
|
||||
errorOccurred= true;
|
||||
});
|
||||
// qDebug() << mFilename;
|
||||
// qDebug() << QProcess::splitCommand(mArguments);
|
||||
process.start();
|
||||
process.closeWriteChannel();
|
||||
process.waitForStarted(5000);
|
||||
|
@ -42,10 +49,33 @@ void ExecutableRunner::run()
|
|||
break;
|
||||
}
|
||||
if (mStop) {
|
||||
process.kill();
|
||||
process.terminate();
|
||||
//break;
|
||||
}
|
||||
if (errorOccurred)
|
||||
break;
|
||||
}
|
||||
if (errorOccurred) {
|
||||
switch (process.error()) {
|
||||
case QProcess::FailedToStart:
|
||||
emit runErrorOccurred(tr("The runner process failed to start."));
|
||||
break;
|
||||
case QProcess::Crashed:
|
||||
if (!mStop)
|
||||
emit runErrorOccurred(tr("The runner process crashed after starting successfully."));
|
||||
break;
|
||||
case QProcess::Timedout:
|
||||
emit runErrorOccurred(tr("The last waitFor...() function timed out."));
|
||||
break;
|
||||
case QProcess::WriteError:
|
||||
emit runErrorOccurred(tr("An error occurred when attempting to write to the runner process."));
|
||||
break;
|
||||
case QProcess::ReadError:
|
||||
emit runErrorOccurred(tr("An error occurred when attempting to read from the runner process."));
|
||||
break;
|
||||
default:
|
||||
emit runErrorOccurred(tr("An unknown error occurred."));
|
||||
}
|
||||
}
|
||||
emit terminated();
|
||||
this->deleteLater();
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ public:
|
|||
signals:
|
||||
void started();
|
||||
void terminated();
|
||||
void runErrorOccurred(const QString& reason);
|
||||
|
||||
public slots:
|
||||
void stop();
|
||||
|
|
|
@ -78,3 +78,15 @@ QString FileCompiler::pipedText()
|
|||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool FileCompiler::prepareForRebuild()
|
||||
{
|
||||
QString exeName = getCompiledExecutableName(mFilename);
|
||||
QFile file(exeName);
|
||||
|
||||
if (!file.remove()) {
|
||||
QFileInfo info(exeName);
|
||||
throw CompileError(tr("Can't delete the old executable file \"%1\".\n").arg(info.absoluteFilePath()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,11 @@ private:
|
|||
|
||||
// Compiler interface
|
||||
protected:
|
||||
QString pipedText();
|
||||
QString pipedText() override;
|
||||
|
||||
// Compiler interface
|
||||
protected:
|
||||
bool prepareForRebuild() override;
|
||||
};
|
||||
|
||||
#endif // FILECOMPILER_H
|
||||
|
|
|
@ -61,3 +61,8 @@ QString StdinCompiler::pipedText()
|
|||
{
|
||||
return mContent;
|
||||
}
|
||||
|
||||
bool StdinCompiler::prepareForRebuild()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,11 @@ private:
|
|||
|
||||
// Compiler interface
|
||||
protected:
|
||||
QString pipedText();
|
||||
QString pipedText() override;
|
||||
|
||||
// Compiler interface
|
||||
protected:
|
||||
bool prepareForRebuild() override;
|
||||
};
|
||||
|
||||
#endif // STDINCOMPILER_H
|
||||
|
|
|
@ -109,12 +109,16 @@ void Editor::loadFile() {
|
|||
this->setModified(false);
|
||||
updateCaption();
|
||||
pMainWindow->updateForEncodingInfo();
|
||||
if (pSettings->editor().syntaxCheck() && pSettings->editor().syntaxCheckWhenSave())
|
||||
pMainWindow->checkSyntaxInBack(this);
|
||||
}
|
||||
|
||||
void Editor::saveFile(const QString &filename) {
|
||||
QFile file(filename);
|
||||
this->lines()->SaveToFile(file,mEncodingOption,mFileEncoding);
|
||||
pMainWindow->updateForEncodingInfo();
|
||||
if (pSettings->editor().syntaxCheck() && pSettings->editor().syntaxCheckWhenSave())
|
||||
pMainWindow->checkSyntaxInBack(this);
|
||||
}
|
||||
|
||||
void Editor::convertToEncoding(const QByteArray &encoding)
|
||||
|
@ -634,7 +638,8 @@ void Editor::onStatusChanged(SynStatusChanges changes)
|
|||
{
|
||||
if (!changes.testFlag(SynStatusChange::scOpenFile) && (lines()->count()!=mLineCount)
|
||||
&& (lines()->count()!=0) && ((mLineCount>0) || (lines()->count()>1))) {
|
||||
pMainWindow->checkSyntaxInBack(this);
|
||||
if (pSettings->editor().syntaxCheck() && pSettings->editor().syntaxCheckWhenLineChanged())
|
||||
pMainWindow->checkSyntaxInBack(this);
|
||||
}
|
||||
mLineCount = lines()->count();
|
||||
// if (not (scOpenFile in Changes)) and (fText.Lines.Count <> fLineCount)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <QComboBox>
|
||||
#include <QFileDialog>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QTranslator>
|
||||
|
||||
#include "settingsdialog/settingsdialog.h"
|
||||
|
@ -293,7 +294,96 @@ void MainWindow::checkSyntaxInBack(Editor *e)
|
|||
// Exit;
|
||||
// fSyntaxChecker.Project := MainForm.fProject;
|
||||
// end;
|
||||
// fSyntaxChecker.CheckSyntax(True);
|
||||
// fSyntaxChecker.CheckSyntax(True);
|
||||
}
|
||||
|
||||
bool MainWindow::compile(bool rebuild)
|
||||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
if (editor != NULL ) {
|
||||
editor->clearSyntaxIssues();
|
||||
ui->tableIssues->clearIssues();
|
||||
if (editor->modified()) {
|
||||
if (!editor->save(false,false))
|
||||
return false;
|
||||
}
|
||||
if (mCompileSuccessionTask) {
|
||||
mCompileSuccessionTask->filename = getCompiledExecutableName(editor->filename());
|
||||
}
|
||||
mCompilerManager->compile(editor->filename(),editor->fileEncoding(),rebuild);
|
||||
openCloseMessageSheet(true);
|
||||
ui->tabMessages->setCurrentWidget(ui->tabCompilerOutput);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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"),
|
||||
tr("Source file is not compiled.")
|
||||
+"<br /><br />"+tr("Compile now?"),
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
||||
ui->actionCompile_Run->trigger();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
QMessageBox::critical(this,"Error",
|
||||
tr("Source file is not compiled."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!filename.isEmpty() && compareFileModifiedTime(filename,exeName)>=0) {
|
||||
if (ui->actionCompile_Run->isEnabled()) {
|
||||
if (QMessageBox::warning(this,tr("Confirm"),
|
||||
tr("Source file is more recent than executable.")
|
||||
+"<br /><br />"+tr("Recompile now?"),
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
||||
ui->actionCompile_Run->trigger();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Pause programs if they contain a console
|
||||
// if devData.ConsolePause and ProgramHasConsole(FileToRun) then begin
|
||||
// if fUseRunParams then
|
||||
// Parameters := '"' + FileToRun + '" ' + fRunParams
|
||||
// else
|
||||
// Parameters := '"' + FileToRun + '"';
|
||||
|
||||
// FileToRun := devDirs.Exec + 'ConsolePauser.exe';
|
||||
// end else begin
|
||||
// if fUseRunParams then
|
||||
// Parameters := fRunParams
|
||||
// else
|
||||
// Parameters := '';
|
||||
// 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());
|
||||
}
|
||||
|
||||
void MainWindow::runExecutable()
|
||||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
if (editor != NULL ) {
|
||||
if (editor->modified()) {
|
||||
if (!editor->save(false,false))
|
||||
return;
|
||||
}
|
||||
QString exeName= getCompiledExecutableName(editor->filename());
|
||||
runExecutable(exeName,editor->filename());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::openCloseMessageSheet(bool open)
|
||||
|
@ -517,6 +607,13 @@ void MainWindow::onCompileFinished()
|
|||
// ResourceOutput.Selected.MakeVisible(False);
|
||||
// CompilerOutputDblClick(ResourceOutput);
|
||||
// end;
|
||||
} else {
|
||||
if (mCompileSuccessionTask) {
|
||||
switch (mCompileSuccessionTask->type) {
|
||||
case MainWindow::CompileSuccessionTaskType::Run:
|
||||
runExecutable(mCompileSuccessionTask->filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
mCheckSyntaxInBack=false;
|
||||
}
|
||||
|
@ -526,23 +623,25 @@ void MainWindow::onCompileErrorOccured(const QString &reason)
|
|||
QMessageBox::critical(this,tr("Compile Failed"),reason);
|
||||
}
|
||||
|
||||
void MainWindow::onRunErrorOccured(const QString &reason)
|
||||
{
|
||||
QMessageBox::critical(this,tr("Run Failed"),reason);
|
||||
}
|
||||
|
||||
void MainWindow::onRunFinished()
|
||||
{
|
||||
qDebug()<<"run finished";
|
||||
}
|
||||
|
||||
void MainWindow::on_actionCompile_triggered()
|
||||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
if (editor != NULL ) {
|
||||
editor->clearSyntaxIssues();
|
||||
ui->tableIssues->clearIssues();
|
||||
mCompilerManager->compile(editor->filename(),editor->fileEncoding());
|
||||
}
|
||||
mCompileSuccessionTask.reset();
|
||||
compile();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionRun_triggered()
|
||||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
if (editor != NULL ) {
|
||||
QString exeName= getCompiledExecutableName(editor->filename());
|
||||
mCompilerManager->run(exeName,"",QFileInfo(exeName).absolutePath());
|
||||
}
|
||||
runExecutable();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionUndo_triggered()
|
||||
|
@ -728,3 +827,21 @@ void MainWindow::on_tabMessages_tabBarDoubleClicked(int index)
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_actionCompile_Run_triggered()
|
||||
{
|
||||
mCompileSuccessionTask = std::make_shared<CompileSuccessionTask>();
|
||||
mCompileSuccessionTask->type = CompileSuccessionTaskType::Run;
|
||||
compile();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionRebuild_triggered()
|
||||
{
|
||||
mCompileSuccessionTask.reset();
|
||||
compile(true);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionStop_Execution_triggered()
|
||||
{
|
||||
mCompilerManager->stopRun();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,20 @@ class MainWindow : public QMainWindow
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
enum class CompileSuccessionTaskType {
|
||||
None,
|
||||
Run,
|
||||
Debug,
|
||||
Profile
|
||||
};
|
||||
|
||||
struct CompileSuccessionTask {
|
||||
CompileSuccessionTaskType type;
|
||||
QString filename;
|
||||
};
|
||||
|
||||
using PCompileSuccessionTask = std::shared_ptr<CompileSuccessionTask>;
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
@ -30,6 +44,9 @@ public:
|
|||
void updateEditorColorSchemes();
|
||||
void updateCompilerSet();
|
||||
void checkSyntaxInBack(Editor* e);
|
||||
bool compile(bool rebuild=false);
|
||||
void runExecutable(const QString& exeName, const QString& filename=QString());
|
||||
void runExecutable();
|
||||
|
||||
void applySettings();
|
||||
|
||||
|
@ -96,11 +113,19 @@ private slots:
|
|||
|
||||
void on_tabMessages_tabBarDoubleClicked(int index);
|
||||
|
||||
void on_actionCompile_Run_triggered();
|
||||
|
||||
void on_actionRebuild_triggered();
|
||||
|
||||
void on_actionStop_Execution_triggered();
|
||||
|
||||
public slots:
|
||||
void onCompileLog(const QString& msg);
|
||||
void onCompileIssue(PCompileIssue issue);
|
||||
void onCompileFinished();
|
||||
void onCompileErrorOccured(const QString& reason);
|
||||
void onRunErrorOccured(const QString& reason);
|
||||
void onRunFinished();
|
||||
|
||||
private:
|
||||
void setupActions();
|
||||
|
@ -120,6 +145,7 @@ private:
|
|||
bool mTabMessagesTogglingState;
|
||||
bool mCheckSyntaxInBack;
|
||||
int mPreviousHeight;
|
||||
PCompileSuccessionTask mCompileSuccessionTask;
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
|
|
|
@ -173,7 +173,7 @@
|
|||
<enum>QTabWidget::South</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tabIssues">
|
||||
<attribute name="icon">
|
||||
|
@ -315,7 +315,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>946</width>
|
||||
<height>25</height>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
@ -341,6 +341,10 @@
|
|||
</property>
|
||||
<addaction name="actionCompile"/>
|
||||
<addaction name="actionRun"/>
|
||||
<addaction name="actionCompile_Run"/>
|
||||
<addaction name="actionRebuild"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionStop_Execution"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuEdit">
|
||||
<property name="title">
|
||||
|
@ -406,6 +410,20 @@
|
|||
</attribute>
|
||||
<addaction name="actionCompile"/>
|
||||
<addaction name="actionRun"/>
|
||||
<addaction name="actionCompile_Run"/>
|
||||
<addaction name="actionRebuild"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBarDebug">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionStop_Execution"/>
|
||||
</widget>
|
||||
<action name="actionNew">
|
||||
<property name="icon">
|
||||
|
@ -648,6 +666,48 @@
|
|||
<string>Convert to UTF-8</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCompile_Run">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/images/newlook24/017-comprun.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Compile & Run</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Compile & Run</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F11</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRebuild">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/images/newlook24/061-rebuild.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rebuild All</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Rebuild All</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F12</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionStop_Execution">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/images/newlook24/008-close.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Stop Execution</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
@ -5024,7 +5024,6 @@ void SynEdit::mousePressEvent(QMouseEvent *event)
|
|||
Qt::MouseButton button = event->button();
|
||||
int X=event->pos().x();
|
||||
int Y=event->pos().y();
|
||||
qDebug()<<"Mouse Pressed";
|
||||
|
||||
QAbstractScrollArea::mousePressEvent(event);
|
||||
|
||||
|
|
|
@ -304,6 +304,36 @@ void Settings::Editor::setRemoveSymbolPairs(bool value)
|
|||
mRemoveSymbolPairs = value;
|
||||
}
|
||||
|
||||
bool Settings::Editor::syntaxCheckWhenLineChanged() const
|
||||
{
|
||||
return mSyntaxCheckWhenLineChanged;
|
||||
}
|
||||
|
||||
void Settings::Editor::setSyntaxCheckWhenLineChanged(bool syntaxCheckWhenLineChanged)
|
||||
{
|
||||
mSyntaxCheckWhenLineChanged = syntaxCheckWhenLineChanged;
|
||||
}
|
||||
|
||||
bool Settings::Editor::syntaxCheckWhenSave() const
|
||||
{
|
||||
return mSyntaxCheckWhenSave;
|
||||
}
|
||||
|
||||
void Settings::Editor::setSyntaxCheckWhenSave(bool syntaxCheckWhenSave)
|
||||
{
|
||||
mSyntaxCheckWhenSave = syntaxCheckWhenSave;
|
||||
}
|
||||
|
||||
bool Settings::Editor::syntaxCheck() const
|
||||
{
|
||||
return mSyntaxCheck;
|
||||
}
|
||||
|
||||
void Settings::Editor::setSyntaxCheck(bool syntaxCheck)
|
||||
{
|
||||
mSyntaxCheck = syntaxCheck;
|
||||
}
|
||||
|
||||
bool Settings::Editor::overwriteSymbols() const
|
||||
{
|
||||
return mOverwriteSymbols;
|
||||
|
@ -723,6 +753,11 @@ void Settings::Editor::doSave()
|
|||
saveValue("complete_global_include", mCompleteGlobalInclude);
|
||||
saveValue("overwrite_symbols", mOverwriteSymbols);
|
||||
saveValue("remove_symbol_pairs",mRemoveSymbolPairs);
|
||||
|
||||
//Auto Syntax Check
|
||||
saveValue("check_syntax",mSyntaxCheck);
|
||||
saveValue("check_syntax_when_save",mSyntaxCheckWhenSave);
|
||||
saveValue("check_syntax_when_line_changed",mSyntaxCheckWhenLineChanged);
|
||||
}
|
||||
|
||||
void Settings::Editor::doLoad()
|
||||
|
@ -796,6 +831,11 @@ void Settings::Editor::doLoad()
|
|||
mCompleteGlobalInclude = boolValue("complete_global_include",true);
|
||||
mOverwriteSymbols = boolValue("overwrite_symbols",true);
|
||||
mRemoveSymbolPairs = boolValue("remove_symbol_pairs",true);
|
||||
|
||||
//Auto Syntax Check
|
||||
mSyntaxCheck = boolValue("check_syntax",true);
|
||||
mSyntaxCheckWhenSave = boolValue("check_syntax_when_save",true);
|
||||
mSyntaxCheckWhenLineChanged = boolValue("check_syntax_when_line_changed",true);
|
||||
}
|
||||
|
||||
SynEditCaretType Settings::Editor::caretForOverwrite() const
|
||||
|
|
|
@ -248,6 +248,15 @@ public:
|
|||
bool removeSymbolPairs() const;
|
||||
void setRemoveSymbolPairs(bool value);
|
||||
|
||||
bool syntaxCheck() const;
|
||||
void setSyntaxCheck(bool syntaxCheck);
|
||||
|
||||
bool syntaxCheckWhenSave() const;
|
||||
void setSyntaxCheckWhenSave(bool syntaxCheckWhenSave);
|
||||
|
||||
bool syntaxCheckWhenLineChanged() const;
|
||||
void setSyntaxCheckWhenLineChanged(bool syntaxCheckWhenLineChanged);
|
||||
|
||||
private:
|
||||
QByteArray mDefaultEncoding;
|
||||
//General
|
||||
|
@ -319,6 +328,11 @@ public:
|
|||
bool mOverwriteSymbols;
|
||||
bool mRemoveSymbolPairs;
|
||||
|
||||
//Auto Syntax Check
|
||||
bool mSyntaxCheck;
|
||||
bool mSyntaxCheckWhenSave;
|
||||
bool mSyntaxCheckWhenLineChanged;
|
||||
|
||||
// _Base interface
|
||||
protected:
|
||||
void doSave() override;
|
||||
|
|
|
@ -82,6 +82,6 @@ void EditorGeneralWidget::doSave()
|
|||
pSettings->editor().setScrollByOneLess(ui->chkScrollByOneLess->isChecked());
|
||||
pSettings->editor().setHalfPageScroll(ui->chkScrollHalfPage->isChecked());
|
||||
|
||||
//pSettings->editor().save();
|
||||
pSettings->editor().save();
|
||||
pMainWindow->updateEditorSettings();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
#include "editorsyntaxcheckwidget.h"
|
||||
#include "ui_editorsyntaxcheckwidget.h"
|
||||
#include "../settings.h"
|
||||
|
||||
EditorSyntaxCheckWidget::EditorSyntaxCheckWidget(const QString &name, const QString &group, QWidget *parent) :
|
||||
SettingsWidget(name,group,parent),
|
||||
ui(new Ui::EditorSyntaxCheckWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
EditorSyntaxCheckWidget::~EditorSyntaxCheckWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void EditorSyntaxCheckWidget::doLoad()
|
||||
{
|
||||
//Auto Syntax Check
|
||||
ui->grpEnableAutoSyntaxCheck->setChecked(pSettings->editor().syntaxCheck());
|
||||
ui->chkSyntaxCheckWhenSave->setChecked(pSettings->editor().syntaxCheckWhenSave());
|
||||
ui->chkSyntaxCheckWhenLineChanged->setChecked(pSettings->editor().syntaxCheckWhenLineChanged());
|
||||
}
|
||||
|
||||
void EditorSyntaxCheckWidget::doSave()
|
||||
{
|
||||
//Auto Syntax Check
|
||||
pSettings->editor().setSyntaxCheck(ui->grpEnableAutoSyntaxCheck->isChecked());
|
||||
pSettings->editor().setSyntaxCheckWhenSave(ui->chkSyntaxCheckWhenSave->isChecked());
|
||||
pSettings->editor().setSyntaxCheckWhenLineChanged(ui->chkSyntaxCheckWhenLineChanged->isChecked());
|
||||
|
||||
pSettings->editor().save();
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef EDITORSYNTAXCHECKWIDGET_H
|
||||
#define EDITORSYNTAXCHECKWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "settingswidget.h"
|
||||
|
||||
namespace Ui {
|
||||
class EditorSyntaxCheckWidget;
|
||||
}
|
||||
|
||||
class EditorSyntaxCheckWidget : public SettingsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditorSyntaxCheckWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
|
||||
~EditorSyntaxCheckWidget();
|
||||
|
||||
private:
|
||||
Ui::EditorSyntaxCheckWidget *ui;
|
||||
|
||||
// SettingsWidget interface
|
||||
protected:
|
||||
void doLoad();
|
||||
void doSave();
|
||||
};
|
||||
|
||||
#endif // EDITORSYNTAXCHECKWIDGET_H
|
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EditorSyntaxCheckWidget</class>
|
||||
<widget class="QWidget" name="EditorSyntaxCheckWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="grpEnableAutoSyntaxCheck">
|
||||
<property name="title">
|
||||
<string>Enable Auto Syntax Check</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkSyntaxCheckWhenSave">
|
||||
<property name="text">
|
||||
<string>Check when save/load file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkSyntaxCheckWhenLineChanged">
|
||||
<property name="text">
|
||||
<string>Check when count of lines changed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -6,6 +6,7 @@
|
|||
#include "editorfontwidget.h"
|
||||
#include "editorclipboardwidget.h"
|
||||
#include "editorcolorschemewidget.h"
|
||||
#include "editorsyntaxcheckwidget.h"
|
||||
#include "editorsymbolcompletionwidget.h"
|
||||
#include "environmentappearencewidget.h"
|
||||
#include <QDebug>
|
||||
|
@ -52,6 +53,11 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
|
|||
pEditorSymbolCompletionWidget->init();
|
||||
addWidget(pEditorSymbolCompletionWidget);
|
||||
|
||||
pEditorSyntaxCheckWidget = new EditorSyntaxCheckWidget(tr("Auto Syntax Checking"),tr("Editor"));
|
||||
pEditorSyntaxCheckWidget->init();
|
||||
addWidget(pEditorSyntaxCheckWidget);
|
||||
|
||||
|
||||
ui->widgetsView->expandAll();
|
||||
//select the first widget of the first group
|
||||
auto groupIndex = ui->widgetsView->model()->index(0,0);
|
||||
|
|
|
@ -17,6 +17,7 @@ class EditorFontWidget;
|
|||
class EditorClipboardWidget;
|
||||
class EditorSymbolCompletionWidget;
|
||||
class EditorColorSchemeWidget;
|
||||
class EditorSyntaxCheckWidget;
|
||||
class EnvironmentAppearenceWidget;
|
||||
class SettingsWidget;
|
||||
class SettingsDialog : public QDialog
|
||||
|
@ -54,6 +55,7 @@ private:
|
|||
EditorColorSchemeWidget *pEditorColorSchemeWidget;
|
||||
EnvironmentAppearenceWidget* pEnvironmentAppearenceWidget;
|
||||
EditorSymbolCompletionWidget* pEditorSymbolCompletionWidget;
|
||||
EditorSyntaxCheckWidget* pEditorSyntaxCheckWidget;
|
||||
};
|
||||
|
||||
#endif // SETTINGSDIALOG_H
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <QDebug>
|
||||
#include <windows.h>
|
||||
#include <QStyleFactory>
|
||||
#include <QDateTime>
|
||||
|
||||
const QByteArray GuessTextEncoding(const QByteArray& text){
|
||||
bool allAscii;
|
||||
|
@ -424,3 +425,16 @@ void changeTheme(const QString &themeName)
|
|||
dynamic_cast<QApplication*>(QApplication::instance())->setStyleSheet(ts.readAll());
|
||||
}
|
||||
}
|
||||
|
||||
int compareFileModifiedTime(const QString &filename1, const QString &filename2)
|
||||
{
|
||||
QFileInfo fileInfo1(filename1);
|
||||
QFileInfo fileInfo2(filename2);
|
||||
qint64 time1=fileInfo1.lastModified().toMSecsSinceEpoch();
|
||||
qint64 time2=fileInfo2.lastModified().toMSecsSinceEpoch();
|
||||
if (time1 > time2)
|
||||
return 1;
|
||||
if (time1 < time2)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ void inflateRect(QRect& rect, int dx, int dy);
|
|||
QString TrimRight(const QString& s);
|
||||
QString TrimLeft(const QString& s);
|
||||
bool StringIsBlank(const QString& s);
|
||||
int compareFileModifiedTime(const QString& filename1, const QString& filename2);
|
||||
|
||||
void changeTheme(const QString& themeName);
|
||||
template <class F>
|
||||
|
|
Loading…
Reference in New Issue