first commit

This commit is contained in:
2026-03-14 05:27:54 +01:00
commit 523a4085cc
14 changed files with 991 additions and 0 deletions

84
.gitignore vendored Normal file
View File

@@ -0,0 +1,84 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
**/.qmlls.ini
# qtcreator generated files
*.pro.user*
*.qbs.user*
CMakeLists.txt.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe
# Directories with generated files
.moc/
.obj/
.pch/
.rcc/
.uic/
/build*/
/.qtcreator/

97
ToDo.pro Normal file
View File

@@ -0,0 +1,97 @@
QT += widgets
CONFIG += c++17
QMAKE_CXXFLAGS += -Wall -Wextra -Wpedantic
QMAKE_CXXFLAGS += -Werror
win32:VERSION = 3.0.0.0 # major.minor.patch.build
else:VERSION = 3.0.0 # major.minor.patch
DEFINES += APP_VERSION=\"\\\"$${VERSION}\\\"\"
DEFINES += APP_NAME=\"\\\"ToDo\\\"\"
# remove possible other optimization flags
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 = "ToDo"
QMAKE_TARGET_DESCRIPTION = "ToDo"
}
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 = 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 += \
dialog.cpp \
list.cpp \
listservice.cpp \
main.cpp \
mainwindow.cpp
HEADERS += \
dialog.h \
list.h \
listservice.h \
mainwindow.h
FORMS += \
dialog.ui \
mainwindow.ui
TRANSLATIONS += \
ToDo_en_150.ts
CONFIG += lrelease
CONFIG += embed_translations
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

3
ToDo_en_150.ts Normal file
View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en_150"></TS>

36
dialog.cpp Normal file
View File

@@ -0,0 +1,36 @@
#include "dialog.h"
#include "ui_dialog.h"
Dialog::Dialog(QWidget *parent, QString title, QString headline, QString message) : QDialog(parent), ui(new Ui::Dialog)
{
ui->setupUi(this);
this->setWindowTitle(title);
ui->headline->setText(headline);
ui->message->setText(message);
}
Dialog::~Dialog()
{
delete ui;
}
QString Dialog::getInput()
{
if (this->result() != Accepted) {
return "";
}
return this->ui->lineEdit->text();
}
void Dialog::on_buttonBox_accepted()
{
accept();
}
void Dialog::on_buttonBox_rejected()
{
reject();
}

29
dialog.h Normal file
View File

@@ -0,0 +1,29 @@
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
namespace Ui {
class Dialog;
}
class Dialog : public QDialog
{
Q_OBJECT
public:
Dialog(QWidget *parent, QString title, QString headline, QString message);
~Dialog();
QString getInput();
private slots:
void on_buttonBox_accepted();
void on_buttonBox_rejected();
private:
Ui::Dialog *ui;
};
#endif // DIALOG_H

186
dialog.ui Normal file
View File

@@ -0,0 +1,186 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="windowModality">
<enum>Qt::WindowModality::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>454</width>
<height>176</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>454</width>
<height>176</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>454</width>
<height>176</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(249, 255, 251);</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="headline">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>22</pointsize>
<fontweight>Light</fontweight>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(138, 176, 106);
padding: 6px;
padding-left: 20 px;
padding-right: 20px;</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="message">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(13, 13, 13);
padding: 6px;
padding-left: 20px;
padding-right: 20px;</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="styleSheet">
<string notr="true">margin: 6px;
margin-left: 20px;
margin-right: 20px;
background-color: rgb(243, 243, 243);
padding: 4px;
color: rgb(13, 13, 13);
border: 2px solid rgb(230, 230, 230);</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>30</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="styleSheet">
<string notr="true">QPushButton {
border: none;
color: rgb(12, 12, 12);
background-color: rgb(217, 217, 217);
padding: 6px;
}
QPushButton::pressed {
background-color: ;
background-color: rgb(192, 192, 192);
}</string>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Discard|QDialogButtonBox::StandardButton::Save</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>30</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

34
list.cpp Normal file
View File

@@ -0,0 +1,34 @@
#include "list.h"
List::List(QUuid uuid, QString name)
{
this->uuid = uuid;
this->name = name;
}
List::List(QString name)
{
this->uuid = QUuid::createUuid();
this->name = name;
}
QUuid List::getUUID()
{
return this->uuid;
}
QString List::getName()
{
return this->name;
}
void List::setName(QString value)
{
this->name = value;
}
List List::duplicate()
{
List l = List(this->getName() + " (copy)");
return l;
}

26
list.h Normal file
View File

@@ -0,0 +1,26 @@
#ifndef LIST_H
#define LIST_H
#include <QUuid>
#include <QString>
class List
{
private:
QUuid uuid;
QString name;
public:
List() {}
List(QUuid uuid, QString name);
List(QString name);
QUuid getUUID();
QString getName();
void setName(QString value);
List duplicate();
};
#endif // LIST_H

50
listservice.cpp Normal file
View File

@@ -0,0 +1,50 @@
#include "listservice.h"
ListService* ListService::_instance = nullptr;
ListService::ListService() {}
ListService *ListService::getInstance()
{
if (_instance == nullptr) {
_instance = new ListService();
}
return _instance;
}
List ListService::create(QString name)
{
// create the object, the uuid is already assigned by itself
List l = List(name);
// store
// TODO: implement the real datastore (SQLite or something like that)
this->store[l.getUUID().toUInt128()] = l;
// return the actual value
onListCreated(l);
return l;
}
List ListService::update(QUuid uuid, QString newName)
{
if (!this->store.contains(uuid.toUInt128())) {
throw new std::exception();
}
List l = this->store.value(uuid.toUInt128(), List("!!!"));
l.setName(newName);
this->store[uuid.toUInt128()] = l;
onListUpdated(l);
return l;
}
void ListService::remove(QUuid uuid)
{
this->store.remove(uuid.toUInt128());
onListDeleted(uuid);
}

37
listservice.h Normal file
View File

@@ -0,0 +1,37 @@
#ifndef LISTSERVICE_H
#define LISTSERVICE_H
#include <QObject>
#include <QMap>
#include "list.h"
/*
*
* ListService is a singleton that query the "lists" over the datasource layer
*
*/
class ListService : public QObject
{
Q_OBJECT
private:
ListService();
static ListService* _instance;
QMap<qint128,List> store;
public:
static ListService* getInstance();
List create(QString name);
List update(QUuid uuid, QString newName);
void remove(QUuid uuid);
signals:
void onListCreated(List value);
void onListUpdated(List value);
void onListDeleted(QUuid uuid);
};
#endif // LISTSERVICE_H

23
main.cpp Normal file
View File

@@ -0,0 +1,23 @@
#include "mainwindow.h"
#include <QApplication>
#include <QLocale>
#include <QTranslator>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTranslator translator;
const QStringList uiLanguages = QLocale::system().uiLanguages();
for (const QString &locale : uiLanguages) {
const QString baseName = "ToDo_" + QLocale(locale).name();
if (translator.load(":/i18n/" + baseName)) {
a.installTranslator(&translator);
break;
}
}
MainWindow w;
w.show();
return QCoreApplication::exec();
}

54
mainwindow.cpp Normal file
View File

@@ -0,0 +1,54 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "dialog.h"
#include "listservice.h"
#include <QDialogButtonBox>
#include <QListWidgetItem>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
/*
* Events
*/
// ui
connect(ui->addListButton, &QPushButton::clicked, this, &MainWindow::openCreateListDialog);
// services
connect(ListService::getInstance(), &ListService::onListCreated, this, &MainWindow::onListCreated);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::openCreateListDialog(bool _)
{
// create the input dialog
Dialog d = Dialog(this, "Create a list", "New List", "Give a name to this list");
auto res = d.exec();
// execute, ignore if not saved
if (res != QDialog::Accepted) {
return;
}
QString newListName = d.getInput();
ListService::getInstance()->create(newListName);
}
void MainWindow::onListCreated(List value)
{
QListWidgetItem* item = new QListWidgetItem();
item->setText(value.getName());
item->setData(Qt::UserRole, QVariant(value.getUUID()));
this->ui->lists->addItem(item);
}

29
mainwindow.h Normal file
View File

@@ -0,0 +1,29 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "list.h"
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow() override;
private slots:
void openCreateListDialog(bool);
void onListCreated(List value);
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

303
mainwindow.ui Normal file
View File

@@ -0,0 +1,303 @@
<?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>1032</width>
<height>629</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>1032</width>
<height>629</height>
</size>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(249, 255, 251);</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>250</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>250</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>28</pointsize>
<fontweight>DemiBold</fontweight>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(119, 167, 92);
border: none;
padding-left: 2px;
border-bottom: 2px solid rgb(242, 242, 242)</string>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="text">
<string>ToDo</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="lists">
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>250</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
<fontweight>Light</fontweight>
</font>
</property>
<property name="styleSheet">
<string notr="true">QListView {
show-decoration-selected: 1; /* make the selection span the entire width of the view */
background-color: rgb(119, 167, 92);
border: none;
padding: 2px;
padding-top: 14px;
}
QListView::item {
padding: 8px;
border: none;
}
QListView::item:selected {
background-color: rgb(170, 216, 130);
}
QListView::item:selected:!active {
background: none;
}
QListView::item:selected:active {
background-color: rgb(170, 216, 130);
}
QListView::item:hover {
background-color: rgb(152, 193, 116);
}</string>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="autoScrollMargin">
<number>2</number>
</property>
<property name="editTriggers">
<set>QAbstractItemView::EditTrigger::NoEditTriggers</set>
</property>
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="defaultDropAction">
<enum>Qt::DropAction::IgnoreAction</enum>
</property>
<property name="supportedDragActions">
<set>Qt::DropAction::IgnoreAction</set>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="horizontalWidget" native="true">
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>250</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(138, 176, 106);</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="addListButton">
<property name="styleSheet">
<string notr="true">border: none;
padding: 6px;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="QIcon::ThemeIcon::DocumentNew"/>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="notes">
<property name="enabled">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">QListView {
show-decoration-selected: 1; /* make the selection span the entire width of the view */
background-color: rgb(242, 242, 242);
border: none;
padding: 2px;
color: rgb(13, 13, 13);
}
QListView::item {
margin: 2px;
padding: 8px;
border: none;
}
QListView::item:alternate {
background: #EEEEEE;
}
QListView::item:selected {
background-color: rgb(154, 154, 154);
}
QListView::item:selected:!active {
background: none;
}
QListView::item:selected:active {
background-color: rgb(154, 154, 154);
}
QListView::item:hover {
background-color: rgb(204, 204, 204);
}</string>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="editTriggers">
<set>QAbstractItemView::EditTrigger::NoEditTriggers</set>
</property>
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="defaultDropAction">
<enum>Qt::DropAction::IgnoreAction</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SelectionMode::NoSelection</enum>
</property>
<property name="supportedDragActions">
<set>Qt::DropAction::IgnoreAction</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>