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__
#ifdef __MINGW32__
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__));
#else
return "unknown";
#endif
#elif _MSC_VER
return QString("MSVC_%1").arg(_MSC_VER);

View File

@@ -5,6 +5,7 @@
#define STATUS_KEY "status"
#define BOARDS_KEY "boards"
#define FILTERS_KEY "filters"
#define DEFAULT_STATUS "default_status"
#include <QUuid>
#include <QColor>
@@ -486,6 +487,14 @@ void MainWindow::init()
}
TaskStateService::getInstance()->updatePriorities(priorities);
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();
redrawBoardList();
return;
@@ -571,6 +580,7 @@ const QJsonDocument MainWindow::getJsonSave()
obj[STATUS_KEY] = jsonStatus;
obj[BOARDS_KEY] = jsonBoards;
obj[FILTERS_KEY] = jsonFilters;
obj[DEFAULT_STATUS] = TaskStateService::getInstance()->getDefaultStatus().getUUID();
doc.setObject(obj);
return doc;
}

View File

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

View File

@@ -67,9 +67,9 @@
<property name="geometry">
<rect>
<x>40</x>
<y>50</y>
<y>64</y>
<width>571</width>
<height>251</height>
<height>161</height>
</rect>
</property>
</widget>
@@ -80,7 +80,7 @@
<property name="geometry">
<rect>
<x>90</x>
<y>350</y>
<y>290</y>
<width>521</width>
<height>21</height>
</rect>
@@ -90,7 +90,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>352</y>
<y>292</y>
<width>58</width>
<height>16</height>
</rect>
@@ -103,7 +103,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>390</y>
<y>330</y>
<width>58</width>
<height>16</height>
</rect>
@@ -119,7 +119,7 @@
<property name="geometry">
<rect>
<x>90</x>
<y>390</y>
<y>330</y>
<width>113</width>
<height>21</height>
</rect>
@@ -135,7 +135,7 @@
<property name="geometry">
<rect>
<x>210</x>
<y>390</y>
<y>330</y>
<width>26</width>
<height>22</height>
</rect>
@@ -148,7 +148,7 @@
<property name="geometry">
<rect>
<x>570</x>
<y>310</y>
<y>240</y>
<width>41</width>
<height>31</height>
</rect>
@@ -164,7 +164,7 @@
<property name="geometry">
<rect>
<x>520</x>
<y>310</y>
<y>240</y>
<width>41</width>
<height>31</height>
</rect>
@@ -180,7 +180,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>310</y>
<y>240</y>
<width>51</width>
<height>31</height>
</rect>
@@ -196,7 +196,7 @@
<property name="geometry">
<rect>
<x>70</x>
<y>310</y>
<y>240</y>
<width>51</width>
<height>31</height>
</rect>
@@ -227,10 +227,10 @@
<widget class="Line" name="line">
<property name="geometry">
<rect>
<x>7</x>
<y>65</y>
<x>10</x>
<y>79</y>
<width>20</width>
<height>221</height>
<height>121</height>
</rect>
</property>
<property name="orientation">
@@ -240,8 +240,8 @@
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>-4</x>
<y>46</y>
<x>0</x>
<y>60</y>
<width>41</width>
<height>16</height>
</rect>
@@ -256,8 +256,8 @@
<widget class="QLabel" name="label_7">
<property name="geometry">
<rect>
<x>-3</x>
<y>290</y>
<x>0</x>
<y>204</y>
<width>41</width>
<height>16</height>
</rect>
@@ -269,6 +269,42 @@
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</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 class="QWidget" name="tab_2">
<attribute name="title">

View File

@@ -21,6 +21,11 @@ void TaskStateService::updatePriorities(QVector<Priority> priorities)
this->priorities = priorities;
}
void TaskStateService::setDefaultStatus(Status s)
{
this->defaultStatus = s;
}
QVector<Status> TaskStateService::getStatuses()
{
return statuses;
@@ -31,6 +36,11 @@ QVector<Priority> TaskStateService::getPriorities()
return priorities;
}
Status TaskStateService::getDefaultStatus()
{
return this->defaultStatus;
}
std::optional<Status> TaskStateService::getStatusByUUID(QString uuid)
{
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), "High", QColor(176, 67, 48)));
statuses.append(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)));
Status defaultStatus = Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "To Do", QColor(143, 143, 143));
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 updatePriorities(QVector<Priority>);
void setDefaultStatus(Status s);
QVector<Status> getStatuses();
QVector<Priority> getPriorities();
Status getDefaultStatus();
std::optional<Status> getStatusByUUID(QString);
std::optional<Priority> getPriorityByUUID(QString);
@@ -26,6 +28,8 @@ private:
TaskStateService();
static TaskStateService *instance;
Status defaultStatus = Status("", "", QColor::fromRgb(0,0,0));
QVector<Priority> priorities;
QVector<Status> statuses;
};