shared: common: Retire 'firstrun' settings logic

This commit is contained in:
Albert S. 2022-06-13 20:13:14 +02:00
부모 a408173064
커밋 8a82da95bd
2개의 변경된 파일24개의 추가작업 그리고 29개의 파일을 삭제

파일 보기

@ -84,10 +84,10 @@ void Common::setPdfViewer()
void Common::ensureConfigured() void Common::ensureConfigured()
{ {
QSettings settings; QSettings settings;
QVariant firstRun = settings.value(SETTINGS_KEY_FIRSTRUN); QString dbpath = databasePath();
if(!firstRun.isValid()) if(dbpath == "")
{ {
QString dbpath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation); dbpath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
QDir dir; QDir dir;
if(!dir.exists(dbpath)) if(!dir.exists(dbpath))
{ {
@ -97,22 +97,14 @@ void Common::ensureConfigured()
} }
} }
dbpath += "/looqs.sqlite"; dbpath += "/looqs.sqlite";
}
if(!QFile::exists(dbpath))
{
if(!initSqliteDatabase(dbpath)) if(!initSqliteDatabase(dbpath))
{ {
throw LooqsGeneralException("Failed to initialize sqlite database"); throw LooqsGeneralException("Failed to initialize sqlite database");
} }
settings.setValue(SETTINGS_KEY_FIRSTRUN, false);
settings.setValue(SETTINGS_KEY_DBPATH, dbpath); settings.setValue(SETTINGS_KEY_DBPATH, dbpath);
setPdfViewer();
}
else
{
QString dbpath = databasePath();
if(!QFile::exists(dbpath))
{
throw LooqsGeneralException("Database " + dbpath + " was not found");
} }
DatabaseFactory factory{dbpath}; DatabaseFactory factory{dbpath};
auto db = factory.forCurrentThread(); auto db = factory.forCurrentThread();
@ -129,6 +121,10 @@ void Common::ensureConfigured()
migrator.performMigrations(); migrator.performMigrations();
migrationLogger << "Database upgraded successfully" << Qt::endl; migrationLogger << "Database upgraded successfully" << Qt::endl;
} }
QVariant pdfViewer = settings.value(SETTINGS_KEY_PDFVIEWER);
if(!pdfViewer.isValid())
{
setPdfViewer();
} }
} }

파일 보기

@ -4,7 +4,6 @@
#include <QFileInfo> #include <QFileInfo>
#define SETTINGS_KEY_DBPATH "dbpath" #define SETTINGS_KEY_DBPATH "dbpath"
#define SETTINGS_KEY_FIRSTRUN "firstrun"
#define SETTINGS_KEY_IPCSOCKETPATH "ipcsocketpath" #define SETTINGS_KEY_IPCSOCKETPATH "ipcsocketpath"
#define SETTINGS_KEY_PDFVIEWER "pdfviewer" #define SETTINGS_KEY_PDFVIEWER "pdfviewer"
#define SETTINGS_KEY_EXCLUDEDPATHS "excludedpaths" #define SETTINGS_KEY_EXCLUDEDPATHS "excludedpaths"