From 32b051b3c75f44e6472ca4d2a06a6d9c2d5ce733 Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Tue, 13 Sep 2022 08:20:37 -0400 Subject: [PATCH] To-Do app: W.-I.-P. --- inkbox.pro | 3 + src/apps/apps.cpp | 11 + src/apps/apps.h | 21 +- src/apps/apps.ui | 351 ++++---- src/apps/todo.cpp | 80 ++ src/apps/todo.h | 32 + src/apps/todo.ui | 177 ++++ src/eink.qrc | 3 +- src/functions.h | 21 + src/resources/new.png | Bin 0 -> 6275 bytes .../virtualKeyboard/virtualkeyboard.cpp | 50 +- src/widgets/virtualKeyboard/virtualkeyboard.h | 3 + .../virtualKeyboard/virtualkeyboard.ui | 760 ++++++++++-------- 13 files changed, 990 insertions(+), 522 deletions(-) create mode 100644 src/apps/todo.cpp create mode 100644 src/apps/todo.h create mode 100644 src/apps/todo.ui create mode 100644 src/resources/new.png diff --git a/inkbox.pro b/inkbox.pro index 926528e..780f530 100644 --- a/inkbox.pro +++ b/inkbox.pro @@ -24,6 +24,7 @@ wi #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ + src/apps/todo.cpp \ src/splash/alert.cpp \ src/apps/apps.cpp \ src/widgets/dialogs/library/bookinfodialog.cpp \ @@ -67,6 +68,7 @@ SOURCES += \ src/settings/powerdaemonsettings.cpp HEADERS += \ + src/apps/todo.h \ src/splash/alert.h \ src/apps/apps.h \ src/widgets/dialogs/library/bookinfodialog.h \ @@ -110,6 +112,7 @@ HEADERS += \ src/settings/powerdaemonsettings.h FORMS += \ + src/apps/todo.ui \ src/splash/alert.ui \ src/apps/apps.ui \ src/widgets/dialogs/library/bookinfodialog.ui \ diff --git a/src/apps/apps.cpp b/src/apps/apps.cpp index 003f531..669391a 100644 --- a/src/apps/apps.cpp +++ b/src/apps/apps.cpp @@ -9,6 +9,7 @@ #include #include #include +#include apps::apps(QWidget *parent) : QWidget(parent), @@ -24,6 +25,7 @@ apps::apps(QWidget *parent) : ui->vncLaunchBtn->setProperty("type", "borderless"); ui->reversiLaunchBtn->setProperty("type", "borderless"); ui->g2048LaunchBtn->setProperty("type", "borderless"); + ui->todoLaunchBtn->setProperty("type", "borderless"); ui->label->setStyleSheet("padding-top: 2px; padding-bottom: 5px"); ui->koboxAppsOpenButton->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); @@ -35,6 +37,7 @@ apps::apps(QWidget *parent) : ui->vncLaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); ui->reversiLaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); ui->g2048LaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); + ui->todoLaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); ui->noUserAppsAvailableLabel->hide(); @@ -391,3 +394,11 @@ void apps::updateJsonFileSlot(QJsonDocument jsonDocumentFunc) void apps::showFailedToParseMainUserAppsJsonFile() { emit showToast("Failed to parse 'apps.json'"); } + +void apps::on_todoLaunchBtn_clicked() +{ + todo * todoWindow = new todo(); + todoWindow->setAttribute(Qt::WA_DeleteOnClose); + todoWindow->setGeometry(QRect(QPoint(0,0), qApp->primaryScreen()->geometry().size())); + todoWindow->show(); +} diff --git a/src/apps/apps.h b/src/apps/apps.h index b208d77..cfd9e4f 100644 --- a/src/apps/apps.h +++ b/src/apps/apps.h @@ -2,10 +2,11 @@ #define APPS_H #include -#include -#include -#include -#include +#include "savedwords.h" +#include "calendarapp.h" +#include "koboxappsdialog.h" +#include "generaldialog.h" +#include "todo.h" #include @@ -40,13 +41,15 @@ private slots: void showUserApps(bool showDisabledJson); void updateJsonFileSlot(QJsonDocument jsonDocument); void showFailedToParseMainUserAppsJsonFile(); + void on_todoLaunchBtn_clicked(); private: - Ui::apps *ui; - savedwords *savedWordsWindow; - calendarApp *calendarWindow; - koboxAppsDialog *koboxAppsDialogWindow; - generalDialog *generalDialogWindow; + Ui::apps * ui; + savedwords * savedWordsWindow; + calendarApp * calendarWindow; + koboxAppsDialog * koboxAppsDialogWindow; + generalDialog * generalDialogWindow; + todo * todoWindow; QFile jsonFile; QJsonDocument jsonDocument; diff --git a/src/apps/apps.ui b/src/apps/apps.ui index 8543dd3..992ae0d 100644 --- a/src/apps/apps.ui +++ b/src/apps/apps.ui @@ -53,8 +53,8 @@ 0 0 - 428 - 542 + 407 + 612 @@ -87,6 +87,35 @@ 6 + + + + + 75 + true + + + + Built-in apps + + + Qt::AlignCenter + + + + + + + QFrame::Plain + + + 3 + + + Qt::Horizontal + + + @@ -95,12 +124,13 @@ 10 - - + + Inter 75 + false true @@ -109,8 +139,8 @@ - - + + 75 @@ -118,7 +148,33 @@ - KoBox apps + VNC viewer + + + + + + + + 75 + true + + + + Calculator + + + + + + + + 75 + true + + + + Launch @@ -136,6 +192,99 @@ + + + + + Inter + 75 + false + true + + + + Launch + + + + + + + + 75 + true + + + + Scribble + + + + + + + + 75 + true + + + + 2048 + + + + + + + + 75 + true + + + + Saved words + + + + + + + + 75 + true + + + + Light Maps + + + + + + + + 75 + true + + + + Reversi + + + + + + + + 75 + true + + + + KoBox apps + + + @@ -150,6 +299,34 @@ + + + + + Inter + 75 + true + + + + Launch + + + + + + + + Inter + 75 + true + + + + Launch + + + @@ -177,114 +354,6 @@ - - - - - 75 - true - - - - Launch - - - - - - - - 75 - true - - - - Saved words - - - - - - - - 75 - true - - - - Reversi - - - - - - - - 75 - true - - - - 2048 - - - - - - - - 75 - true - - - - Scribble - - - - - - - - 75 - true - - - - Calculator - - - - - - - - Inter - 75 - false - true - - - - Launch - - - - - - - - Inter - 75 - false - true - - - - Launch - - - @@ -298,8 +367,8 @@ - - + + 75 @@ -307,12 +376,12 @@ - Light Maps + To-Do - - + + Inter @@ -325,50 +394,8 @@ - - - - - 75 - true - - - - VNC viewer - - - - - - - QFrame::Plain - - - 3 - - - Qt::Horizontal - - - - - - - - 75 - true - - - - Built-in apps - - - Qt::AlignCenter - - - diff --git a/src/apps/todo.cpp b/src/apps/todo.cpp new file mode 100644 index 0000000..035df60 --- /dev/null +++ b/src/apps/todo.cpp @@ -0,0 +1,80 @@ +#include "todo.h" +#include "ui_todo.h" + +#include "functions.h" + +todo::todo(QWidget *parent) : + QWidget(parent), + ui(new Ui::todo) +{ + ui->setupUi(this); + this->setStyleSheet(readFile("/mnt/onboard/.adds/inkbox/eink.qss")); + this->setFont(QFont("u001")); + + ui->closeBtn->setProperty("type", "borderless"); + ui->newListBtn->setProperty("type", "borderless"); + ui->closeBtn->setIcon(QIcon(":/resources/close.png")); + ui->newListBtn->setIcon(QIcon(":/resources/new.png")); + + refreshList(); +} + +todo::~todo() +{ + delete ui; +} + +void todo::on_closeBtn_clicked() +{ + this->close(); +} + + +void todo::on_newListBtn_clicked() +{ + global::keyboard::embed = false; + virtualkeyboard * virtualKeyboardWidget = new virtualkeyboard(this); + virtualKeyboardWidget->setAttribute(Qt::WA_DeleteOnClose); + QObject::connect(virtualKeyboardWidget, &virtualkeyboard::enterBtnPressed, this, &todo::createNewList); + virtualKeyboardWidget->show(); + ui->statusLabel->setText("Enter the list's name"); +} + +void todo::createNewList(QString listName) { + log("Initializing new To-Do list with name '" + listName + "'", className); + QJsonDocument document; + int index = 0; + if(QFile::exists(global::localLibrary::todoDatabasePath)) { + document = readTodoDatabase(); + QJsonObject object = document.object(); + index = object.length(); + if(!(index <= object[QString::number(index)].toObject().value("Name").toInt())) { + // TODO + index++; + } + } + QJsonObject mainObject = document.object(); + QJsonObject listObject; + + listObject.insert("Name", listName); + mainObject.insert(QString::number(index), listObject); + + document.setObject(mainObject); + writeTodoDatabase(document); + + ui->statusLabel->setText("Select or create a new list"); + refreshList(); +} + +void todo::refreshList() { + if(QFile::exists(global::localLibrary::todoDatabasePath)) { + ui->listWidget->clear(); + QJsonObject mainObject = readTodoDatabase().object(); + for(int i = 0; i < mainObject.length(); i++) { + QString name = mainObject[QString::number(i)].toObject().value("Name").toString(); + if(!name.isEmpty()) { + ui->listWidget->addItem(name); + } + } + } +} diff --git a/src/apps/todo.h b/src/apps/todo.h new file mode 100644 index 0000000..b7089be --- /dev/null +++ b/src/apps/todo.h @@ -0,0 +1,32 @@ +#ifndef TODO_H +#define TODO_H + +#include + +#include "virtualkeyboard.h" + +namespace Ui { +class todo; +} + +class todo : public QWidget +{ + Q_OBJECT + +public: + QString className = this->metaObject()->className(); + explicit todo(QWidget *parent = nullptr); + ~todo(); + +private slots: + void on_closeBtn_clicked(); + void on_newListBtn_clicked(); + void createNewList(QString listName); + void refreshList(); + +private: + Ui::todo *ui; + virtualkeyboard * virtualKeyboardWidget; +}; + +#endif // TODO_H diff --git a/src/apps/todo.ui b/src/apps/todo.ui new file mode 100644 index 0000000..222a2af --- /dev/null +++ b/src/apps/todo.ui @@ -0,0 +1,177 @@ + + + todo + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + + + + + + U001 + + + + Select or create a new list + + + + + + + + Inter + 75 + true + + + + To-Do + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + QFrame::Plain + + + Qt::Vertical + + + + + + + + + + + QFrame::Plain + + + 4 + + + Qt::Horizontal + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + true + + + + + 0 + 0 + 382 + 229 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + diff --git a/src/eink.qrc b/src/eink.qrc index 91f1794..1479da5 100644 --- a/src/eink.qrc +++ b/src/eink.qrc @@ -97,6 +97,7 @@ resources/wifi-50.png resources/wifi-75.png resources/wifi-100.png - resources/log.png + resources/log.png + resources/new.png diff --git a/src/functions.h b/src/functions.h index 64f0832..8cb91fb 100644 --- a/src/functions.h +++ b/src/functions.h @@ -95,6 +95,7 @@ namespace global { inline bool wifiPassphraseDialog; inline QString keyboardText; inline QString keypadText; + inline bool embed = true; } namespace toast { inline QString message; @@ -139,6 +140,7 @@ namespace global { static inline QString recentBooksDatabasePath = databaseDirectoryPath + "RecentBooks.db"; static inline QString pinnedBooksDatabasePath = databaseDirectoryPath + "PinnedBooks.db"; static inline QString highlightsDatabasePath = databaseDirectoryPath + "Highlights.db"; + static inline QString todoDatabasePath = databaseDirectoryPath + "ToDo.db"; inline bool headless; namespace bookOptionsDialog { inline int bookID; @@ -978,6 +980,25 @@ namespace { QFile::remove(global::localLibrary::highlightsDatabasePath); writeFile(global::localLibrary::highlightsDatabasePath, qCompress(QJsonDocument(jsonObject).toJson()).toBase64()); } + QJsonDocument readTodoDatabase() { + // Read To-Do database from file + QFile database(global::localLibrary::todoDatabasePath); + QByteArray data; + if(database.open(QIODevice::ReadOnly)) { + data = database.readAll(); + database.close(); + } + else { + QString function = __func__; log(function + ": Failed to open To-Do database file for reading at '" + database.fileName() + "'", "functions"); + } + + // Parse JSON data + return QJsonDocument::fromJson(data); + } + void writeTodoDatabase(QJsonDocument jsonDocument) { + QFile::remove(global::localLibrary::todoDatabasePath); + writeFile(global::localLibrary::todoDatabasePath, jsonDocument.toJson()); + } void highlightBookText(QString text, QString bookPath, bool remove) { if(remove == false) { if(!QFile::exists(global::localLibrary::highlightsDatabasePath)) { diff --git a/src/resources/new.png b/src/resources/new.png new file mode 100644 index 0000000000000000000000000000000000000000..85815bacc796497941cdf6f239c4a1e4248d2fd1 GIT binary patch literal 6275 zcmb_g2~<;8w>}AB5M`<$h(@SXrGgBlGRh>VwJ3;&5WzqM8I)N}Kn4>;1W3YAGk z1(N_lGz<|EMFES5iWg)CQPIm>3{x213GKi7)?0o5>wD|nwUT@9K6~EZ+503H4><0T zlU0`m0LbnA!TulsSonwqGE(sNCGyQ20GRW~?d%ThwX@RDeVUN ziF=>F8MHT)Y@VPhXn2mj+tDcM%F|-M-!CiI+ z+Ecdg_7pej@x%1YhX;RE(n`D$~=+E;nUeQ4i=& z=NtUeM!Z_-7_PQg*K5T_TtnfFWLe!O$B`clFWp%8%zI_>ff46^J)~)*=s{YGw5A>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y2(kZ4zIFL4I(z>JBomt1D0r44T4! zOFu5=c`8Jn)&T>z!RU!{EQcr0s(C$}jseN_L5N{(mf2{$MUN$C?0a7Hn~S?K23z?D z7cLo+Fp=8E#v<%R?_?}RnM-iG3;!&dZr%Rdu_)uBOpyi#pNz{2ahVx4>Gxtbrqc$5nZ}D`|e|8rzeC}6Am8ve~3?2f! zkJo%PR?M%+2c)fhkLngRS}r68m!O9>0?P528gnbv#TAV0q5i_BM-%|3C-`oz8`)2p zSGOJT2D6%qrQiB0gQ1TiEBg)i7v$CR-Y%lR>M3T=nZ z-0^4|W}Q)j5>8ABriO_uWBWuNb28Z$=*FkHCb%xW)COzNo4)09yMS(r152Yg7wTUb zc2xMgugL=BO2H#ONY3mWg>gE1VEjdI65QWzc}2m+i-)c7VEjNgc_Bu)ZnvSQ$MrRX zr;%t@EX-bc7c!iyla;a)BsYa2B33P=WgKzMIk<4wS@(hkMz3{{Nk0$^ZPPmTT zOIpHKN>L`b@|f`v^sujdD4*+65<)BO#n+XR95L)7`oZdgsE5v=t8qKh>_Yd2MJB$I zLwFZ{TPXGQ+_uWVC&DG<1g&OiUENVhitGl@1)8uq1)EvuL|7`Wdad1>n*`e60c4P9 zeTW>gUT`iZKk5witQcg6%1hfL-15klk4zaVR5G00Ih74gAXHz0CG{VOkr4 zkU>_OLYjWmD^PNfzY!e;*uFNcvO>}ST0K<|@D Quvld8E=T*~os_fx0kq^5x&QzG literal 0 HcmV?d00001 diff --git a/src/widgets/virtualKeyboard/virtualkeyboard.cpp b/src/widgets/virtualKeyboard/virtualkeyboard.cpp index e00800a..8efa742 100644 --- a/src/widgets/virtualKeyboard/virtualkeyboard.cpp +++ b/src/widgets/virtualKeyboard/virtualkeyboard.cpp @@ -2,6 +2,7 @@ #include "ui_virtualkeyboard.h" #include +#include #include virtualkeyboard::virtualkeyboard(QWidget *parent) : @@ -9,6 +10,33 @@ virtualkeyboard::virtualkeyboard(QWidget *parent) : ui(new Ui::virtualkeyboard) { ui->setupUi(this); + this->setStyleSheet(readFile("/mnt/onboard/.adds/inkbox/eink.qss")); + + if(global::keyboard::embed == false) { + global::keyboard::embed = true; + embed = false; + ui->leftSpacerWidget->hide(); + ui->rightSpacerWidget->hide(); + ui->leftSpacerWidget->deleteLater(); + ui->rightSpacerWidget->deleteLater(); + ui->enterBtn->setProperty("type", "borderless"); + { + int padding = 13; + if(global::deviceID == "n873\n") { + padding = 27; + } + else if(global::deviceID == "n437\n") { + padding = 20; + } + ui->enterBtn->setStyleSheet("font-weight: bold; font-size: 9pt; padding: " + QString::number(padding) + "px"); + ui->enterBtn->setIcon(QIcon(":/resources/arrow-right.png")); + } + } + else { + embed = true; + ui->enterBtn->hide(); + ui->enterBtn->deleteLater(); + } ui->n1->setProperty("type", "borderless"); ui->n2->setProperty("type", "borderless"); @@ -193,11 +221,12 @@ virtualkeyboard::virtualkeyboard(QWidget *parent) : if(global::keyboard::vncDialog == true or global::keyboard::wifiPassphraseDialog == true or global::keyboard::encfsDialog == true) { ui->lineEdit->setFont(QFont("Roboto Mono")); } - else if(global::keyboard::searchDialog == true){ + else { ui->lineEdit->setFont(QFont("u001")); } - else { - ui->lineEdit->setFont(QFont("Roboto")); + + if(embed == false) { + adjust_size_function(); } } @@ -672,7 +701,14 @@ void virtualkeyboard::reverseKeys(keyboardMode keyboardMode) { } void virtualkeyboard::adjust_size_function() { - emit adjust_size(); + if(embed == true) { + emit adjust_size(); + } + else { + this->setFixedHeight(QGuiApplication::screens()[0]->size().height() * 45 / 100); + this->setFixedWidth(QGuiApplication::screens()[0]->size().width()); + this->move(0, (QGuiApplication::screens()[0]->size().height() - this->height())); + } } void virtualkeyboard::clearLineEdit() { @@ -680,3 +716,9 @@ void virtualkeyboard::clearLineEdit() { QString text = ui->lineEdit->text(); global::keyboard::keyboardText = text; } + +void virtualkeyboard::on_enterBtn_clicked() +{ + emit enterBtnPressed(ui->lineEdit->text()); + this->close(); +} diff --git a/src/widgets/virtualKeyboard/virtualkeyboard.h b/src/widgets/virtualKeyboard/virtualkeyboard.h index 31c85cc..833e4e2 100644 --- a/src/widgets/virtualKeyboard/virtualkeyboard.h +++ b/src/widgets/virtualKeyboard/virtualkeyboard.h @@ -18,6 +18,7 @@ public: ~virtualkeyboard(); bool shift = false; bool specialCharacters = false; + bool embed; enum class keyboardMode { lowerCase, upperCase, @@ -69,6 +70,7 @@ private slots: void on_lm_clicked(); void on_shiftBtn_clicked(); void adjust_size_function(); + void on_enterBtn_clicked(); private: Ui::virtualkeyboard *ui; @@ -76,6 +78,7 @@ private: signals: void adjust_size(); + void enterBtnPressed(QString string); }; #endif // VIRTUALKEYBOARD_H diff --git a/src/widgets/virtualKeyboard/virtualkeyboard.ui b/src/widgets/virtualKeyboard/virtualkeyboard.ui index 3aac739..6b7fda9 100644 --- a/src/widgets/virtualKeyboard/virtualkeyboard.ui +++ b/src/widgets/virtualKeyboard/virtualkeyboard.ui @@ -6,7 +6,7 @@ 0 0 - 999 + 1235 283 @@ -27,362 +27,430 @@ 0 - - - 0 - - - - - - - - 0 - - - 0 - - - - - 0 - - - 0 - - - 0 - + + + + + 0 - - - - - - - - p + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal - - - - - - x + + + 40 + 20 + - - - - - - e - - - - - - - 0 - - - - - - - r - - - - - - - v - - - - - - - 6 - - - - - - - 2 - - - - - - - 3 - - - - - - - 9 - - - - - - - 1 - - - - - - - c - - - - - - - - - - - - - - b - - - - - - - 8 - - - - - - - y - - - - - - - u - - - - - - - 5 - - - - - - - w - - - - - - - t - - - - - - - m - - - - - - - - - - - - - - 7 - - - - - - - q - - - - - - - i - - - - - - - z - - - - - - - . - - - - - - - 4 - - - - - - - o - - - - - - - n - - - - - - - l - - - - - - - k - - - - - - - j - - - - - - - h - - - - - - - g - - - - - - - f - - - - - - - d - - - - - - - s - - - - - - - a - - - - - - - # - - + + + + + + + + + Space + + + + + + + 0 + + + + + + + + + + + + + + 0 + + + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + p + + + + + + + x + + + + + + + e + + + + + + + 0 + + + + + + + r + + + + + + + v + + + + + + + 6 + + + + + + + 2 + + + + + + + 3 + + + + + + + 9 + + + + + + + 1 + + + + + + + c + + + + + + + + + + + + + + b + + + + + + + 8 + + + + + + + y + + + + + + + u + + + + + + + 5 + + + + + + + w + + + + + + + t + + + + + + + m + + + + + + + + + + + + + + 7 + + + + + + + q + + + + + + + i + + + + + + + z + + + + + + + . + + + + + + + 4 + + + + + + + o + + + + + + + n + + + + + + + l + + + + + + + k + + + + + + + j + + + + + + + h + + + + + + + g + + + + + + + f + + + + + + + d + + + + + + + s + + + + + + + a + + + + + + + # + + + + + + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 40 + 20 + + + + + + + + + - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Space - - - - + + + + +