fix: can't correctly generate project resource file for compile
add: project compiler set option dialog
This commit is contained in:
parent
e0e09155d7
commit
b8533e3ced
|
@ -520,19 +520,19 @@ bool Project::saveUnits()
|
|||
case FileType::CSource:
|
||||
case FileType::CppHeader:
|
||||
case FileType::CppSource:
|
||||
ini.SetBoolValue(groupName,"CompileCpp", unit->compileCpp());
|
||||
ini.SetLongValue(groupName,"CompileCpp", unit->compileCpp());
|
||||
break;
|
||||
case FileType::WindowsResourceSource:
|
||||
unit->setFolder("Resources");
|
||||
}
|
||||
|
||||
ini.SetValue(groupName,"Folder", toByteArray(unit->folder()));
|
||||
ini.SetBoolValue(groupName,"Compile", unit->compile());
|
||||
ini.SetBoolValue(groupName,"Link", unit->link());
|
||||
ini.SetLongValue(groupName,"Compile", unit->compile());
|
||||
ini.SetLongValue(groupName,"Link", unit->link());
|
||||
ini.SetLongValue(groupName,"Priority", unit->priority());
|
||||
ini.SetBoolValue(groupName,"OverrideBuildCmd", unit->overrideBuildCmd());
|
||||
ini.SetLongValue(groupName,"OverrideBuildCmd", unit->overrideBuildCmd());
|
||||
ini.SetValue(groupName,"BuildCmd", toByteArray(unit->buildCmd()));
|
||||
ini.SetBoolValue(groupName,"DetectEncoding", unit->encoding()==ENCODING_AUTO_DETECT);
|
||||
ini.SetLongValue(groupName,"DetectEncoding", unit->encoding()==ENCODING_AUTO_DETECT);
|
||||
ini.SetValue(groupName,"FileEncoding", toByteArray(unit->encoding()));
|
||||
}
|
||||
ini.SetLongValue("Project","UnitCount",count);
|
||||
|
@ -589,30 +589,30 @@ void Project::saveOptions()
|
|||
ini.SetValue("Project","Compiler", toByteArray(mOptions.compilerCmd));
|
||||
ini.SetValue("Project","CppCompiler", toByteArray(mOptions.cppCompilerCmd));
|
||||
ini.SetValue("Project","Linker", toByteArray(mOptions.linkerCmd));
|
||||
ini.SetBoolValue("Project","IsCpp", mOptions.useGPP);
|
||||
ini.SetLongValue("Project","IsCpp", mOptions.useGPP);
|
||||
ini.SetValue("Project","Icon", toByteArray(extractRelativePath(directory(), mOptions.icon)));
|
||||
ini.SetValue("Project","ExeOutput", toByteArray(mOptions.exeOutput));
|
||||
ini.SetValue("Project","ObjectOutput", toByteArray(mOptions.objectOutput));
|
||||
ini.SetValue("Project","LogOutput", toByteArray(mOptions.logOutput));
|
||||
ini.SetBoolValue("Project","LogOutputEnabled", mOptions.logOutputEnabled);
|
||||
ini.SetBoolValue("Project","OverrideOutput", mOptions.overrideOutput);
|
||||
ini.SetLongValue("Project","LogOutputEnabled", mOptions.logOutputEnabled);
|
||||
ini.SetLongValue("Project","OverrideOutput", mOptions.overrideOutput);
|
||||
ini.SetValue("Project","OverrideOutputName", toByteArray(mOptions.overridenOutput));
|
||||
ini.SetValue("Project","HostApplication", toByteArray(mOptions.hostApplication));
|
||||
ini.SetBoolValue("Project","UseCustomMakefile", mOptions.useCustomMakefile);
|
||||
ini.SetLongValue("Project","UseCustomMakefile", mOptions.useCustomMakefile);
|
||||
ini.SetValue("Project","CustomMakefile", toByteArray(mOptions.customMakefile));
|
||||
ini.SetBoolValue("Project","UsePrecompiledHeader", mOptions.usePrecompiledHeader);
|
||||
ini.SetLongValue("Project","UsePrecompiledHeader", mOptions.usePrecompiledHeader);
|
||||
ini.SetValue("Project","PrecompiledHeader", toByteArray(mOptions.precompiledHeader));
|
||||
ini.SetValue("Project","CommandLine", toByteArray(mOptions.cmdLineArgs));
|
||||
ini.SetValue("Project","Folders", toByteArray(mFolders.join(";")));
|
||||
ini.SetBoolValue("Project","IncludeVersionInfo", mOptions.includeVersionInfo);
|
||||
ini.SetBoolValue("Project","SupportXPThemes", mOptions.supportXPThemes);
|
||||
ini.SetLongValue("Project","IncludeVersionInfo", mOptions.includeVersionInfo);
|
||||
ini.SetLongValue("Project","SupportXPThemes", mOptions.supportXPThemes);
|
||||
ini.SetLongValue("Project","CompilerSet", mOptions.compilerSet);
|
||||
ini.SetValue("Project","CompilerSettings", mOptions.compilerOptions);
|
||||
ini.SetBoolValue("Project","StaticLink", mOptions.staticLink);
|
||||
ini.SetBoolValue("Project","AddCharset", mOptions.addCharset);
|
||||
ini.SetLongValue("Project","StaticLink", mOptions.staticLink);
|
||||
ini.SetLongValue("Project","AddCharset", mOptions.addCharset);
|
||||
ini.SetValue("Project","Encoding",toByteArray(mOptions.encoding));
|
||||
//for Red Panda Dev C++ 6 compatibility
|
||||
ini.SetBoolValue("Project","UseUTF8",mOptions.encoding == ENCODING_UTF8);
|
||||
ini.SetLongValue("Project","UseUTF8",mOptions.encoding == ENCODING_UTF8);
|
||||
|
||||
ini.SetLongValue("VersionInfo","Major", mOptions.versionInfo.major);
|
||||
ini.SetLongValue("VersionInfo","Minor", mOptions.versionInfo.minor);
|
||||
|
@ -629,8 +629,8 @@ void Project::saveOptions()
|
|||
ini.SetValue("VersionInfo","OriginalFilename", toByteArray(mOptions.versionInfo.originalFilename));
|
||||
ini.SetValue("VersionInfo","ProductName", toByteArray(mOptions.versionInfo.productName));
|
||||
ini.SetValue("VersionInfo","ProductVersion", toByteArray(mOptions.versionInfo.productVersion));
|
||||
ini.SetBoolValue("VersionInfo","AutoIncBuildNr", mOptions.versionInfo.autoIncBuildNr);
|
||||
ini.SetBoolValue("VersionInfo","SyncProduct", mOptions.versionInfo.syncProduct);
|
||||
ini.SetLongValue("VersionInfo","AutoIncBuildNr", mOptions.versionInfo.autoIncBuildNr);
|
||||
ini.SetLongValue("VersionInfo","SyncProduct", mOptions.versionInfo.syncProduct);
|
||||
|
||||
|
||||
//delete outdated dev4 project options
|
||||
|
@ -749,10 +749,20 @@ void Project::buildPrivateResource(bool forceSave)
|
|||
QString rcFile;
|
||||
if (!mOptions.privateResource.isEmpty()) {
|
||||
rcFile = QDir(directory()).filePath(mOptions.privateResource);
|
||||
if (changeFileExt(rcFile, DEV_PROJECT_EXT) == mFilename)
|
||||
rcFile = changeFileExt(mFilename,QString("_private") + RC_EXT);
|
||||
} else
|
||||
rcFile = changeFileExt(mFilename,QString("_private") + RC_EXT);
|
||||
if (changeFileExt(rcFile, DEV_PROJECT_EXT) == mFilename) {
|
||||
QFileInfo fileInfo(mFilename);
|
||||
rcFile = includeTrailingPathDelimiter(fileInfo.absolutePath())
|
||||
+ fileInfo.baseName()
|
||||
+ "_private."
|
||||
+ RC_EXT;
|
||||
}
|
||||
} else {
|
||||
QFileInfo fileInfo(mFilename);
|
||||
rcFile = includeTrailingPathDelimiter(fileInfo.absolutePath())
|
||||
+ fileInfo.baseName()
|
||||
+ "_private."
|
||||
+ RC_EXT;
|
||||
}
|
||||
rcFile = extractRelativePath(mFilename, rcFile);
|
||||
rcFile.replace(' ','_');
|
||||
|
||||
|
@ -953,15 +963,15 @@ void Project::buildPrivateResource(bool forceSave)
|
|||
contents.append("");
|
||||
contents.append("/* VERSION DEFINITIONS */");
|
||||
contents.append("#define VER_STRING\t" +
|
||||
QString("\"%d.%d.%d.%d\"")
|
||||
QString("\"%1.%2.%3.%4\"")
|
||||
.arg(mOptions.versionInfo.major)
|
||||
.arg(mOptions.versionInfo.minor)
|
||||
.arg(mOptions.versionInfo.release)
|
||||
.arg(mOptions.versionInfo.build));
|
||||
contents.append(QString("#define VER_MAJOR\t%1").arg(mOptions.versionInfo.major));
|
||||
contents.append(QString("#define VER_MINOR\t%1").arg(mOptions.versionInfo.minor));
|
||||
contents.append(QString("#define VER_RELEASE\t").arg(mOptions.versionInfo.release));
|
||||
contents.append(QString("#define VER_BUILD\t").arg(mOptions.versionInfo.build));
|
||||
contents.append(QString("#define VER_RELEASE\t%1").arg(mOptions.versionInfo.release));
|
||||
contents.append(QString("#define VER_BUILD\t%1").arg(mOptions.versionInfo.build));
|
||||
contents.append(QString("#define COMPANY_NAME\t\"%1\"")
|
||||
.arg(mOptions.versionInfo.companyName));
|
||||
contents.append(QString("#define FILE_VERSION\t\"%1\"")
|
||||
|
@ -1000,7 +1010,7 @@ void Project::checkProjectFileForUpdate(SimpleIni &ini)
|
|||
QByteArray groupName = toByteArray(QString("Unit%1").arg(uCount+i));
|
||||
ini.SetValue(groupName,"Filename", toByteArray(s));
|
||||
ini.SetValue(groupName,"Folder", "Resources");
|
||||
ini.SetBoolValue(groupName,"Compile",true);
|
||||
ini.SetLongValue(groupName,"Compile",true);
|
||||
}
|
||||
ini.SetLongValue("Project","UnitCount",uCount+sl.count());
|
||||
QString folders = QString::fromLocal8Bit(ini.GetValue("Project","Folders",""));
|
||||
|
|
|
@ -1587,6 +1587,11 @@ int Settings::CompilerSet::charToValue(char valueChar)
|
|||
}
|
||||
}
|
||||
|
||||
char Settings::CompilerSet::valueToChar(int val)
|
||||
{
|
||||
return ValueToChar[val];
|
||||
}
|
||||
|
||||
static void addExistingDirectory(QStringList& dirs, const QString& directory) {
|
||||
if (!directoryExists(directory))
|
||||
return;
|
||||
|
|
|
@ -873,6 +873,7 @@ public:
|
|||
|
||||
|
||||
static int charToValue(char valueChar);
|
||||
static char valueToChar(int val);
|
||||
private:
|
||||
// Initialization
|
||||
void setExecutables();
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
#include "projectcompilerwidget.h"
|
||||
#include "ui_projectcompilerwidget.h"
|
||||
#include "../settings.h"
|
||||
#include "../project.h"
|
||||
#include "../mainwindow.h"
|
||||
|
||||
ProjectCompilerWidget::ProjectCompilerWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ProjectCompilerWidget::ProjectCompilerWidget(const QString &name, const QString &group, QWidget *parent) :
|
||||
SettingsWidget(name,group,parent),
|
||||
ui(new Ui::ProjectCompilerWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
@ -12,3 +15,113 @@ ProjectCompilerWidget::~ProjectCompilerWidget()
|
|||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ProjectCompilerWidget::refreshOptions()
|
||||
{
|
||||
Settings::PCompilerSet pSet = pSettings->compilerSets().defaultSet();
|
||||
if (!pSet)
|
||||
return;
|
||||
QTabWidget* pTab = ui->tabOptions;
|
||||
while (pTab->count()>0) {
|
||||
QWidget* p=pTab->widget(0);
|
||||
if (p!=nullptr) {
|
||||
pTab->removeTab(0);
|
||||
p->setParent(nullptr);
|
||||
delete p;
|
||||
}
|
||||
}
|
||||
|
||||
for (int index=0; index< pSet->options().count();index++){
|
||||
PCompilerOption pOption =pSet->options()[index];
|
||||
QWidget* pWidget = nullptr;
|
||||
for (int i=0;i<pTab->count();i++) {
|
||||
if (pOption->section == pTab->tabText(i)) {
|
||||
pWidget = pTab->widget(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pWidget == nullptr) {
|
||||
pWidget = new QWidget();
|
||||
pTab->addTab(pWidget,pOption->section);
|
||||
pWidget->setLayout(new QGridLayout());
|
||||
}
|
||||
QGridLayout *pLayout = static_cast<QGridLayout*>(pWidget->layout());
|
||||
int row = pLayout->rowCount();
|
||||
pLayout->addWidget(new QLabel(pOption->name),row,0);
|
||||
QComboBox* pCombo = new QComboBox();
|
||||
if (pOption->choices.count()>0) {
|
||||
for (int i=0;i<pOption->choices.count();i++) {
|
||||
QString choice = pOption->choices[i];
|
||||
QStringList valueName=choice.split("=");
|
||||
if (valueName.length()<2) {
|
||||
pCombo->addItem("");
|
||||
} else {
|
||||
pCombo->addItem(valueName[0]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pCombo->addItem(QObject::tr("No"));
|
||||
pCombo->addItem(QObject::tr("Yes"));
|
||||
}
|
||||
int value;
|
||||
if (index<mOptions.length()) {
|
||||
value = pSet->charToValue(mOptions[index]);
|
||||
} else {
|
||||
value = pOption->value;
|
||||
}
|
||||
pCombo->setCurrentIndex(value);
|
||||
pLayout->addWidget(pCombo,row,1);
|
||||
}
|
||||
for (int i=0;i<pTab->count();i++) {
|
||||
QWidget* pWidget = pTab->widget(i);
|
||||
QGridLayout *pLayout = static_cast<QGridLayout*>(pWidget->layout());
|
||||
int row = pLayout->rowCount();
|
||||
QSpacerItem* horizontalSpacer = new QSpacerItem(10, 100, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
pLayout->addItem(horizontalSpacer,row,0);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectCompilerWidget::doLoad()
|
||||
{
|
||||
mOptions = pMainWindow->project()->options().compilerOptions;
|
||||
ui->cbCompilerSet->setCurrentIndex(pMainWindow->project()->options().compilerSet);
|
||||
}
|
||||
|
||||
void ProjectCompilerWidget::doSave()
|
||||
{
|
||||
Settings::PCompilerSet pSet = pSettings->compilerSets().defaultSet();
|
||||
if (!pSet)
|
||||
return;
|
||||
//read values in the options widget
|
||||
QTabWidget* pTab = ui->tabOptions;
|
||||
for (int i=0;i<pTab->count();i++) {
|
||||
QString section = pTab->tabText(i);
|
||||
QWidget* pWidget = pTab->widget(i);
|
||||
QGridLayout* pLayout = static_cast<QGridLayout*>(pWidget->layout());
|
||||
if (pLayout != nullptr) {
|
||||
for (int j=1;j<pLayout->rowCount()-1;j++) {
|
||||
QString name = static_cast<QLabel *>(pLayout->itemAtPosition(j,0)->widget())->text();
|
||||
QComboBox* pCombo = static_cast<QComboBox *>(pLayout->itemAtPosition(j,1)->widget());
|
||||
mOptions.clear();
|
||||
for (int index=0;index<pSet->options().count();index++) {
|
||||
PCompilerOption pOption = pSet->options()[index];
|
||||
if (pOption->section == section && pOption->name == name) {
|
||||
char val = pSet->valueToChar( pCombo->currentIndex());
|
||||
mOptions.append(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pMainWindow->project()->options().compilerSet = ui->cbCompilerSet->currentIndex();
|
||||
pMainWindow->project()->options().compilerOptions = mOptions;
|
||||
}
|
||||
|
||||
void ProjectCompilerWidget::init()
|
||||
{
|
||||
SettingsWidget::init();
|
||||
ui->cbCompilerSet->clear();
|
||||
for (const Settings::PCompilerSet& set:pSettings->compilerSets().list()){
|
||||
ui->cbCompilerSet->addItem(set->name());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,21 +2,33 @@
|
|||
#define PROJECTCOMPILERWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "settingswidget.h"
|
||||
|
||||
namespace Ui {
|
||||
class ProjectCompilerWidget;
|
||||
}
|
||||
|
||||
class ProjectCompilerWidget : public QWidget
|
||||
class ProjectCompilerWidget : public SettingsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ProjectCompilerWidget(QWidget *parent = nullptr);
|
||||
explicit ProjectCompilerWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
|
||||
~ProjectCompilerWidget();
|
||||
|
||||
private:
|
||||
void refreshOptions();
|
||||
private:
|
||||
Ui::ProjectCompilerWidget *ui;
|
||||
QByteArray mOptions;
|
||||
|
||||
// SettingsWidget interface
|
||||
protected:
|
||||
void doLoad() override;
|
||||
void doSave() override;
|
||||
|
||||
// SettingsWidget interface
|
||||
public:
|
||||
void init() override;
|
||||
};
|
||||
|
||||
#endif // PROJECTCOMPILERWIDGET_H
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
<widget class="QWidget" name="widget" native="true"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<widget class="QTabWidget" name="tabOptions">
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Tab 1</string>
|
||||
|
|
|
@ -24,9 +24,6 @@ void ProjectFilesWidget::doLoad()
|
|||
ui->treeProject->setModel(project->model());
|
||||
ui->treeProject->expandAll();
|
||||
ui->grpFileOptions->setEnabled(false);
|
||||
ui->spinPriority->setMinimum(0);
|
||||
ui->spinPriority->setMaximum(9999);
|
||||
ui->cbEncoding->addItems(pSystemConsts->codecNames());
|
||||
}
|
||||
|
||||
void ProjectFilesWidget::doSave()
|
||||
|
@ -182,3 +179,12 @@ void ProjectFilesWidget::on_treeProject_clicked(const QModelIndex &index)
|
|||
on_treeProject_doubleClicked(index);
|
||||
}
|
||||
|
||||
void ProjectFilesWidget::init()
|
||||
{
|
||||
SettingsWidget::init();
|
||||
ui->spinPriority->setMinimum(0);
|
||||
ui->spinPriority->setMaximum(9999);
|
||||
ui->cbEncoding->clear();
|
||||
ui->cbEncoding->addItems(pSystemConsts->codecNames());
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,10 @@ private slots:
|
|||
void on_txtBuildCommand_textChanged();
|
||||
void on_cbEncoding_currentTextChanged(const QString &arg1);
|
||||
void on_treeProject_clicked(const QModelIndex &index);
|
||||
|
||||
// SettingsWidget interface
|
||||
public:
|
||||
void init() override;
|
||||
};
|
||||
|
||||
#endif // PROJECTFILESWIDGET_H
|
||||
|
|
|
@ -59,7 +59,6 @@ void ProjectGeneralWidget::doLoad()
|
|||
.arg(totalCount).arg(srcCount).arg(headerCount)
|
||||
.arg(resCount).arg(otherCount));
|
||||
|
||||
ui->cbDefaultEncoding->addItems(pSystemConsts->codecNames());
|
||||
ui->cbDefaultEncoding->setCurrentText(project->options().encoding);
|
||||
|
||||
ui->lstType->setCurrentRow( static_cast<int>(project->options().type));
|
||||
|
@ -121,3 +120,10 @@ void ProjectGeneralWidget::on_btnRemove_clicked()
|
|||
ui->btnRemove->setEnabled(!mIconPath.isEmpty());
|
||||
}
|
||||
|
||||
void ProjectGeneralWidget::init()
|
||||
{
|
||||
SettingsWidget::init();
|
||||
ui->cbDefaultEncoding->clear();
|
||||
ui->cbDefaultEncoding->addItems(pSystemConsts->codecNames());
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,10 @@ protected:
|
|||
private slots:
|
||||
void on_btnBrowse_clicked();
|
||||
void on_btnRemove_clicked();
|
||||
|
||||
// SettingsWidget interface
|
||||
public:
|
||||
void init() override;
|
||||
};
|
||||
|
||||
#endif // PROJECTGENERALWIDGET_H
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "formattergeneralwidget.h"
|
||||
#include "projectgeneralwidget.h"
|
||||
#include "projectfileswidget.h"
|
||||
#include "projectcompilerwidget.h"
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <QModelIndex>
|
||||
|
@ -158,6 +159,10 @@ PSettingsDialog SettingsDialog::projectOptionDialog()
|
|||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
widget = new ProjectCompilerWidget(tr("Compiler Set"),tr("Project"));
|
||||
widget->init();
|
||||
dialog->addWidget(widget);
|
||||
|
||||
dialog->selectFirstWidget();
|
||||
|
||||
return dialog;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#define DEV_PROJECT_EXT "dev"
|
||||
#define RC_EXT "rc"
|
||||
#define RES_EXT "rc"
|
||||
#define RES_EXT "res"
|
||||
#define H_EXT "h"
|
||||
#define OBJ_EXT "o"
|
||||
#define DEF_EXT "def"
|
||||
|
|
|
@ -193,7 +193,7 @@ FileType getFileType(const QString &filename)
|
|||
if (filename.endsWith(".inl",PATH_SENSITIVITY)) {
|
||||
return FileType::CppHeader;
|
||||
}
|
||||
if (filename.endsWith(".res",PATH_SENSITIVITY)) {
|
||||
if (filename.endsWith(".rc",PATH_SENSITIVITY)) {
|
||||
return FileType::WindowsResourceSource;
|
||||
}
|
||||
return FileType::Other;
|
||||
|
@ -461,10 +461,14 @@ QString changeFileExt(const QString& filename, const QString& ext)
|
|||
QFileInfo fileInfo(filename);
|
||||
QString suffix = fileInfo.suffix();
|
||||
QString name = fileInfo.fileName();
|
||||
QString path;
|
||||
if (fileInfo.path() != ".") {
|
||||
path = includeTrailingPathDelimiter(fileInfo.path());
|
||||
}
|
||||
if (suffix.isEmpty()) {
|
||||
return filename+"."+ext;
|
||||
return path+filename+"."+ext;
|
||||
} else {
|
||||
return fileInfo.completeBaseName()+"."+ext;
|
||||
return path+fileInfo.completeBaseName()+"."+ext;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue