diff --git a/saoriapplication.cpp b/saoriapplication.cpp index ec1ae58..110176e 100644 --- a/saoriapplication.cpp +++ b/saoriapplication.cpp @@ -46,18 +46,26 @@ loadSettings(); QDir dir; - if (!dir.mkpath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation))) { + if (dir.mkpath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation))) { + m_cacheDirectory = QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); + } else { m_cacheDirectory = dir; } - if (!dir.mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation))) { + if (dir.mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation))) { + m_dataDirectory = QDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); + } else { m_dataDirectory = dir; } + m_db = QSqlDatabase::addDatabase("QSQLITE"); + m_db.setDatabaseName(m_dataDirectory.absolutePath() + "/" + SAORI_SQLFILE); + m_db.open(); } SaoriApplication::~SaoriApplication() { saveInstancesSettings(); saveAccountsSettings(); + m_db.close(); } Saoridon *SaoriApplication::findInstance(QUrl instance) diff --git a/saoriapplication.h b/saoriapplication.h index dc471f2..7c6ae94 100644 --- a/saoriapplication.h +++ b/saoriapplication.h @@ -33,6 +33,7 @@ #include #include #include +#include class SaoriApplication : public QApplication { @@ -55,6 +56,7 @@ static SaoriApplication *m_self; QDir m_cacheDirectory; QDir m_dataDirectory; + QSqlDatabase m_db; protected: void loadSettings();