mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-03 18:23:19 +00:00
Add color to tags
This commit is contained in:
parent
689eea07a7
commit
dc4f0795c7
4 changed files with 29 additions and 1 deletions
|
@ -43,6 +43,15 @@ Backend::Backend()
|
||||||
for (const QJsonValueRef &filePath : jsonFilesPath.toArray()) {
|
for (const QJsonValueRef &filePath : jsonFilesPath.toArray()) {
|
||||||
mirai.loadFile(filePath.toString().toStdString());
|
mirai.loadFile(filePath.toString().toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto jsonTagsConfig = json["tags"];
|
||||||
|
if (jsonTagsConfig.isObject()) {
|
||||||
|
for (auto &jsonTagConfigKey : jsonTagsConfig.toObject().keys()) {
|
||||||
|
tagsConfig[jsonTagConfigKey] =
|
||||||
|
jsonTagsConfig.toObject()[jsonTagConfigKey].toObject()["color"].toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
view = mirai.getTasks();
|
view = mirai.getTasks();
|
||||||
rebuildQMLTasksList();
|
rebuildQMLTasksList();
|
||||||
}
|
}
|
||||||
|
@ -227,3 +236,8 @@ QVariant Backend::getFiles()
|
||||||
{
|
{
|
||||||
return QVariant::fromValue(QMLTasksFiles);
|
return QVariant::fromValue(QMLTasksFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Backend::getTagColor(QString tag)
|
||||||
|
{
|
||||||
|
return tagsConfig[tag];
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
#include <QtQml/qqmlregistration.h>
|
#include <QtQml/qqmlregistration.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <qmap.h>
|
||||||
|
|
||||||
#include "TaskItem.h"
|
#include "TaskItem.h"
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ class Backend : public QObject
|
||||||
Q_INVOKABLE void updateTodo(int todoIndex, QString state, QString text, QString date);
|
Q_INVOKABLE void updateTodo(int todoIndex, QString state, QString text, QString date);
|
||||||
Q_INVOKABLE void removeTodo(int todoIndex);
|
Q_INVOKABLE void removeTodo(int todoIndex);
|
||||||
Q_INVOKABLE void hideCompletedTasks(bool shouldHide);
|
Q_INVOKABLE void hideCompletedTasks(bool shouldHide);
|
||||||
|
Q_INVOKABLE QString getTagColor(QString tag);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void rebuildQMLTasksList();
|
void rebuildQMLTasksList();
|
||||||
|
@ -70,6 +72,7 @@ class Backend : public QObject
|
||||||
QList<QString> QMLTags;
|
QList<QString> QMLTags;
|
||||||
QList<QString> QMLActiveTagsFilter;
|
QList<QString> QMLActiveTagsFilter;
|
||||||
QList<QString> QMLActiveFilesFilter;
|
QList<QString> QMLActiveFilesFilter;
|
||||||
|
QMap<QString, QString> tagsConfig;
|
||||||
|
|
||||||
bool shouldHideCompletedTasks_ = true;
|
bool shouldHideCompletedTasks_ = true;
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,14 @@ ColumnLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
color: backend.activeTagsFilter.includes(modelData) ? MiraiColorPalette.filterSelected : mouse.hovered ? MiraiColorPalette.filterHovered : "transparent"
|
color: backend.activeTagsFilter.includes(modelData) ? MiraiColorPalette.filterSelected : mouse.hovered ? MiraiColorPalette.filterHovered : "transparent"
|
||||||
radius: 4
|
radius: 4
|
||||||
|
QtObject {
|
||||||
|
id: internal
|
||||||
|
property string configTagColor: backend.getTagColor(modelData)
|
||||||
|
}
|
||||||
AppText {
|
AppText {
|
||||||
|
|
||||||
text: modelData
|
text: modelData
|
||||||
|
color: internal.configTagColor != "" ? internal.configTagColor : MiraiColorPalette.text
|
||||||
padding: 4
|
padding: 4
|
||||||
}
|
}
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
|
|
@ -18,8 +18,13 @@ Rectangle {
|
||||||
implicitHeight: childrenRect.height
|
implicitHeight: childrenRect.height
|
||||||
radius: 8
|
radius: 8
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
id: internal
|
||||||
|
property string configTagColor: backend.getTagColor(control.text)
|
||||||
|
}
|
||||||
|
|
||||||
AppText {
|
AppText {
|
||||||
color: control.textColor
|
color: internal.configTagColor != "" ? internal.configTagColor : control.textColor
|
||||||
padding: 2
|
padding: 2
|
||||||
leftPadding: 6
|
leftPadding: 6
|
||||||
rightPadding: 6
|
rightPadding: 6
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue