Implemented project manager, app data, welcome window
This commit is contained in:
		@@ -8,20 +8,23 @@
 | 
			
		||||
namespace Ember
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
AppDataStorage::AppDataStorage()
 | 
			
		||||
boost::filesystem::path AppDataStorage::s_appData;
 | 
			
		||||
boost::filesystem::path AppDataStorage::s_recentProjects;
 | 
			
		||||
 | 
			
		||||
void AppDataStorage::initialize()
 | 
			
		||||
{
 | 
			
		||||
    QString appData = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
 | 
			
		||||
    m_appData = appData.toStdString();
 | 
			
		||||
    m_recentProjects = m_appData;
 | 
			
		||||
    m_recentProjects += RECENT_PROJECTS_FILENAME;
 | 
			
		||||
    s_appData = appData.toStdString();
 | 
			
		||||
    s_recentProjects = s_appData;
 | 
			
		||||
    s_recentProjects += RECENT_PROJECTS_FILENAME;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AppDataStorage::readRecentProjects(std::vector<RecentProject> &projects)
 | 
			
		||||
{
 | 
			
		||||
    if (boost::filesystem::exists(m_recentProjects))
 | 
			
		||||
    if (boost::filesystem::exists(s_recentProjects))
 | 
			
		||||
    {
 | 
			
		||||
        pugi::xml_document doc;
 | 
			
		||||
        doc.load_file(m_recentProjects.c_str());
 | 
			
		||||
        doc.load_file(s_recentProjects.c_str());
 | 
			
		||||
 | 
			
		||||
        for (auto& node : doc.document_element())
 | 
			
		||||
        {
 | 
			
		||||
@@ -54,8 +57,8 @@ void AppDataStorage::storeRecentProjects(const std::vector<RecentProject> &proje
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Save file, ensure directory exists
 | 
			
		||||
    boost::filesystem::create_directories(m_appData);
 | 
			
		||||
    doc.save_file(m_recentProjects.string().c_str());
 | 
			
		||||
    boost::filesystem::create_directories(s_appData);
 | 
			
		||||
    doc.save_file(s_recentProjects.string().c_str());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -12,23 +12,23 @@ namespace Ember
 | 
			
		||||
class AppDataStorage
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    AppDataStorage();
 | 
			
		||||
    static void initialize();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @brief Reads recent projects
 | 
			
		||||
     * @param projects List will be saved to given vector.
 | 
			
		||||
     */
 | 
			
		||||
    void readRecentProjects(std::vector<RecentProject>& projects);
 | 
			
		||||
    static void readRecentProjects(std::vector<RecentProject>& projects);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @brief Stores recent projects
 | 
			
		||||
     * @param projects List of projects.
 | 
			
		||||
     */
 | 
			
		||||
    void storeRecentProjects(const std::vector<RecentProject>& projects);
 | 
			
		||||
    static void storeRecentProjects(const std::vector<RecentProject>& projects);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    boost::filesystem::path m_appData;
 | 
			
		||||
    boost::filesystem::path m_recentProjects;
 | 
			
		||||
    static boost::filesystem::path s_appData;
 | 
			
		||||
    static boost::filesystem::path s_recentProjects;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user