First commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.pro.*
|
||||||
24
Info.plist
Normal file
24
Info.plist
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>TaskBoard</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string></string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.aureliedelhaie.TaskBoard</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
<string>10.14</string>
|
||||||
|
<key>NSPrincipalClass</key>
|
||||||
|
<string>NSApplication</string>
|
||||||
|
<key>NSSupportsAutomaticGraphicsSwitching</key>
|
||||||
|
<true/>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string>icon.icns</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
108
TaskBoard.pro
Normal file
108
TaskBoard.pro
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
QT += core gui
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
DEFINES += APP_VERSION=\"\\\"$${VERSION}\\\"\"
|
||||||
|
DEFINES += APP_NAME=\"\\\"TaskBoard\\\"\"
|
||||||
|
|
||||||
|
win32 {
|
||||||
|
message("Build for Windows")
|
||||||
|
QMAKE_CXXFLAGS_RELEASE -= -O
|
||||||
|
QMAKE_CXXFLAGS_RELEASE -= -O1
|
||||||
|
QMAKE_CXXFLAGS_RELEASE *= -O2
|
||||||
|
DEFINES += APP_OS=\"\\\"Windows\\\"\"
|
||||||
|
DEFINES += APP_OS_VERSION=\"\\\"$$system(ver)\\\"\"
|
||||||
|
equals(QMAKE_TARGET.arch, arm64) {
|
||||||
|
message("CPU Architecture : aarch64")
|
||||||
|
DEFINES += APP_ARCH=\"\\\"arm64\\\"\"
|
||||||
|
}
|
||||||
|
equals(QMAKE_TARGET.arch, x86_64) {
|
||||||
|
message("CPU Architecture : x64")
|
||||||
|
QMAKE_CXXFLAGS_RELEASE += -favor:INTEL64
|
||||||
|
DEFINES += APP_ARCH=\"\\\"x64\\\"\"
|
||||||
|
}
|
||||||
|
RC_ICONS = icon.ico
|
||||||
|
QMAKE_TARGET_COMPANY = "Aurelie Delhaie"
|
||||||
|
QMAKE_TARGET_PRODUCT = "TaskBoard"
|
||||||
|
QMAKE_TARGET_DESCRIPTION = "TaskBoard"
|
||||||
|
}
|
||||||
|
|
||||||
|
macx {
|
||||||
|
message("Build for macOS")
|
||||||
|
ICON = icon.icns
|
||||||
|
QMAKE_INFO_PLIST = Info.plist
|
||||||
|
QMAKE_CXXFLAGS_RELEASE -= -O
|
||||||
|
QMAKE_CXXFLAGS_RELEASE -= -O1
|
||||||
|
QMAKE_CXXFLAGS_RELEASE -= -O2
|
||||||
|
QMAKE_CXXFLAGS_RELEASE *= -O3
|
||||||
|
QMAKE_APPLE_DEVICE_ARCHS = x86_64 arm64
|
||||||
|
DEFINES += APP_OS=\"\\\"macOS\\\"\"
|
||||||
|
DEFINES += APP_OS_VERSION=\"\\\"$$system(uname -r)\\\"\"
|
||||||
|
DEFINES += APP_ARCH=\"\\\"universal\\\"\"
|
||||||
|
}
|
||||||
|
|
||||||
|
linux-* {
|
||||||
|
message("Build for Linux")
|
||||||
|
DEFINES += APP_OS=\"\\\"$$system(cat /etc/issue | cut -d\' \' -f1)\\\"\"
|
||||||
|
DEFINES += APP_OS_VERSION=\"\\\"$$system(uname -r)\\\"\"
|
||||||
|
DEFINES += APP_ARCH=\"\\\"$$system(uname -m)\\\"\"
|
||||||
|
ARCH = $$system(uname -m)
|
||||||
|
equals(ARCH, aarch64) {
|
||||||
|
message("CPU Architecture : aarch64")
|
||||||
|
QMAKE_CXXFLAGS_RELEASE += -mtune=cortex-a72
|
||||||
|
}
|
||||||
|
equals(ARCH, amd64) {
|
||||||
|
message("CPU Architecture : amd64")
|
||||||
|
QMAKE_CXXFLAGS_RELEASE += -march=skylake
|
||||||
|
}
|
||||||
|
QMAKE_CXXFLAGS_RELEASE *= -O3
|
||||||
|
}
|
||||||
|
|
||||||
|
# You can make your code fail to compile if it uses deprecated APIs.
|
||||||
|
# In order to do so, uncomment the following line.
|
||||||
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
src/frames/aboutdialog.cpp \
|
||||||
|
src/models/board.cpp \
|
||||||
|
src/main.cpp \
|
||||||
|
src/frames/mainwindow.cpp \
|
||||||
|
src/frames/namedialog.cpp \
|
||||||
|
src/frames/prefdialog.cpp \
|
||||||
|
src/models/priority.cpp \
|
||||||
|
src/models/status.cpp \
|
||||||
|
src/models/task.cpp \
|
||||||
|
src/frames/taskdialog.cpp \
|
||||||
|
src/tools.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
src/frames/aboutdialog.h \
|
||||||
|
src/models/board.h \
|
||||||
|
src/frames/mainwindow.h \
|
||||||
|
src/frames/namedialog.h \
|
||||||
|
src/frames/prefdialog.h \
|
||||||
|
src/models/priority.h \
|
||||||
|
src/models/status.h \
|
||||||
|
src/models/task.h \
|
||||||
|
src/frames/taskdialog.h \
|
||||||
|
src/tools.h
|
||||||
|
|
||||||
|
FORMS += \
|
||||||
|
src/frames/aboutdialog.ui \
|
||||||
|
src/frames/mainwindow.ui \
|
||||||
|
src/frames/namedialog.ui \
|
||||||
|
src/frames/prefdialog.ui \
|
||||||
|
src/frames/taskdialog.ui
|
||||||
|
|
||||||
|
# Default rules for deployment.
|
||||||
|
qnx: target.path = /tmp/$${TARGET}/bin
|
||||||
|
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||||
|
!isEmpty(target.path): INSTALLS += target
|
||||||
|
|
||||||
|
RESOURCES += \
|
||||||
|
resources.qrc
|
||||||
5
resources.qrc
Normal file
5
resources.qrc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/images">
|
||||||
|
<file>resources/logo.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
||||||
BIN
resources/.DS_Store
vendored
Normal file
BIN
resources/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
resources/logo.png
Normal file
BIN
resources/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
BIN
src/.DS_Store
vendored
Normal file
BIN
src/.DS_Store
vendored
Normal file
Binary file not shown.
16
src/frames/aboutdialog.cpp
Normal file
16
src/frames/aboutdialog.cpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#include "aboutdialog.h"
|
||||||
|
#include "ui_aboutdialog.h"
|
||||||
|
|
||||||
|
AboutDialog::AboutDialog(QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::AboutDialog)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
ui->appName->setText(QString("%1 (%2)").arg(APP_NAME, APP_ARCH));
|
||||||
|
ui->version->setText(QString("v%1").arg(APP_VERSION));
|
||||||
|
}
|
||||||
|
|
||||||
|
AboutDialog::~AboutDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
22
src/frames/aboutdialog.h
Normal file
22
src/frames/aboutdialog.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef ABOUTDIALOG_H
|
||||||
|
#define ABOUTDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class AboutDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class AboutDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit AboutDialog(QWidget *parent = nullptr);
|
||||||
|
~AboutDialog();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::AboutDialog *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ABOUTDIALOG_H
|
||||||
116
src/frames/aboutdialog.ui
Normal file
116
src/frames/aboutdialog.ui
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>AboutDialog</class>
|
||||||
|
<widget class="QDialog" name="AboutDialog">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::ApplicationModal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>419</width>
|
||||||
|
<height>323</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>419</width>
|
||||||
|
<height>323</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>419</width>
|
||||||
|
<height>323</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>About TaskBoard</string>
|
||||||
|
</property>
|
||||||
|
<property name="modal">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>64</width>
|
||||||
|
<height>64</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>64</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">image: url(:/images/resources/logo.png);</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="appName">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">font-size: 20px;</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="version">
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="about">
|
||||||
|
<property name="text">
|
||||||
|
<string>Made with ♥ by Aurélie</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTextEdit" name="textEdit">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="html">
|
||||||
|
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
|
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
||||||
|
p, li { white-space: pre-wrap; }
|
||||||
|
hr { height: 1px; border-width: 0; }
|
||||||
|
</style></head><body style=" font-family:'.AppleSystemUIFont'; font-size:13pt; font-weight:400; font-style:normal;">
|
||||||
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:700;">TODO: </span>Third parties</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
283
src/frames/mainwindow.cpp
Normal file
283
src/frames/mainwindow.cpp
Normal file
@@ -0,0 +1,283 @@
|
|||||||
|
#include "mainwindow.h"
|
||||||
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
|
#include <QUuid>
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
|
#include "prefdialog.h"
|
||||||
|
#include "aboutdialog.h"
|
||||||
|
#include "namedialog.h"
|
||||||
|
#include "taskdialog.h"
|
||||||
|
#include "../tools.h"
|
||||||
|
|
||||||
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
|
: QMainWindow(parent)
|
||||||
|
, ui(new Ui::MainWindow)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
connect(ui->actionPreferences, &QAction::triggered, this, &MainWindow::openPreferences);
|
||||||
|
connect(ui->actionAbout, &QAction::triggered, this, &MainWindow::openAbout);
|
||||||
|
connect(ui->actionNew, &QAction::triggered, this, &MainWindow::onNewBoardClick);
|
||||||
|
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &MainWindow::onBoardSelected);
|
||||||
|
connect(ui->actionNew_task, &QAction::triggered, this, &MainWindow::onNewTaskClick);
|
||||||
|
connect(ui->treeWidget, &QTreeWidget::itemDoubleClicked, this, &MainWindow::onEditTask);
|
||||||
|
this->priorities = defaultPriorities();
|
||||||
|
this->status = defaultStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::~MainWindow()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < boards.count(); i++)
|
||||||
|
{
|
||||||
|
Board *b = boards.takeAt(i);
|
||||||
|
delete b;
|
||||||
|
}
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::openPreferences()
|
||||||
|
{
|
||||||
|
PrefDialog dialog(this);
|
||||||
|
if (dialog.exec() == QDialog::DialogCode::Accepted)
|
||||||
|
{
|
||||||
|
this->priorities = dialog.getPriorities();
|
||||||
|
this->status = dialog.getStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::openAbout()
|
||||||
|
{
|
||||||
|
AboutDialog dialog(this);
|
||||||
|
dialog.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onNewBoardClick()
|
||||||
|
{
|
||||||
|
NameDialog dialog("Create a board", "New empty board", this);
|
||||||
|
if (dialog.exec() == QDialog::DialogCode::Accepted)
|
||||||
|
{
|
||||||
|
QString name = dialog.getChoosenName();
|
||||||
|
Board *b = new Board(name);
|
||||||
|
boards.append(b);
|
||||||
|
QListWidgetItem *item = new QListWidgetItem(name);
|
||||||
|
ui->listWidget->addItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onNewTaskClick()
|
||||||
|
{
|
||||||
|
if (selectedBoardIndex > -1)
|
||||||
|
{
|
||||||
|
TaskDialog dialog(status, priorities, this);
|
||||||
|
if (dialog.exec() == QDialog::DialogCode::Accepted)
|
||||||
|
{
|
||||||
|
Task t = dialog.getTask();
|
||||||
|
Board *b = boards[selectedBoardIndex];
|
||||||
|
b->add(t);
|
||||||
|
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||||
|
item->setText(0, t.getTitle());
|
||||||
|
item->setText(1, getStatusLabel(t.getStatusUUID()));
|
||||||
|
item->setText(2, getPriorityLabel(t.getPriorityUUID()));
|
||||||
|
item->setText(3, t.getExpectedFor().toString());
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
bgColor = item->background(2);
|
||||||
|
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);
|
||||||
|
|
||||||
|
ui->treeWidget->addTopLevelItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onBoardSelected(int i)
|
||||||
|
{
|
||||||
|
selectedBoardIndex = i;
|
||||||
|
if (selectedBoardIndex > -1)
|
||||||
|
{
|
||||||
|
Board *b = boards[selectedBoardIndex];
|
||||||
|
ui->label->setText(b->getName());
|
||||||
|
ui->actionNew_task->setDisabled(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->label->setText("<- Select a board");
|
||||||
|
ui->actionNew_task->setDisabled(true);
|
||||||
|
}
|
||||||
|
redrawTaskTree();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onEditTask(QTreeWidgetItem *item)
|
||||||
|
{
|
||||||
|
if (item != nullptr && selectedBoardIndex > -1)
|
||||||
|
{
|
||||||
|
Board *b = boards[selectedBoardIndex];
|
||||||
|
int row = ui->treeWidget->indexOfTopLevelItem(item);
|
||||||
|
Task *t = b->taskAt(row);
|
||||||
|
if (t != nullptr)
|
||||||
|
{
|
||||||
|
TaskDialog dialog(t, status, priorities, this);
|
||||||
|
if (dialog.exec() == QDialog::DialogCode::Accepted)
|
||||||
|
{
|
||||||
|
Task editedTask = dialog.getTask();
|
||||||
|
t->update(editedTask);
|
||||||
|
item->setText(0, editedTask.getTitle());
|
||||||
|
item->setText(1, getStatusLabel(editedTask.getStatusUUID()));
|
||||||
|
item->setText(2, getPriorityLabel(editedTask.getPriorityUUID()));
|
||||||
|
item->setText(3, editedTask.getExpectedFor().toString());
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
bgColor = item->background(2);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<Priority> MainWindow::defaultPriorities()
|
||||||
|
{
|
||||||
|
QVector<Priority> res;
|
||||||
|
res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "Low", QColor::fromString("#309db0")));
|
||||||
|
res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "Medium", QColor::fromString("#b08e30")));
|
||||||
|
res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "High", QColor::fromString("#b04330")));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<Status> MainWindow::defaultStatus()
|
||||||
|
{
|
||||||
|
QVector<Status> res;
|
||||||
|
res.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "To Do", QColor::fromString("#8f8f8f")));
|
||||||
|
res.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "Working on", QColor::fromString("#5f30b0")));
|
||||||
|
res.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "Completed", QColor::fromString("#30b049")));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString MainWindow::getPriorityLabel(QString uuid)
|
||||||
|
{
|
||||||
|
QString res = "";
|
||||||
|
foreach (Priority p, priorities)
|
||||||
|
{
|
||||||
|
if (p.getUUID() == uuid)
|
||||||
|
{
|
||||||
|
res = p.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString MainWindow::getStatusLabel(QString uuid)
|
||||||
|
{
|
||||||
|
QString res = "";
|
||||||
|
foreach (Status s, status)
|
||||||
|
{
|
||||||
|
if (s.getUUID() == uuid)
|
||||||
|
{
|
||||||
|
res = s.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QColor MainWindow::getPriorityColor(QString uuid, QColor defaultColor)
|
||||||
|
{
|
||||||
|
QColor color = defaultColor;
|
||||||
|
foreach (Priority p, priorities)
|
||||||
|
{
|
||||||
|
if (p.getUUID() == uuid)
|
||||||
|
{
|
||||||
|
color = p.getColor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QColor MainWindow::getStatusColor(QString uuid, QColor defaultColor)
|
||||||
|
{
|
||||||
|
QColor color = defaultColor;
|
||||||
|
foreach (Status s, status)
|
||||||
|
{
|
||||||
|
if (s.getUUID() == uuid)
|
||||||
|
{
|
||||||
|
color = s.getColor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::redrawBoardList()
|
||||||
|
{
|
||||||
|
QListWidget *l = ui->listWidget;
|
||||||
|
for (int i = 0; i < l->count(); i++)
|
||||||
|
{
|
||||||
|
delete l->takeItem(i);
|
||||||
|
}
|
||||||
|
foreach (Board *b, boards)
|
||||||
|
{
|
||||||
|
QListWidgetItem *item = new QListWidgetItem(b->getName());
|
||||||
|
l->addItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::redrawTaskTree()
|
||||||
|
{
|
||||||
|
QTreeWidget *l = ui->treeWidget;
|
||||||
|
for (int i = 0; i < l->topLevelItemCount(); i++)
|
||||||
|
{
|
||||||
|
delete l->takeTopLevelItem(i);
|
||||||
|
}
|
||||||
|
if (selectedBoardIndex > -1)
|
||||||
|
{
|
||||||
|
Board *b = boards[selectedBoardIndex];
|
||||||
|
foreach (Task *t, b->getTasks())
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||||
|
item->setText(0, t->getTitle());
|
||||||
|
item->setText(1, getStatusLabel(t->getStatusUUID()));
|
||||||
|
item->setText(2, getPriorityLabel(t->getPriorityUUID()));
|
||||||
|
item->setText(3, t->getExpectedFor().toString());
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
bgColor = item->background(2);
|
||||||
|
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);
|
||||||
|
|
||||||
|
ui->treeWidget->addTopLevelItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
52
src/frames/mainwindow.h
Normal file
52
src/frames/mainwindow.h
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
#ifndef MAINWINDOW_H
|
||||||
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QTreeWidgetItem>
|
||||||
|
#include <QBrush>
|
||||||
|
|
||||||
|
#include "../models/priority.h"
|
||||||
|
#include "../models/status.h"
|
||||||
|
#include "../models/board.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
namespace Ui { class MainWindow; }
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
class MainWindow : public QMainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
MainWindow(QWidget *parent = nullptr);
|
||||||
|
~MainWindow();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void openPreferences();
|
||||||
|
void openAbout();
|
||||||
|
void onNewBoardClick();
|
||||||
|
void onNewTaskClick();
|
||||||
|
void onBoardSelected(int i);
|
||||||
|
void onEditTask(QTreeWidgetItem*);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::MainWindow *ui;
|
||||||
|
|
||||||
|
int selectedBoardIndex = -1;
|
||||||
|
QVector<Priority> priorities;
|
||||||
|
QVector<Status> status;
|
||||||
|
QVector<Board*> boards;
|
||||||
|
|
||||||
|
QVector<Priority> defaultPriorities();
|
||||||
|
QVector<Status> defaultStatus();
|
||||||
|
|
||||||
|
const QString getPriorityLabel(QString uuid);
|
||||||
|
const QString getStatusLabel(QString uuid);
|
||||||
|
|
||||||
|
const QColor getPriorityColor(QString uuid, QColor defaultColor);
|
||||||
|
const QColor getStatusColor(QString uuid, QColor defaultColor);
|
||||||
|
|
||||||
|
void redrawBoardList();
|
||||||
|
void redrawTaskTree();
|
||||||
|
};
|
||||||
|
#endif // MAINWINDOW_H
|
||||||
154
src/frames/mainwindow.ui
Normal file
154
src/frames/mainwindow.ui
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>MainWindow</class>
|
||||||
|
<widget class="QMainWindow" name="MainWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1159</width>
|
||||||
|
<height>702</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>1159</width>
|
||||||
|
<height>702</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>TaskBoard</string>
|
||||||
|
</property>
|
||||||
|
<property name="tabShape">
|
||||||
|
<enum>QTabWidget::Rounded</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="listWidget">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>250</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>250</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>26</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string><- Select a board</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTreeWidget" name="treeWidget">
|
||||||
|
<property name="alternatingRowColors">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="columnCount">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Name</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Status</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Priority</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>Expected for</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenuBar" name="menuBar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1159</width>
|
||||||
|
<height>24</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<widget class="QMenu" name="menuAbout">
|
||||||
|
<property name="title">
|
||||||
|
<string>About</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionPreferences"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionAbout"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuBoard">
|
||||||
|
<property name="title">
|
||||||
|
<string>Board</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionNew"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuTask">
|
||||||
|
<property name="title">
|
||||||
|
<string>Task</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionNew_task"/>
|
||||||
|
</widget>
|
||||||
|
<addaction name="menuBoard"/>
|
||||||
|
<addaction name="menuTask"/>
|
||||||
|
<addaction name="menuAbout"/>
|
||||||
|
</widget>
|
||||||
|
<action name="actionPreferences">
|
||||||
|
<property name="text">
|
||||||
|
<string>Preferences</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionNew">
|
||||||
|
<property name="text">
|
||||||
|
<string>New Board</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionAbout">
|
||||||
|
<property name="text">
|
||||||
|
<string>About TaskBoard</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionNew_task">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>New task</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
25
src/frames/namedialog.cpp
Normal file
25
src/frames/namedialog.cpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#include "namedialog.h"
|
||||||
|
#include "ui_namedialog.h"
|
||||||
|
|
||||||
|
NameDialog::NameDialog(QString label, QString defaultName, QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::NameDialog)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
this->setWindowTitle(label);
|
||||||
|
this->defaultName = defaultName;
|
||||||
|
}
|
||||||
|
|
||||||
|
NameDialog::~NameDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString NameDialog::getChoosenName()
|
||||||
|
{
|
||||||
|
if (ui->lineEdit->text().length() > 0)
|
||||||
|
{
|
||||||
|
return ui->lineEdit->text();
|
||||||
|
}
|
||||||
|
return defaultName;
|
||||||
|
}
|
||||||
25
src/frames/namedialog.h
Normal file
25
src/frames/namedialog.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef NAMEDIALOG_H
|
||||||
|
#define NAMEDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class NameDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class NameDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit NameDialog(QString label, QString defaultName, QWidget *parent = nullptr);
|
||||||
|
~NameDialog();
|
||||||
|
const QString getChoosenName();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::NameDialog *ui;
|
||||||
|
|
||||||
|
QString defaultName;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NAMEDIALOG_H
|
||||||
109
src/frames/namedialog.ui
Normal file
109
src/frames/namedialog.ui
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>NameDialog</class>
|
||||||
|
<widget class="QDialog" name="NameDialog">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::WindowModal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>133</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>400</width>
|
||||||
|
<height>133</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>400</width>
|
||||||
|
<height>133</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<property name="modal">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>40</x>
|
||||||
|
<y>90</y>
|
||||||
|
<width>341</width>
|
||||||
|
<height>32</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" name="lineEdit">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>50</y>
|
||||||
|
<width>381</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>30</y>
|
||||||
|
<width>58</width>
|
||||||
|
<height>16</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Name</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>NameDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>NameDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
||||||
209
src/frames/prefdialog.cpp
Normal file
209
src/frames/prefdialog.cpp
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
#include "prefdialog.h"
|
||||||
|
#include "ui_prefdialog.h"
|
||||||
|
|
||||||
|
#include <QColorDialog>
|
||||||
|
#include <QUuid>
|
||||||
|
|
||||||
|
#include "../tools.h"
|
||||||
|
|
||||||
|
PrefDialog::PrefDialog(QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::PrefDialog)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
connect(ui->addStatusButton, &QPushButton::clicked, this, &PrefDialog::onAddStatusButtonClick);
|
||||||
|
connect(ui->addPriorityButton, &QPushButton::clicked, this, &PrefDialog::onAddPriorityButtonClick);
|
||||||
|
connect(ui->statusListWidget, &QListWidget::currentRowChanged, this, &PrefDialog::onItemSelectionChange);
|
||||||
|
connect(ui->priorityListWidget, &QListWidget::currentRowChanged, this, &PrefDialog::onItemSelectionChange);
|
||||||
|
connect(ui->colorStatusButton, &QToolButton::clicked, this, &PrefDialog::onButtonColorButtonClick);
|
||||||
|
connect(ui->colorPriorityButton, &QToolButton::clicked, this, &PrefDialog::onButtonColorButtonClick);
|
||||||
|
connect(ui->nameStatusEdit, &QLineEdit::textEdited, this, &PrefDialog::onNameChange);
|
||||||
|
connect(ui->namePriorityEdit, &QLineEdit::textEdited, this, &PrefDialog::onNameChange);
|
||||||
|
connect(ui->removeStatusButton, &QPushButton::clicked, this, &PrefDialog::onRemoveStatusButtonClick);
|
||||||
|
connect(ui->removePriorityButton, &QPushButton::clicked, this, &PrefDialog::onRemovePriorityButtonClick);
|
||||||
|
}
|
||||||
|
|
||||||
|
PrefDialog::~PrefDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<Priority> PrefDialog::getPriorities()
|
||||||
|
{
|
||||||
|
int count = ui->priorityListWidget->count();
|
||||||
|
QVector<Priority> res;
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
QListWidgetItem *item = ui->priorityListWidget->item(i);
|
||||||
|
Priority p(priorityUUIDRef[i], item->text(), item->background().color());
|
||||||
|
res.append(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<Status> PrefDialog::getStatus()
|
||||||
|
{
|
||||||
|
int count = ui->statusListWidget->count();
|
||||||
|
QVector<Status> res;
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
QListWidgetItem *item = ui->statusListWidget->item(i);
|
||||||
|
Status s(statusUUIDRef[i], item->text(), item->background().color());
|
||||||
|
res.append(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrefDialog::onAddStatusButtonClick()
|
||||||
|
{
|
||||||
|
QColor bgColor = Tools::getRandomColor();
|
||||||
|
QListWidgetItem *item = new QListWidgetItem("New status");
|
||||||
|
QUuid uuid = QUuid::createUuid();
|
||||||
|
statusUUIDRef.append(uuid.toString(QUuid::WithoutBraces));
|
||||||
|
|
||||||
|
setItemColor(item, bgColor);
|
||||||
|
|
||||||
|
ui->statusListWidget->addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrefDialog::onAddPriorityButtonClick()
|
||||||
|
{
|
||||||
|
QColor bgColor = Tools::getRandomColor();
|
||||||
|
QListWidgetItem *item = new QListWidgetItem("Low");
|
||||||
|
QUuid uuid = QUuid::createUuid();
|
||||||
|
priorityUUIDRef.append(uuid.toString(QUuid::WithoutBraces));
|
||||||
|
|
||||||
|
setItemColor(item, bgColor);
|
||||||
|
|
||||||
|
ui->priorityListWidget->addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrefDialog::onItemSelectionChange(int index)
|
||||||
|
{
|
||||||
|
QListWidget *listWidget = static_cast<QListWidget*>(QObject::sender());
|
||||||
|
QPushButton *removeBtn;
|
||||||
|
QToolButton *colorBtn;
|
||||||
|
QLineEdit *nameEdit;
|
||||||
|
QLineEdit *colorEdit;
|
||||||
|
|
||||||
|
if (listWidget == ui->statusListWidget)
|
||||||
|
{
|
||||||
|
removeBtn = ui->removeStatusButton;
|
||||||
|
colorBtn = ui->colorStatusButton;
|
||||||
|
nameEdit = ui->nameStatusEdit;
|
||||||
|
colorEdit = ui->colorStatusEdit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
removeBtn = ui->removePriorityButton;
|
||||||
|
colorBtn = ui->colorPriorityButton;
|
||||||
|
nameEdit = ui->namePriorityEdit;
|
||||||
|
colorEdit = ui->colorPriorityEdit;
|
||||||
|
}
|
||||||
|
bool d = (index == -1);
|
||||||
|
removeBtn->setDisabled(d);
|
||||||
|
colorBtn->setDisabled(d);
|
||||||
|
nameEdit->setDisabled(d);
|
||||||
|
colorEdit->setDisabled(d);
|
||||||
|
if (!d)
|
||||||
|
{
|
||||||
|
QListWidgetItem *current = listWidget->item(index);
|
||||||
|
nameEdit->setText(current->text());
|
||||||
|
colorEdit->setText(current->background().color().name());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nameEdit->clear();
|
||||||
|
colorEdit->clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrefDialog::onButtonColorButtonClick()
|
||||||
|
{
|
||||||
|
QColorDialog dialog(this);
|
||||||
|
if (dialog.exec() == DialogCode::Accepted)
|
||||||
|
{
|
||||||
|
QToolButton *sender = static_cast<QToolButton*>(QObject::sender());
|
||||||
|
QLineEdit *colorEdit;
|
||||||
|
QListWidgetItem *item;
|
||||||
|
if (sender == ui->colorStatusButton)
|
||||||
|
{
|
||||||
|
colorEdit = ui->colorStatusEdit;
|
||||||
|
item = ui->statusListWidget->currentItem();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
colorEdit = ui->colorPriorityEdit;
|
||||||
|
item = ui->priorityListWidget->currentItem();
|
||||||
|
}
|
||||||
|
QColor selectedColor = dialog.selectedColor();
|
||||||
|
colorEdit->setText(selectedColor.name());
|
||||||
|
setItemColor(item, selectedColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrefDialog::onNameChange()
|
||||||
|
{
|
||||||
|
QLineEdit *sender = static_cast<QLineEdit*>(QObject::sender());
|
||||||
|
QListWidgetItem *item;
|
||||||
|
if (sender == ui->nameStatusEdit)
|
||||||
|
{
|
||||||
|
if (ui->statusListWidget->selectedItems().size() != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
item = ui->statusListWidget->currentItem();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ui->priorityListWidget->selectedItems().size() != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
item = ui->priorityListWidget->currentItem();
|
||||||
|
}
|
||||||
|
item->setText(sender->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrefDialog::onRemoveStatusButtonClick()
|
||||||
|
{
|
||||||
|
if (ui->statusListWidget->selectedItems().size() != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int index = ui->statusListWidget->currentRow();
|
||||||
|
delete ui->statusListWidget->takeItem(index);
|
||||||
|
statusUUIDRef.removeAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrefDialog::onRemovePriorityButtonClick()
|
||||||
|
{
|
||||||
|
if (ui->priorityListWidget->selectedItems().size() != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int index = ui->priorityListWidget->currentRow();
|
||||||
|
delete ui->priorityListWidget->takeItem(index);
|
||||||
|
priorityUUIDRef.removeAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrefDialog::setItemColor(QListWidgetItem *item, QColor bgColor)
|
||||||
|
{
|
||||||
|
QColor fgColor = Tools::getForegroundColor(bgColor);
|
||||||
|
|
||||||
|
// Set background
|
||||||
|
QBrush bg = item->background();
|
||||||
|
bg.setStyle(Qt::BrushStyle::SolidPattern);
|
||||||
|
bg.setColor(bgColor);
|
||||||
|
item->setBackground(bg);
|
||||||
|
|
||||||
|
// Set foreground
|
||||||
|
QBrush fg = item->foreground();
|
||||||
|
fg.setStyle(Qt::BrushStyle::SolidPattern);
|
||||||
|
fg.setColor(fgColor);
|
||||||
|
item->setForeground(fg);
|
||||||
|
}
|
||||||
44
src/frames/prefdialog.h
Normal file
44
src/frames/prefdialog.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#ifndef PREFDIALOG_H
|
||||||
|
#define PREFDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QColor>
|
||||||
|
#include <QListWidgetItem>
|
||||||
|
|
||||||
|
#include "../models/priority.h"
|
||||||
|
#include "../models/status.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class PrefDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class PrefDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit PrefDialog(QWidget *parent = nullptr);
|
||||||
|
~PrefDialog();
|
||||||
|
|
||||||
|
QVector<Priority> getPriorities();
|
||||||
|
QVector<Status> getStatus();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onAddStatusButtonClick();
|
||||||
|
void onAddPriorityButtonClick();
|
||||||
|
void onItemSelectionChange(int);
|
||||||
|
void onButtonColorButtonClick();
|
||||||
|
void onNameChange();
|
||||||
|
void onRemoveStatusButtonClick();
|
||||||
|
void onRemovePriorityButtonClick();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::PrefDialog *ui;
|
||||||
|
|
||||||
|
QVector<QString> statusUUIDRef;
|
||||||
|
QVector<QString> priorityUUIDRef;
|
||||||
|
|
||||||
|
void setItemColor(QListWidgetItem*, QColor);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PREFDIALOG_H
|
||||||
323
src/frames/prefdialog.ui
Normal file
323
src/frames/prefdialog.ui
Normal file
@@ -0,0 +1,323 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>PrefDialog</class>
|
||||||
|
<widget class="QDialog" name="PrefDialog">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::ApplicationModal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>655</width>
|
||||||
|
<height>535</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>655</width>
|
||||||
|
<height>535</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>655</width>
|
||||||
|
<height>535</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Preferences</string>
|
||||||
|
</property>
|
||||||
|
<property name="modal">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>300</x>
|
||||||
|
<y>490</y>
|
||||||
|
<width>341</width>
|
||||||
|
<height>32</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>631</width>
|
||||||
|
<height>471</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="tab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Status</string>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QListWidget" name="statusListWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>601</width>
|
||||||
|
<height>291</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" name="nameStatusEdit">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>90</x>
|
||||||
|
<y>350</y>
|
||||||
|
<width>521</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>352</y>
|
||||||
|
<width>58</width>
|
||||||
|
<height>16</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Name</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>390</y>
|
||||||
|
<width>58</width>
|
||||||
|
<height>16</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Color</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" name="colorStatusEdit">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>90</x>
|
||||||
|
<y>390</y>
|
||||||
|
<width>113</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QToolButton" name="colorStatusButton">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>210</x>
|
||||||
|
<y>390</y>
|
||||||
|
<width>26</width>
|
||||||
|
<height>22</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="addStatusButton">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>570</x>
|
||||||
|
<y>300</y>
|
||||||
|
<width>41</width>
|
||||||
|
<height>32</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>+</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="removeStatusButton">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>520</x>
|
||||||
|
<y>300</y>
|
||||||
|
<width>41</width>
|
||||||
|
<height>32</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>-</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_2">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Priorities</string>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QLineEdit" name="namePriorityEdit">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>90</x>
|
||||||
|
<y>350</y>
|
||||||
|
<width>521</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>352</y>
|
||||||
|
<width>58</width>
|
||||||
|
<height>16</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Name</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" name="colorPriorityEdit">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>90</x>
|
||||||
|
<y>390</y>
|
||||||
|
<width>113</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QListWidget" name="priorityListWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>601</width>
|
||||||
|
<height>291</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>390</y>
|
||||||
|
<width>58</width>
|
||||||
|
<height>16</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Color</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QToolButton" name="colorPriorityButton">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>210</x>
|
||||||
|
<y>390</y>
|
||||||
|
<width>26</width>
|
||||||
|
<height>22</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="addPriorityButton">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>570</x>
|
||||||
|
<y>300</y>
|
||||||
|
<width>41</width>
|
||||||
|
<height>32</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>+</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="removePriorityButton">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>520</x>
|
||||||
|
<y>300</y>
|
||||||
|
<width>41</width>
|
||||||
|
<height>32</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>-</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>PrefDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>PrefDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
||||||
111
src/frames/taskdialog.cpp
Normal file
111
src/frames/taskdialog.cpp
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
#include "taskdialog.h"
|
||||||
|
#include "ui_taskdialog.h"
|
||||||
|
|
||||||
|
#include <QDate>
|
||||||
|
|
||||||
|
TaskDialog::TaskDialog(QVector<Status> status, QVector<Priority> priorities, QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::TaskDialog)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
this->setWindowTitle("New task");
|
||||||
|
this->status = status;
|
||||||
|
this->priorities = priorities;
|
||||||
|
|
||||||
|
foreach (Status s, this->status)
|
||||||
|
{
|
||||||
|
ui->statusCombo->addItem(s.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (Priority p, this->priorities)
|
||||||
|
{
|
||||||
|
ui->priorityCombo->addItem(p.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate expectedFor = QDate::currentDate();
|
||||||
|
expectedFor = expectedFor.addDays(10);
|
||||||
|
ui->expectedForEdit->setDate(expectedFor);
|
||||||
|
}
|
||||||
|
|
||||||
|
TaskDialog::TaskDialog(Task *t, QVector<Status> status, QVector<Priority> priorities, QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::TaskDialog)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
this->setWindowTitle("Edit task");
|
||||||
|
this->status = status;
|
||||||
|
this->priorities = priorities;
|
||||||
|
|
||||||
|
foreach (Status s, this->status)
|
||||||
|
{
|
||||||
|
ui->statusCombo->addItem(s.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (Priority p, this->priorities)
|
||||||
|
{
|
||||||
|
ui->priorityCombo->addItem(p.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// set fields
|
||||||
|
ui->nameEdit->setText(t->getTitle());
|
||||||
|
ui->descriptionEdit->setMarkdown(t->getDescription());
|
||||||
|
ui->expectedForEdit->setDate(t->getExpectedFor());
|
||||||
|
|
||||||
|
if (t->getPriorityUUID().length() > 0)
|
||||||
|
{
|
||||||
|
int refindex = -1;
|
||||||
|
for (int i = 0; i < this->priorities.count(); i++)
|
||||||
|
{
|
||||||
|
if (this->priorities[i].getUUID() == t->getPriorityUUID())
|
||||||
|
{
|
||||||
|
refindex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (refindex > -1)
|
||||||
|
{
|
||||||
|
ui->priorityCombo->setCurrentIndex(refindex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t->getStatusUUID().length() > 0)
|
||||||
|
{
|
||||||
|
int refindex = -1;
|
||||||
|
for (int i = 0; i < this->status.count(); i++)
|
||||||
|
{
|
||||||
|
if (this->status[i].getUUID() == t->getStatusUUID())
|
||||||
|
{
|
||||||
|
refindex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (refindex > -1)
|
||||||
|
{
|
||||||
|
ui->statusCombo->setCurrentIndex(refindex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TaskDialog::~TaskDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
Task TaskDialog::getTask()
|
||||||
|
{
|
||||||
|
QString title = ui->nameEdit->text();
|
||||||
|
QString description = ui->descriptionEdit->toMarkdown(QTextDocument::MarkdownFeature::MarkdownDialectCommonMark);
|
||||||
|
QDate expectedFor = ui->expectedForEdit->date();
|
||||||
|
QString priorityUUID = "";
|
||||||
|
if (ui->priorityCombo->currentIndex() > -1)
|
||||||
|
{
|
||||||
|
Priority priority = priorities[ui->priorityCombo->currentIndex()];
|
||||||
|
priorityUUID = priority.getUUID();
|
||||||
|
}
|
||||||
|
QString statusUUID = "";
|
||||||
|
if (ui->statusCombo->currentIndex() > -1)
|
||||||
|
{
|
||||||
|
Status s = status[ui->statusCombo->currentIndex()];
|
||||||
|
statusUUID = s.getUUID();
|
||||||
|
}
|
||||||
|
return Task(title, description, expectedFor, priorityUUID, statusUUID);
|
||||||
|
}
|
||||||
33
src/frames/taskdialog.h
Normal file
33
src/frames/taskdialog.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef TASKDIALOG_H
|
||||||
|
#define TASKDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
#include "../models/status.h"
|
||||||
|
#include "../models/priority.h"
|
||||||
|
#include "../models/task.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class TaskDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class TaskDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit TaskDialog(QVector<Status>, QVector<Priority>, QWidget *parent = nullptr);
|
||||||
|
TaskDialog(Task*, QVector<Status>, QVector<Priority>, QWidget *parent = nullptr);
|
||||||
|
~TaskDialog();
|
||||||
|
|
||||||
|
Task getTask();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::TaskDialog *ui;
|
||||||
|
|
||||||
|
QVector<Status> status;
|
||||||
|
QVector<Priority> priorities;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TASKDIALOG_H
|
||||||
159
src/frames/taskdialog.ui
Normal file
159
src/frames/taskdialog.ui
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>TaskDialog</class>
|
||||||
|
<widget class="QDialog" name="TaskDialog">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::WindowModal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>481</width>
|
||||||
|
<height>557</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>481</width>
|
||||||
|
<height>557</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<property name="modal">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Name</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="nameEdit"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Description</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTextEdit" name="descriptionEdit"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Expected for</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDateEdit" name="expectedForEdit"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Status</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="statusCombo"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Priority</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="priorityCombo"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>TaskDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>TaskDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
||||||
11
src/main.cpp
Normal file
11
src/main.cpp
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#include "frames/mainwindow.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
MainWindow w;
|
||||||
|
w.show();
|
||||||
|
return a.exec();
|
||||||
|
}
|
||||||
BIN
src/models/.DS_Store
vendored
Normal file
BIN
src/models/.DS_Store
vendored
Normal file
Binary file not shown.
40
src/models/board.cpp
Normal file
40
src/models/board.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#include "board.h"
|
||||||
|
|
||||||
|
Board::Board(QString name)
|
||||||
|
{
|
||||||
|
this->name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
Board::~Board()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < tasks.count(); i++)
|
||||||
|
{
|
||||||
|
Task *t = tasks.takeAt(i);
|
||||||
|
delete t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString Board::getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Board::add(Task t)
|
||||||
|
{
|
||||||
|
tasks.append(new Task(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
Task *Board::taskAt(int i)
|
||||||
|
{
|
||||||
|
if (i >= 0 && i < tasks.count())
|
||||||
|
{
|
||||||
|
return tasks[i];
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QVector<Task *> Board::getTasks()
|
||||||
|
{
|
||||||
|
return tasks;
|
||||||
|
}
|
||||||
|
|
||||||
26
src/models/board.h
Normal file
26
src/models/board.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#ifndef BOARD_H
|
||||||
|
#define BOARD_H
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
#include "task.h"
|
||||||
|
|
||||||
|
class Board
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Board(QString name);
|
||||||
|
~Board();
|
||||||
|
|
||||||
|
const QString getName();
|
||||||
|
void add(Task);
|
||||||
|
Task *taskAt(int);
|
||||||
|
const QVector<Task*> getTasks();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVector<Task*> tasks;
|
||||||
|
QString name;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BOARD_H
|
||||||
23
src/models/priority.cpp
Normal file
23
src/models/priority.cpp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#include "priority.h"
|
||||||
|
|
||||||
|
Priority::Priority(QString uuid, QString name, QColor color)
|
||||||
|
{
|
||||||
|
this->uuid = uuid;
|
||||||
|
this->name = name;
|
||||||
|
this->color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString Priority::getName()
|
||||||
|
{
|
||||||
|
return this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString Priority::getUUID()
|
||||||
|
{
|
||||||
|
return this->uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QColor Priority::getColor()
|
||||||
|
{
|
||||||
|
return this->color;
|
||||||
|
}
|
||||||
23
src/models/priority.h
Normal file
23
src/models/priority.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef PRIORITY_H
|
||||||
|
#define PRIORITY_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
|
class Priority
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Priority(QString uuid, QString name, QColor color);
|
||||||
|
|
||||||
|
const QString getName();
|
||||||
|
const QString getUUID();
|
||||||
|
const QColor getColor();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString uuid;
|
||||||
|
QString name;
|
||||||
|
QColor color;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PRIORITY_H
|
||||||
23
src/models/status.cpp
Normal file
23
src/models/status.cpp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#include "status.h"
|
||||||
|
|
||||||
|
Status::Status(QString uuid, QString name, QColor color)
|
||||||
|
{
|
||||||
|
this->uuid = uuid;
|
||||||
|
this->name = name;
|
||||||
|
this->color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString Status::getName()
|
||||||
|
{
|
||||||
|
return this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString Status::getUUID()
|
||||||
|
{
|
||||||
|
return this->uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QColor Status::getColor()
|
||||||
|
{
|
||||||
|
return this->color;
|
||||||
|
}
|
||||||
22
src/models/status.h
Normal file
22
src/models/status.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef STATUS_H
|
||||||
|
#define STATUS_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
|
class Status
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Status(QString uuid, QString name, QColor color);
|
||||||
|
|
||||||
|
const QString getName();
|
||||||
|
const QString getUUID();
|
||||||
|
const QColor getColor();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString uuid;
|
||||||
|
QString name;
|
||||||
|
QColor color;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // STATUS_H
|
||||||
44
src/models/task.cpp
Normal file
44
src/models/task.cpp
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#include "task.h"
|
||||||
|
|
||||||
|
Task::Task(QString title, QString description, QDate expectedFor, QString priorityUUID, QString statusUUID)
|
||||||
|
{
|
||||||
|
this->title = title;
|
||||||
|
this->description = description;
|
||||||
|
this->expectedFor = expectedFor;
|
||||||
|
this->priorityUUID = priorityUUID;
|
||||||
|
this->statusUUID = statusUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString Task::getTitle()
|
||||||
|
{
|
||||||
|
return this->title;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString Task::getDescription()
|
||||||
|
{
|
||||||
|
return this->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QDate Task::getExpectedFor()
|
||||||
|
{
|
||||||
|
return this->expectedFor;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString Task::getPriorityUUID()
|
||||||
|
{
|
||||||
|
return this->priorityUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString Task::getStatusUUID()
|
||||||
|
{
|
||||||
|
return this->statusUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Task::update(Task t)
|
||||||
|
{
|
||||||
|
this->title = t.title;
|
||||||
|
this->description = t.description;
|
||||||
|
this->expectedFor = t.expectedFor;
|
||||||
|
this->priorityUUID = t.priorityUUID;
|
||||||
|
this->statusUUID = t.statusUUID;
|
||||||
|
}
|
||||||
28
src/models/task.h
Normal file
28
src/models/task.h
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#ifndef TASK_H
|
||||||
|
#define TASK_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QDate>
|
||||||
|
|
||||||
|
class Task
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Task(QString title, QString description, QDate expectedFor, QString priorityUUID, QString statusUUID);
|
||||||
|
|
||||||
|
const QString getTitle();
|
||||||
|
const QString getDescription();
|
||||||
|
const QDate getExpectedFor();
|
||||||
|
const QString getPriorityUUID();
|
||||||
|
const QString getStatusUUID();
|
||||||
|
|
||||||
|
void update(Task);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString title;
|
||||||
|
QString description;
|
||||||
|
QDate expectedFor;
|
||||||
|
QString priorityUUID;
|
||||||
|
QString statusUUID;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TASK_H
|
||||||
48
src/tools.cpp
Normal file
48
src/tools.cpp
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#include "tools.h"
|
||||||
|
|
||||||
|
#define BRIGHTNESS_THRESHOLD 170
|
||||||
|
#define WHITECOLOR 240
|
||||||
|
#define BLACKCOLOR 15
|
||||||
|
|
||||||
|
Tools::Tools()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor Tools::getRandomColor()
|
||||||
|
{
|
||||||
|
srand(time(0));
|
||||||
|
int r = arc4random() % 255;
|
||||||
|
int g = arc4random() % 255;
|
||||||
|
int b = arc4random() % 255;
|
||||||
|
return QColor(r, g, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor Tools::getForegroundColor(QColor background)
|
||||||
|
{
|
||||||
|
int avg = background.red();
|
||||||
|
avg += background.green();
|
||||||
|
avg += background.blue();
|
||||||
|
avg = avg / 3;
|
||||||
|
|
||||||
|
int avg2 = background.red();
|
||||||
|
avg2 += background.green();
|
||||||
|
avg2 = avg2 / 2;
|
||||||
|
|
||||||
|
int avg3 = background.red();
|
||||||
|
avg3 += background.blue();
|
||||||
|
avg3 = avg3 / 2;
|
||||||
|
|
||||||
|
int avg4 = background.green();
|
||||||
|
avg4 += background.blue();
|
||||||
|
avg4 = avg4 / 2;
|
||||||
|
|
||||||
|
if (avg < BRIGHTNESS_THRESHOLD && avg2 < BRIGHTNESS_THRESHOLD && avg3 < BRIGHTNESS_THRESHOLD && avg4 < BRIGHTNESS_THRESHOLD)
|
||||||
|
{
|
||||||
|
return QColor(WHITECOLOR, WHITECOLOR, WHITECOLOR);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QColor(BLACKCOLOR, BLACKCOLOR, BLACKCOLOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
16
src/tools.h
Normal file
16
src/tools.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef TOOLS_H
|
||||||
|
#define TOOLS_H
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
|
class Tools
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Tools();
|
||||||
|
|
||||||
|
static QColor getRandomColor();
|
||||||
|
static QColor getForegroundColor(QColor background);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TOOLS_H
|
||||||
Reference in New Issue
Block a user