Compare commits
1 Commits
v0.3.1-bet
...
0.3.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69f4ec570a |
@@ -4,8 +4,8 @@ greaterThan(QT_MAJOR_VERSION, 5): QT += widgets
|
|||||||
|
|
||||||
CONFIG += c++17
|
CONFIG += c++17
|
||||||
|
|
||||||
win32:VERSION = 0.3.0.0 # major.minor.patch.build
|
win32:VERSION = 0.3.1.0 # major.minor.patch.build
|
||||||
else:VERSION = 0.3.0 # major.minor.patch
|
else:VERSION = 0.3.1 # major.minor.patch
|
||||||
|
|
||||||
DEFINES += APP_VERSION=\"\\\"$${VERSION}\\\"\"
|
DEFINES += APP_VERSION=\"\\\"$${VERSION}\\\"\"
|
||||||
DEFINES += APP_NAME=\"\\\"TaskBoard\\\"\"
|
DEFINES += APP_NAME=\"\\\"TaskBoard\\\"\"
|
||||||
@@ -77,10 +77,12 @@ SOURCES += \
|
|||||||
src/frames/namedialog.cpp \
|
src/frames/namedialog.cpp \
|
||||||
src/frames/prefdialog.cpp \
|
src/frames/prefdialog.cpp \
|
||||||
src/models/filter.cpp \
|
src/models/filter.cpp \
|
||||||
|
src/models/generalpreferences.cpp \
|
||||||
src/models/priority.cpp \
|
src/models/priority.cpp \
|
||||||
src/models/status.cpp \
|
src/models/status.cpp \
|
||||||
src/models/task.cpp \
|
src/models/task.cpp \
|
||||||
src/frames/taskdialog.cpp \
|
src/frames/taskdialog.cpp \
|
||||||
|
src/services/configservice.cpp \
|
||||||
src/services/taskstateservice.cpp \
|
src/services/taskstateservice.cpp \
|
||||||
src/tools.cpp
|
src/tools.cpp
|
||||||
|
|
||||||
@@ -93,10 +95,12 @@ HEADERS += \
|
|||||||
src/frames/namedialog.h \
|
src/frames/namedialog.h \
|
||||||
src/frames/prefdialog.h \
|
src/frames/prefdialog.h \
|
||||||
src/models/filter.h \
|
src/models/filter.h \
|
||||||
|
src/models/generalpreferences.h \
|
||||||
src/models/priority.h \
|
src/models/priority.h \
|
||||||
src/models/status.h \
|
src/models/status.h \
|
||||||
src/models/task.h \
|
src/models/task.h \
|
||||||
src/frames/taskdialog.h \
|
src/frames/taskdialog.h \
|
||||||
|
src/services/configservice.h \
|
||||||
src/services/taskstateservice.h \
|
src/services/taskstateservice.h \
|
||||||
src/tools.h
|
src/tools.h
|
||||||
|
|
||||||
|
|||||||
@@ -11,17 +11,17 @@ BoardConfigDialog::BoardConfigDialog(Board *b, QWidget *parent) :
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->nameField->setText(b->getName());
|
ui->nameField->setText(b->getName());
|
||||||
ui->descriptionField->setPlainText(b->getDescription());
|
ui->descriptionField->setPlainText(b->getDescription());
|
||||||
if (!b->isAutoStatus())
|
ui->boardStatusModeComboBox->setCurrentIndex(b->getStatusMode());
|
||||||
|
if (b->getStatusMode() == CUSTOM_STATUS_MODE)
|
||||||
{
|
{
|
||||||
QVector<Status> statuses = TaskStateService::getInstance()->getStatuses();
|
QVector<Status> statuses = TaskStateService::getInstance()->getStatuses();
|
||||||
foreach (Status s, statuses)
|
foreach (Status s, statuses)
|
||||||
{
|
{
|
||||||
ui->statusCombobox->addItem(s.getName(), s.getUUID());
|
ui->statusCombobox->addItem(s.getName(), s.getUUID());
|
||||||
}
|
}
|
||||||
ui->autoStatusCheckbox->setChecked(false);
|
|
||||||
ui->statusCombobox->setEnabled(true);
|
ui->statusCombobox->setEnabled(true);
|
||||||
}
|
}
|
||||||
connect(ui->autoStatusCheckbox, &QCheckBox::stateChanged, this, &BoardConfigDialog::onAutoStatusCheckboxChange);
|
connect(ui->boardStatusModeComboBox, &QComboBox::currentIndexChanged, this, &BoardConfigDialog::onAutoStatusCheckboxChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
BoardConfigDialog::~BoardConfigDialog()
|
BoardConfigDialog::~BoardConfigDialog()
|
||||||
@@ -39,14 +39,14 @@ const QString BoardConfigDialog::getDescription()
|
|||||||
return ui->descriptionField->toPlainText();
|
return ui->descriptionField->toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BoardConfigDialog::isAutoStatus()
|
uint8_t BoardConfigDialog::getBoardStatusMode()
|
||||||
{
|
{
|
||||||
return ui->autoStatusCheckbox->isChecked();
|
return ui->boardStatusModeComboBox->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString BoardConfigDialog::getStatus()
|
const QString BoardConfigDialog::getStatus()
|
||||||
{
|
{
|
||||||
if (!ui->autoStatusCheckbox->isChecked())
|
if (ui->boardStatusModeComboBox->currentIndex() == CUSTOM_STATUS_MODE)
|
||||||
{
|
{
|
||||||
if (!ui->statusCombobox->currentData().isNull())
|
if (!ui->statusCombobox->currentData().isNull())
|
||||||
{
|
{
|
||||||
@@ -56,9 +56,9 @@ const QString BoardConfigDialog::getStatus()
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoardConfigDialog::onAutoStatusCheckboxChange(int state)
|
void BoardConfigDialog::onAutoStatusCheckboxChange(int status)
|
||||||
{
|
{
|
||||||
if (state == Qt::CheckState::Unchecked)
|
if (status == CUSTOM_STATUS_MODE)
|
||||||
{
|
{
|
||||||
QVector<Status> statuses = TaskStateService::getInstance()->getStatuses();
|
QVector<Status> statuses = TaskStateService::getInstance()->getStatuses();
|
||||||
foreach (Status s, statuses)
|
foreach (Status s, statuses)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public:
|
|||||||
|
|
||||||
const QString getName();
|
const QString getName();
|
||||||
const QString getDescription();
|
const QString getDescription();
|
||||||
bool isAutoStatus();
|
uint8_t getBoardStatusMode();
|
||||||
const QString getStatus();
|
const QString getStatus();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|||||||
@@ -42,17 +42,37 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="autoStatusCheckbox">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Auto determine status</string>
|
<string>Board status mode</string>
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<widget class="QComboBox" name="boardStatusModeComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Auto</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Manual</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>None</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="statusContainer">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|||||||
@@ -355,22 +355,12 @@ void MainWindow::onEditNameBoardMenu()
|
|||||||
QString newDesc = dialog.getDescription();
|
QString newDesc = dialog.getDescription();
|
||||||
b->setName(newName);
|
b->setName(newName);
|
||||||
b->setDescription(newDesc);
|
b->setDescription(newDesc);
|
||||||
if (!dialog.isAutoStatus())
|
|
||||||
{
|
|
||||||
std::optional<Status> status = TaskStateService::getInstance()->getStatusByUUID(dialog.getStatus());
|
std::optional<Status> status = TaskStateService::getInstance()->getStatusByUUID(dialog.getStatus());
|
||||||
if (status.has_value())
|
if (status.has_value())
|
||||||
{
|
{
|
||||||
b->setDirtyStatus(status.value());
|
b->setStatus(status.value());
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b->removeDirtyStatus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b->removeDirtyStatus();
|
|
||||||
}
|
}
|
||||||
|
b->setStatusMode(dialog.getBoardStatusMode());
|
||||||
QListWidgetItem *item = ui->boardList->item(i);
|
QListWidgetItem *item = ui->boardList->item(i);
|
||||||
item->setText(newName);
|
item->setText(newName);
|
||||||
item->setToolTip(newDesc);
|
item->setToolTip(newDesc);
|
||||||
|
|||||||
@@ -59,6 +59,52 @@
|
|||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QWidget" name="tab_3">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>General</string>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>161</width>
|
||||||
|
<height>18</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>At startup</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>40</y>
|
||||||
|
<width>81</width>
|
||||||
|
<height>18</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Open...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox" name="comboBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>100</x>
|
||||||
|
<y>35</y>
|
||||||
|
<width>521</width>
|
||||||
|
<height>26</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Status</string>
|
<string>Status</string>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#define UUID_KEY "uuid"
|
#define UUID_KEY "uuid"
|
||||||
#define DESCRIPTION_KEY "description"
|
#define DESCRIPTION_KEY "description"
|
||||||
#define AUTOSTATUS_KEY "auto_status"
|
#define AUTOSTATUS_KEY "auto_status"
|
||||||
|
#define STATUSMODE_KEY "status_mode"
|
||||||
#define STATUS_KEY "status"
|
#define STATUS_KEY "status"
|
||||||
|
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
@@ -19,6 +20,7 @@ Board::Board(QString name, QString description)
|
|||||||
this->uuid = uuid.toString(QUuid::WithoutBraces);
|
this->uuid = uuid.toString(QUuid::WithoutBraces);
|
||||||
this->name = name;
|
this->name = name;
|
||||||
this->description = description;
|
this->description = description;
|
||||||
|
this->statusMode = NO_STATUS_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Board::Board(QJsonObject obj)
|
Board::Board(QJsonObject obj)
|
||||||
@@ -27,7 +29,19 @@ Board::Board(QJsonObject obj)
|
|||||||
this->uuid = obj[UUID_KEY].toString(uuid.toString(QUuid::WithoutBraces));
|
this->uuid = obj[UUID_KEY].toString(uuid.toString(QUuid::WithoutBraces));
|
||||||
this->name = obj[NAME_KEY].toString("!Missing name!");
|
this->name = obj[NAME_KEY].toString("!Missing name!");
|
||||||
this->description = obj[DESCRIPTION_KEY].toString("");
|
this->description = obj[DESCRIPTION_KEY].toString("");
|
||||||
this->autoStatus = obj[AUTOSTATUS_KEY].toBool(true);
|
if (obj.contains(AUTOSTATUS_KEY))
|
||||||
|
{
|
||||||
|
this->statusMode = obj[AUTOSTATUS_KEY].toBool(true) ? AUTO_STATUS_MODE : CUSTOM_STATUS_MODE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int val = obj[STATUSMODE_KEY].toInt(NO_STATUS_MODE);
|
||||||
|
if (val > std::numeric_limits<uint8_t>::max() || val < 0)
|
||||||
|
{
|
||||||
|
val = AUTO_STATUS_MODE;
|
||||||
|
}
|
||||||
|
this->statusMode = val;
|
||||||
|
}
|
||||||
this->statusUUID = obj[STATUS_KEY].toString();
|
this->statusUUID = obj[STATUS_KEY].toString();
|
||||||
QJsonArray jsonTasks = obj[TASKS_KEY].toArray();
|
QJsonArray jsonTasks = obj[TASKS_KEY].toArray();
|
||||||
foreach (QJsonValue value, jsonTasks) {
|
foreach (QJsonValue value, jsonTasks) {
|
||||||
@@ -62,7 +76,7 @@ const QString Board::getDescription()
|
|||||||
|
|
||||||
const QString Board::getStatus()
|
const QString Board::getStatus()
|
||||||
{
|
{
|
||||||
if (autoStatus)
|
if (statusMode == AUTO_STATUS_MODE)
|
||||||
{
|
{
|
||||||
TaskStateService *tss = TaskStateService::getInstance();
|
TaskStateService *tss = TaskStateService::getInstance();
|
||||||
int16_t h = -1;
|
int16_t h = -1;
|
||||||
@@ -78,12 +92,16 @@ const QString Board::getStatus()
|
|||||||
}
|
}
|
||||||
return suuid;
|
return suuid;
|
||||||
}
|
}
|
||||||
|
else if (statusMode == NO_STATUS_MODE)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return statusUUID;
|
return statusUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Board::isAutoStatus()
|
uint8_t Board::getStatusMode()
|
||||||
{
|
{
|
||||||
return autoStatus;
|
return statusMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Board::setName(const QString name)
|
void Board::setName(const QString name)
|
||||||
@@ -96,17 +114,21 @@ void Board::setDescription(const QString description)
|
|||||||
this->description = description;
|
this->description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Board::setDirtyStatus(Status s)
|
void Board::setStatus(Status s)
|
||||||
{
|
{
|
||||||
this->autoStatus = false;
|
this->statusMode = CUSTOM_STATUS_MODE;
|
||||||
this->statusUUID = s.getUUID();
|
this->statusUUID = s.getUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Board::removeDirtyStatus()
|
|
||||||
|
void Board::setStatusMode(uint8_t mode)
|
||||||
|
{
|
||||||
|
this->statusMode = mode;
|
||||||
|
if (mode != CUSTOM_STATUS_MODE)
|
||||||
{
|
{
|
||||||
this->autoStatus = true;
|
|
||||||
this->statusUUID = "";
|
this->statusUUID = "";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Board::add(Task t)
|
void Board::add(Task t)
|
||||||
{
|
{
|
||||||
@@ -145,7 +167,7 @@ const QJsonObject Board::toJson()
|
|||||||
obj[NAME_KEY] = this->name;
|
obj[NAME_KEY] = this->name;
|
||||||
obj[UUID_KEY] = this->uuid;
|
obj[UUID_KEY] = this->uuid;
|
||||||
obj[STATUS_KEY] = this->statusUUID;
|
obj[STATUS_KEY] = this->statusUUID;
|
||||||
obj[AUTOSTATUS_KEY] = this->autoStatus;
|
obj[STATUSMODE_KEY] = this->statusMode;
|
||||||
obj[TASKS_KEY] = array;
|
obj[TASKS_KEY] = array;
|
||||||
obj[DESCRIPTION_KEY] = description;
|
obj[DESCRIPTION_KEY] = description;
|
||||||
return obj;
|
return obj;
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "status.h"
|
#include "status.h"
|
||||||
|
|
||||||
|
#define AUTO_STATUS_MODE 0
|
||||||
|
#define CUSTOM_STATUS_MODE 1
|
||||||
|
#define NO_STATUS_MODE 2
|
||||||
|
|
||||||
class Board
|
class Board
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -19,12 +23,12 @@ public:
|
|||||||
const QString getName();
|
const QString getName();
|
||||||
const QString getDescription();
|
const QString getDescription();
|
||||||
const QString getStatus();
|
const QString getStatus();
|
||||||
bool isAutoStatus();
|
uint8_t getStatusMode();
|
||||||
|
|
||||||
void setName(const QString name);
|
void setName(const QString name);
|
||||||
void setDescription(const QString description);
|
void setDescription(const QString description);
|
||||||
void setDirtyStatus(Status s);
|
void setStatus(Status s);
|
||||||
void removeDirtyStatus();
|
void setStatusMode(uint8_t mode);
|
||||||
|
|
||||||
void add(Task);
|
void add(Task);
|
||||||
void remove(uint16_t index);
|
void remove(uint16_t index);
|
||||||
@@ -41,8 +45,7 @@ private:
|
|||||||
QString description;
|
QString description;
|
||||||
|
|
||||||
QString statusUUID;
|
QString statusUUID;
|
||||||
bool autoStatus;
|
uint8_t statusMode;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BOARD_H
|
#endif // BOARD_H
|
||||||
|
|||||||
55
src/models/generalpreferences.cpp
Normal file
55
src/models/generalpreferences.cpp
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#include "generalpreferences.h"
|
||||||
|
|
||||||
|
#define PRELOAD_TYPE_KEY "preload_type"
|
||||||
|
#define PRELOAD_FACE_UUID_KEY "pr_face_uuid"
|
||||||
|
|
||||||
|
GeneralPreferences::GeneralPreferences()
|
||||||
|
{
|
||||||
|
this->preloadType = NO_PRELOAD_TYPE;
|
||||||
|
this->preloadUUID = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
GeneralPreferences::GeneralPreferences(QJsonObject obj)
|
||||||
|
{
|
||||||
|
int val = obj[PRELOAD_TYPE_KEY].toInt(NO_PRELOAD_TYPE);
|
||||||
|
if (val > std::numeric_limits<uint8_t>::max() || val < 0)
|
||||||
|
{
|
||||||
|
val = NO_PRELOAD_TYPE;
|
||||||
|
}
|
||||||
|
this->preloadType = val;
|
||||||
|
this->preloadUUID = obj[PRELOAD_FACE_UUID_KEY].toString("");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t GeneralPreferences::getPreloadType()
|
||||||
|
{
|
||||||
|
return this->preloadType;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<QString> GeneralPreferences::getPreloadUUID()
|
||||||
|
{
|
||||||
|
if (this->preloadType == NO_PRELOAD_TYPE || this->preloadUUID.isEmpty())
|
||||||
|
{
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
return std::optional<QString> {this->preloadUUID};
|
||||||
|
}
|
||||||
|
|
||||||
|
void GeneralPreferences::setPreloadType(uint8_t type)
|
||||||
|
{
|
||||||
|
this->preloadType = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GeneralPreferences::setPreloadUUID(QString uuid)
|
||||||
|
{
|
||||||
|
this->preloadUUID = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QJsonObject GeneralPreferences::toJson()
|
||||||
|
{
|
||||||
|
QJsonObject obj;
|
||||||
|
|
||||||
|
obj[PRELOAD_TYPE_KEY] = this->preloadType;
|
||||||
|
obj[PRELOAD_FACE_UUID_KEY] = this->preloadUUID;
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
31
src/models/generalpreferences.h
Normal file
31
src/models/generalpreferences.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#ifndef GENERALPREFERENCES_H
|
||||||
|
#define GENERALPREFERENCES_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
#define NO_PRELOAD_TYPE 0
|
||||||
|
#define FILTER_PRELOAD_TYPE 1
|
||||||
|
#define BOARD_PRELOAD_TYPE 2
|
||||||
|
|
||||||
|
class GeneralPreferences
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GeneralPreferences();
|
||||||
|
GeneralPreferences(QJsonObject);
|
||||||
|
|
||||||
|
uint8_t getPreloadType();
|
||||||
|
std::optional<QString> getPreloadUUID();
|
||||||
|
|
||||||
|
void setPreloadType(uint8_t type);
|
||||||
|
void setPreloadUUID(QString uuid);
|
||||||
|
|
||||||
|
const QJsonObject toJson();
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint8_t preloadType;
|
||||||
|
QString preloadUUID;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GENERALPREFERENCES_H
|
||||||
33
src/services/configservice.cpp
Normal file
33
src/services/configservice.cpp
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#include "configservice.h"
|
||||||
|
|
||||||
|
ConfigService *ConfigService::instance = nullptr;
|
||||||
|
|
||||||
|
ConfigService::~ConfigService()
|
||||||
|
{
|
||||||
|
delete data;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigService *ConfigService::getInstance()
|
||||||
|
{
|
||||||
|
if (instance == nullptr)
|
||||||
|
{
|
||||||
|
instance = new ConfigService();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigService::loadConfig(GeneralPreferences data)
|
||||||
|
{
|
||||||
|
delete this->data;
|
||||||
|
this->data = new GeneralPreferences(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
GeneralPreferences *ConfigService::getConfig()
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigService::ConfigService()
|
||||||
|
{
|
||||||
|
data = new GeneralPreferences();
|
||||||
|
}
|
||||||
22
src/services/configservice.h
Normal file
22
src/services/configservice.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef CONFIGSERVICE_H
|
||||||
|
#define CONFIGSERVICE_H
|
||||||
|
|
||||||
|
#include "../models/generalpreferences.h"
|
||||||
|
|
||||||
|
class ConfigService
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
~ConfigService();
|
||||||
|
static ConfigService *getInstance();
|
||||||
|
|
||||||
|
void loadConfig(GeneralPreferences);
|
||||||
|
GeneralPreferences *getConfig();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static ConfigService *instance;
|
||||||
|
ConfigService();
|
||||||
|
|
||||||
|
GeneralPreferences *data;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CONFIGSERVICE_H
|
||||||
Reference in New Issue
Block a user