From 55326a3659bbacb193741b733ca332686ae27523 Mon Sep 17 00:00:00 2001 From: "royqh1979@gmail.com" Date: Sat, 17 Apr 2021 14:52:47 +0800 Subject: [PATCH] * settings dialog can correctly disable/enable apply button --- RedPandaIDE/main.cpp | 8 +- RedPandaIDE/settings.cpp | 282 ++++++++++++------ RedPandaIDE/settings.h | 54 ++-- RedPandaIDE/settingsdialog/settingswidget.cpp | 8 +- RedPandaIDE/settingsdialog/settingswidget.h | 3 +- RedPandaIDE/utils.cpp | 2 +- 6 files changed, 232 insertions(+), 125 deletions(-) diff --git a/RedPandaIDE/main.cpp b/RedPandaIDE/main.cpp index d5928864..35e16004 100644 --- a/RedPandaIDE/main.cpp +++ b/RedPandaIDE/main.cpp @@ -68,7 +68,13 @@ int main(int argc, char *argv[]) auto settings = std::unique_ptr(pSettings); //settings->compilerSets().addSets("e:/workspace/contributes/Dev-CPP/MinGW32_GCC92"); +// settings->compilerSets().findSets(); +// settings->compilerSets().saveSets(); settings->compilerSets().loadSets(); +// qDebug() << settings->compilerSets().defaultSet()->binDirs(); +// settings->compilerSets().loadSets(); +// qDebug() << settings->compilerSets().defaultSet()->defines(); +// qDebug() << settings->compilerSets().defaultSet()->CCompiler(); // qDebug()<compilerSets().size(); // qDebug()<compilerSets().list().at(0)->binDirs(); MainWindow mainWindow; @@ -76,6 +82,6 @@ int main(int argc, char *argv[]) mainWindow.show(); int retCode = app.exec(); // save settings - settings->compilerSets().saveSets(); +// settings->compilerSets().saveSets(); return retCode; } diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 85def1e8..1c654f0d 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -5,6 +5,7 @@ #include "utils.h" #include #include "systemconsts.h" +#include const char ValueToChar[28] = {'0', '1', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', '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); } +void Settings::setValue(const QString &key, const QVariant &value) +{ + mSettings.setValue(key,value); +} + QVariant Settings::value(const QString& group, const QString &key) { mSettings.beginGroup(group); auto act = finally([this] { @@ -51,6 +57,11 @@ QVariant Settings::value(const QString& group, const QString &key) { return mSettings.value(key); } +QVariant Settings::value(const QString &key) +{ + return mSettings.value(key); +} + Settings::Dirs &Settings::dirs() { 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): @@ -132,23 +143,25 @@ Settings::CompilerSet::CompilerSet(const QString& compilerFolder): if (!compilerFolder.isEmpty()) { setProperties(compilerFolder+"/bin"); + //manually set the directories + setDirectories(compilerFolder); + setExecutables(); - //manually set the directories - setDirectories(); - setUserInput(); + + setDefines(); } setOptions(); } Settings::CompilerSet::CompilerSet(const Settings::CompilerSet &set): - mCCompilerName(set.mCCompilerName), - mCppCompilerName(set.mCppCompilerName), - mMakeName(set.mMakeName), - mDebuggerName(set.mDebuggerName), - mProfilerName(set.mProfilerName), - mResourceCompilerName(set.mResourceCompilerName), + mCCompiler(set.mCCompiler), + mCppCompiler(set.mCppCompiler), + mMake(set.mMake), + mDebugger(set.mDebugger), + mProfiler(set.mProfiler), + mResourceCompiler(set.mResourceCompiler), mBinDirs(set.mBinDirs), mCIncludeDirs(set.mCIncludeDirs), mCppIncludeDirs(set.mCppIncludeDirs), @@ -157,7 +170,6 @@ Settings::CompilerSet::CompilerSet(const Settings::CompilerSet &set): mVersion(set.mVersion), mType(set.mType), mName(set.mName), - mFolder(set.mFolder), mDefines(set.mDefines), mTarget(set.mTarget), mUseCustomCompileParams(set.mUseCustomCompileParams), @@ -228,64 +240,64 @@ bool Settings::CompilerSet::dirsValid(QString &msg) 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() @@ -348,16 +360,6 @@ void Settings::CompilerSet::setName(const QString &value) mName = value; } -const QString &Settings::CompilerSet::folder() -{ - return mFolder; -} - -void Settings::CompilerSet::setFolder(const QString &value) -{ - mFolder = value; -} - QStringList& Settings::CompilerSet::defines() { return mDefines; @@ -490,7 +492,6 @@ void Settings::CompilerSet::setProperties(const QString &binDir) delimPos2++; mVersion = output.mid(delimPos1,delimPos2-delimPos1); - // Find compiler builder delimPos1 = delimPos2; while ((delimPos1 < output.length()) && !(output[delimPos1] == '(')) @@ -517,7 +518,7 @@ void Settings::CompilerSet::setProperties(const QString &binDir) // Set compiler folder QDir tmpDir(binDir); tmpDir.cdUp(); - mFolder = tmpDir.path(); + QString folder = tmpDir.path(); // Obtain compiler target arguments.clear(); @@ -525,10 +526,10 @@ void Settings::CompilerSet::setProperties(const QString &binDir) mDumpMachine = getCompilerOutput(binDir, GCC_PROGRAM, arguments); // Add the default directories - addExistingDirectory(mBinDirs, mFolder + QDir::separator() + "bin"); - addExistingDirectory(mLibDirs, mFolder + QDir::separator() + "lib"); - addExistingDirectory(mCIncludeDirs, mFolder + QDir::separator() + "include"); - addExistingDirectory(mCppIncludeDirs, mFolder + QDir::separator() + "include"); + addExistingDirectory(mBinDirs, folder + QDir::separator() + "bin"); + addExistingDirectory(mLibDirs, folder + QDir::separator() + "lib"); + addExistingDirectory(mCIncludeDirs, folder + QDir::separator() + "include"); + addExistingDirectory(mCppIncludeDirs, folder + QDir::separator() + "include"); // Find default directories arguments.clear(); @@ -602,15 +603,19 @@ void Settings::CompilerSet::setProperties(const QString &binDir) } } +} + +void Settings::CompilerSet::setDefines() { // get default defines - arguments.clear(); + QStringList arguments; arguments.append("-dM"); arguments.append("-E"); arguments.append("-x"); arguments.append("c++"); arguments.append("-std=c++17"); 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' mDefines.clear(); @@ -625,72 +630,72 @@ void Settings::CompilerSet::setProperties(const QString &binDir) void Settings::CompilerSet::setExecutables() { - mCCompilerName = GCC_PROGRAM; - mCppCompilerName = GPP_PROGRAM; - mDebuggerName = GDB_PROGRAM; - mMakeName = MAKE_PROGRAM; - mResourceCompilerName = WINDRES_PROGRAM; - mProfilerName = GPROF_PROGRAM; + mCCompiler = findProgramInBinDirs(GCC_PROGRAM); + mCppCompiler = findProgramInBinDirs(GPP_PROGRAM); + mDebugger = findProgramInBinDirs(GDB_PROGRAM); + mMake = findProgramInBinDirs(MAKE_PROGRAM); + mResourceCompiler = findProgramInBinDirs(WINDRES_PROGRAM); + mProfiler = findProgramInBinDirs(GPROF_PROGRAM); } -void Settings::CompilerSet::setDirectories() +void Settings::CompilerSet::setDirectories(const QString& folder) { // Try to obtain our target/autoconf folder if (!mDumpMachine.isEmpty()) { //mingw-w64 bin folder addExistingDirectory(mBinDirs, - mFolder + QDir::separator() + "lib" + folder + QDir::separator() + "lib" + QDir::separator() + "gcc" + mDumpMachine + QDir::separator() + mVersion); // Regular include folder - addExistingDirectory(mCIncludeDirs, mFolder + QDir::separator() + mDumpMachine + QDir::separator() + "include"); - addExistingDirectory(mCppIncludeDirs, mFolder + QDir::separator()+ mDumpMachine + QDir::separator() + "include"); + addExistingDirectory(mCIncludeDirs, folder + QDir::separator() + mDumpMachine + QDir::separator() + "include"); + addExistingDirectory(mCppIncludeDirs, folder + QDir::separator()+ mDumpMachine + QDir::separator() + "include"); // Other include folder? addExistingDirectory(mCIncludeDirs, - mFolder + QDir::separator() + "lib" + QDir::separator() + "gcc" + folder + QDir::separator() + "lib" + QDir::separator() + "gcc" + QDir::separator() + mDumpMachine + QDir::separator() + mVersion + QDir::separator() + "include"); addExistingDirectory(mCppIncludeDirs, - mFolder + QDir::separator() + "lib" + QDir::separator() + "gcc" + folder + QDir::separator() + "lib" + QDir::separator() + "gcc" + QDir::separator() + mDumpMachine + QDir::separator() + mVersion + QDir::separator() + "include"); addExistingDirectory(mCIncludeDirs, - mFolder + QDir::separator() + "lib" + folder + QDir::separator() + "lib" + QDir::separator() + "gcc" + QDir::separator() + mDumpMachine + QDir::separator() + mVersion + QDir::separator() + "include-fixed"); addExistingDirectory(mCppIncludeDirs, - mFolder + QDir::separator() + "lib" + folder + QDir::separator() + "lib" + QDir::separator() + "gcc" + QDir::separator() + mDumpMachine + QDir::separator() + mVersion + QDir::separator() + "include-fixed"); // C++ only folder (mingw.org) addExistingDirectory(mCppIncludeDirs, - mFolder + QDir::separator() + "lib" + QDir::separator() + "gcc" + folder + QDir::separator() + "lib" + QDir::separator() + "gcc" + QDir::separator() + mDumpMachine + QDir::separator() + mVersion + QDir::separator() + "include" + QDir::separator() + "c++"); addExistingDirectory(mCppIncludeDirs, - mFolder + QDir::separator() + "lib" + QDir::separator() + "gcc" + folder + QDir::separator() + "lib" + QDir::separator() + "gcc" + QDir::separator() + mDumpMachine + QDir::separator() + mVersion + QDir::separator() + "include" + QDir::separator() + "c++" + QDir::separator() + mDumpMachine ); addExistingDirectory(mCppIncludeDirs, - mFolder + QDir::separator() + "lib" + QDir::separator() + "gcc" + folder + QDir::separator() + "lib" + QDir::separator() + "gcc" + QDir::separator() + mDumpMachine + QDir::separator() + mVersion + QDir::separator() + "include" + QDir::separator() + "c++" + QDir::separator() + "backward"); // C++ only folder (Mingw-w64) addExistingDirectory(mCppIncludeDirs, - mFolder + QDir::separator() + "include" + QDir::separator() + "c++" + folder + QDir::separator() + "include" + QDir::separator() + "c++" + QDir::separator() + mVersion ); addExistingDirectory(mCppIncludeDirs, - mFolder + QDir::separator() + "include" + QDir::separator() + "c++" + folder + QDir::separator() + "include" + QDir::separator() + "c++" + QDir::separator() + mVersion + QDir::separator() + mDumpMachine ); addExistingDirectory(mCppIncludeDirs, - mFolder + QDir::separator() + "include" + QDir::separator() + "c++" + folder + QDir::separator() + "include" + QDir::separator() + "c++" + 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"); } +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 result; @@ -966,6 +982,7 @@ void Settings::CompilerSets::clearSets() void Settings::CompilerSets::findSets() { + clearSets(); addSets(includeTrailingPathDelimiter(mSettings->dirs().app())+"MinGW32"); addSets(includeTrailingPathDelimiter(mSettings->dirs().app())+"MinGW64"); } @@ -1044,16 +1061,49 @@ Settings::PCompilerSet Settings::CompilerSets::defaultSet() 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) { PCompilerSet pSet = mList[index]; mSettings->mSettings.beginGroup(QString(SETTING_COMPILTER_SET).arg(index)); - mSettings->mSettings.setValue("ccompiler", pSet->CCompilerName()); - mSettings->mSettings.setValue("cppcompiler", pSet->cppCompilerName()); - mSettings->mSettings.setValue("debugger", pSet->debuggerName()); - mSettings->mSettings.setValue("make", pSet->makeName()); - mSettings->mSettings.setValue("windres", pSet->resourceCompilerName()); - mSettings->mSettings.setValue("profiler", pSet->profilerName()); + + savePath("ccompiler", pSet->CCompiler()); + savePath("cppcompiler", pSet->cppCompiler()); + savePath("debugger", pSet->debugger()); + savePath("make", pSet->make()); + savePath("windres", pSet->resourceCompiler()); + savePath("profiler", pSet->profiler()); // Save option string 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("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 - mSettings->mSettings.setValue("Bins",pSet->binDirs()); - mSettings->mSettings.setValue("C",pSet->CIncludeDirs()); - mSettings->mSettings.setValue("Cpp",pSet->CppIncludeDirs()); - mSettings->mSettings.setValue("Libs",pSet->LibDirs()); + savePathList("Bins",pSet->binDirs()); + savePathList("C",pSet->CIncludeDirs()); + savePathList("Cpp",pSet->CppIncludeDirs()); + savePathList("Libs",pSet->LibDirs()); 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) { PCompilerSet pSet = std::make_shared(); mSettings->mSettings.beginGroup(QString(SETTING_COMPILTER_SET).arg(index)); - pSet->setCCompilerName(mSettings->mSettings.value("ccompiler").toString()); - pSet->setCppCompilerName(mSettings->mSettings.value("cppcompiler").toString()); - pSet->setDebuggerName(mSettings->mSettings.value("debugger").toString()); - pSet->setMakeName(mSettings->mSettings.value("make").toString()); - pSet->setResourceCompilerName(mSettings->mSettings.value("windres").toString()); - pSet->setProfilerName(mSettings->mSettings.value("profiler").toString()); + + pSet->setCCompiler(loadPath("ccompiler")); + pSet->setCppCompiler(loadPath("cppcompiler")); + pSet->setDebugger(loadPath("debugger")); + pSet->setMake(loadPath("make")); + pSet->setResourceCompiler(loadPath("windres")); + pSet->setProfiler(loadPath("profiler")); // Save option string 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->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 - pSet->binDirs().clear(); - pSet->binDirs().append(mSettings->mSettings.value("Bins").toStringList()); - pSet->CIncludeDirs().clear(); - pSet->CIncludeDirs().append(mSettings->mSettings.value("C").toStringList()); - pSet->CppIncludeDirs().clear(); - pSet->CppIncludeDirs().append(mSettings->mSettings.value("Cpp").toStringList()); - pSet->LibDirs().clear(); - pSet->LibDirs().append(mSettings->mSettings.value("Libs").toStringList()); + loadPathList("Bins",pSet->binDirs()); + loadPathList("C",pSet->CIncludeDirs()); + loadPathList("Cpp",pSet->CppIncludeDirs()); + loadPathList("Libs",pSet->LibDirs()); mSettings->mSettings.endGroup(); + + pSet->setDefines(); return pSet; } diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h index 32886d6c..7e2c6af3 100644 --- a/RedPandaIDE/settings.h +++ b/RedPandaIDE/settings.h @@ -58,7 +58,7 @@ public: class Dirs: public _Base { public: explicit Dirs(Settings * settings); - const QString app() const; + QString app() const; }; class Editor: public _Base { @@ -90,18 +90,18 @@ public: bool dirsValid(QString& msg); //properties - const QString& CCompilerName() const; - void setCCompilerName(const QString& name); - const QString& cppCompilerName() const; - void setCppCompilerName(const QString& name); - const QString& makeName() const; - void setMakeName(const QString& name); - const QString& debuggerName() const; - void setDebuggerName(const QString& name); - const QString& profilerName() const; - void setProfilerName(const QString& name); - const QString& resourceCompilerName() const; - void setResourceCompilerName(const QString& name); + const QString& CCompiler() const; + void setCCompiler(const QString& name); + const QString& cppCompiler() const; + void setCppCompiler(const QString& name); + const QString& make() const; + void setMake(const QString& name); + const QString& debugger() const; + void setDebugger(const QString& name); + const QString& profiler() const; + void setProfiler(const QString& name); + const QString& resourceCompiler() const; + void setResourceCompiler(const QString& name); QStringList& binDirs(); QStringList& CIncludeDirs(); @@ -116,8 +116,6 @@ public: void setType(const QString& value); const QString& name(); void setName(const QString& value); - const QString& folder(); - void setFolder(const QString& value); QStringList& defines(); const QString& target(); void setTarget(const QString& value); @@ -141,26 +139,31 @@ public: QByteArray iniOptions() const; void setIniOptions(const QByteArray& value); + //load hard defines + void setDefines(); + private: int charToValue(char valueChar); // Initialization void setProperties(const QString& binDir); void setExecutables(); - void setDirectories(); + void setDirectories(const QString& folder); void setUserInput(); void setOptions(); + QString findProgramInBinDirs(const QString name); + QByteArray getCompilerOutput(const QString& binDir, const QString& binFile, const QStringList& arguments); private: // Executables, most are hardcoded - QString mCCompilerName; - QString mCppCompilerName; - QString mMakeName; - QString mDebuggerName; - QString mProfilerName; - QString mResourceCompilerName; + QString mCCompiler; + QString mCppCompiler; + QString mMake; + QString mDebugger; + QString mProfiler; + QString mResourceCompiler; // Directories, mostly hardcoded too QStringList mBinDirs; @@ -173,7 +176,6 @@ public: QString mVersion; // "4.7.1" QString mType; // "TDM-GCC", "MinGW" QString mName; // "TDM-GCC 4.7.1 Release" - QString mFolder; // MinGW64, MinGW32 QStringList mDefines; // list of predefined constants QString mTarget; // 'X86_64' / 'i686' @@ -212,7 +214,11 @@ public: void setDefaultIndex(int value); PCompilerSet defaultSet(); private: + void savePath(const QString& name, const QString& path); + void savePathList(const QString& name, const QStringList& pathList); void saveSet(int index); + QString loadPath(const QString& name); + void loadPathList(const QString& name, QStringList& list); PCompilerSet loadSet(int index); CompilerSetList mList; int mDefaultIndex; @@ -228,7 +234,9 @@ public: Settings& operator= (const Settings&& settings) = delete; 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 &key, const QVariant &value); QVariant value(const QString& group, const QString &key); + QVariant value(const QString &key); Dirs& dirs(); Editor& editor(); diff --git a/RedPandaIDE/settingsdialog/settingswidget.cpp b/RedPandaIDE/settingsdialog/settingswidget.cpp index 18ceb759..559792a1 100644 --- a/RedPandaIDE/settingsdialog/settingswidget.cpp +++ b/RedPandaIDE/settingsdialog/settingswidget.cpp @@ -1,6 +1,7 @@ #include "settingswidget.h" #include +#include #include #include @@ -24,6 +25,9 @@ void SettingsWidget::init() for (QPlainTextEdit* p:findChildren()) { connect(p, &QPlainTextEdit::textChanged, this, &SettingsWidget::setSettingsChanged); } + for (QComboBox* p: findChildren()) { + connect(p, QOverload::of(&QComboBox::currentIndexChanged) ,this, &SettingsWidget::setSettingsChanged); + } } void SettingsWidget::load() @@ -48,7 +52,7 @@ const QString &SettingsWidget::name() return mName; } -bool SettingsWidget::settingsChanged() +bool SettingsWidget::isSettingsChanged() { return mSettingsChanged; } @@ -56,9 +60,11 @@ bool SettingsWidget::settingsChanged() void SettingsWidget::setSettingsChanged() { mSettingsChanged = true; + emit settingsChanged(true); } void SettingsWidget::clearSettingsChanged() { mSettingsChanged = false; + emit settingsChanged(false); } diff --git a/RedPandaIDE/settingsdialog/settingswidget.h b/RedPandaIDE/settingsdialog/settingswidget.h index e1f9c245..424da4f1 100644 --- a/RedPandaIDE/settingsdialog/settingswidget.h +++ b/RedPandaIDE/settingsdialog/settingswidget.h @@ -14,6 +14,7 @@ public: void load(); void save(); signals: + void settingsChanged(bool changed); protected: virtual void doLoad() = 0; @@ -21,7 +22,7 @@ protected: public: const QString& group(); const QString& name(); - bool settingsChanged(); + bool isSettingsChanged(); public slots: void setSettingsChanged(); void clearSettingsChanged(); diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp index d5f4193b..069ec71a 100644 --- a/RedPandaIDE/utils.cpp +++ b/RedPandaIDE/utils.cpp @@ -109,7 +109,7 @@ QByteArray runAndGetOutput(const QString &cmd, const QString& workingDir, const bool isNonPrintableAsciiChar(char ch) { - return (ch>32) or (ch<0); + return (ch<=32) and (ch>=0); } bool fileExists(const QString &file)