diff --git a/ToDo.pro b/ToDo.pro index d2fa5dc..f8d3110 100644 --- a/ToDo.pro +++ b/ToDo.pro @@ -8,6 +8,9 @@ QMAKE_CXXFLAGS += -Werror win32:VERSION = 0.0.1.0 # major.minor.patch.build else:VERSION = 0.0.1 # major.minor.patch +DEFINES += APP_VERSION=\"\\\"$${VERSION}.preview1\\\"\" +TMP_APP_ARCH = APP_ARCH=\"\\\"unknown\\\"\" + # remove possible other optimization flags win32 { message("Build for Windows") @@ -16,10 +19,12 @@ win32 { QMAKE_CXXFLAGS_RELEASE *= -O2 equals(QMAKE_TARGET.arch, arm64) { message("CPU Architecture : aarch64") + TMP_APP_ARCH = APP_ARCH=\"\\\"arm64\\\"\" } equals(QMAKE_TARGET.arch, x86_64) { message("CPU Architecture : x64") QMAKE_CXXFLAGS_RELEASE += -favor:INTEL64 + TMP_APP_ARCH = APP_ARCH=\"\\\"x64\\\"\" } RC_ICONS = icon.ico QMAKE_TARGET_COMPANY = "Aurelie Delhaie" @@ -37,28 +42,34 @@ macx { QMAKE_CXXFLAGS_RELEASE *= -O3 QMAKE_APPLE_DEVICE_ARCHS = arm64 QMAKE_CXXFLAGS_RELEASE += -march=armv8.6-a+fp16+simd + TMP_APP_ARCH = APP_ARCH=\"\\\"arm64\\\"\" } linux-* { message("Build for Linux") - equals(ARCH, aarch64) { + equals(QMAKE_HOST.arch, aarch64) { message("CPU Architecture : aarch64") QMAKE_CXXFLAGS_RELEASE += -mtune=armv8.6-a+fp16+simd + TMP_APP_ARCH = APP_ARCH=\"\\\"aarch64\\\"\" } - equals(ARCH, amd64) { + equals(QMAKE_HOST.arch, amd64) { message("CPU Architecture : amd64") QMAKE_CXXFLAGS_RELEASE += -march=tigerlake QMAKE_CXXFLAGS_RELEASE += -mtune=intel + TMP_APP_ARCH = APP_ARCH=\"\\\"amd64\\\"\" } QMAKE_CXXFLAGS_RELEASE *= -O3 } +DEFINES += $$TMP_APP_ARCH + # 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/core/noteservice.cpp \ + src/gui/dialog/about/aboutdialog.cpp \ src/gui/dialog/input/inputdialog.cpp \ src/obj/list.cpp \ src/core/listservice.cpp \ @@ -68,6 +79,7 @@ SOURCES += \ HEADERS += \ src/core/noteservice.h \ + src/gui/dialog/about/aboutdialog.h \ src/gui/dialog/input/inputdialog.h \ src/obj/list.h \ src/core/listservice.h \ @@ -75,6 +87,7 @@ HEADERS += \ src/obj/note.h FORMS += \ + src/gui/dialog/about/aboutdialog.ui \ src/gui/dialog/input/inputdialog.ui \ src/gui/mainwindow.ui @@ -87,3 +100,6 @@ CONFIG += embed_translations qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target + +RESOURCES += \ + src/resources.qrc diff --git a/src/gui/dialog/about/aboutdialog.cpp b/src/gui/dialog/about/aboutdialog.cpp new file mode 100644 index 0000000..dd3755f --- /dev/null +++ b/src/gui/dialog/about/aboutdialog.cpp @@ -0,0 +1,15 @@ +#include "aboutdialog.h" +#include "ui_aboutdialog.h" + +AboutDialog::AboutDialog(QWidget *parent) + : QDialog(parent) + , ui(new Ui::AboutDialog) +{ + ui->setupUi(this); + ui->versionLabel->setText(QString("%1-%2").arg(APP_VERSION, APP_ARCH)); +} + +AboutDialog::~AboutDialog() +{ + delete ui; +} diff --git a/src/gui/dialog/about/aboutdialog.h b/src/gui/dialog/about/aboutdialog.h new file mode 100644 index 0000000..4474ece --- /dev/null +++ b/src/gui/dialog/about/aboutdialog.h @@ -0,0 +1,22 @@ +#ifndef ABOUTDIALOG_H +#define ABOUTDIALOG_H + +#include + +namespace Ui { +class AboutDialog; +} + +class AboutDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AboutDialog(QWidget *parent = nullptr); + ~AboutDialog(); + +private: + Ui::AboutDialog *ui; +}; + +#endif // ABOUTDIALOG_H diff --git a/src/gui/dialog/about/aboutdialog.ui b/src/gui/dialog/about/aboutdialog.ui new file mode 100644 index 0000000..890b32e --- /dev/null +++ b/src/gui/dialog/about/aboutdialog.ui @@ -0,0 +1,121 @@ + + + AboutDialog + + + Qt::WindowModality::WindowModal + + + + 0 + 0 + 258 + 183 + + + + + 258 + 183 + + + + + 258 + 183 + + + + Qt::ContextMenuPolicy::NoContextMenu + + + About ToDo + + + + :/images/icon.png:/images/icon.png + + + true + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + :/images/icon.png + + + true + + + Qt::AlignmentFlag::AlignCenter + + + + + + + + + font-weight: 200; +font-size: 36px; + + + ToDo + + + Qt::AlignmentFlag::AlignCenter + + + + + + + 0.0.0-dev + + + Qt::AlignmentFlag::AlignCenter + + + + + + + Qt::Orientation::Vertical + + + + 20 + 40 + + + + + + + + + + + + + diff --git a/src/gui/dialog/input/inputdialog.ui b/src/gui/dialog/input/inputdialog.ui index 82dcc77..dd1db82 100644 --- a/src/gui/dialog/input/inputdialog.ui +++ b/src/gui/dialog/input/inputdialog.ui @@ -3,7 +3,7 @@ InputDialog - Qt::WindowModality::ApplicationModal + Qt::WindowModality::WindowModal @@ -28,6 +28,10 @@ Dialog + + + :/images/icon.png:/images/icon.png + background-color: rgb(249, 255, 251); @@ -191,6 +195,8 @@ QPushButton::pressed { - + + + diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index a3f77b4..a0f7e98 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -2,6 +2,7 @@ #include "ui_mainwindow.h" #include "src/gui/dialog/input/inputdialog.h" +#include "src/gui/dialog/about/aboutdialog.h" #include "src/core/listservice.h" #include "src/core/noteservice.h" @@ -16,6 +17,8 @@ MainWindow::MainWindow(QWidget *parent) { ui->setupUi(this); + ui->version->setText(QString("%1").arg(APP_VERSION)); + /* * Events */ @@ -28,6 +31,11 @@ MainWindow::MainWindow(QWidget *parent) connect(ui->saveNoteButton, &QPushButton::clicked, this, &MainWindow::onSaveNoteButtonClicked); connect(ui->notes, &QListWidget::itemChanged, this, &MainWindow::onNoteChanged); + // action menu + connect(ui->actionNew_list, &QAction::triggered, this, &MainWindow::openCreateListDialog); + connect(ui->actionAbout, &QAction::triggered, this, &MainWindow::openAboutDialog); + connect(ui->actionClose, &QAction::triggered, this, &MainWindow::quit); + // services connect(ListService::getInstance(), &ListService::onListCreated, this, &MainWindow::onListCreated); connect(ListService::getInstance(), &ListService::onListUpdated, this, &MainWindow::onListUpdate); @@ -59,6 +67,12 @@ void MainWindow::openCreateListDialog(bool) ListService::getInstance()->create(newListName); } +void MainWindow::openAboutDialog() +{ + AboutDialog d(this); + d.exec(); +} + void MainWindow::onListCreated(List value) { QListWidgetItem* item = new QListWidgetItem(); @@ -307,6 +321,11 @@ void MainWindow::onListContextMenuRename(bool) } } +void MainWindow::quit() +{ + QApplication::closeAllWindows(); +} + inline void MainWindow::preload() { QList lists = ListService::getInstance()->getAll(); diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 64655ab..ba04e88 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -23,6 +23,7 @@ public: private slots: void openCreateListDialog(bool); + void openAboutDialog(); void onListCreated(List value); void onListUpdate(List value); void onListDeleted(QUuid uuid); @@ -36,6 +37,7 @@ private slots: void onListRightClick(const QPoint &pos); void onListContextMenuDelete(bool); void onListContextMenuRename(bool); + void quit(); private: Ui::MainWindow *ui; diff --git a/src/gui/mainwindow.ui b/src/gui/mainwindow.ui index a625a84..e55933c 100644 --- a/src/gui/mainwindow.ui +++ b/src/gui/mainwindow.ui @@ -19,6 +19,10 @@ ToDo + + + :/images/icon.png:/images/icon.png + @@ -75,14 +79,16 @@ 28 - DemiBold + ExtraLight background-color: rgb(119, 167, 92); +color: rgb(249, 255, 251); border: none; padding-left: 2px; -border-bottom: 2px solid rgb(242, 242, 242) +border-bottom: 2px solid rgb(242, 242, 242); +font-weight: 200; 0 @@ -207,13 +213,32 @@ QListView::item:hover { 0 + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Minimum + + + + 6 + 20 + + + + false + + color: rgb(74, 104, 57); + - 0.0.1 + 0.0.0-dev @@ -368,7 +393,7 @@ padding: 8px; - + false @@ -399,7 +424,76 @@ padding: 8px; + + + + 0 + 0 + 1032 + 24 + + + + background-color: rgb(119, 167, 92); +color: rgb(249, 255, 251); +font-weight: 200; + + + + Help + + + + + + File + + + + + + + + + + + + + + About + + + QAction::MenuRole::AboutRole + + + + + + + + New list... + + + Ctrl+N + + + + + + + + Close + + + Ctrl+Q + + + QAction::MenuRole::QuitRole + + - + + + diff --git a/src/icon.png b/src/icon.png new file mode 100644 index 0000000..843a235 Binary files /dev/null and b/src/icon.png differ diff --git a/src/resources.qrc b/src/resources.qrc new file mode 100644 index 0000000..ff6f51a --- /dev/null +++ b/src/resources.qrc @@ -0,0 +1,5 @@ + + + icon.png + +