ui: added initial auto-detection for cpp standard headers and java runtime library

* when Coati is started with no java-path or global cxx header or framework paths in the appsettings they are auto-detected using the first working detector
* order in which the detectors are shown in gui now matches the order they are added to the combined detector.
This commit is contained in:
malte_langkabel
2016-10-12 19:10:03 +02:00
parent c018020a73
commit 97b151371b
8 changed files with 151 additions and 59 deletions
+61 -8
View File
@@ -1,10 +1,3 @@
#include "utility/AppPath.h"
#include "utility/commandline/CommandLineParser.h"
#include "utility/ResourcePaths.h"
#include "utility/ScopedFunctor.h"
#include "utility/UserPaths.h"
#include "utility/Version.h"
#include "Application.h"
#include "ProjectFactoryModuleC.h"
#include "ProjectFactoryModuleCpp.h"
@@ -17,8 +10,61 @@
#include "qt/utility/utilityQt.h"
#include "qt/view/QtViewFactory.h"
#include "qt/window/QtMainWindow.h"
#include "settings/ApplicationSettings.h"
#include "utility/AppPath.h"
#include "utility/commandline/CommandLineParser.h"
#include "utility/ResourcePaths.h"
#include "utility/ScopedFunctor.h"
#include "utility/UserPaths.h"
#include "utility/utilityPathDetection.h"
#include "utility/Version.h"
#include "version.h"
void prefillJavaRuntimePath()
{
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
if (settings->getJavaPath().empty())
{
std::shared_ptr<CombinedPathDetector> javaPathDetector = utility::getJavaRuntimePathDetector();
std::vector<FilePath> paths = javaPathDetector->getPaths();
if (!paths.empty())
{
settings->setJavaPath(paths.front().str());
settings->save();
}
}
}
void prefillCxxHeaderPaths()
{
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
if (settings->getHeaderSearchPaths().empty())
{
std::shared_ptr<CombinedPathDetector> cxxHeaderDetector = utility::getCxxHeaderPathDetector();
std::vector<FilePath> paths = cxxHeaderDetector->getPaths();
if (!paths.empty())
{
settings->setHeaderSearchPaths(paths);
settings->save();
}
}
}
void prefillCxxFrameworkPaths()
{
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
if (settings->getFrameworkSearchPaths().empty())
{
std::shared_ptr<CombinedPathDetector> cxxFrameworkDetector = utility::getCxxFrameworkPathDetector();
std::vector<FilePath> paths = cxxFrameworkDetector->getPaths();
if (!paths.empty())
{
settings->setFrameworkSearchPaths(paths);
settings->save();
}
}
}
int main(int argc, char *argv[])
{
QApplication::setApplicationName("Coati");
@@ -51,6 +97,10 @@ int main(int argc, char *argv[])
Application::destroyInstance();
});
prefillJavaRuntimePath();
prefillCxxHeaderPaths();
prefillCxxFrameworkPaths();
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleC>());
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleCpp>());
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleJava>());
@@ -90,6 +140,10 @@ int main(int argc, char *argv[])
Application::destroyInstance();
});
prefillJavaRuntimePath();
prefillCxxHeaderPaths();
prefillCxxFrameworkPaths();
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleC>());
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleCpp>());
Application::getInstance()->addProjectFactoryModule(std::make_shared<ProjectFactoryModuleJava>());
@@ -102,4 +156,3 @@ int main(int argc, char *argv[])
return qtApp.exec();
}
}