Implemented project manager, app data, welcome window

This commit is contained in:
2018-08-07 17:51:29 +03:00
parent 49a4a17407
commit 7e355c1981
15 changed files with 561 additions and 27 deletions

View File

@ -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());
}
}

View File

@ -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;
};
}