* settings dialog can correctly disable/enable apply button
This commit is contained in:
parent
fb2ed9b84e
commit
55326a3659
|
@ -68,7 +68,13 @@ int main(int argc, char *argv[])
|
||||||
auto settings = std::unique_ptr<Settings>(pSettings);
|
auto settings = std::unique_ptr<Settings>(pSettings);
|
||||||
|
|
||||||
//settings->compilerSets().addSets("e:/workspace/contributes/Dev-CPP/MinGW32_GCC92");
|
//settings->compilerSets().addSets("e:/workspace/contributes/Dev-CPP/MinGW32_GCC92");
|
||||||
|
// settings->compilerSets().findSets();
|
||||||
|
// settings->compilerSets().saveSets();
|
||||||
settings->compilerSets().loadSets();
|
settings->compilerSets().loadSets();
|
||||||
|
// qDebug() << settings->compilerSets().defaultSet()->binDirs();
|
||||||
|
// settings->compilerSets().loadSets();
|
||||||
|
// qDebug() << settings->compilerSets().defaultSet()->defines();
|
||||||
|
// qDebug() << settings->compilerSets().defaultSet()->CCompiler();
|
||||||
// qDebug()<<settings->compilerSets().size();
|
// qDebug()<<settings->compilerSets().size();
|
||||||
// qDebug()<<settings->compilerSets().list().at(0)->binDirs();
|
// qDebug()<<settings->compilerSets().list().at(0)->binDirs();
|
||||||
MainWindow mainWindow;
|
MainWindow mainWindow;
|
||||||
|
@ -76,6 +82,6 @@ int main(int argc, char *argv[])
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
int retCode = app.exec();
|
int retCode = app.exec();
|
||||||
// save settings
|
// save settings
|
||||||
settings->compilerSets().saveSets();
|
// settings->compilerSets().saveSets();
|
||||||
return retCode;
|
return retCode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include "systemconsts.h"
|
#include "systemconsts.h"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
const char ValueToChar[28] = {'0', '1', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
|
const char ValueToChar[28] = {'0', '1', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
|
||||||
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
|
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
|
||||||
|
@ -43,6 +44,11 @@ void Settings::setValue(const QString& group, const QString &key, const QVariant
|
||||||
mSettings.setValue(key,value);
|
mSettings.setValue(key,value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::setValue(const QString &key, const QVariant &value)
|
||||||
|
{
|
||||||
|
mSettings.setValue(key,value);
|
||||||
|
}
|
||||||
|
|
||||||
QVariant Settings::value(const QString& group, const QString &key) {
|
QVariant Settings::value(const QString& group, const QString &key) {
|
||||||
mSettings.beginGroup(group);
|
mSettings.beginGroup(group);
|
||||||
auto act = finally([this] {
|
auto act = finally([this] {
|
||||||
|
@ -51,6 +57,11 @@ QVariant Settings::value(const QString& group, const QString &key) {
|
||||||
return mSettings.value(key);
|
return mSettings.value(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant Settings::value(const QString &key)
|
||||||
|
{
|
||||||
|
return mSettings.value(key);
|
||||||
|
}
|
||||||
|
|
||||||
Settings::Dirs &Settings::dirs()
|
Settings::Dirs &Settings::dirs()
|
||||||
{
|
{
|
||||||
return mDirs;
|
return mDirs;
|
||||||
|
@ -71,9 +82,9 @@ Settings::Dirs::Dirs(Settings *settings):
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString Settings::Dirs::app() const
|
QString Settings::Dirs::app() const
|
||||||
{
|
{
|
||||||
QApplication::instance()->applicationDirPath();
|
return QApplication::instance()->applicationDirPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::_Base::_Base(Settings *settings, const QString &groupName):
|
Settings::_Base::_Base(Settings *settings, const QString &groupName):
|
||||||
|
@ -132,23 +143,25 @@ Settings::CompilerSet::CompilerSet(const QString& compilerFolder):
|
||||||
if (!compilerFolder.isEmpty()) {
|
if (!compilerFolder.isEmpty()) {
|
||||||
setProperties(compilerFolder+"/bin");
|
setProperties(compilerFolder+"/bin");
|
||||||
|
|
||||||
|
//manually set the directories
|
||||||
|
setDirectories(compilerFolder);
|
||||||
|
|
||||||
setExecutables();
|
setExecutables();
|
||||||
|
|
||||||
//manually set the directories
|
|
||||||
setDirectories();
|
|
||||||
|
|
||||||
setUserInput();
|
setUserInput();
|
||||||
|
|
||||||
|
setDefines();
|
||||||
}
|
}
|
||||||
setOptions();
|
setOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::CompilerSet::CompilerSet(const Settings::CompilerSet &set):
|
Settings::CompilerSet::CompilerSet(const Settings::CompilerSet &set):
|
||||||
mCCompilerName(set.mCCompilerName),
|
mCCompiler(set.mCCompiler),
|
||||||
mCppCompilerName(set.mCppCompilerName),
|
mCppCompiler(set.mCppCompiler),
|
||||||
mMakeName(set.mMakeName),
|
mMake(set.mMake),
|
||||||
mDebuggerName(set.mDebuggerName),
|
mDebugger(set.mDebugger),
|
||||||
mProfilerName(set.mProfilerName),
|
mProfiler(set.mProfiler),
|
||||||
mResourceCompilerName(set.mResourceCompilerName),
|
mResourceCompiler(set.mResourceCompiler),
|
||||||
mBinDirs(set.mBinDirs),
|
mBinDirs(set.mBinDirs),
|
||||||
mCIncludeDirs(set.mCIncludeDirs),
|
mCIncludeDirs(set.mCIncludeDirs),
|
||||||
mCppIncludeDirs(set.mCppIncludeDirs),
|
mCppIncludeDirs(set.mCppIncludeDirs),
|
||||||
|
@ -157,7 +170,6 @@ Settings::CompilerSet::CompilerSet(const Settings::CompilerSet &set):
|
||||||
mVersion(set.mVersion),
|
mVersion(set.mVersion),
|
||||||
mType(set.mType),
|
mType(set.mType),
|
||||||
mName(set.mName),
|
mName(set.mName),
|
||||||
mFolder(set.mFolder),
|
|
||||||
mDefines(set.mDefines),
|
mDefines(set.mDefines),
|
||||||
mTarget(set.mTarget),
|
mTarget(set.mTarget),
|
||||||
mUseCustomCompileParams(set.mUseCustomCompileParams),
|
mUseCustomCompileParams(set.mUseCustomCompileParams),
|
||||||
|
@ -228,64 +240,64 @@ bool Settings::CompilerSet::dirsValid(QString &msg)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &Settings::CompilerSet::CCompilerName() const
|
const QString &Settings::CompilerSet::CCompiler() const
|
||||||
{
|
{
|
||||||
return mCCompilerName;
|
return mCCompiler;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::CompilerSet::setCCompilerName(const QString &name)
|
void Settings::CompilerSet::setCCompiler(const QString &name)
|
||||||
{
|
{
|
||||||
mCCompilerName = name;
|
mCCompiler = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &Settings::CompilerSet::cppCompilerName() const
|
const QString &Settings::CompilerSet::cppCompiler() const
|
||||||
{
|
{
|
||||||
return mCppCompilerName;
|
return mCppCompiler;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::CompilerSet::setCppCompilerName(const QString &name)
|
void Settings::CompilerSet::setCppCompiler(const QString &name)
|
||||||
{
|
{
|
||||||
mCppCompilerName = name;
|
mCppCompiler = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &Settings::CompilerSet::makeName() const
|
const QString &Settings::CompilerSet::make() const
|
||||||
{
|
{
|
||||||
return mMakeName;
|
return mMake;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::CompilerSet::setMakeName(const QString &name)
|
void Settings::CompilerSet::setMake(const QString &name)
|
||||||
{
|
{
|
||||||
mMakeName = name;
|
mMake = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &Settings::CompilerSet::debuggerName() const
|
const QString &Settings::CompilerSet::debugger() const
|
||||||
{
|
{
|
||||||
return mDebuggerName;
|
return mDebugger;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::CompilerSet::setDebuggerName(const QString &name)
|
void Settings::CompilerSet::setDebugger(const QString &name)
|
||||||
{
|
{
|
||||||
mDebuggerName = name;
|
mDebugger = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &Settings::CompilerSet::profilerName() const
|
const QString &Settings::CompilerSet::profiler() const
|
||||||
{
|
{
|
||||||
return mProfilerName;
|
return mProfiler;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::CompilerSet::setProfilerName(const QString &name)
|
void Settings::CompilerSet::setProfiler(const QString &name)
|
||||||
{
|
{
|
||||||
mProfilerName = name;
|
mProfiler = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &Settings::CompilerSet::resourceCompilerName() const
|
const QString &Settings::CompilerSet::resourceCompiler() const
|
||||||
{
|
{
|
||||||
return mResourceCompilerName;
|
return mResourceCompiler;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::CompilerSet::setResourceCompilerName(const QString &name)
|
void Settings::CompilerSet::setResourceCompiler(const QString &name)
|
||||||
{
|
{
|
||||||
mResourceCompilerName = name;
|
mResourceCompiler = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList &Settings::CompilerSet::binDirs()
|
QStringList &Settings::CompilerSet::binDirs()
|
||||||
|
@ -348,16 +360,6 @@ void Settings::CompilerSet::setName(const QString &value)
|
||||||
mName = value;
|
mName = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &Settings::CompilerSet::folder()
|
|
||||||
{
|
|
||||||
return mFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Settings::CompilerSet::setFolder(const QString &value)
|
|
||||||
{
|
|
||||||
mFolder = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList& Settings::CompilerSet::defines()
|
QStringList& Settings::CompilerSet::defines()
|
||||||
{
|
{
|
||||||
return mDefines;
|
return mDefines;
|
||||||
|
@ -490,7 +492,6 @@ void Settings::CompilerSet::setProperties(const QString &binDir)
|
||||||
delimPos2++;
|
delimPos2++;
|
||||||
mVersion = output.mid(delimPos1,delimPos2-delimPos1);
|
mVersion = output.mid(delimPos1,delimPos2-delimPos1);
|
||||||
|
|
||||||
|
|
||||||
// Find compiler builder
|
// Find compiler builder
|
||||||
delimPos1 = delimPos2;
|
delimPos1 = delimPos2;
|
||||||
while ((delimPos1 < output.length()) && !(output[delimPos1] == '('))
|
while ((delimPos1 < output.length()) && !(output[delimPos1] == '('))
|
||||||
|
@ -517,7 +518,7 @@ void Settings::CompilerSet::setProperties(const QString &binDir)
|
||||||
// Set compiler folder
|
// Set compiler folder
|
||||||
QDir tmpDir(binDir);
|
QDir tmpDir(binDir);
|
||||||
tmpDir.cdUp();
|
tmpDir.cdUp();
|
||||||
mFolder = tmpDir.path();
|
QString folder = tmpDir.path();
|
||||||
|
|
||||||
// Obtain compiler target
|
// Obtain compiler target
|
||||||
arguments.clear();
|
arguments.clear();
|
||||||
|
@ -525,10 +526,10 @@ void Settings::CompilerSet::setProperties(const QString &binDir)
|
||||||
mDumpMachine = getCompilerOutput(binDir, GCC_PROGRAM, arguments);
|
mDumpMachine = getCompilerOutput(binDir, GCC_PROGRAM, arguments);
|
||||||
|
|
||||||
// Add the default directories
|
// Add the default directories
|
||||||
addExistingDirectory(mBinDirs, mFolder + QDir::separator() + "bin");
|
addExistingDirectory(mBinDirs, folder + QDir::separator() + "bin");
|
||||||
addExistingDirectory(mLibDirs, mFolder + QDir::separator() + "lib");
|
addExistingDirectory(mLibDirs, folder + QDir::separator() + "lib");
|
||||||
addExistingDirectory(mCIncludeDirs, mFolder + QDir::separator() + "include");
|
addExistingDirectory(mCIncludeDirs, folder + QDir::separator() + "include");
|
||||||
addExistingDirectory(mCppIncludeDirs, mFolder + QDir::separator() + "include");
|
addExistingDirectory(mCppIncludeDirs, folder + QDir::separator() + "include");
|
||||||
|
|
||||||
// Find default directories
|
// Find default directories
|
||||||
arguments.clear();
|
arguments.clear();
|
||||||
|
@ -602,15 +603,19 @@ void Settings::CompilerSet::setProperties(const QString &binDir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::CompilerSet::setDefines() {
|
||||||
// get default defines
|
// get default defines
|
||||||
arguments.clear();
|
QStringList arguments;
|
||||||
arguments.append("-dM");
|
arguments.append("-dM");
|
||||||
arguments.append("-E");
|
arguments.append("-E");
|
||||||
arguments.append("-x");
|
arguments.append("-x");
|
||||||
arguments.append("c++");
|
arguments.append("c++");
|
||||||
arguments.append("-std=c++17");
|
arguments.append("-std=c++17");
|
||||||
arguments.append(NULL_FILE);
|
arguments.append(NULL_FILE);
|
||||||
output = getCompilerOutput(binDir,GCC_PROGRAM,arguments);
|
QFileInfo ccompiler(mCCompiler);
|
||||||
|
QByteArray output = getCompilerOutput(ccompiler.absolutePath(),ccompiler.baseName(),arguments);
|
||||||
// 'cpp.exe -dM -E -x c++ -std=c++17 NUL'
|
// 'cpp.exe -dM -E -x c++ -std=c++17 NUL'
|
||||||
|
|
||||||
mDefines.clear();
|
mDefines.clear();
|
||||||
|
@ -625,72 +630,72 @@ void Settings::CompilerSet::setProperties(const QString &binDir)
|
||||||
|
|
||||||
void Settings::CompilerSet::setExecutables()
|
void Settings::CompilerSet::setExecutables()
|
||||||
{
|
{
|
||||||
mCCompilerName = GCC_PROGRAM;
|
mCCompiler = findProgramInBinDirs(GCC_PROGRAM);
|
||||||
mCppCompilerName = GPP_PROGRAM;
|
mCppCompiler = findProgramInBinDirs(GPP_PROGRAM);
|
||||||
mDebuggerName = GDB_PROGRAM;
|
mDebugger = findProgramInBinDirs(GDB_PROGRAM);
|
||||||
mMakeName = MAKE_PROGRAM;
|
mMake = findProgramInBinDirs(MAKE_PROGRAM);
|
||||||
mResourceCompilerName = WINDRES_PROGRAM;
|
mResourceCompiler = findProgramInBinDirs(WINDRES_PROGRAM);
|
||||||
mProfilerName = GPROF_PROGRAM;
|
mProfiler = findProgramInBinDirs(GPROF_PROGRAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::CompilerSet::setDirectories()
|
void Settings::CompilerSet::setDirectories(const QString& folder)
|
||||||
{
|
{
|
||||||
// Try to obtain our target/autoconf folder
|
// Try to obtain our target/autoconf folder
|
||||||
if (!mDumpMachine.isEmpty()) {
|
if (!mDumpMachine.isEmpty()) {
|
||||||
//mingw-w64 bin folder
|
//mingw-w64 bin folder
|
||||||
addExistingDirectory(mBinDirs,
|
addExistingDirectory(mBinDirs,
|
||||||
mFolder + QDir::separator() + "lib"
|
folder + QDir::separator() + "lib"
|
||||||
+ QDir::separator() + "gcc" + mDumpMachine
|
+ QDir::separator() + "gcc" + mDumpMachine
|
||||||
+ QDir::separator() + mVersion);
|
+ QDir::separator() + mVersion);
|
||||||
|
|
||||||
// Regular include folder
|
// Regular include folder
|
||||||
addExistingDirectory(mCIncludeDirs, mFolder + QDir::separator() + mDumpMachine + QDir::separator() + "include");
|
addExistingDirectory(mCIncludeDirs, folder + QDir::separator() + mDumpMachine + QDir::separator() + "include");
|
||||||
addExistingDirectory(mCppIncludeDirs, mFolder + QDir::separator()+ mDumpMachine + QDir::separator() + "include");
|
addExistingDirectory(mCppIncludeDirs, folder + QDir::separator()+ mDumpMachine + QDir::separator() + "include");
|
||||||
|
|
||||||
// Other include folder?
|
// Other include folder?
|
||||||
addExistingDirectory(mCIncludeDirs,
|
addExistingDirectory(mCIncludeDirs,
|
||||||
mFolder + QDir::separator() + "lib" + QDir::separator() + "gcc"
|
folder + QDir::separator() + "lib" + QDir::separator() + "gcc"
|
||||||
+ QDir::separator() + mDumpMachine + QDir::separator()
|
+ QDir::separator() + mDumpMachine + QDir::separator()
|
||||||
+ mVersion + QDir::separator() + "include");
|
+ mVersion + QDir::separator() + "include");
|
||||||
addExistingDirectory(mCppIncludeDirs,
|
addExistingDirectory(mCppIncludeDirs,
|
||||||
mFolder + QDir::separator() + "lib" + QDir::separator() + "gcc"
|
folder + QDir::separator() + "lib" + QDir::separator() + "gcc"
|
||||||
+ QDir::separator() + mDumpMachine + QDir::separator()
|
+ QDir::separator() + mDumpMachine + QDir::separator()
|
||||||
+ mVersion + QDir::separator() + "include");
|
+ mVersion + QDir::separator() + "include");
|
||||||
|
|
||||||
addExistingDirectory(mCIncludeDirs,
|
addExistingDirectory(mCIncludeDirs,
|
||||||
mFolder + QDir::separator() + "lib"
|
folder + QDir::separator() + "lib"
|
||||||
+ QDir::separator() + "gcc" + QDir::separator() + mDumpMachine
|
+ QDir::separator() + "gcc" + QDir::separator() + mDumpMachine
|
||||||
+ QDir::separator() + mVersion + QDir::separator() + "include-fixed");
|
+ QDir::separator() + mVersion + QDir::separator() + "include-fixed");
|
||||||
addExistingDirectory(mCppIncludeDirs,
|
addExistingDirectory(mCppIncludeDirs,
|
||||||
mFolder + QDir::separator() + "lib"
|
folder + QDir::separator() + "lib"
|
||||||
+ QDir::separator() + "gcc" + QDir::separator() + mDumpMachine
|
+ QDir::separator() + "gcc" + QDir::separator() + mDumpMachine
|
||||||
+ QDir::separator() + mVersion + QDir::separator() + "include-fixed");
|
+ QDir::separator() + mVersion + QDir::separator() + "include-fixed");
|
||||||
|
|
||||||
// C++ only folder (mingw.org)
|
// C++ only folder (mingw.org)
|
||||||
addExistingDirectory(mCppIncludeDirs,
|
addExistingDirectory(mCppIncludeDirs,
|
||||||
mFolder + QDir::separator() + "lib" + QDir::separator() + "gcc"
|
folder + QDir::separator() + "lib" + QDir::separator() + "gcc"
|
||||||
+ QDir::separator() + mDumpMachine + QDir::separator() + mVersion
|
+ QDir::separator() + mDumpMachine + QDir::separator() + mVersion
|
||||||
+ QDir::separator() + "include" + QDir::separator() + "c++");
|
+ QDir::separator() + "include" + QDir::separator() + "c++");
|
||||||
addExistingDirectory(mCppIncludeDirs,
|
addExistingDirectory(mCppIncludeDirs,
|
||||||
mFolder + QDir::separator() + "lib" + QDir::separator() + "gcc"
|
folder + QDir::separator() + "lib" + QDir::separator() + "gcc"
|
||||||
+ QDir::separator() + mDumpMachine + QDir::separator() + mVersion
|
+ QDir::separator() + mDumpMachine + QDir::separator() + mVersion
|
||||||
+ QDir::separator() + "include" + QDir::separator() + "c++"
|
+ QDir::separator() + "include" + QDir::separator() + "c++"
|
||||||
+ QDir::separator() + mDumpMachine );
|
+ QDir::separator() + mDumpMachine );
|
||||||
addExistingDirectory(mCppIncludeDirs,
|
addExistingDirectory(mCppIncludeDirs,
|
||||||
mFolder + QDir::separator() + "lib" + QDir::separator() + "gcc"
|
folder + QDir::separator() + "lib" + QDir::separator() + "gcc"
|
||||||
+ QDir::separator() + mDumpMachine + QDir::separator() + mVersion
|
+ QDir::separator() + mDumpMachine + QDir::separator() + mVersion
|
||||||
+ QDir::separator() + "include" + QDir::separator() + "c++"
|
+ QDir::separator() + "include" + QDir::separator() + "c++"
|
||||||
+ QDir::separator() + "backward");
|
+ QDir::separator() + "backward");
|
||||||
|
|
||||||
// C++ only folder (Mingw-w64)
|
// C++ only folder (Mingw-w64)
|
||||||
addExistingDirectory(mCppIncludeDirs,
|
addExistingDirectory(mCppIncludeDirs,
|
||||||
mFolder + QDir::separator() + "include" + QDir::separator() + "c++"
|
folder + QDir::separator() + "include" + QDir::separator() + "c++"
|
||||||
+ QDir::separator() + mVersion );
|
+ QDir::separator() + mVersion );
|
||||||
addExistingDirectory(mCppIncludeDirs,
|
addExistingDirectory(mCppIncludeDirs,
|
||||||
mFolder + QDir::separator() + "include" + QDir::separator() + "c++"
|
folder + QDir::separator() + "include" + QDir::separator() + "c++"
|
||||||
+ QDir::separator() + mVersion + QDir::separator() + mDumpMachine );
|
+ QDir::separator() + mVersion + QDir::separator() + mDumpMachine );
|
||||||
addExistingDirectory(mCppIncludeDirs,
|
addExistingDirectory(mCppIncludeDirs,
|
||||||
mFolder + QDir::separator() + "include" + QDir::separator() + "c++"
|
folder + QDir::separator() + "include" + QDir::separator() + "c++"
|
||||||
+ QDir::separator() + mVersion + QDir::separator() + "backward");
|
+ QDir::separator() + mVersion + QDir::separator() + "backward");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -838,6 +843,17 @@ void Settings::CompilerSet::setOptions()
|
||||||
addOption(tr("Use pipes instead of temporary files during compilation (-pipe)"), groupName, true, true, false, 0, "-pipe");
|
addOption(tr("Use pipes instead of temporary files during compilation (-pipe)"), groupName, true, true, false, 0, "-pipe");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Settings::CompilerSet::findProgramInBinDirs(const QString name)
|
||||||
|
{
|
||||||
|
for (const QString& dir : mBinDirs) {
|
||||||
|
QFileInfo f(includeTrailingPathDelimiter(dir) + name);
|
||||||
|
if (f.exists() && f.isExecutable()) {
|
||||||
|
return f.absoluteFilePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray Settings::CompilerSet::iniOptions() const
|
QByteArray Settings::CompilerSet::iniOptions() const
|
||||||
{
|
{
|
||||||
QByteArray result;
|
QByteArray result;
|
||||||
|
@ -966,6 +982,7 @@ void Settings::CompilerSets::clearSets()
|
||||||
|
|
||||||
void Settings::CompilerSets::findSets()
|
void Settings::CompilerSets::findSets()
|
||||||
{
|
{
|
||||||
|
clearSets();
|
||||||
addSets(includeTrailingPathDelimiter(mSettings->dirs().app())+"MinGW32");
|
addSets(includeTrailingPathDelimiter(mSettings->dirs().app())+"MinGW32");
|
||||||
addSets(includeTrailingPathDelimiter(mSettings->dirs().app())+"MinGW64");
|
addSets(includeTrailingPathDelimiter(mSettings->dirs().app())+"MinGW64");
|
||||||
}
|
}
|
||||||
|
@ -1044,16 +1061,49 @@ Settings::PCompilerSet Settings::CompilerSets::defaultSet()
|
||||||
return PCompilerSet();
|
return PCompilerSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::CompilerSets::savePath(const QString& name, const QString& path) {
|
||||||
|
QString s;
|
||||||
|
QString prefix1 = excludeTrailingPathDelimiter(mSettings->mDirs.app()) + "/";
|
||||||
|
QString prefix2 = excludeTrailingPathDelimiter(mSettings->mDirs.app()) + QDir::separator();
|
||||||
|
if (path.startsWith(prefix1, Qt::CaseInsensitive)) {
|
||||||
|
s = "%AppPath%/"+ path.mid(prefix1.length());
|
||||||
|
} else if (path.startsWith(prefix2, Qt::CaseInsensitive)) {
|
||||||
|
s = "%AppPath%/"+ path.mid(prefix2.length());
|
||||||
|
} else {
|
||||||
|
s= path;
|
||||||
|
}
|
||||||
|
mSettings->mSettings.setValue(name,s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::CompilerSets::savePathList(const QString& name, const QStringList& pathList) {
|
||||||
|
QStringList sl;
|
||||||
|
for (const QString& path: pathList) {
|
||||||
|
QString s;
|
||||||
|
QString prefix1 = excludeTrailingPathDelimiter(mSettings->mDirs.app()) + "/";
|
||||||
|
QString prefix2 = excludeTrailingPathDelimiter(mSettings->mDirs.app()) + QDir::separator();
|
||||||
|
if (path.startsWith(prefix1, Qt::CaseInsensitive)) {
|
||||||
|
s = "%AppPath%/"+ path.mid(prefix1.length());
|
||||||
|
} else if (path.startsWith(prefix2, Qt::CaseInsensitive)) {
|
||||||
|
s = "%AppPath%/" + path.mid(prefix2.length());
|
||||||
|
} else {
|
||||||
|
s= path;
|
||||||
|
}
|
||||||
|
sl.append(s);
|
||||||
|
}
|
||||||
|
mSettings->mSettings.setValue(name,sl);
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::CompilerSets::saveSet(int index)
|
void Settings::CompilerSets::saveSet(int index)
|
||||||
{
|
{
|
||||||
PCompilerSet pSet = mList[index];
|
PCompilerSet pSet = mList[index];
|
||||||
mSettings->mSettings.beginGroup(QString(SETTING_COMPILTER_SET).arg(index));
|
mSettings->mSettings.beginGroup(QString(SETTING_COMPILTER_SET).arg(index));
|
||||||
mSettings->mSettings.setValue("ccompiler", pSet->CCompilerName());
|
|
||||||
mSettings->mSettings.setValue("cppcompiler", pSet->cppCompilerName());
|
savePath("ccompiler", pSet->CCompiler());
|
||||||
mSettings->mSettings.setValue("debugger", pSet->debuggerName());
|
savePath("cppcompiler", pSet->cppCompiler());
|
||||||
mSettings->mSettings.setValue("make", pSet->makeName());
|
savePath("debugger", pSet->debugger());
|
||||||
mSettings->mSettings.setValue("windres", pSet->resourceCompilerName());
|
savePath("make", pSet->make());
|
||||||
mSettings->mSettings.setValue("profiler", pSet->profilerName());
|
savePath("windres", pSet->resourceCompiler());
|
||||||
|
savePath("profiler", pSet->profiler());
|
||||||
|
|
||||||
// Save option string
|
// Save option string
|
||||||
mSettings->mSettings.setValue("Options", pSet->iniOptions());
|
mSettings->mSettings.setValue("Options", pSet->iniOptions());
|
||||||
|
@ -1066,25 +1116,56 @@ void Settings::CompilerSets::saveSet(int index)
|
||||||
mSettings->mSettings.setValue("StaticLink", pSet->staticLink());
|
mSettings->mSettings.setValue("StaticLink", pSet->staticLink());
|
||||||
mSettings->mSettings.setValue("AddCharset", pSet->autoAddCharsetParams());
|
mSettings->mSettings.setValue("AddCharset", pSet->autoAddCharsetParams());
|
||||||
|
|
||||||
|
// Misc. properties
|
||||||
|
mSettings->mSettings.setValue("DumpMachine", pSet->dumpMachine());
|
||||||
|
mSettings->mSettings.setValue("Version", pSet->version());
|
||||||
|
mSettings->mSettings.setValue("Type", pSet->type());
|
||||||
|
mSettings->mSettings.setValue("Name", pSet->name());
|
||||||
|
mSettings->mSettings.setValue("Target", pSet->target());
|
||||||
|
|
||||||
// Paths
|
// Paths
|
||||||
mSettings->mSettings.setValue("Bins",pSet->binDirs());
|
savePathList("Bins",pSet->binDirs());
|
||||||
mSettings->mSettings.setValue("C",pSet->CIncludeDirs());
|
savePathList("C",pSet->CIncludeDirs());
|
||||||
mSettings->mSettings.setValue("Cpp",pSet->CppIncludeDirs());
|
savePathList("Cpp",pSet->CppIncludeDirs());
|
||||||
mSettings->mSettings.setValue("Libs",pSet->LibDirs());
|
savePathList("Libs",pSet->LibDirs());
|
||||||
|
|
||||||
mSettings->mSettings.endGroup();
|
mSettings->mSettings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Settings::CompilerSets::loadPath(const QString &name)
|
||||||
|
{
|
||||||
|
QString s = mSettings->mSettings.value(name).toString();
|
||||||
|
QString prefix = "%AppPath%/";
|
||||||
|
if (s.startsWith(prefix)) {
|
||||||
|
s = includeTrailingPathDelimiter(mSettings->mDirs.app()) + s.mid(prefix.length());
|
||||||
|
}
|
||||||
|
return QFileInfo(s).absoluteFilePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::CompilerSets::loadPathList(const QString &name, QStringList& list)
|
||||||
|
{
|
||||||
|
list.clear();
|
||||||
|
QStringList sl = mSettings->mSettings.value(name).toStringList();
|
||||||
|
QString prefix = "%AppPath%/";
|
||||||
|
for (QString& s:sl) {
|
||||||
|
if (s.startsWith(prefix)) {
|
||||||
|
s = includeTrailingPathDelimiter(mSettings->mDirs.app()) + s.mid(prefix.length());
|
||||||
|
}
|
||||||
|
list.append(QFileInfo(s).absoluteFilePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Settings::PCompilerSet Settings::CompilerSets::loadSet(int index)
|
Settings::PCompilerSet Settings::CompilerSets::loadSet(int index)
|
||||||
{
|
{
|
||||||
PCompilerSet pSet = std::make_shared<CompilerSet>();
|
PCompilerSet pSet = std::make_shared<CompilerSet>();
|
||||||
mSettings->mSettings.beginGroup(QString(SETTING_COMPILTER_SET).arg(index));
|
mSettings->mSettings.beginGroup(QString(SETTING_COMPILTER_SET).arg(index));
|
||||||
pSet->setCCompilerName(mSettings->mSettings.value("ccompiler").toString());
|
|
||||||
pSet->setCppCompilerName(mSettings->mSettings.value("cppcompiler").toString());
|
pSet->setCCompiler(loadPath("ccompiler"));
|
||||||
pSet->setDebuggerName(mSettings->mSettings.value("debugger").toString());
|
pSet->setCppCompiler(loadPath("cppcompiler"));
|
||||||
pSet->setMakeName(mSettings->mSettings.value("make").toString());
|
pSet->setDebugger(loadPath("debugger"));
|
||||||
pSet->setResourceCompilerName(mSettings->mSettings.value("windres").toString());
|
pSet->setMake(loadPath("make"));
|
||||||
pSet->setProfilerName(mSettings->mSettings.value("profiler").toString());
|
pSet->setResourceCompiler(loadPath("windres"));
|
||||||
|
pSet->setProfiler(loadPath("profiler"));
|
||||||
|
|
||||||
// Save option string
|
// Save option string
|
||||||
pSet->setIniOptions(mSettings->mSettings.value("Options").toByteArray());
|
pSet->setIniOptions(mSettings->mSettings.value("Options").toByteArray());
|
||||||
|
@ -1097,16 +1178,21 @@ Settings::PCompilerSet Settings::CompilerSets::loadSet(int index)
|
||||||
pSet->setStaticLink(mSettings->mSettings.value("StaticLink").toBool());
|
pSet->setStaticLink(mSettings->mSettings.value("StaticLink").toBool());
|
||||||
pSet->setAutoAddCharsetParams(mSettings->mSettings.value("AddCharset").toBool());
|
pSet->setAutoAddCharsetParams(mSettings->mSettings.value("AddCharset").toBool());
|
||||||
|
|
||||||
|
pSet->setDumpMachine(mSettings->mSettings.value("DumpMachine").toString());
|
||||||
|
pSet->setVersion(mSettings->mSettings.value("Version").toString());
|
||||||
|
pSet->setType(mSettings->mSettings.value("Type").toString());
|
||||||
|
pSet->setName(mSettings->mSettings.value("Name").toString());
|
||||||
|
pSet->setTarget(mSettings->mSettings.value("Target").toString());
|
||||||
|
|
||||||
|
|
||||||
// Paths
|
// Paths
|
||||||
pSet->binDirs().clear();
|
loadPathList("Bins",pSet->binDirs());
|
||||||
pSet->binDirs().append(mSettings->mSettings.value("Bins").toStringList());
|
loadPathList("C",pSet->CIncludeDirs());
|
||||||
pSet->CIncludeDirs().clear();
|
loadPathList("Cpp",pSet->CppIncludeDirs());
|
||||||
pSet->CIncludeDirs().append(mSettings->mSettings.value("C").toStringList());
|
loadPathList("Libs",pSet->LibDirs());
|
||||||
pSet->CppIncludeDirs().clear();
|
|
||||||
pSet->CppIncludeDirs().append(mSettings->mSettings.value("Cpp").toStringList());
|
|
||||||
pSet->LibDirs().clear();
|
|
||||||
pSet->LibDirs().append(mSettings->mSettings.value("Libs").toStringList());
|
|
||||||
|
|
||||||
mSettings->mSettings.endGroup();
|
mSettings->mSettings.endGroup();
|
||||||
|
|
||||||
|
pSet->setDefines();
|
||||||
return pSet;
|
return pSet;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ public:
|
||||||
class Dirs: public _Base {
|
class Dirs: public _Base {
|
||||||
public:
|
public:
|
||||||
explicit Dirs(Settings * settings);
|
explicit Dirs(Settings * settings);
|
||||||
const QString app() const;
|
QString app() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Editor: public _Base {
|
class Editor: public _Base {
|
||||||
|
@ -90,18 +90,18 @@ public:
|
||||||
|
|
||||||
bool dirsValid(QString& msg);
|
bool dirsValid(QString& msg);
|
||||||
//properties
|
//properties
|
||||||
const QString& CCompilerName() const;
|
const QString& CCompiler() const;
|
||||||
void setCCompilerName(const QString& name);
|
void setCCompiler(const QString& name);
|
||||||
const QString& cppCompilerName() const;
|
const QString& cppCompiler() const;
|
||||||
void setCppCompilerName(const QString& name);
|
void setCppCompiler(const QString& name);
|
||||||
const QString& makeName() const;
|
const QString& make() const;
|
||||||
void setMakeName(const QString& name);
|
void setMake(const QString& name);
|
||||||
const QString& debuggerName() const;
|
const QString& debugger() const;
|
||||||
void setDebuggerName(const QString& name);
|
void setDebugger(const QString& name);
|
||||||
const QString& profilerName() const;
|
const QString& profiler() const;
|
||||||
void setProfilerName(const QString& name);
|
void setProfiler(const QString& name);
|
||||||
const QString& resourceCompilerName() const;
|
const QString& resourceCompiler() const;
|
||||||
void setResourceCompilerName(const QString& name);
|
void setResourceCompiler(const QString& name);
|
||||||
|
|
||||||
QStringList& binDirs();
|
QStringList& binDirs();
|
||||||
QStringList& CIncludeDirs();
|
QStringList& CIncludeDirs();
|
||||||
|
@ -116,8 +116,6 @@ public:
|
||||||
void setType(const QString& value);
|
void setType(const QString& value);
|
||||||
const QString& name();
|
const QString& name();
|
||||||
void setName(const QString& value);
|
void setName(const QString& value);
|
||||||
const QString& folder();
|
|
||||||
void setFolder(const QString& value);
|
|
||||||
QStringList& defines();
|
QStringList& defines();
|
||||||
const QString& target();
|
const QString& target();
|
||||||
void setTarget(const QString& value);
|
void setTarget(const QString& value);
|
||||||
|
@ -141,26 +139,31 @@ public:
|
||||||
QByteArray iniOptions() const;
|
QByteArray iniOptions() const;
|
||||||
void setIniOptions(const QByteArray& value);
|
void setIniOptions(const QByteArray& value);
|
||||||
|
|
||||||
|
//load hard defines
|
||||||
|
void setDefines();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int charToValue(char valueChar);
|
int charToValue(char valueChar);
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
void setProperties(const QString& binDir);
|
void setProperties(const QString& binDir);
|
||||||
void setExecutables();
|
void setExecutables();
|
||||||
void setDirectories();
|
void setDirectories(const QString& folder);
|
||||||
void setUserInput();
|
void setUserInput();
|
||||||
void setOptions();
|
void setOptions();
|
||||||
|
|
||||||
|
QString findProgramInBinDirs(const QString name);
|
||||||
|
|
||||||
QByteArray getCompilerOutput(const QString& binDir, const QString& binFile,
|
QByteArray getCompilerOutput(const QString& binDir, const QString& binFile,
|
||||||
const QStringList& arguments);
|
const QStringList& arguments);
|
||||||
private:
|
private:
|
||||||
// Executables, most are hardcoded
|
// Executables, most are hardcoded
|
||||||
QString mCCompilerName;
|
QString mCCompiler;
|
||||||
QString mCppCompilerName;
|
QString mCppCompiler;
|
||||||
QString mMakeName;
|
QString mMake;
|
||||||
QString mDebuggerName;
|
QString mDebugger;
|
||||||
QString mProfilerName;
|
QString mProfiler;
|
||||||
QString mResourceCompilerName;
|
QString mResourceCompiler;
|
||||||
|
|
||||||
// Directories, mostly hardcoded too
|
// Directories, mostly hardcoded too
|
||||||
QStringList mBinDirs;
|
QStringList mBinDirs;
|
||||||
|
@ -173,7 +176,6 @@ public:
|
||||||
QString mVersion; // "4.7.1"
|
QString mVersion; // "4.7.1"
|
||||||
QString mType; // "TDM-GCC", "MinGW"
|
QString mType; // "TDM-GCC", "MinGW"
|
||||||
QString mName; // "TDM-GCC 4.7.1 Release"
|
QString mName; // "TDM-GCC 4.7.1 Release"
|
||||||
QString mFolder; // MinGW64, MinGW32
|
|
||||||
QStringList mDefines; // list of predefined constants
|
QStringList mDefines; // list of predefined constants
|
||||||
QString mTarget; // 'X86_64' / 'i686'
|
QString mTarget; // 'X86_64' / 'i686'
|
||||||
|
|
||||||
|
@ -212,7 +214,11 @@ public:
|
||||||
void setDefaultIndex(int value);
|
void setDefaultIndex(int value);
|
||||||
PCompilerSet defaultSet();
|
PCompilerSet defaultSet();
|
||||||
private:
|
private:
|
||||||
|
void savePath(const QString& name, const QString& path);
|
||||||
|
void savePathList(const QString& name, const QStringList& pathList);
|
||||||
void saveSet(int index);
|
void saveSet(int index);
|
||||||
|
QString loadPath(const QString& name);
|
||||||
|
void loadPathList(const QString& name, QStringList& list);
|
||||||
PCompilerSet loadSet(int index);
|
PCompilerSet loadSet(int index);
|
||||||
CompilerSetList mList;
|
CompilerSetList mList;
|
||||||
int mDefaultIndex;
|
int mDefaultIndex;
|
||||||
|
@ -228,7 +234,9 @@ public:
|
||||||
Settings& operator= (const Settings&& settings) = delete;
|
Settings& operator= (const Settings&& settings) = delete;
|
||||||
void setDefault(const QString& group, const QString &key, const QVariant &value);
|
void setDefault(const QString& group, const QString &key, const QVariant &value);
|
||||||
void setValue(const QString& group, const QString &key, const QVariant &value);
|
void setValue(const QString& group, const QString &key, const QVariant &value);
|
||||||
|
void setValue(const QString &key, const QVariant &value);
|
||||||
QVariant value(const QString& group, const QString &key);
|
QVariant value(const QString& group, const QString &key);
|
||||||
|
QVariant value(const QString &key);
|
||||||
|
|
||||||
Dirs& dirs();
|
Dirs& dirs();
|
||||||
Editor& editor();
|
Editor& editor();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "settingswidget.h"
|
#include "settingswidget.h"
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QComboBox>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
|
||||||
|
@ -24,6 +25,9 @@ void SettingsWidget::init()
|
||||||
for (QPlainTextEdit* p:findChildren<QPlainTextEdit*>()) {
|
for (QPlainTextEdit* p:findChildren<QPlainTextEdit*>()) {
|
||||||
connect(p, &QPlainTextEdit::textChanged, this, &SettingsWidget::setSettingsChanged);
|
connect(p, &QPlainTextEdit::textChanged, this, &SettingsWidget::setSettingsChanged);
|
||||||
}
|
}
|
||||||
|
for (QComboBox* p: findChildren<QComboBox*>()) {
|
||||||
|
connect(p, QOverload<int>::of(&QComboBox::currentIndexChanged) ,this, &SettingsWidget::setSettingsChanged);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsWidget::load()
|
void SettingsWidget::load()
|
||||||
|
@ -48,7 +52,7 @@ const QString &SettingsWidget::name()
|
||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SettingsWidget::settingsChanged()
|
bool SettingsWidget::isSettingsChanged()
|
||||||
{
|
{
|
||||||
return mSettingsChanged;
|
return mSettingsChanged;
|
||||||
}
|
}
|
||||||
|
@ -56,9 +60,11 @@ bool SettingsWidget::settingsChanged()
|
||||||
void SettingsWidget::setSettingsChanged()
|
void SettingsWidget::setSettingsChanged()
|
||||||
{
|
{
|
||||||
mSettingsChanged = true;
|
mSettingsChanged = true;
|
||||||
|
emit settingsChanged(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsWidget::clearSettingsChanged()
|
void SettingsWidget::clearSettingsChanged()
|
||||||
{
|
{
|
||||||
mSettingsChanged = false;
|
mSettingsChanged = false;
|
||||||
|
emit settingsChanged(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ public:
|
||||||
void load();
|
void load();
|
||||||
void save();
|
void save();
|
||||||
signals:
|
signals:
|
||||||
|
void settingsChanged(bool changed);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void doLoad() = 0;
|
virtual void doLoad() = 0;
|
||||||
|
@ -21,7 +22,7 @@ protected:
|
||||||
public:
|
public:
|
||||||
const QString& group();
|
const QString& group();
|
||||||
const QString& name();
|
const QString& name();
|
||||||
bool settingsChanged();
|
bool isSettingsChanged();
|
||||||
public slots:
|
public slots:
|
||||||
void setSettingsChanged();
|
void setSettingsChanged();
|
||||||
void clearSettingsChanged();
|
void clearSettingsChanged();
|
||||||
|
|
|
@ -109,7 +109,7 @@ QByteArray runAndGetOutput(const QString &cmd, const QString& workingDir, const
|
||||||
|
|
||||||
bool isNonPrintableAsciiChar(char ch)
|
bool isNonPrintableAsciiChar(char ch)
|
||||||
{
|
{
|
||||||
return (ch>32) or (ch<0);
|
return (ch<=32) and (ch>=0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fileExists(const QString &file)
|
bool fileExists(const QString &file)
|
||||||
|
|
Loading…
Reference in New Issue