diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index b65902b3..9f4da50b 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -79,6 +79,7 @@ SOURCES += \ utils.cpp \ widgets/coloredit.cpp \ widgets/consolewidget.cpp \ + widgets/filepropertiesdialog.cpp \ widgets/headercompletionpopup.cpp \ widgets/issuestable.cpp \ widgets/qconsole.cpp \ @@ -154,6 +155,7 @@ HEADERS += \ common.h \ widgets/coloredit.h \ widgets/consolewidget.h \ + widgets/filepropertiesdialog.h \ widgets/headercompletionpopup.h \ widgets/issuestable.h \ widgets/qconsole.h \ @@ -180,6 +182,7 @@ FORMS += \ settingsdialog/environmentappearencewidget.ui \ settingsdialog/executorgeneralwidget.ui \ settingsdialog/settingsdialog.ui \ + widgets/filepropertiesdialog.ui \ widgets/searchdialog.ui TRANSLATIONS += \ diff --git a/RedPandaIDE/compiler/compilermanager.cpp b/RedPandaIDE/compiler/compilermanager.cpp index fbf4b45e..2f7ef267 100644 --- a/RedPandaIDE/compiler/compilermanager.cpp +++ b/RedPandaIDE/compiler/compilermanager.cpp @@ -61,7 +61,7 @@ void CompilerManager::compile(const QString& filename, const QByteArray& encodin } } -void CompilerManager::checkSyntax(const QString &filename, const QString &content) +void CompilerManager::checkSyntax(const QString &filename, const QString &content, bool isAscii) { if (!pSettings->compilerSets().defaultSet()) { QMessageBox::critical(pMainWindow, @@ -76,7 +76,7 @@ void CompilerManager::checkSyntax(const QString &filename, const QString &conten } mSyntaxCheckErrorCount = 0; - mBackgroundSyntaxChecker = new StdinCompiler(filename,content,true,true); + mBackgroundSyntaxChecker = new StdinCompiler(filename,content,isAscii,true,true); connect(mBackgroundSyntaxChecker, &Compiler::compileFinished, this ,&CompilerManager::onSyntaxCheckFinished); connect(mBackgroundSyntaxChecker, &Compiler::compileIssue, this, &CompilerManager::onSyntaxCheckIssue); connect(mBackgroundSyntaxChecker, &Compiler::compileFinished, pMainWindow, &MainWindow::onCompileFinished); diff --git a/RedPandaIDE/compiler/compilermanager.h b/RedPandaIDE/compiler/compilermanager.h index e3ccbee9..e7386f49 100644 --- a/RedPandaIDE/compiler/compilermanager.h +++ b/RedPandaIDE/compiler/compilermanager.h @@ -19,7 +19,7 @@ public: bool running(); 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 checkSyntax(const QString&filename, const QString& content, bool isAscii); void run(const QString& filename, const QString& arguments, const QString& workDir); void stopRun(); void stopCompile(); diff --git a/RedPandaIDE/compiler/stdincompiler.cpp b/RedPandaIDE/compiler/stdincompiler.cpp index 13b06022..72c8008b 100644 --- a/RedPandaIDE/compiler/stdincompiler.cpp +++ b/RedPandaIDE/compiler/stdincompiler.cpp @@ -2,10 +2,12 @@ #include "compilermanager.h" #include #include +#include "../platform.h" -StdinCompiler::StdinCompiler(const QString &filename, const QString& content, bool silent, bool onlyCheckSyntax): +StdinCompiler::StdinCompiler(const QString &filename, const QString& content,bool isAscii, bool silent, bool onlyCheckSyntax): Compiler(filename,silent,onlyCheckSyntax), - mContent(content) + mContent(content), + mIsAscii(isAscii) { } @@ -26,6 +28,8 @@ bool StdinCompiler::prepareForCompile() if (fileType == FileType::Other) fileType = FileType::CppSource; QString strFileType; + if (!mIsAscii) + mArguments += getCharsetArgument(getDefaultSystemEncoding()); switch(fileType) { case FileType::CSource: case FileType::CHeader: diff --git a/RedPandaIDE/compiler/stdincompiler.h b/RedPandaIDE/compiler/stdincompiler.h index 5c9bef3b..6e81cd86 100644 --- a/RedPandaIDE/compiler/stdincompiler.h +++ b/RedPandaIDE/compiler/stdincompiler.h @@ -8,7 +8,7 @@ class StdinCompiler : public Compiler Q_OBJECT public: - explicit StdinCompiler(const QString& filename, const QString& content, bool silent,bool onlyCheckSyntax); + explicit StdinCompiler(const QString& filename, const QString& content, bool isAscii, bool silent,bool onlyCheckSyntax); // Compiler interface protected: @@ -17,6 +17,7 @@ protected: private: QString mContent; + bool mIsAscii; // Compiler interface protected: diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 435d3b40..6fef59ee 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -614,7 +614,8 @@ void MainWindow::checkSyntaxInBack(Editor *e) mCheckSyntaxInBack=true; e->clearSyntaxIssues(); ui->tableIssues->clearIssues(); - mCompilerManager->checkSyntax(e->filename(),e->lines()->text()); + mCompilerManager->checkSyntax(e->filename(),e->lines()->text(), + e->fileEncoding() == ENCODING_ASCII); // if not PrepareForCompile(cttStdin,True) then begin // fCheckSyntaxInBack:=False; // Exit; diff --git a/RedPandaIDE/widgets/filepropertiesdialog.cpp b/RedPandaIDE/widgets/filepropertiesdialog.cpp new file mode 100644 index 00000000..efa020d9 --- /dev/null +++ b/RedPandaIDE/widgets/filepropertiesdialog.cpp @@ -0,0 +1,14 @@ +#include "filepropertiesdialog.h" +#include "ui_filepropertiesdialog.h" + +FilePropertiesDialog::FilePropertiesDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::FilePropertiesDialog) +{ + ui->setupUi(this); +} + +FilePropertiesDialog::~FilePropertiesDialog() +{ + delete ui; +} diff --git a/RedPandaIDE/widgets/filepropertiesdialog.h b/RedPandaIDE/widgets/filepropertiesdialog.h new file mode 100644 index 00000000..ed613c26 --- /dev/null +++ b/RedPandaIDE/widgets/filepropertiesdialog.h @@ -0,0 +1,22 @@ +#ifndef FILEPROPERTIESDIALOG_H +#define FILEPROPERTIESDIALOG_H + +#include + +namespace Ui { +class FilePropertiesDialog; +} + +class FilePropertiesDialog : public QDialog +{ + Q_OBJECT + +public: + explicit FilePropertiesDialog(QWidget *parent = nullptr); + ~FilePropertiesDialog(); + +private: + Ui::FilePropertiesDialog *ui; +}; + +#endif // FILEPROPERTIESDIALOG_H diff --git a/RedPandaIDE/widgets/filepropertiesdialog.ui b/RedPandaIDE/widgets/filepropertiesdialog.ui new file mode 100644 index 00000000..1a84f4a8 --- /dev/null +++ b/RedPandaIDE/widgets/filepropertiesdialog.ui @@ -0,0 +1,18 @@ + + FilePropertiesDialog + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + +