mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-02 09:23:18 +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()) {
|
||||
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();
|
||||
rebuildQMLTasksList();
|
||||
}
|
||||
|
@ -227,3 +236,8 @@ QVariant Backend::getFiles()
|
|||
{
|
||||
return QVariant::fromValue(QMLTasksFiles);
|
||||
}
|
||||
|
||||
QString Backend::getTagColor(QString tag)
|
||||
{
|
||||
return tagsConfig[tag];
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <QtCore/QString>
|
||||
#include <QtQml/qqmlregistration.h>
|
||||
#include <memory>
|
||||
#include <qmap.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 removeTodo(int todoIndex);
|
||||
Q_INVOKABLE void hideCompletedTasks(bool shouldHide);
|
||||
Q_INVOKABLE QString getTagColor(QString tag);
|
||||
|
||||
private:
|
||||
void rebuildQMLTasksList();
|
||||
|
@ -70,6 +72,7 @@ class Backend : public QObject
|
|||
QList<QString> QMLTags;
|
||||
QList<QString> QMLActiveTagsFilter;
|
||||
QList<QString> QMLActiveFilesFilter;
|
||||
QMap<QString, QString> tagsConfig;
|
||||
|
||||
bool shouldHideCompletedTasks_ = true;
|
||||
|
||||
|
|
|
@ -64,8 +64,14 @@ ColumnLayout {
|
|||
Layout.fillWidth: true
|
||||
color: backend.activeTagsFilter.includes(modelData) ? MiraiColorPalette.filterSelected : mouse.hovered ? MiraiColorPalette.filterHovered : "transparent"
|
||||
radius: 4
|
||||
QtObject {
|
||||
id: internal
|
||||
property string configTagColor: backend.getTagColor(modelData)
|
||||
}
|
||||
AppText {
|
||||
|
||||
text: modelData
|
||||
color: internal.configTagColor != "" ? internal.configTagColor : MiraiColorPalette.text
|
||||
padding: 4
|
||||
}
|
||||
MouseArea {
|
||||
|
|
|
@ -18,8 +18,13 @@ Rectangle {
|
|||
implicitHeight: childrenRect.height
|
||||
radius: 8
|
||||
|
||||
QtObject {
|
||||
id: internal
|
||||
property string configTagColor: backend.getTagColor(control.text)
|
||||
}
|
||||
|
||||
AppText {
|
||||
color: control.textColor
|
||||
color: internal.configTagColor != "" ? internal.configTagColor : control.textColor
|
||||
padding: 2
|
||||
leftPadding: 6
|
||||
rightPadding: 6
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue