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

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);
}