summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouie S <louie@example.com>2024-03-12 17:13:50 -0400
committerLouie S <louie@example.com>2024-03-12 17:13:50 -0400
commite9c68303aaa353f003a0c68d11d04b9c6062104b (patch)
tree319da294a4b35bea46471d5c9d04ddebe3c40024
parent7aadb8987a6e044c7922817ce797332c4f037476 (diff)
Remove settings file, integrate into assignmentList.cpp
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/assignmentList.cpp12
-rw-r--r--src/settings.cpp14
-rw-r--r--src/settings.h8
4 files changed, 7 insertions, 29 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6e40f3a..44b4646 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -63,8 +63,6 @@ set(project_sources
"src/rule.h"
"src/ruleLayout.cpp"
"src/ruleLayout.h"
- "src/settings.cpp"
- "src/settings.h"
)
add_executable(assignment-list
diff --git a/src/assignmentList.cpp b/src/assignmentList.cpp
index 09ef6e3..953d443 100644
--- a/src/assignmentList.cpp
+++ b/src/assignmentList.cpp
@@ -2,6 +2,7 @@
#include <QApplication>
#include <QCoreApplication>
#include <QDate>
+#include <QDir>
#include <QFile>
#include <QMessageBox>
#include <QObject>
@@ -18,7 +19,6 @@
#include "entryLayout.h"
#include "groupLayout.h"
#include "preferencesDialog.h"
-#include "settings.h"
AssignmentList::AssignmentList() {
// set QSettings information
@@ -35,12 +35,14 @@ AssignmentList::AssignmentList() {
void AssignmentList::initializeSettings() {
QSettings settings;
- QFile path = settings.fileName();
+ QDir local_data_dir(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
- if(!path.exists()) {
- qDebug() << "Creating Config";
- Settings::createConfig();
+ settings.beginGroup("paths");
+ if(!settings.contains("db_path")) {
+ qDebug() << "Setting default db_path";
+ settings.setValue("db_path", local_data_dir.filePath("data.db"));
}
+ settings.endGroup();
}
void AssignmentList::initializeUI() {
diff --git a/src/settings.cpp b/src/settings.cpp
deleted file mode 100644
index 4fe67d1..0000000
--- a/src/settings.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <QDir>
-#include <QSettings>
-#include <QStandardPaths>
-
-#include "settings.h"
-
-void Settings::createConfig() {
- QSettings settings;
- QDir local_data_dir(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
-
- settings.beginGroup("paths");
- settings.setValue("db_path", local_data_dir.filePath("data.db"));
- settings.endGroup();
-}
diff --git a/src/settings.h b/src/settings.h
deleted file mode 100644
index bec3c22..0000000
--- a/src/settings.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef SETTINGS_H
-#define SETTINGS_H
-
-namespace Settings {
- void createConfig();
-};
-
-#endif