work save: fix project file encoding setting
compiler set - exec charset setting
This commit is contained in:
parent
8cffef2cb6
commit
d9f36ae3cd
|
@ -68,8 +68,7 @@ QList<PCharsetInfo> CharsetInfoManager::findCharsetsByLanguageName(const QString
|
||||||
{
|
{
|
||||||
QList<PCharsetInfo> result;
|
QList<PCharsetInfo> result;
|
||||||
foreach (const PCharsetInfo& info, mCodePages) {
|
foreach (const PCharsetInfo& info, mCodePages) {
|
||||||
if (info->language == languageName
|
if (info->enabled && info->language == languageName)
|
||||||
&& info->enabled)
|
|
||||||
result.append(info);
|
result.append(info);
|
||||||
}
|
}
|
||||||
std::sort(result.begin(),result.end(),[](const PCharsetInfo& info1,const PCharsetInfo& info2){
|
std::sort(result.begin(),result.end(),[](const PCharsetInfo& info1,const PCharsetInfo& info2){
|
||||||
|
@ -78,6 +77,17 @@ QList<PCharsetInfo> CharsetInfoManager::findCharsetsByLanguageName(const QString
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CharsetInfoManager::findLanguageByCharsetName(const QString &encodingName)
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach (const PCharsetInfo& info, mCodePages) {
|
||||||
|
if (info->enabled &&
|
||||||
|
QString::compare(info->name, encodingName, Qt::CaseInsensitive)==0)
|
||||||
|
return info->language;
|
||||||
|
}
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
CharsetInfoManager::CharsetInfoManager():QObject()
|
CharsetInfoManager::CharsetInfoManager():QObject()
|
||||||
{
|
{
|
||||||
mCodePages.append(std::make_shared<CharsetInfo>(37,"IBM037","",false));
|
mCodePages.append(std::make_shared<CharsetInfo>(37,"IBM037","",false));
|
||||||
|
|
|
@ -42,6 +42,7 @@ public:
|
||||||
PCharsetInfo findCharsetByCodepage(int codepage);
|
PCharsetInfo findCharsetByCodepage(int codepage);
|
||||||
QStringList languageNames();
|
QStringList languageNames();
|
||||||
QList<PCharsetInfo> findCharsetsByLanguageName(const QString& languageName);
|
QList<PCharsetInfo> findCharsetsByLanguageName(const QString& languageName);
|
||||||
|
QString findLanguageByCharsetName(const QString& encodingName);
|
||||||
private:
|
private:
|
||||||
QList<PCharsetInfo> mCodePages;
|
QList<PCharsetInfo> mCodePages;
|
||||||
};
|
};
|
||||||
|
|
|
@ -2307,6 +2307,16 @@ QByteArray Settings::CompilerSet::getCompilerOutput(const QString &binDir, const
|
||||||
return result.trimmed();
|
return result.trimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString &Settings::CompilerSet::execCharser() const
|
||||||
|
{
|
||||||
|
return mExecCharser;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::CompilerSet::setExecCharser(const QString &newExecCharser)
|
||||||
|
{
|
||||||
|
mExecCharser = newExecCharser;
|
||||||
|
}
|
||||||
|
|
||||||
const QString &Settings::CompilerSet::debugServer() const
|
const QString &Settings::CompilerSet::debugServer() const
|
||||||
{
|
{
|
||||||
return mDebugServer;
|
return mDebugServer;
|
||||||
|
@ -2750,6 +2760,7 @@ void Settings::CompilerSets::saveSet(int index)
|
||||||
mSettings->mSettings.setValue("customLinkParams", pSet->customLinkParams());
|
mSettings->mSettings.setValue("customLinkParams", pSet->customLinkParams());
|
||||||
mSettings->mSettings.setValue("AddCharset", pSet->autoAddCharsetParams());
|
mSettings->mSettings.setValue("AddCharset", pSet->autoAddCharsetParams());
|
||||||
mSettings->mSettings.setValue("StaticLink", pSet->staticLink());
|
mSettings->mSettings.setValue("StaticLink", pSet->staticLink());
|
||||||
|
mSettings->mSettings.setValue("ExecCharser", pSet->execCharser());
|
||||||
|
|
||||||
// Misc. properties
|
// Misc. properties
|
||||||
mSettings->mSettings.setValue("DumpMachine", pSet->dumpMachine());
|
mSettings->mSettings.setValue("DumpMachine", pSet->dumpMachine());
|
||||||
|
@ -2815,6 +2826,7 @@ Settings::PCompilerSet Settings::CompilerSets::loadSet(int index)
|
||||||
pSet->setCustomLinkParams(mSettings->mSettings.value("customLinkParams").toString());
|
pSet->setCustomLinkParams(mSettings->mSettings.value("customLinkParams").toString());
|
||||||
pSet->setAutoAddCharsetParams(mSettings->mSettings.value("AddCharset").toBool());
|
pSet->setAutoAddCharsetParams(mSettings->mSettings.value("AddCharset").toBool());
|
||||||
pSet->setStaticLink(mSettings->mSettings.value("StaticLink").toBool());
|
pSet->setStaticLink(mSettings->mSettings.value("StaticLink").toBool());
|
||||||
|
pSet->setExecCharser(mSettings->mSettings.value("ExecCharser").toString());
|
||||||
|
|
||||||
pSet->setDumpMachine(mSettings->mSettings.value("DumpMachine").toString());
|
pSet->setDumpMachine(mSettings->mSettings.value("DumpMachine").toString());
|
||||||
pSet->setVersion(mSettings->mSettings.value("Version").toString());
|
pSet->setVersion(mSettings->mSettings.value("Version").toString());
|
||||||
|
|
|
@ -1177,6 +1177,9 @@ public:
|
||||||
int compilerSetType() const;
|
int compilerSetType() const;
|
||||||
void setCompilerSetType(int newCompilerSetType);
|
void setCompilerSetType(int newCompilerSetType);
|
||||||
|
|
||||||
|
const QString &execCharser() const;
|
||||||
|
void setExecCharser(const QString &newExecCharser);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Initialization
|
// Initialization
|
||||||
void setExecutables();
|
void setExecutables();
|
||||||
|
@ -1222,6 +1225,7 @@ public:
|
||||||
QString mCustomCompileParams;
|
QString mCustomCompileParams;
|
||||||
QString mCustomLinkParams;
|
QString mCustomLinkParams;
|
||||||
bool mAutoAddCharsetParams;
|
bool mAutoAddCharsetParams;
|
||||||
|
QString mExecCharser;
|
||||||
bool mStaticLink;
|
bool mStaticLink;
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include "../utils.h"
|
#include "../utils.h"
|
||||||
#include "../iconsmanager.h"
|
#include "../iconsmanager.h"
|
||||||
|
#include "../platform.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
@ -56,6 +57,19 @@ CompilerSetOptionWidget::~CompilerSetOptionWidget()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CompilerSetOptionWidget::init()
|
||||||
|
{
|
||||||
|
ui->cbEncodingDetails->setVisible(false);
|
||||||
|
ui->cbEncoding->clear();
|
||||||
|
ui->cbEncoding->addItem(tr("Auto detect"),ENCODING_AUTO_DETECT);
|
||||||
|
ui->cbEncoding->addItem(tr("ANSI"),ENCODING_SYSTEM_DEFAULT);
|
||||||
|
ui->cbEncoding->addItem(tr("UTF-8"),ENCODING_UTF8);
|
||||||
|
foreach (const QString& langName, pCharsetInfoManager->languageNames()) {
|
||||||
|
ui->cbEncoding->addItem(langName,langName);
|
||||||
|
}
|
||||||
|
SettingsWidget::init();
|
||||||
|
}
|
||||||
|
|
||||||
void resetOptionTabs(Settings::PCompilerSet pSet,QTabWidget* pTab)
|
void resetOptionTabs(Settings::PCompilerSet pSet,QTabWidget* pTab)
|
||||||
{
|
{
|
||||||
while (pTab->count()>0) {
|
while (pTab->count()>0) {
|
||||||
|
|
|
@ -42,9 +42,12 @@ private:
|
||||||
|
|
||||||
|
|
||||||
// SettingsWidget interface
|
// SettingsWidget interface
|
||||||
|
public:
|
||||||
|
void init() override;
|
||||||
protected:
|
protected:
|
||||||
void doLoad() override;
|
void doLoad() override;
|
||||||
void doSave() override;
|
void doSave() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reloadCurrentCompilerSet();
|
void reloadCurrentCompilerSet();
|
||||||
void saveCurrentCompilerSet();
|
void saveCurrentCompilerSet();
|
||||||
|
@ -57,6 +60,7 @@ private slots:
|
||||||
void on_btnRenameCompilerSet_pressed();
|
void on_btnRenameCompilerSet_pressed();
|
||||||
void on_btnRemoveCompilerSet_pressed();
|
void on_btnRemoveCompilerSet_pressed();
|
||||||
void updateIcons();
|
void updateIcons();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COMPILERSETOPTIONWIDGET_H
|
#endif // COMPILERSETOPTIONWIDGET_H
|
||||||
|
|
|
@ -121,10 +121,34 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="chkAutoAddCharset">
|
<widget class="QWidget" name="widget" native="true">
|
||||||
<property name="text">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<string>Add Charset arguments when calling the compiler</string>
|
<property name="leftMargin">
|
||||||
</property>
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="chkAutoAddCharset">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add Charset arguments when calling the compiler</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="cbEncoding"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="cbEncodingDetails"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -108,6 +108,28 @@ void ProjectFilesWidget::disableFileOptions()
|
||||||
ui->txtBuildCommand->setPlainText("");
|
ui->txtBuildCommand->setPlainText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProjectFilesWidget::loadUnitEncoding(PProjectUnit unit)
|
||||||
|
{
|
||||||
|
if (unit->encoding() == ENCODING_AUTO_DETECT
|
||||||
|
|| unit->encoding() == ENCODING_SYSTEM_DEFAULT
|
||||||
|
|| unit->encoding() == ENCODING_UTF8) {
|
||||||
|
ui->cbEncoding->setCurrentText(unit->encoding());
|
||||||
|
ui->cbEncodingDetail->clear();
|
||||||
|
ui->cbEncodingDetail->setVisible(false);
|
||||||
|
} else {
|
||||||
|
QString encoding = unit->encoding();
|
||||||
|
QString language = pCharsetInfoManager->findLanguageByCharsetName(encoding);
|
||||||
|
ui->cbEncoding->setCurrentText(language);
|
||||||
|
ui->cbEncodingDetail->setVisible(true);
|
||||||
|
ui->cbEncodingDetail->clear();
|
||||||
|
QList<PCharsetInfo> infos = pCharsetInfoManager->findCharsetsByLanguageName(language);
|
||||||
|
foreach (const PCharsetInfo& info, infos) {
|
||||||
|
ui->cbEncodingDetail->addItem(info->name);
|
||||||
|
}
|
||||||
|
ui->cbEncodingDetail->setCurrentText(encoding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ProjectFilesWidget::on_treeProject_doubleClicked(const QModelIndex &index)
|
void ProjectFilesWidget::on_treeProject_doubleClicked(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
if (!index.isValid()) {
|
if (!index.isValid()) {
|
||||||
|
@ -130,7 +152,7 @@ void ProjectFilesWidget::on_treeProject_doubleClicked(const QModelIndex &index)
|
||||||
ui->chkOverrideBuildCommand->setChecked(unit->overrideBuildCmd());
|
ui->chkOverrideBuildCommand->setChecked(unit->overrideBuildCmd());
|
||||||
ui->txtBuildCommand->setPlainText(unit->buildCmd());
|
ui->txtBuildCommand->setPlainText(unit->buildCmd());
|
||||||
ui->txtBuildCommand->setEnabled(ui->chkOverrideBuildCommand->isChecked());
|
ui->txtBuildCommand->setEnabled(ui->chkOverrideBuildCommand->isChecked());
|
||||||
ui->cbEncoding->setCurrentText(unit->encoding());
|
loadUnitEncoding(unit);
|
||||||
} else {
|
} else {
|
||||||
disableFileOptions();
|
disableFileOptions();
|
||||||
}
|
}
|
||||||
|
@ -201,7 +223,7 @@ void ProjectFilesWidget::on_cbEncoding_currentTextChanged(const QString &)
|
||||||
PProjectUnit unit = currentUnit();
|
PProjectUnit unit = currentUnit();
|
||||||
if(!unit)
|
if(!unit)
|
||||||
return;
|
return;
|
||||||
unit->setEncoding(userData.toLocal8Bit());
|
unit->setEncoding(userData.toUtf8());
|
||||||
ui->cbEncodingDetail->setVisible(false);
|
ui->cbEncodingDetail->setVisible(false);
|
||||||
ui->cbEncodingDetail->clear();
|
ui->cbEncodingDetail->clear();
|
||||||
} else {
|
} else {
|
||||||
|
@ -241,6 +263,6 @@ void ProjectFilesWidget::on_cbEncodingDetail_currentTextChanged(const QString &)
|
||||||
PProjectUnit unit = currentUnit();
|
PProjectUnit unit = currentUnit();
|
||||||
if(!unit)
|
if(!unit)
|
||||||
return;
|
return;
|
||||||
unit->setEncoding(ui->cbEncodingDetail->currentText().toLocal8Bit());
|
unit->setEncoding(ui->cbEncodingDetail->currentText().toUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ private:
|
||||||
PProjectUnit currentUnit();
|
PProjectUnit currentUnit();
|
||||||
void copyUnits();
|
void copyUnits();
|
||||||
void disableFileOptions();
|
void disableFileOptions();
|
||||||
|
void loadUnitEncoding(PProjectUnit unit);
|
||||||
private slots:
|
private slots:
|
||||||
void on_treeProject_doubleClicked(const QModelIndex &index);
|
void on_treeProject_doubleClicked(const QModelIndex &index);
|
||||||
void on_spinPriority_valueChanged(int arg1);
|
void on_spinPriority_valueChanged(int arg1);
|
||||||
|
|
Loading…
Reference in New Issue