work save:
- change editor's encoding also change project unit's encoding Option - ascii encoding file don't add encoding info when generating project make file - make Settings Dialog more general
This commit is contained in:
parent
6335991ccf
commit
1a00443f89
|
@ -1,6 +1,7 @@
|
|||
#include "compiler.h"
|
||||
#include "utils.h"
|
||||
#include "compilermanager.h"
|
||||
#include "../systemconsts.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QProcess>
|
||||
|
@ -527,7 +528,11 @@ void Compiler::runCommand(const QString &cmd, const QString &arguments, const Q
|
|||
if (!cmdDir.isEmpty()) {
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
QString path = env.value("PATH");
|
||||
path = cmdDir + ';' + path;
|
||||
if (path.isEmpty()) {
|
||||
path = cmdDir;
|
||||
} else {
|
||||
path = cmdDir + PATH_SEPARATOR + path;
|
||||
}
|
||||
env.insert("PATH",path);
|
||||
process.setProcessEnvironment(env);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ bool FileCompiler::prepareForCompile()
|
|||
log(tr("Processing %1 source file:").arg(strFileType));
|
||||
log("------------------");
|
||||
log(tr("%1 Compiler: %2").arg(strFileType).arg(mCompiler));
|
||||
log(tr("Command: %1 %2").arg(QFileInfo(mCompiler).fileName()).arg(mArguments));
|
||||
log(tr("Command: %1 %2").arg(extractFileName(mCompiler)).arg(mArguments));
|
||||
mDirectory = extractFileDir(mFilename);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -324,10 +324,10 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
|
|||
QString encodingStr;
|
||||
if (mProject->options().addCharset) {
|
||||
if (unit->encoding() == ENCODING_AUTO_DETECT) {
|
||||
if (unit->editor())
|
||||
if (unit->editor() && unit->editor()->fileEncoding()!=ENCODING_ASCII)
|
||||
encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2")
|
||||
.arg(unit->editor()->fileEncoding(),getDefaultSystemEncoding());
|
||||
} else {
|
||||
} else if (unit->encoding()!=ENCODING_ASCII) {
|
||||
encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2")
|
||||
.arg(unit->encoding(),getDefaultSystemEncoding());
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ bool ProjectCompiler::prepareForCompile()
|
|||
log(tr("Processing makefile:"));
|
||||
log("--------");
|
||||
log(tr("- makefile processer: %1").arg(mCompiler));
|
||||
log(tr("- Command: %1 %2").arg(mCompiler).arg(mArguments));
|
||||
log(tr("- Command: %1 %2").arg(extractFileName(mCompiler)).arg(mArguments));
|
||||
log("");
|
||||
|
||||
return true;
|
||||
|
|
|
@ -56,7 +56,7 @@ bool StdinCompiler::prepareForCompile()
|
|||
log(tr("Processing %1 source file:").arg(strFileType));
|
||||
log("------------------");
|
||||
log(tr("%1 Compiler: %2").arg(strFileType).arg(mCompiler));
|
||||
log(tr("Command: %1 %2").arg(QFileInfo(mCompiler).fileName()).arg(mArguments));
|
||||
log(tr("Command: %1 %2").arg(extractFileName(mCompiler)).arg(mArguments));
|
||||
mDirectory = extractFileDir(mFilename);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -296,6 +296,16 @@ void Editor::setEncodingOption(const QByteArray& encoding) noexcept{
|
|||
loadFile();
|
||||
else
|
||||
pMainWindow->updateForEncodingInfo();
|
||||
if (mInProject) {
|
||||
std::shared_ptr<Project> project = pMainWindow->project();
|
||||
if (project) {
|
||||
int index = project->indexInUnits(this);
|
||||
if (index>=0) {
|
||||
PProjectUnit unit = project->units()[index];
|
||||
unit->setEncoding(mEncodingOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const QByteArray& Editor::fileEncoding() const noexcept{
|
||||
return mFileEncoding;
|
||||
|
|
|
@ -1447,23 +1447,18 @@ void MainWindow::openShell(const QString &folder, const QString &shellCommand)
|
|||
});
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
QString path = env.value("PATH");
|
||||
|
||||
QStringList pathAdded;
|
||||
if (pSettings->compilerSets().defaultSet()) {
|
||||
foreach(const QString& dir, pSettings->compilerSets().defaultSet()->binDirs()) {
|
||||
#ifdef Q_OS_WIN
|
||||
path+=";";
|
||||
#else
|
||||
path+=":";
|
||||
#endif
|
||||
path+=dir;
|
||||
pathAdded.append(dir);
|
||||
}
|
||||
}
|
||||
#ifdef Q_OS_WIN
|
||||
path+=";";
|
||||
#else
|
||||
path+=":";
|
||||
#endif
|
||||
path+=pSettings->dirs().app();
|
||||
pathAdded.append(pSettings->dirs().app());
|
||||
if (!path.isEmpty()) {
|
||||
path+= PATH_SEPARATOR + pathAdded.join(PATH_SEPARATOR);
|
||||
} else {
|
||||
path = pathAdded.join(PATH_SEPARATOR);
|
||||
}
|
||||
env.insert("PATH",path);
|
||||
process.setProcessEnvironment(env);
|
||||
process.startDetached();
|
||||
|
@ -1884,8 +1879,9 @@ void MainWindow::on_actionSaveAs_triggered()
|
|||
void MainWindow::on_actionOptions_triggered()
|
||||
{
|
||||
bool oldCodeCompletion = pSettings->codeCompletion().enabled();
|
||||
SettingsDialog settingsDialog;
|
||||
settingsDialog.exec();
|
||||
PSettingsDialog settingsDialog = SettingsDialog::optionDialog();
|
||||
settingsDialog->exec();
|
||||
|
||||
bool newCodeCompletion = pSettings->codeCompletion().enabled();
|
||||
if (!oldCodeCompletion && newCodeCompletion) {
|
||||
Editor *e = mEditorList->getEditor();
|
||||
|
|
|
@ -32,77 +32,6 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
|
|||
|
||||
ui->btnApply->setEnabled(false);
|
||||
|
||||
pEnvironmentAppearenceWidget = new EnvironmentAppearenceWidget(tr("Appearence"),tr("Environment"));
|
||||
pEnvironmentAppearenceWidget->init();
|
||||
addWidget(pEnvironmentAppearenceWidget);
|
||||
|
||||
pCompilerSetOptionWidget = new CompilerSetOptionWidget(tr("Compiler Set"),tr("Compiler"));
|
||||
pCompilerSetOptionWidget->init();
|
||||
addWidget(pCompilerSetOptionWidget);
|
||||
|
||||
pCompilerAutolinkWidget = new CompilerAutolinkWidget(tr("Auto Link"),tr("Compiler"));
|
||||
pCompilerAutolinkWidget->init();
|
||||
addWidget(pCompilerAutolinkWidget);
|
||||
|
||||
pEditorGeneralWidget = new EditorGeneralWidget(tr("General"),tr("Editor"));
|
||||
pEditorGeneralWidget->init();
|
||||
addWidget(pEditorGeneralWidget);
|
||||
|
||||
pEditorFontWidget = new EditorFontWidget(tr("Font"),tr("Editor"));
|
||||
pEditorFontWidget->init();
|
||||
addWidget(pEditorFontWidget);
|
||||
|
||||
pEditorClipboardWidget = new EditorClipboardWidget(tr("Copy & Export"),tr("Editor"));
|
||||
pEditorClipboardWidget->init();
|
||||
addWidget(pEditorClipboardWidget);
|
||||
|
||||
pEditorColorSchemeWidget = new EditorColorSchemeWidget(tr("Color"),tr("Editor"));
|
||||
pEditorColorSchemeWidget->init();
|
||||
addWidget(pEditorColorSchemeWidget);
|
||||
|
||||
pEditorCodeCompletionWidget = new EditorCodeCompletionWidget(tr("Code Completion"),tr("Editor"));
|
||||
pEditorCodeCompletionWidget->init();
|
||||
addWidget(pEditorCodeCompletionWidget);
|
||||
|
||||
pEditorSymbolCompletionWidget = new EditorSymbolCompletionWidget(tr("Symbol Completion"),tr("Editor"));
|
||||
pEditorSymbolCompletionWidget->init();
|
||||
addWidget(pEditorSymbolCompletionWidget);
|
||||
|
||||
pEditorSyntaxCheckWidget = new EditorSyntaxCheckWidget(tr("Auto Syntax Checking"),tr("Editor"));
|
||||
pEditorSyntaxCheckWidget->init();
|
||||
addWidget(pEditorSyntaxCheckWidget);
|
||||
|
||||
pEditorAutoSaveWidget = new EditorAutoSaveWidget(tr("Auto save"),tr("Editor"));
|
||||
pEditorAutoSaveWidget->init();
|
||||
addWidget(pEditorAutoSaveWidget);
|
||||
|
||||
pEditorMiscWidget = new EditorMiscWidget(tr("Misc"),tr("Editor"));
|
||||
pEditorMiscWidget->init();
|
||||
addWidget(pEditorMiscWidget);
|
||||
|
||||
|
||||
pExecutorGeneralWidget = new ExecutorGeneralWidget(tr("General"),tr("Program Runner"));
|
||||
pExecutorGeneralWidget->init();
|
||||
addWidget(pExecutorGeneralWidget);
|
||||
|
||||
pDebugGeneralWidget = new DebugGeneralWidget(tr("General"),tr("Debugger"));
|
||||
pDebugGeneralWidget->init();
|
||||
addWidget(pDebugGeneralWidget);
|
||||
|
||||
pFormatterGeneralWidget = new FormatterGeneralWidget(tr("General"),tr("Code Formatter"));
|
||||
pFormatterGeneralWidget->init();
|
||||
addWidget(pFormatterGeneralWidget);
|
||||
|
||||
|
||||
ui->widgetsView->expandAll();
|
||||
//select the first widget of the first group
|
||||
auto groupIndex = ui->widgetsView->model()->index(0,0);
|
||||
auto widgetIndex = ui->widgetsView->model()->index(0,0, groupIndex);
|
||||
ui->widgetsView->selectionModel()->setCurrentIndex(
|
||||
widgetIndex,
|
||||
QItemSelectionModel::Select
|
||||
);
|
||||
on_widgetsView_clicked(widgetIndex);
|
||||
}
|
||||
|
||||
SettingsDialog::~SettingsDialog()
|
||||
|
@ -130,7 +59,89 @@ void SettingsDialog::addWidget(SettingsWidget *pWidget)
|
|||
pWidgetItem->setData(mSettingWidgets.count()-1, GetWidgetIndexRole);
|
||||
pGroupItem->appendRow(pWidgetItem);
|
||||
connect(pWidget, &SettingsWidget::settingsChanged,
|
||||
this , &SettingsDialog::widget_settings_changed);
|
||||
this , &SettingsDialog::widget_settings_changed);
|
||||
}
|
||||
|
||||
void SettingsDialog::selectFirstWidget()
|
||||
{
|
||||
ui->widgetsView->expandAll();
|
||||
//select the first widget of the first group
|
||||
auto groupIndex = ui->widgetsView->model()->index(0,0);
|
||||
auto widgetIndex = ui->widgetsView->model()->index(0,0, groupIndex);
|
||||
ui->widgetsView->selectionModel()->setCurrentIndex(
|
||||
widgetIndex,
|
||||
QItemSelectionModel::Select
|
||||
);
|
||||
on_widgetsView_clicked(widgetIndex);
|
||||
}
|
||||
|
||||
PSettingsDialog SettingsDialog::optionDialog()
|
||||
{
|
||||
PSettingsDialog dialog = std::make_shared<SettingsDialog>();
|
||||
|
||||
SettingsWidget* widget = new EnvironmentAppearenceWidget(tr("Appearence"),tr("Environment"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new CompilerSetOptionWidget(tr("Compiler Set"),tr("Compiler"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new CompilerAutolinkWidget(tr("Auto Link"),tr("Compiler"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new EditorGeneralWidget(tr("General"),tr("Editor"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new EditorFontWidget(tr("Font"),tr("Editor"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new EditorClipboardWidget(tr("Copy & Export"),tr("Editor"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new EditorColorSchemeWidget(tr("Color"),tr("Editor"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new EditorCodeCompletionWidget(tr("Code Completion"),tr("Editor"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new EditorSymbolCompletionWidget(tr("Symbol Completion"),tr("Editor"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new EditorSyntaxCheckWidget(tr("Auto Syntax Checking"),tr("Editor"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new EditorAutoSaveWidget(tr("Auto save"),tr("Editor"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new EditorMiscWidget(tr("Misc"),tr("Editor"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new ExecutorGeneralWidget(tr("General"),tr("Program Runner"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new DebugGeneralWidget(tr("General"),tr("Debugger"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new FormatterGeneralWidget(tr("General"),tr("Code Formatter"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
dialog->selectFirstWidget();
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,22 +10,8 @@ namespace Ui {
|
|||
class SettingsDialog;
|
||||
}
|
||||
|
||||
class CompilerSetOptionWidget;
|
||||
class CompilerAutolinkWidget;
|
||||
class EditorGeneralWidget;
|
||||
class EditorFontWidget;
|
||||
class EditorClipboardWidget;
|
||||
class EditorSymbolCompletionWidget;
|
||||
class EditorColorSchemeWidget;
|
||||
class EditorSyntaxCheckWidget;
|
||||
class EditorCodeCompletionWidget;
|
||||
class EditorAutoSaveWidget;
|
||||
class EditorMiscWidget;
|
||||
class EnvironmentAppearenceWidget;
|
||||
class ExecutorGeneralWidget;
|
||||
class DebugGeneralWidget;
|
||||
class FormatterGeneralWidget;
|
||||
class SettingsWidget;
|
||||
class SettingsDialog;
|
||||
using PSettingsDialog = std::shared_ptr<SettingsDialog>;
|
||||
class SettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -38,6 +24,11 @@ public:
|
|||
~SettingsDialog();
|
||||
|
||||
void addWidget(SettingsWidget* pWidget);
|
||||
|
||||
void selectFirstWidget();
|
||||
|
||||
static PSettingsDialog optionDialog();
|
||||
|
||||
private slots:
|
||||
void widget_settings_changed(bool value);
|
||||
void on_widgetsView_clicked(const QModelIndex &index);
|
||||
|
@ -54,21 +45,21 @@ private:
|
|||
QList<SettingsWidget*> mSettingWidgets;
|
||||
QStandardItemModel model;
|
||||
|
||||
CompilerSetOptionWidget *pCompilerSetOptionWidget;
|
||||
CompilerAutolinkWidget *pCompilerAutolinkWidget;
|
||||
EditorGeneralWidget *pEditorGeneralWidget;
|
||||
EditorFontWidget *pEditorFontWidget;
|
||||
EditorClipboardWidget *pEditorClipboardWidget;
|
||||
EditorColorSchemeWidget *pEditorColorSchemeWidget;
|
||||
EnvironmentAppearenceWidget *pEnvironmentAppearenceWidget;
|
||||
EditorSymbolCompletionWidget *pEditorSymbolCompletionWidget;
|
||||
EditorCodeCompletionWidget *pEditorCodeCompletionWidget;
|
||||
EditorSyntaxCheckWidget *pEditorSyntaxCheckWidget;
|
||||
EditorAutoSaveWidget *pEditorAutoSaveWidget;
|
||||
EditorMiscWidget *pEditorMiscWidget;
|
||||
ExecutorGeneralWidget *pExecutorGeneralWidget;
|
||||
DebugGeneralWidget *pDebugGeneralWidget;
|
||||
FormatterGeneralWidget *pFormatterGeneralWidget;
|
||||
// CompilerSetOptionWidget *pCompilerSetOptionWidget;
|
||||
// CompilerAutolinkWidget *pCompilerAutolinkWidget;
|
||||
// EditorGeneralWidget *pEditorGeneralWidget;
|
||||
// EditorFontWidget *pEditorFontWidget;
|
||||
// EditorClipboardWidget *pEditorClipboardWidget;
|
||||
// EditorColorSchemeWidget *pEditorColorSchemeWidget;
|
||||
// EnvironmentAppearenceWidget *pEnvironmentAppearenceWidget;
|
||||
// EditorSymbolCompletionWidget *pEditorSymbolCompletionWidget;
|
||||
// EditorCodeCompletionWidget *pEditorCodeCompletionWidget;
|
||||
// EditorSyntaxCheckWidget *pEditorSyntaxCheckWidget;
|
||||
// EditorAutoSaveWidget *pEditorAutoSaveWidget;
|
||||
// EditorMiscWidget *pEditorMiscWidget;
|
||||
// ExecutorGeneralWidget *pExecutorGeneralWidget;
|
||||
// DebugGeneralWidget *pDebugGeneralWidget;
|
||||
// FormatterGeneralWidget *pFormatterGeneralWidget;
|
||||
};
|
||||
|
||||
#endif // SETTINGSDIALOG_H
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#ifdef Q_OS_WIN
|
||||
# define PATH_SENSITIVITY Qt::CaseInsensitive
|
||||
# define PATH_SEPARATOR ";"
|
||||
# define NULL_FILE "NUL"
|
||||
# define EXECUTABLE_EXT "exe"
|
||||
# define STATIC_LIB_EXT "a"
|
||||
|
@ -37,6 +38,7 @@
|
|||
# define MAKEFILE_NAME "makefile.win"
|
||||
#elif Q_OS_LINUX
|
||||
# define PATH_SENSITIVITY Qt::CaseSensitive
|
||||
# define PATH_SEPARATOR ":"
|
||||
# define NULL_FILE "/dev/null"
|
||||
# define EXECUTABLE_EXT ""
|
||||
# define STATIC_LIB_EXT "a"
|
||||
|
|
Loading…
Reference in New Issue