To-Do app: W.-I.-P.

This commit is contained in:
Nicolas Mailloux 2022-09-13 08:20:37 -04:00
parent 3555a4a90a
commit 32b051b3c7
13 changed files with 990 additions and 522 deletions

View file

@ -24,6 +24,7 @@ wi
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \ SOURCES += \
src/apps/todo.cpp \
src/splash/alert.cpp \ src/splash/alert.cpp \
src/apps/apps.cpp \ src/apps/apps.cpp \
src/widgets/dialogs/library/bookinfodialog.cpp \ src/widgets/dialogs/library/bookinfodialog.cpp \
@ -67,6 +68,7 @@ SOURCES += \
src/settings/powerdaemonsettings.cpp src/settings/powerdaemonsettings.cpp
HEADERS += \ HEADERS += \
src/apps/todo.h \
src/splash/alert.h \ src/splash/alert.h \
src/apps/apps.h \ src/apps/apps.h \
src/widgets/dialogs/library/bookinfodialog.h \ src/widgets/dialogs/library/bookinfodialog.h \
@ -110,6 +112,7 @@ HEADERS += \
src/settings/powerdaemonsettings.h src/settings/powerdaemonsettings.h
FORMS += \ FORMS += \
src/apps/todo.ui \
src/splash/alert.ui \ src/splash/alert.ui \
src/apps/apps.ui \ src/apps/apps.ui \
src/widgets/dialogs/library/bookinfodialog.ui \ src/widgets/dialogs/library/bookinfodialog.ui \

View file

@ -9,6 +9,7 @@
#include <QJsonObject> #include <QJsonObject>
#include <QJsonValue> #include <QJsonValue>
#include <QJsonArray> #include <QJsonArray>
#include <QScreen>
apps::apps(QWidget *parent) : apps::apps(QWidget *parent) :
QWidget(parent), QWidget(parent),
@ -24,6 +25,7 @@ apps::apps(QWidget *parent) :
ui->vncLaunchBtn->setProperty("type", "borderless"); ui->vncLaunchBtn->setProperty("type", "borderless");
ui->reversiLaunchBtn->setProperty("type", "borderless"); ui->reversiLaunchBtn->setProperty("type", "borderless");
ui->g2048LaunchBtn->setProperty("type", "borderless"); ui->g2048LaunchBtn->setProperty("type", "borderless");
ui->todoLaunchBtn->setProperty("type", "borderless");
ui->label->setStyleSheet("padding-top: 2px; padding-bottom: 5px"); ui->label->setStyleSheet("padding-top: 2px; padding-bottom: 5px");
ui->koboxAppsOpenButton->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); 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->vncLaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px");
ui->reversiLaunchBtn->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->g2048LaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px");
ui->todoLaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px");
ui->noUserAppsAvailableLabel->hide(); ui->noUserAppsAvailableLabel->hide();
@ -391,3 +394,11 @@ void apps::updateJsonFileSlot(QJsonDocument jsonDocumentFunc)
void apps::showFailedToParseMainUserAppsJsonFile() { void apps::showFailedToParseMainUserAppsJsonFile() {
emit showToast("Failed to parse 'apps.json'"); 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();
}

View file

@ -2,10 +2,11 @@
#define APPS_H #define APPS_H
#include <QWidget> #include <QWidget>
#include <savedwords.h> #include "savedwords.h"
#include <calendarapp.h> #include "calendarapp.h"
#include <koboxappsdialog.h> #include "koboxappsdialog.h"
#include <generaldialog.h> #include "generaldialog.h"
#include "todo.h"
#include <QJsonDocument> #include <QJsonDocument>
@ -40,13 +41,15 @@ private slots:
void showUserApps(bool showDisabledJson); void showUserApps(bool showDisabledJson);
void updateJsonFileSlot(QJsonDocument jsonDocument); void updateJsonFileSlot(QJsonDocument jsonDocument);
void showFailedToParseMainUserAppsJsonFile(); void showFailedToParseMainUserAppsJsonFile();
void on_todoLaunchBtn_clicked();
private: private:
Ui::apps *ui; Ui::apps * ui;
savedwords *savedWordsWindow; savedwords * savedWordsWindow;
calendarApp *calendarWindow; calendarApp * calendarWindow;
koboxAppsDialog *koboxAppsDialogWindow; koboxAppsDialog * koboxAppsDialogWindow;
generalDialog *generalDialogWindow; generalDialog * generalDialogWindow;
todo * todoWindow;
QFile jsonFile; QFile jsonFile;
QJsonDocument jsonDocument; QJsonDocument jsonDocument;

View file

@ -53,8 +53,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>428</width> <width>407</width>
<height>542</height> <height>612</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
@ -87,6 +87,35 @@
<property name="verticalSpacing"> <property name="verticalSpacing">
<number>6</number> <number>6</number>
</property> </property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Built-in apps</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>3</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0"> <item row="2" column="0">
<layout class="QGridLayout" name="gridLayout_5"> <layout class="QGridLayout" name="gridLayout_5">
<property name="bottomMargin"> <property name="bottomMargin">
@ -95,12 +124,13 @@
<property name="verticalSpacing"> <property name="verticalSpacing">
<number>10</number> <number>10</number>
</property> </property>
<item row="4" column="1"> <item row="1" column="1">
<widget class="QPushButton" name="calendarLaunchBtn"> <widget class="QPushButton" name="scribbleLaunchBtn">
<property name="font"> <property name="font">
<font> <font>
<family>Inter</family> <family>Inter</family>
<weight>75</weight> <weight>75</weight>
<italic>false</italic>
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
@ -109,8 +139,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="8" column="0">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="vncViewerLabel">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight> <weight>75</weight>
@ -118,7 +148,33 @@
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>KoBox apps</string> <string>VNC viewer</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Calculator</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="g2048LaunchBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Launch</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -136,6 +192,99 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1">
<widget class="QPushButton" name="lightmapsLaunchBtn">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Launch</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="scribbleLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Scribble</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="g2048Label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>2048</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Saved words</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Light Maps</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="reversiLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Reversi</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>KoBox apps</string>
</property>
</widget>
</item>
<item row="5" column="1"> <item row="5" column="1">
<widget class="QPushButton" name="savedWordsLaunchBtn"> <widget class="QPushButton" name="savedWordsLaunchBtn">
<property name="font"> <property name="font">
@ -150,6 +299,34 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1">
<widget class="QPushButton" name="calendarLaunchBtn">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Launch</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QPushButton" name="vncLaunchBtn">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Launch</string>
</property>
</widget>
</item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QPushButton" name="reversiLaunchBtn"> <widget class="QPushButton" name="reversiLaunchBtn">
<property name="font"> <property name="font">
@ -177,114 +354,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1">
<widget class="QPushButton" name="g2048LaunchBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Launch</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Saved words</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="reversiLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Reversi</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="g2048Label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>2048</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="scribbleLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Scribble</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Calculator</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QPushButton" name="lightmapsLaunchBtn">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Launch</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="scribbleLaunchBtn">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Launch</string>
</property>
</widget>
</item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QLabel" name="calendarLabel"> <widget class="QLabel" name="calendarLabel">
<property name="font"> <property name="font">
@ -298,8 +367,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item row="9" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="todoLabel">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight> <weight>75</weight>
@ -307,12 +376,12 @@
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>Light Maps</string> <string>To-Do</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="1"> <item row="9" column="1">
<widget class="QPushButton" name="vncLaunchBtn"> <widget class="QPushButton" name="todoLaunchBtn">
<property name="font"> <property name="font">
<font> <font>
<family>Inter</family> <family>Inter</family>
@ -325,50 +394,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0">
<widget class="QLabel" name="vncViewerLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>VNC viewer</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item row="1" column="0">
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>3</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Built-in apps</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>

80
src/apps/todo.cpp Normal file
View file

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

32
src/apps/todo.h Normal file
View file

@ -0,0 +1,32 @@
#ifndef TODO_H
#define TODO_H
#include <QWidget>
#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

177
src/apps/todo.ui Normal file
View file

@ -0,0 +1,177 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>todo</class>
<widget class="QWidget" name="todo">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="4">
<widget class="QLabel" name="statusLabel">
<property name="font">
<font>
<family>U001</family>
</font>
</property>
<property name="text">
<string>Select or create a new list</string>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QLabel" name="todoLabel">
<property name="font">
<font>
<family>Inter</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>To-Do</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="closeBtn">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="5">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="newListBtn">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Line" name="line_2">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>4</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QStackedWidget" name="stackedWidget">
<widget class="QWidget" name="page_3">
<layout class="QVBoxLayout" name="verticalLayout_4">
<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>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>382</width>
<height>229</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<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>
<widget class="QListWidget" name="listWidget"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_4"/>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -97,6 +97,7 @@
<file>resources/wifi-50.png</file> <file>resources/wifi-50.png</file>
<file>resources/wifi-75.png</file> <file>resources/wifi-75.png</file>
<file>resources/wifi-100.png</file> <file>resources/wifi-100.png</file>
<file>resources/log.png</file> <file>resources/log.png</file>
<file>resources/new.png</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -95,6 +95,7 @@ namespace global {
inline bool wifiPassphraseDialog; inline bool wifiPassphraseDialog;
inline QString keyboardText; inline QString keyboardText;
inline QString keypadText; inline QString keypadText;
inline bool embed = true;
} }
namespace toast { namespace toast {
inline QString message; inline QString message;
@ -139,6 +140,7 @@ namespace global {
static inline QString recentBooksDatabasePath = databaseDirectoryPath + "RecentBooks.db"; static inline QString recentBooksDatabasePath = databaseDirectoryPath + "RecentBooks.db";
static inline QString pinnedBooksDatabasePath = databaseDirectoryPath + "PinnedBooks.db"; static inline QString pinnedBooksDatabasePath = databaseDirectoryPath + "PinnedBooks.db";
static inline QString highlightsDatabasePath = databaseDirectoryPath + "Highlights.db"; static inline QString highlightsDatabasePath = databaseDirectoryPath + "Highlights.db";
static inline QString todoDatabasePath = databaseDirectoryPath + "ToDo.db";
inline bool headless; inline bool headless;
namespace bookOptionsDialog { namespace bookOptionsDialog {
inline int bookID; inline int bookID;
@ -978,6 +980,25 @@ namespace {
QFile::remove(global::localLibrary::highlightsDatabasePath); QFile::remove(global::localLibrary::highlightsDatabasePath);
writeFile(global::localLibrary::highlightsDatabasePath, qCompress(QJsonDocument(jsonObject).toJson()).toBase64()); 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) { void highlightBookText(QString text, QString bookPath, bool remove) {
if(remove == false) { if(remove == false) {
if(!QFile::exists(global::localLibrary::highlightsDatabasePath)) { if(!QFile::exists(global::localLibrary::highlightsDatabasePath)) {

BIN
src/resources/new.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View file

@ -2,6 +2,7 @@
#include "ui_virtualkeyboard.h" #include "ui_virtualkeyboard.h"
#include <QTimer> #include <QTimer>
#include <QScreen>
#include <QDebug> #include <QDebug>
virtualkeyboard::virtualkeyboard(QWidget *parent) : virtualkeyboard::virtualkeyboard(QWidget *parent) :
@ -9,6 +10,33 @@ virtualkeyboard::virtualkeyboard(QWidget *parent) :
ui(new Ui::virtualkeyboard) ui(new Ui::virtualkeyboard)
{ {
ui->setupUi(this); 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->n1->setProperty("type", "borderless");
ui->n2->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) { if(global::keyboard::vncDialog == true or global::keyboard::wifiPassphraseDialog == true or global::keyboard::encfsDialog == true) {
ui->lineEdit->setFont(QFont("Roboto Mono")); ui->lineEdit->setFont(QFont("Roboto Mono"));
} }
else if(global::keyboard::searchDialog == true){ else {
ui->lineEdit->setFont(QFont("u001")); 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() { 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() { void virtualkeyboard::clearLineEdit() {
@ -680,3 +716,9 @@ void virtualkeyboard::clearLineEdit() {
QString text = ui->lineEdit->text(); QString text = ui->lineEdit->text();
global::keyboard::keyboardText = text; global::keyboard::keyboardText = text;
} }
void virtualkeyboard::on_enterBtn_clicked()
{
emit enterBtnPressed(ui->lineEdit->text());
this->close();
}

View file

@ -18,6 +18,7 @@ public:
~virtualkeyboard(); ~virtualkeyboard();
bool shift = false; bool shift = false;
bool specialCharacters = false; bool specialCharacters = false;
bool embed;
enum class keyboardMode { enum class keyboardMode {
lowerCase, lowerCase,
upperCase, upperCase,
@ -69,6 +70,7 @@ private slots:
void on_lm_clicked(); void on_lm_clicked();
void on_shiftBtn_clicked(); void on_shiftBtn_clicked();
void adjust_size_function(); void adjust_size_function();
void on_enterBtn_clicked();
private: private:
Ui::virtualkeyboard *ui; Ui::virtualkeyboard *ui;
@ -76,6 +78,7 @@ private:
signals: signals:
void adjust_size(); void adjust_size();
void enterBtnPressed(QString string);
}; };
#endif // VIRTUALKEYBOARD_H #endif // VIRTUALKEYBOARD_H

View file

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>999</width> <width>1235</width>
<height>283</height> <height>283</height>
</rect> </rect>
</property> </property>
@ -27,362 +27,430 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <widget class="QStackedWidget" name="mainWidget">
<property name="bottomMargin"> <widget class="QWidget" name="page_7">
<number>0</number> <layout class="QVBoxLayout" name="verticalLayout_3">
</property> <item>
<item row="0" column="3"> <layout class="QGridLayout" name="gridLayout">
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item row="1" column="3">
<widget class="QStackedWidget" name="stackedWidget">
<property name="lineWidth">
<number>0</number>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item row="2" column="3">
<layout class="QGridLayout" name="gridLayout_3"> <widget class="QStackedWidget" name="rightSpacerWidget">
<item row="13" column="3"> <widget class="QWidget" name="page_11">
<layout class="QGridLayout" name="gridLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_5">
<item row="2" column="12"> <property name="leftMargin">
<widget class="QPushButton" name="lp"> <number>0</number>
<property name="text"> </property>
<string>p</string> <property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="rightSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property> </property>
</widget> <property name="sizeHint" stdset="0">
</item> <size>
<item row="7" column="3"> <width>40</width>
<widget class="QPushButton" name="lx"> <height>20</height>
<property name="text"> </size>
<string>x</string>
</property> </property>
</widget> </spacer>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="le">
<property name="text">
<string>e</string>
</property>
</widget>
</item>
<item row="0" column="12">
<widget class="QPushButton" name="n0">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QPushButton" name="lr">
<property name="text">
<string>r</string>
</property>
</widget>
</item>
<item row="7" column="6">
<widget class="QPushButton" name="lv">
<property name="text">
<string>v</string>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QPushButton" name="n6">
<property name="text">
<string>6</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="n2">
<property name="text">
<string>2</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="n3">
<property name="text">
<string>3</string>
</property>
</widget>
</item>
<item row="0" column="10">
<widget class="QPushButton" name="n9">
<property name="text">
<string>9</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="n1">
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item row="7" column="4">
<widget class="QPushButton" name="lc">
<property name="text">
<string>c</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QPushButton" name="shiftBtn">
<property name="text">
<string>⇧</string>
</property>
</widget>
</item>
<item row="7" column="7">
<widget class="QPushButton" name="lb">
<property name="text">
<string>b</string>
</property>
</widget>
</item>
<item row="0" column="9">
<widget class="QPushButton" name="n8">
<property name="text">
<string>8</string>
</property>
</widget>
</item>
<item row="2" column="7">
<widget class="QPushButton" name="ly">
<property name="text">
<string>y</string>
</property>
</widget>
</item>
<item row="2" column="8">
<widget class="QPushButton" name="lu">
<property name="text">
<string>u</string>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QPushButton" name="n5">
<property name="text">
<string>5</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="lw">
<property name="text">
<string>w</string>
</property>
</widget>
</item>
<item row="2" column="6">
<widget class="QPushButton" name="lt">
<property name="text">
<string>t</string>
</property>
</widget>
</item>
<item row="7" column="9">
<widget class="QPushButton" name="lm">
<property name="text">
<string>m</string>
</property>
</widget>
</item>
<item row="7" column="12">
<widget class="QPushButton" name="eraseBtn">
<property name="text">
<string>⌫</string>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QPushButton" name="n7">
<property name="text">
<string>7</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="lq">
<property name="text">
<string>q</string>
</property>
</widget>
</item>
<item row="2" column="9">
<widget class="QPushButton" name="li">
<property name="text">
<string>i</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QPushButton" name="lz">
<property name="text">
<string>z</string>
</property>
</widget>
</item>
<item row="7" column="10">
<widget class="QPushButton" name="spt">
<property name="text">
<string>.</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="n4">
<property name="text">
<string>4</string>
</property>
</widget>
</item>
<item row="2" column="10">
<widget class="QPushButton" name="lo">
<property name="text">
<string>o</string>
</property>
</widget>
</item>
<item row="7" column="8">
<widget class="QPushButton" name="ln">
<property name="text">
<string>n</string>
</property>
</widget>
</item>
<item row="6" column="12">
<widget class="QPushButton" name="ll">
<property name="text">
<string>l</string>
</property>
</widget>
</item>
<item row="6" column="10">
<widget class="QPushButton" name="lk">
<property name="text">
<string>k</string>
</property>
</widget>
</item>
<item row="6" column="9">
<widget class="QPushButton" name="lj">
<property name="text">
<string>j</string>
</property>
</widget>
</item>
<item row="6" column="8">
<widget class="QPushButton" name="lh">
<property name="text">
<string>h</string>
</property>
</widget>
</item>
<item row="6" column="7">
<widget class="QPushButton" name="lg">
<property name="text">
<string>g</string>
</property>
</widget>
</item>
<item row="6" column="6">
<widget class="QPushButton" name="lf">
<property name="text">
<string>f</string>
</property>
</widget>
</item>
<item row="6" column="4">
<widget class="QPushButton" name="ld">
<property name="text">
<string>d</string>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QPushButton" name="ls">
<property name="text">
<string>s</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QPushButton" name="la">
<property name="text">
<string>a</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QPushButton" name="sat">
<property name="text">
<string>#</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget>
<widget class="QWidget" name="page_12"/>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="spaceBtn">
<property name="text">
<string>Space</string>
</property>
</widget>
</item>
<item row="1" column="2">
<layout class="QGridLayout" name="gridLayout_2">
<property name="topMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="enterBtn">
<property name="text">
<string/>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="2">
<widget class="QStackedWidget" name="stackedWidget">
<property name="lineWidth">
<number>0</number>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_2">
<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>
<layout class="QGridLayout" name="gridLayout_3">
<item row="13" column="3">
<layout class="QGridLayout" name="gridLayout_4">
<item row="2" column="12">
<widget class="QPushButton" name="lp">
<property name="text">
<string>p</string>
</property>
</widget>
</item>
<item row="7" column="3">
<widget class="QPushButton" name="lx">
<property name="text">
<string>x</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="le">
<property name="text">
<string>e</string>
</property>
</widget>
</item>
<item row="0" column="12">
<widget class="QPushButton" name="n0">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QPushButton" name="lr">
<property name="text">
<string>r</string>
</property>
</widget>
</item>
<item row="7" column="6">
<widget class="QPushButton" name="lv">
<property name="text">
<string>v</string>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QPushButton" name="n6">
<property name="text">
<string>6</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="n2">
<property name="text">
<string>2</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="n3">
<property name="text">
<string>3</string>
</property>
</widget>
</item>
<item row="0" column="10">
<widget class="QPushButton" name="n9">
<property name="text">
<string>9</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="n1">
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item row="7" column="4">
<widget class="QPushButton" name="lc">
<property name="text">
<string>c</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QPushButton" name="shiftBtn">
<property name="text">
<string>⇧</string>
</property>
</widget>
</item>
<item row="7" column="7">
<widget class="QPushButton" name="lb">
<property name="text">
<string>b</string>
</property>
</widget>
</item>
<item row="0" column="9">
<widget class="QPushButton" name="n8">
<property name="text">
<string>8</string>
</property>
</widget>
</item>
<item row="2" column="7">
<widget class="QPushButton" name="ly">
<property name="text">
<string>y</string>
</property>
</widget>
</item>
<item row="2" column="8">
<widget class="QPushButton" name="lu">
<property name="text">
<string>u</string>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QPushButton" name="n5">
<property name="text">
<string>5</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="lw">
<property name="text">
<string>w</string>
</property>
</widget>
</item>
<item row="2" column="6">
<widget class="QPushButton" name="lt">
<property name="text">
<string>t</string>
</property>
</widget>
</item>
<item row="7" column="9">
<widget class="QPushButton" name="lm">
<property name="text">
<string>m</string>
</property>
</widget>
</item>
<item row="7" column="12">
<widget class="QPushButton" name="eraseBtn">
<property name="text">
<string>⌫</string>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QPushButton" name="n7">
<property name="text">
<string>7</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="lq">
<property name="text">
<string>q</string>
</property>
</widget>
</item>
<item row="2" column="9">
<widget class="QPushButton" name="li">
<property name="text">
<string>i</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QPushButton" name="lz">
<property name="text">
<string>z</string>
</property>
</widget>
</item>
<item row="7" column="10">
<widget class="QPushButton" name="spt">
<property name="text">
<string>.</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="n4">
<property name="text">
<string>4</string>
</property>
</widget>
</item>
<item row="2" column="10">
<widget class="QPushButton" name="lo">
<property name="text">
<string>o</string>
</property>
</widget>
</item>
<item row="7" column="8">
<widget class="QPushButton" name="ln">
<property name="text">
<string>n</string>
</property>
</widget>
</item>
<item row="6" column="12">
<widget class="QPushButton" name="ll">
<property name="text">
<string>l</string>
</property>
</widget>
</item>
<item row="6" column="10">
<widget class="QPushButton" name="lk">
<property name="text">
<string>k</string>
</property>
</widget>
</item>
<item row="6" column="9">
<widget class="QPushButton" name="lj">
<property name="text">
<string>j</string>
</property>
</widget>
</item>
<item row="6" column="8">
<widget class="QPushButton" name="lh">
<property name="text">
<string>h</string>
</property>
</widget>
</item>
<item row="6" column="7">
<widget class="QPushButton" name="lg">
<property name="text">
<string>g</string>
</property>
</widget>
</item>
<item row="6" column="6">
<widget class="QPushButton" name="lf">
<property name="text">
<string>f</string>
</property>
</widget>
</item>
<item row="6" column="4">
<widget class="QPushButton" name="ld">
<property name="text">
<string>d</string>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QPushButton" name="ls">
<property name="text">
<string>s</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QPushButton" name="la">
<property name="text">
<string>a</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QPushButton" name="sat">
<property name="text">
<string>#</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2"/>
</widget>
</item>
<item row="2" column="1">
<widget class="QStackedWidget" name="leftSpacerWidget">
<widget class="QWidget" name="page_9">
<layout class="QVBoxLayout" name="verticalLayout_4">
<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="leftSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_10"/>
</widget>
</item>
</layout> </layout>
</widget> </item>
<widget class="QWidget" name="page_2"/> </layout>
</widget> </widget>
</item> <widget class="QWidget" name="page_8"/>
<item row="1" column="1"> </widget>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="spaceBtn">
<property name="text">
<string>Space</string>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>