From 361dda51baf2f08ba339a0ba97f14dca09388964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lie=20Delhaie?= Date: Sun, 25 Dec 2022 10:59:15 +0100 Subject: [PATCH] Fix task priority/status color, fix editable field in config, Fix column length, Fix redraw after updating config --- TaskBoard.pro | 4 +- src/frames/mainwindow.cpp | 124 +++++++++++++------------------------- src/frames/mainwindow.h | 1 + src/frames/prefdialog.ui | 16 +++-- 4 files changed, 57 insertions(+), 88 deletions(-) diff --git a/TaskBoard.pro b/TaskBoard.pro index 65e0306..5c719c4 100644 --- a/TaskBoard.pro +++ b/TaskBoard.pro @@ -4,8 +4,8 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++17 -win32:VERSION = 0.1.0.0 # major.minor.patch.build -else:VERSION = 0.1.0 # major.minor.patch +win32:VERSION = 0.1.1.0 # major.minor.patch.build +else:VERSION = 0.1.1 # major.minor.patch DEFINES += APP_VERSION=\"\\\"$${VERSION}\\\"\" DEFINES += APP_NAME=\"\\\"TaskBoard\\\"\" diff --git a/src/frames/mainwindow.cpp b/src/frames/mainwindow.cpp index f2e87bd..5a3de9c 100644 --- a/src/frames/mainwindow.cpp +++ b/src/frames/mainwindow.cpp @@ -24,6 +24,10 @@ MainWindow::MainWindow(QWidget *parent) ui->setupUi(this); init(); this->selectedBoardIndex = -1; + // Change "name" column size + ui->taskList->header()->resizeSection(0, 520); + // Change "status" column size + ui->taskList->header()->resizeSection(1, 150); connect(ui->actionPreferences, &QAction::triggered, this, &MainWindow::openPreferences); connect(ui->actionAbout, &QAction::triggered, this, &MainWindow::openAbout); connect(ui->actionNew, &QAction::triggered, this, &MainWindow::onNewBoardClick); @@ -54,6 +58,7 @@ void MainWindow::openPreferences() this->priorities = dialog.getPriorities(); this->status = dialog.getStatus(); save(); + redrawTaskTree(); } } @@ -126,33 +131,7 @@ void MainWindow::onNewTaskClick() Board *b = boards[selectedBoardIndex]; b->add(t); QTreeWidgetItem *item = new QTreeWidgetItem(); - item->setText(0, t.getTitle()); - item->setText(3, t.getExpectedFor().toString()); - - if (!t.getStatusUUID().isEmpty()) - { - item->setText(1, getStatusLabel(t.getStatusUUID())); - QBrush bgColor = item->background(1); - QBrush fgColor = item->foreground(1); - bgColor.setColor(getStatusColor(t.getStatusUUID(), bgColor.color())); - bgColor.setStyle(Qt::BrushStyle::SolidPattern); - fgColor.setColor(Tools::getForegroundColor(bgColor.color())); - item->setBackground(1, bgColor); - item->setForeground(1, fgColor); - } - - if (!t.getPriorityUUID().isEmpty()) - { - item->setText(2, getPriorityLabel(t.getPriorityUUID())); - QBrush bgColor = item->background(2); - QBrush fgColor = item->foreground(2); - bgColor.setColor(getPriorityColor(t.getPriorityUUID(), bgColor.color())); - bgColor.setStyle(Qt::BrushStyle::SolidPattern); - fgColor.setColor(Tools::getForegroundColor(bgColor.color())); - item->setBackground(2, bgColor); - item->setForeground(2, fgColor); - } - + updateTaskRow(item, t); ui->taskList->addTopLevelItem(item); save(); } @@ -190,33 +169,7 @@ void MainWindow::onEditTask(QTreeWidgetItem *item) { Task editedTask = dialog.getTask(); t->update(editedTask); - item->setText(0, editedTask.getTitle()); - item->setText(3, editedTask.getExpectedFor().toString()); - - if (!editedTask.getStatusUUID().isEmpty()) - { - item->setText(1, getStatusLabel(editedTask.getStatusUUID())); - QBrush bgColor = item->background(1); - QBrush fgColor = item->foreground(1); - bgColor.setColor(getStatusColor(editedTask.getStatusUUID(), bgColor.color())); - bgColor.setStyle(Qt::BrushStyle::SolidPattern); - fgColor.setColor(Tools::getForegroundColor(bgColor.color())); - item->setBackground(1, bgColor); - item->setForeground(1, fgColor); - } - - if (!editedTask.getPriorityUUID().isEmpty()) - { - item->setText(2, getPriorityLabel(editedTask.getPriorityUUID())); - QBrush bgColor = item->background(2); - QBrush fgColor = item->foreground(2); - bgColor.setColor(getPriorityColor(editedTask.getPriorityUUID(), bgColor.color())); - bgColor.setStyle(Qt::BrushStyle::SolidPattern); - fgColor.setColor(Tools::getForegroundColor(bgColor.color())); - item->setBackground(2, bgColor); - item->setForeground(2, fgColor); - } - + updateTaskRow(item, editedTask); save(); } } @@ -312,6 +265,7 @@ void MainWindow::init() QVector MainWindow::defaultPriorities() { QVector res; + res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "None", QColor("#d9d9d9"))); res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "Low", QColor("#309db0"))); res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "Medium", QColor("#b08e30"))); res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "High", QColor("#b04330"))); @@ -402,6 +356,40 @@ const QJsonDocument MainWindow::getJsonSave() return doc; } +void MainWindow::updateTaskRow(QTreeWidgetItem *item, Task t) +{ + item->setText(0, t.getTitle()); + item->setToolTip(0, t.getDescription()); + item->setText(3, t.getExpectedFor().toString()); + + if (!t.getStatusUUID().isEmpty()) + { + item->setText(1, getStatusLabel(t.getStatusUUID())); + QBrush bgColor = item->background(1); + QBrush fgColor = item->foreground(1); + bgColor.setColor(getStatusColor(t.getStatusUUID(), bgColor.color())); + bgColor.setStyle(Qt::BrushStyle::SolidPattern); + fgColor.setColor(Tools::getForegroundColor(bgColor.color())); + fgColor.setStyle(Qt::BrushStyle::SolidPattern); + item->setBackground(1, bgColor); + item->setForeground(1, fgColor); + } + + if (!t.getPriorityUUID().isEmpty()) + { + item->setText(2, getPriorityLabel(t.getPriorityUUID())); + QBrush bgColor = item->background(2); + QBrush fgColor = item->foreground(2); + bgColor.setColor(getPriorityColor(t.getPriorityUUID(), bgColor.color())); + bgColor.setStyle(Qt::BrushStyle::SolidPattern); + fgColor.setColor(Tools::getForegroundColor(bgColor.color())); + fgColor.setStyle(Qt::BrushStyle::SolidPattern); + item->setBackground(2, bgColor); + item->setForeground(2, fgColor); + } +} + + void MainWindow::redrawBoardList() { QListWidget *l = ui->boardList; @@ -431,33 +419,7 @@ void MainWindow::redrawTaskTree() foreach (Task *t, b->getTasks()) { QTreeWidgetItem *item = new QTreeWidgetItem(); - item->setText(0, t->getTitle()); - item->setText(3, t->getExpectedFor().toString()); - - if (!t->getStatusUUID().isEmpty()) - { - item->setText(1, getStatusLabel(t->getStatusUUID())); - QBrush bgColor = item->background(1); - QBrush fgColor = item->foreground(1); - bgColor.setColor(getStatusColor(t->getStatusUUID(), bgColor.color())); - bgColor.setStyle(Qt::BrushStyle::SolidPattern); - fgColor.setColor(Tools::getForegroundColor(bgColor.color())); - item->setBackground(1, bgColor); - item->setForeground(1, fgColor); - } - - if (!t->getPriorityUUID().isEmpty()) - { - item->setText(2, getPriorityLabel(t->getPriorityUUID())); - QBrush bgColor = item->background(2); - QBrush fgColor = item->foreground(2); - bgColor.setColor(getPriorityColor(t->getPriorityUUID(), bgColor.color())); - bgColor.setStyle(Qt::BrushStyle::SolidPattern); - fgColor.setColor(Tools::getForegroundColor(bgColor.color())); - item->setBackground(2, bgColor); - item->setForeground(2, fgColor); - } - + updateTaskRow(item, *t); ui->taskList->addTopLevelItem(item); } } diff --git a/src/frames/mainwindow.h b/src/frames/mainwindow.h index f9a6491..807dedd 100644 --- a/src/frames/mainwindow.h +++ b/src/frames/mainwindow.h @@ -57,6 +57,7 @@ private: const QJsonDocument getJsonSave(); + void updateTaskRow(QTreeWidgetItem *item, Task t); void redrawBoardList(); void redrawTaskTree(); void save(); diff --git a/src/frames/prefdialog.ui b/src/frames/prefdialog.ui index 94dbc82..dde847f 100644 --- a/src/frames/prefdialog.ui +++ b/src/frames/prefdialog.ui @@ -124,6 +124,9 @@ 21 + + true + @@ -145,7 +148,7 @@ 570 - 300 + 310 41 32 @@ -161,9 +164,9 @@ 520 - 300 + 310 41 - 32 + 31 @@ -213,6 +216,9 @@ 21 + + true + @@ -257,7 +263,7 @@ 570 - 300 + 310 41 32 @@ -273,7 +279,7 @@ 520 - 300 + 310 41 32