Load and generate default status

This commit is contained in:
2024-10-31 08:11:03 +01:00
parent e40dfb8f69
commit 09e5f4cd41
6 changed files with 89 additions and 21 deletions

View File

@@ -28,8 +28,10 @@ QString AboutDialog::getCompilerInfo()
#elif __GNUC__ #elif __GNUC__
#ifdef __MINGW32__ #ifdef __MINGW32__
return QString("MinGW_%1.%2").arg(QString::number(__MINGW32_MAJOR_VERSION), QString::number(__MINGW32_MINOR_VERSION)); return QString("MinGW_%1.%2").arg(QString::number(__MINGW32_MAJOR_VERSION), QString::number(__MINGW32_MINOR_VERSION));
#else #elif __linux__
return QString("GLIBC_%1.%2").arg(QString::number(__GLIBC__), QString::number(__GLIBC_MINOR__)); return QString("GLIBC_%1.%2").arg(QString::number(__GLIBC__), QString::number(__GLIBC_MINOR__));
#else
return "unknown";
#endif #endif
#elif _MSC_VER #elif _MSC_VER
return QString("MSVC_%1").arg(_MSC_VER); return QString("MSVC_%1").arg(_MSC_VER);

View File

@@ -5,6 +5,7 @@
#define STATUS_KEY "status" #define STATUS_KEY "status"
#define BOARDS_KEY "boards" #define BOARDS_KEY "boards"
#define FILTERS_KEY "filters" #define FILTERS_KEY "filters"
#define DEFAULT_STATUS "default_status"
#include <QUuid> #include <QUuid>
#include <QColor> #include <QColor>
@@ -486,6 +487,14 @@ void MainWindow::init()
} }
TaskStateService::getInstance()->updatePriorities(priorities); TaskStateService::getInstance()->updatePriorities(priorities);
TaskStateService::getInstance()->updateStatuses(statuses); TaskStateService::getInstance()->updateStatuses(statuses);
QString defaultStatusUUID = save[DEFAULT_STATUS].toString("");
for (Status s : TaskStateService::getInstance()->getStatuses())
{
if (s.getUUID() == defaultStatusUUID)
{
TaskStateService::getInstance()->setDefaultStatus(s);
}
}
redrawFilterList(); redrawFilterList();
redrawBoardList(); redrawBoardList();
return; return;
@@ -571,6 +580,7 @@ const QJsonDocument MainWindow::getJsonSave()
obj[STATUS_KEY] = jsonStatus; obj[STATUS_KEY] = jsonStatus;
obj[BOARDS_KEY] = jsonBoards; obj[BOARDS_KEY] = jsonBoards;
obj[FILTERS_KEY] = jsonFilters; obj[FILTERS_KEY] = jsonFilters;
obj[DEFAULT_STATUS] = TaskStateService::getInstance()->getDefaultStatus().getUUID();
doc.setObject(obj); doc.setObject(obj);
return doc; return doc;
} }

View File

@@ -48,6 +48,8 @@ private:
void init(); void init();
// properties
int16_t selectedBoardIndex; int16_t selectedBoardIndex;
int16_t selectedFilterIndex; int16_t selectedFilterIndex;
@@ -60,6 +62,8 @@ private:
QVector<Board*> boards; QVector<Board*> boards;
QVector<Filter> filters; QVector<Filter> filters;
// functions
QVector<Priority> defaultPriorities(); QVector<Priority> defaultPriorities();
QVector<Status> defaultStatus(); QVector<Status> defaultStatus();
QVector<Filter> defaultFilters(); QVector<Filter> defaultFilters();

View File

@@ -67,9 +67,9 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>40</x> <x>40</x>
<y>50</y> <y>64</y>
<width>571</width> <width>571</width>
<height>251</height> <height>161</height>
</rect> </rect>
</property> </property>
</widget> </widget>
@@ -80,7 +80,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>90</x> <x>90</x>
<y>350</y> <y>290</y>
<width>521</width> <width>521</width>
<height>21</height> <height>21</height>
</rect> </rect>
@@ -90,7 +90,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>352</y> <y>292</y>
<width>58</width> <width>58</width>
<height>16</height> <height>16</height>
</rect> </rect>
@@ -103,7 +103,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>390</y> <y>330</y>
<width>58</width> <width>58</width>
<height>16</height> <height>16</height>
</rect> </rect>
@@ -119,7 +119,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>90</x> <x>90</x>
<y>390</y> <y>330</y>
<width>113</width> <width>113</width>
<height>21</height> <height>21</height>
</rect> </rect>
@@ -135,7 +135,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>210</x> <x>210</x>
<y>390</y> <y>330</y>
<width>26</width> <width>26</width>
<height>22</height> <height>22</height>
</rect> </rect>
@@ -148,7 +148,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>570</x> <x>570</x>
<y>310</y> <y>240</y>
<width>41</width> <width>41</width>
<height>31</height> <height>31</height>
</rect> </rect>
@@ -164,7 +164,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>520</x> <x>520</x>
<y>310</y> <y>240</y>
<width>41</width> <width>41</width>
<height>31</height> <height>31</height>
</rect> </rect>
@@ -180,7 +180,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>310</y> <y>240</y>
<width>51</width> <width>51</width>
<height>31</height> <height>31</height>
</rect> </rect>
@@ -196,7 +196,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>70</x> <x>70</x>
<y>310</y> <y>240</y>
<width>51</width> <width>51</width>
<height>31</height> <height>31</height>
</rect> </rect>
@@ -227,10 +227,10 @@
<widget class="Line" name="line"> <widget class="Line" name="line">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>7</x> <x>10</x>
<y>65</y> <y>79</y>
<width>20</width> <width>20</width>
<height>221</height> <height>121</height>
</rect> </rect>
</property> </property>
<property name="orientation"> <property name="orientation">
@@ -240,8 +240,8 @@
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>-4</x> <x>0</x>
<y>46</y> <y>60</y>
<width>41</width> <width>41</width>
<height>16</height> <height>16</height>
</rect> </rect>
@@ -256,8 +256,8 @@
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_7">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>-3</x> <x>0</x>
<y>290</y> <y>204</y>
<width>41</width> <width>41</width>
<height>16</height> <height>16</height>
</rect> </rect>
@@ -269,6 +269,42 @@
<set>Qt::AlignmentFlag::AlignCenter</set> <set>Qt::AlignmentFlag::AlignCenter</set>
</property> </property>
</widget> </widget>
<widget class="Line" name="line_2">
<property name="geometry">
<rect>
<x>20</x>
<y>360</y>
<width>591</width>
<height>16</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
<widget class="QLabel" name="label_8">
<property name="geometry">
<rect>
<x>10</x>
<y>390</y>
<width>141</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Default (for new task)</string>
</property>
</widget>
<widget class="QComboBox" name="defaultStatusCombobox">
<property name="geometry">
<rect>
<x>440</x>
<y>384</y>
<width>171</width>
<height>26</height>
</rect>
</property>
</widget>
</widget> </widget>
<widget class="QWidget" name="tab_2"> <widget class="QWidget" name="tab_2">
<attribute name="title"> <attribute name="title">

View File

@@ -21,6 +21,11 @@ void TaskStateService::updatePriorities(QVector<Priority> priorities)
this->priorities = priorities; this->priorities = priorities;
} }
void TaskStateService::setDefaultStatus(Status s)
{
this->defaultStatus = s;
}
QVector<Status> TaskStateService::getStatuses() QVector<Status> TaskStateService::getStatuses()
{ {
return statuses; return statuses;
@@ -31,6 +36,11 @@ QVector<Priority> TaskStateService::getPriorities()
return priorities; return priorities;
} }
Status TaskStateService::getDefaultStatus()
{
return this->defaultStatus;
}
std::optional<Status> TaskStateService::getStatusByUUID(QString uuid) std::optional<Status> TaskStateService::getStatusByUUID(QString uuid)
{ {
foreach (Status s, statuses) { foreach (Status s, statuses) {
@@ -74,7 +84,9 @@ TaskStateService::TaskStateService()
priorities.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "Medium", QColor(176, 142, 48))); priorities.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "Medium", QColor(176, 142, 48)));
priorities.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "High", QColor(176, 67, 48))); priorities.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "High", QColor(176, 67, 48)));
statuses.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "To Do", QColor(143, 143, 143))); Status defaultStatus = Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "To Do", QColor(143, 143, 143));
statuses.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "Working on", QColor(95, 48, 176)));
statuses.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "Completed", QColor(48, 176, 73))); statuses.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "Completed", QColor(48, 176, 73)));
statuses.append(defaultStatus);
statuses.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "Working on", QColor(95, 48, 176)));
this->defaultStatus = defaultStatus;
} }

View File

@@ -13,9 +13,11 @@ public:
void updateStatuses(QVector<Status>); void updateStatuses(QVector<Status>);
void updatePriorities(QVector<Priority>); void updatePriorities(QVector<Priority>);
void setDefaultStatus(Status s);
QVector<Status> getStatuses(); QVector<Status> getStatuses();
QVector<Priority> getPriorities(); QVector<Priority> getPriorities();
Status getDefaultStatus();
std::optional<Status> getStatusByUUID(QString); std::optional<Status> getStatusByUUID(QString);
std::optional<Priority> getPriorityByUUID(QString); std::optional<Priority> getPriorityByUUID(QString);
@@ -26,6 +28,8 @@ private:
TaskStateService(); TaskStateService();
static TaskStateService *instance; static TaskStateService *instance;
Status defaultStatus = Status("", "", QColor::fromRgb(0,0,0));
QVector<Priority> priorities; QVector<Priority> priorities;
QVector<Status> statuses; QVector<Status> statuses;
}; };