Warning, file /maui/strike/src/controllers/projectmanager.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 #include "projectmanager.h" 0002 0003 #include <QDebug> 0004 #include <QDir> 0005 0006 #include <MauiKit3/FileBrowsing/fmstatic.h> 0007 0008 #include "cmakeprojectmanager.h" 0009 #include "cmakeapi.h" 0010 0011 #include "projectpreferences.h" 0012 0013 ProjectManager::ProjectManager(QObject *parent) : QObject(parent) 0014 , m_projectManager(new CMakeProjectManager(this)) 0015 , m_preferences(new ProjectPreferences(this)) 0016 ,m_active(false) 0017 { 0018 connect(this, &ProjectManager::projectUrlChanged, [this](QUrl) 0019 { 0020 //check cmake file actually exists 0021 if(!FMStatic::fileExists(m_projectUrl)) 0022 { 0023 qWarning() << "CMake main file doesn't exists. Can not procced"; 0024 m_active = false; 0025 return; 0026 } 0027 0028 //from cmake file determine the source directory 0029 m_projectPath = FMStatic::fileDir(m_projectUrl); 0030 emit this->projectPathChanged(m_projectPath); 0031 0032 //by default set the build directory as ./build 0033 m_preferences->setBuildDir(m_projectPath.toString()+"/build"); 0034 0035 //maybe try to load a logo form the source directory 0036 qDebug() << "Project Logo" << m_projectPath.toString() +"/logo.png" << FMStatic::fileExists(QUrl(m_projectPath.toString() +"/logo.png")); 0037 0038 if(FMStatic::fileExists(QUrl(m_projectPath.toString() +"/logo.png"))) 0039 { 0040 m_projectLogo = m_projectPath.toString() +"/logo.png"; 0041 emit this->projectLogoChanged(m_projectLogo); 0042 } 0043 0044 m_active = true; 0045 emit activeChanged(); 0046 0047 }); 0048 } 0049 0050 QUrl ProjectManager::projectUrl() const 0051 { 0052 return m_projectUrl; 0053 } 0054 0055 ProjectPreferences *ProjectManager::preferences() const 0056 { 0057 return m_preferences; 0058 } 0059 0060 CMakeProjectManager *ProjectManager::manager() const 0061 { 0062 return m_projectManager; 0063 } 0064 0065 QUrl ProjectManager::projectPath() const 0066 { 0067 return m_projectPath; 0068 } 0069 0070 QString ProjectManager::projectLogo() const 0071 { 0072 return m_projectLogo; 0073 } 0074 0075 void ProjectManager::setProjectUrl(QUrl projectUrl) 0076 { 0077 if (m_projectUrl == projectUrl) 0078 return; 0079 0080 qDebug() << "Setting up new project from " << projectUrl; 0081 0082 m_projectUrl = projectUrl; 0083 emit projectUrlChanged(m_projectUrl); 0084 } 0085 0086 void ProjectManager::configure() 0087 { 0088 //when starting to configure take into account all the preferences 0089 0090 //start the initial configuration of the project, like parsing and creating the needed files 0091 m_projectManager->init(); 0092 } 0093 0094 bool ProjectManager::active() const 0095 { 0096 return m_active; 0097 }