Implement logger; design language fixes

This commit is contained in:
Nicolas Mailloux 2022-04-05 00:47:15 -04:00
parent 65639294fe
commit f652dbddf0
39 changed files with 95 additions and 40 deletions

View file

@ -12,7 +12,7 @@ alert::alert(QWidget *parent) :
ui(new Ui::alert)
{
ui->setupUi(this);
alert::setFont(QFont("u001"));
ui->messageLabel->setFont(QFont("u001"));
// Getting the screen's size
float sW = QGuiApplication::screens()[0]->size().width();
@ -82,9 +82,9 @@ alert::alert(QWidget *parent) :
qApp->quit();
}
ui->warningLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 18pt }");
ui->warningLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 16pt }");
ui->messageLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 10pt }");
ui->securityLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 12pt }");
ui->securityLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 11pt }");
ui->continueBtn->setProperty("type", "borderless");
ui->resetBtn->setProperty("type", "borderless");
ui->continueBtn->setStyleSheet("padding: 20px");

View file

@ -14,6 +14,7 @@ class alert : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit alert(QWidget *parent = nullptr);
~alert();
bool signatureError = false;

View file

@ -114,6 +114,7 @@ void apps::on_calculatorLaunchBtn_clicked()
void apps::on_koboxAppsOpenButton_clicked()
{
koboxAppsDialogWindow = new koboxAppsDialog();
connect(koboxAppsDialogWindow, SIGNAL(showToast(QString)), SLOT(showToastNative(QString)));
koboxAppsDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
koboxAppsDialogWindow->show();
}
@ -146,3 +147,7 @@ void apps::on_g2048LaunchBtn_clicked()
process.startDetached("2048", QStringList());
qApp->quit();
}
void apps::showToastNative(QString messageToDisplay) {
emit showToast(messageToDisplay);
}

3
apps.h
View file

@ -16,6 +16,7 @@ class apps : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit apps(QWidget *parent = nullptr);
~apps();
@ -31,6 +32,7 @@ private slots:
void on_reversiLaunchBtn_clicked();
void refreshScreenNative();
void on_g2048LaunchBtn_clicked();
void showToastNative(QString messageToDisplay);
private:
Ui::apps *ui;
@ -41,6 +43,7 @@ private:
signals:
void refreshScreen();
void showToast(QString messageToDisplay);
};
#endif // APPS_H

View file

@ -12,6 +12,7 @@ class bookInfoDialog : public QDialog
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit bookInfoDialog(QWidget *parent = nullptr);
~bookInfoDialog();
float sH;

View file

@ -14,6 +14,7 @@ class brightnessDialog : public QDialog
Q_OBJECT
public:
QString className = this->metaObject()->className();
QString checkconfig_str_val;
int oldValue;
int oldWarmthValue;

View file

@ -12,6 +12,7 @@ class calendarApp : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit calendarApp(QWidget *parent = nullptr);
~calendarApp();

View file

@ -14,6 +14,7 @@ class dictionaryWidget : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit dictionaryWidget(QWidget *parent = nullptr);
~dictionaryWidget();
void dictionaryLookup(std::string word, QString first_letter, int position);

View file

@ -16,13 +16,9 @@ encryptionManager::encryptionManager(QWidget *parent) :
ui(new Ui::encryptionManager)
{
ui->setupUi(this);
ui->encryptionSetupLabel->setFont(QFont("u001"));
ui->successLabel->setFont(QFont("u001"));
ui->failureLabel->setFont(QFont("u001"));
ui->descriptionLabel->setFont(QFont("u001"));
ui->successDescriptionLabel->setFont(QFont("u001"));
ui->failureDescriptionLabel->setFont(QFont("u001"));
ui->warningLabel->setFont(QFont("u001"));
ui->warningDescriptionLabel->setFont(QFont("u001"));
// Stylesheet
@ -31,11 +27,11 @@ encryptionManager::encryptionManager(QWidget *parent) :
this->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
ui->encryptionSetupLabel->setStyleSheet("font-size: 18pt; font-weight: bold");
ui->encryptionSetupLabel->setStyleSheet("font-size: 15pt; font-weight: bold");
ui->descriptionLabel->setStyleSheet("font-size: 10pt");
ui->successLabel->setStyleSheet("font-size: 18pt; font-weight: bold");
ui->successLabel->setStyleSheet("font-size: 15pt; font-weight: bold");
ui->successDescriptionLabel->setStyleSheet("font-size: 10pt");
ui->failureLabel->setStyleSheet("font-size: 18pt; font-weight: bold");
ui->failureLabel->setStyleSheet("font-size: 15pt; font-weight: bold");
ui->failureDescriptionLabel->setStyleSheet("font-size: 10pt");
ui->setupContinueBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold; border-radius: 10px");
ui->setupAbortBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold; border-radius: 10px");
@ -43,7 +39,7 @@ encryptionManager::encryptionManager(QWidget *parent) :
ui->failureContinueBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold; border-radius: 10px");
ui->acceptBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold; border-radius: 10px");
ui->usbmsBtn->setStyleSheet("background: lightGrey; border: 3px solid black; color: black; padding: 10px; outline: none; font-size: 10pt; font-weight: bold; border-radius: 10px");
ui->warningLabel->setStyleSheet("font-size: 18pt; font-weight: bold");
ui->warningLabel->setStyleSheet("font-size: 15pt; font-weight: bold");
ui->warningDescriptionLabel->setStyleSheet("font-size: 10pt");
// Getting the screen's size
@ -259,7 +255,7 @@ void encryptionManager::unlockEncryptedStorage() {
std::string unlockTime_str = to_string(currentEpoch);
global::encfs::unlockTime = QDateTime::fromTime_t(currentEpoch).toString();
QString message = "FATAL: 4 invalid passphrase tries, locking down device until " + global::encfs::unlockTime;
qDebug() << message;
log(message, className);
string_writeconfig("/external_root/boot/flags/ENCRYPT_LOCK", unlockTime_str);
global::encfs::lockdown = true;
setupMessageBoxRan = true;
@ -328,7 +324,7 @@ void encryptionManager::on_failureContinueBtn_clicked()
void encryptionManager::setupFailedAuthenticationMessageBox() {
ui->activityWidget->hide();
QMessageBox::critical(this, tr("Invalid argument"), tr("Invalid passphrase. Please try again."));
QMessageBox::critical(this, tr("Invalid argument"), tr("<font face='u001'>Invalid passphrase. Please try again.</font>"));
QFile::remove("/external_root/run/encfs_mounted");
quit_restart();
}

View file

@ -16,6 +16,7 @@ class encryptionManager : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit encryptionManager(QWidget *parent = nullptr);
~encryptionManager();
bool setupExitWidgetRan = false;

View file

@ -75,8 +75,7 @@
<item row="5" column="0">
<widget class="QLabel" name="descriptionLabel">
<property name="text">
<string>&lt;font face=&quot;u001&quot;&gt;Encrypted storage allows you to keep your most important files and data safe from anyone else than you.
Would you like to enable it&lt;/font&gt;&lt;font face=&quot;Inter&quot;&gt;?&lt;/font&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-family:'u001';&quot;&gt;Encrypted storage allows you to keep your most important files and data safe from anyone else but you. Would you like to enable it&lt;/span&gt;&lt;span style=&quot; font-family:'Inter';&quot;&gt;?&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>

View file

@ -12,6 +12,7 @@
#include <QTimer>
#include <QDebug>
#include <QRandomGenerator>
#include <QDateTime>
#include <stdio.h>
#include <fcntl.h>
@ -116,6 +117,9 @@ namespace global {
namespace localStorage {
inline QStringList searchResultsPaths;
}
namespace logger {
inline bool status;
}
inline QString systemInfoText;
inline bool forbidOpenSearchDialog;
inline bool isN705;
@ -142,6 +146,13 @@ namespace {
int defaultPdfPageWidth;
int defaultPdfPageHeight;
bool checked_box = false;
void log(QString message, QString className) {
if(global::logger::status == true) {
QDebug logger = qDebug();
logger.noquote();
logger << QDateTime::currentDateTime().toString("dd/MM/yyyy @ hh:mm:ss") << "|" << className + ":" << message;
}
}
bool checkconfig(QString file) {
if(QFile::exists(file)) {
QFile config(file);
@ -690,7 +701,6 @@ namespace {
}
return exitCode;
}
}
#endif // FUNCTIONS_H

View file

@ -650,13 +650,13 @@ void generalDialog::syncGutenbergCatalog() {
connect(syncCheckTimer, &QTimer::timeout, [&]() {
if(QFile::exists("/inkbox/gutenbergSyncDone") == true) {
if(checkconfig("/inkbox/gutenbergSyncDone") == true) {
qDebug() << "Gutenberg sync successfully completed";
log("Gutenberg sync successfully completed", className);
gutenbergSyncDone = true;
gutenbergSyncStatus = true;
emit closeIndefiniteToast();
}
else {
qDebug() << "Gutenberg sync encountered an error";
log("Gutenberg sync encountered an error", className);
gutenbergSyncDone = true;
gutenbergSyncStatus = false;
emit closeIndefiniteToast();

View file

@ -22,6 +22,7 @@ class generalDialog : public QDialog
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit generalDialog(QWidget *parent = nullptr);
~generalDialog();
bool resetDialog = false;

View file

@ -12,6 +12,7 @@ class hourglassAnimationWidget : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit hourglassAnimationWidget(QWidget *parent = nullptr);
~hourglassAnimationWidget();
int i;

View file

@ -90,8 +90,8 @@ void koboxAppsDialog::on_launchBtn_clicked()
{
index = ui->appsList->currentIndex();
itemText = index.data(Qt::DisplayRole).toString();
if(itemText == "") {
QMessageBox::critical(this, tr("Invalid argument"), tr("Please select an application."));
if(itemText.isEmpty()) {
emit showToast("Please select an application");
}
else {
// DPI setting

View file

@ -15,6 +15,7 @@ class koboxAppsDialog : public QDialog
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit koboxAppsDialog(QWidget *parent = nullptr);
~koboxAppsDialog();
@ -30,6 +31,9 @@ private slots:
void on_cancelBtn_clicked();
void on_launchBtn_clicked();
signals:
void showToast(QString messageToDisplay);
private:
Ui::koboxAppsDialog *ui;
usbms_splash *usbmsSplashWindow;

View file

@ -15,6 +15,7 @@ class koboxSettings : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit koboxSettings(QWidget *parent = nullptr);
~koboxSettings();

View file

@ -14,6 +14,7 @@ class libraryWidget : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit libraryWidget(QWidget *parent = nullptr);
~libraryWidget();
float sH;

View file

@ -32,6 +32,13 @@
int main(int argc, char *argv[])
{
global::deviceID = readFile("/opt/inkbox_device");
if(char * debug = std::getenv("DEBUG")) {
if(std::atoi(debug) == 1) {
global::logger::status = true;
}
}
setDefaultWorkDir();
if(checkconfig(".config/18-encrypted_storage/status") == true and checkconfig("/external_root/run/encfs_mounted") == false) {
// Open Encryption Manager to unlock encrypted storage

View file

@ -314,7 +314,7 @@ MainWindow::MainWindow(QWidget *parent)
;
}
else {
qDebug() << "Warning! Battery is at a critical charge level!";
log("Warning! Battery is at a critical charge level!", className);
openCriticalBatteryAlertWindow();
}
}
@ -334,7 +334,7 @@ MainWindow::MainWindow(QWidget *parent)
;
}
else {
qDebug() << "Warning! Battery is low!";
log("Warning! Battery is low!", className);
openLowBatteryDialog();
}
}
@ -662,6 +662,7 @@ void MainWindow::on_appsBtn_clicked()
// Create widget
appsWindow = new apps();
connect(appsWindow, SIGNAL(refreshScreen()), SLOT(refreshScreen()));
connect(appsWindow, SIGNAL(showToast(QString)), SLOT(showToast(QString)));
ui->stackedWidget->insertWidget(1, appsWindow);
global::mainwindow::tabSwitcher::appsWidgetCreated = true;
@ -1029,7 +1030,7 @@ void MainWindow::showToast(QString messageToDisplay) {
}
void MainWindow::hello(int testNumber) {
qDebug() << "Hello" << testNumber;
log("Hello" + QString::number(testNumber), className);
}
void MainWindow::closeIndefiniteToast() {
@ -1079,11 +1080,11 @@ void MainWindow::checkForUpdate() {
if(checkconfig("/mnt/onboard/onboard/.inkbox/can_update") == true) {
if(checkconfig("/tmp/cancelUpdateDialog") == false) {
// I'm sorry.
qDebug() << "An update is available.";
log("An update is available.", className);
QTimer::singleShot(2000, this, SLOT(openUpdateDialog()));
}
else {
qDebug() << "Not showing update dialog, user dismissed it...";
log("Not showing update dialog, user dismissed it ...", className);
}
}
}

View file

@ -30,6 +30,7 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
QString className = this->metaObject()->className();
MainWindow(QWidget *parent = nullptr);
~MainWindow();

View file

@ -13,18 +13,18 @@ otaManager::otaManager(QWidget *parent) :
ui->setupUi(this);
QThread::msleep(500);
if(global::otaUpdate::downloadOta == false) {
qDebug() << "Checking for available OTA update ...";
log("Checking for available OTA update ...", className);
string_writeconfig("/opt/ibxd", "ota_update_check\n");
QTimer * otaCheckTimer = new QTimer(this);
otaCheckTimer->setInterval(100);
connect(otaCheckTimer, &QTimer::timeout, [&]() {
if(QFile::exists("/run/can_ota_update") == true) {
if(checkconfig("/run/can_ota_update") == true) {
qDebug() << "OTA update is available!";
log("OTA update is available!", className);
emit canOtaUpdate(true);
}
else {
qDebug() << "No OTA update available.";
log("No OTA update available.", className);
emit canOtaUpdate(false);
}
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
@ -35,7 +35,7 @@ otaManager::otaManager(QWidget *parent) :
otaCheckTimer->start();
}
else {
qDebug() << "Downloading OTA update ...";
log("Downloading OTA update ...", className);
QFile::remove("/run/can_install_ota_update");
string_writeconfig("/opt/ibxd", "ota_update_download\n");
QTimer * otaDownloadTimer = new QTimer(this);
@ -43,12 +43,12 @@ otaManager::otaManager(QWidget *parent) :
connect(otaDownloadTimer, &QTimer::timeout, [&]() {
if(QFile::exists("/run/can_install_ota_update") == true) {
if(checkconfig("/run/can_install_ota_update") == true) {
qDebug() << "Download succeeded.";
log("Download succeeded.", className);
emit downloadedOtaUpdate(true);
global::otaUpdate::downloadOta = false;
}
else {
qDebug() << "Download failed.";
log("Download failed.", className);
emit downloadedOtaUpdate(false);
global::otaUpdate::downloadOta = false;
}

View file

@ -12,6 +12,7 @@ class otaManager : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit otaManager(QWidget *parent = nullptr);
~otaManager();

1
quit.h
View file

@ -14,6 +14,7 @@ class quit : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit quit(QWidget *parent = nullptr);
~quit();

View file

@ -219,7 +219,7 @@ reader::reader(QWidget *parent) :
}
}
}
qDebug() << "Reader: Opening file" << book_file;
log("Opening file '" + book_file + "'", className);
// Writing book path to file
std::string book_file_str = book_file.toStdString();
@ -697,7 +697,7 @@ reader::reader(QWidget *parent) :
}
else {
if(isBatteryCritical() == true) {
qDebug() << "Warning! Battery is at a critical charge level!";
log("Warning! Battery is at a critical charge level!", className);
openCriticalBatteryAlertWindow();
}
}
@ -716,7 +716,7 @@ reader::reader(QWidget *parent) :
;
}
else {
qDebug() << "Warning! Battery is low!";
log("Warning! Battery is low!", className);
openLowBatteryDialog();
}
}

View file

@ -46,6 +46,7 @@ class reader : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit reader(QWidget *parent = nullptr);
~reader();

View file

@ -19,6 +19,7 @@ class savedwords : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit savedwords(QWidget *parent = nullptr);
~savedwords();
QString words;

View file

@ -14,6 +14,7 @@ class searchResultsWidget : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit searchResultsWidget(QWidget *parent = nullptr);
~searchResultsWidget();
void setListViewContents(QStringList searchResults);

View file

@ -55,7 +55,7 @@ settings::settings(QWidget *parent) :
ui->generateSystemReportBtn->setStyleSheet("font-size: 9pt");
ui->checkOtaUpdateBtn->setStyleSheet("font-size: 9pt");
ui->comboBox->setStyleSheet("font-size: 9pt");
ui->tzComboBox->setStyleSheet("font-size: 9pt");
ui->tzComboBox->setStyleSheet("font-size: 8.5pt");
ui->sleepTimeoutComboBox->setStyleSheet("font-size: 9pt");
ui->setPasscodeBtn->setStyleSheet("font-size: 9pt");
ui->repackBtn->setStyleSheet("font-size: 9pt");

View file

@ -19,6 +19,7 @@ class settings : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
int settings_page = 1;
bool launch_sh = false;
bool ui_enable_changed = false;

View file

@ -15,6 +15,7 @@ class settingsChooser : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit settingsChooser(QWidget *parent = nullptr);
~settingsChooser();

View file

@ -12,6 +12,7 @@ class textwidget : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit textwidget(QWidget *parent = nullptr);
~textwidget();

View file

@ -14,6 +14,7 @@ class toast : public QDialog
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit toast(QWidget *parent = nullptr);
~toast();
void centerToast();

View file

@ -13,6 +13,7 @@ usbms_splash::usbms_splash(QWidget *parent) :
{
ui->setupUi(this);
usbms_splash::setFont(QFont("u001"));
ui->label->setFont(QFont("Inter"));
// Getting the screen's size
sW = QGuiApplication::screens()[0]->size().width();
@ -29,8 +30,9 @@ usbms_splash::usbms_splash(QWidget *parent) :
this->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
ui->label->setFont(QFont("Inter"));
ui->label->setText("Launching KoBox subsystem");
ui->label->setStyleSheet("font-size: 14pt");
ui->label->setStyleSheet("font-size: 14pt; font-weight: bold");
ui->label_3->setText("Please wait, this could take a while.");
if(global::deviceID == "n905\n") {
ui->label_3->setStyleSheet("font-size: 11pt");
@ -48,7 +50,7 @@ usbms_splash::usbms_splash(QWidget *parent) :
float stdIconHeight = sH / 1.15;
this->setStyleSheet("background-color:black;");
ui->label->setStyleSheet("QLabel { background-color : black; color : white; font-size: 15pt }");
ui->label->setStyleSheet("QLabel { background-color : black; color : white; font-size: 15pt; font-weight: bold }");
ui->label_3->setStyleSheet("QLabel { background-color : black; color : white; font-size: 10pt }");
QPixmap pixmap(":/resources/usbms.png");
@ -64,6 +66,7 @@ usbms_splash::usbms_splash(QWidget *parent) :
void usbms_splash::usbms_launch()
{
log("Entering USBMS session ...", className);
string_writeconfig("/tmp/in_usbms", "true");
QTimer::singleShot(1500, this, SLOT(brightnessDown()));
@ -114,13 +117,15 @@ void usbms_splash::usbms_launch()
qApp->quit();
}
else {
qDebug() << "Exiting USBMS session...";
ui->label->setText("Processing content");
log("Exiting USBMS session ...", className);
// '<font/>' bit: because nothing else works ...
ui->label->setText("<font face='Inter'>Processing content</font>");
ui->label->setFont(QFont("Inter"));
ui->label_3->setText("Please wait");
ui->label_3->setFont(QFont("u001"));
ui->label->setStyleSheet("QLabel { background-color : black; color : white; font-size: 15pt; font-weight: bold }");
ui->label_3->setStyleSheet("QLabel { background-color : black; color : white; font-size: 11pt }");
ui->label->setFont(QFont("u001"));
ui->label_3->setFont(QFont("u001"));
float stdIconWidth = sW / 2;
float stdIconHeight = sH / 2;
@ -181,6 +186,7 @@ void usbms_splash::restartServices() {
// Checking for updates
string_writeconfig("/opt/ibxd", "update_inkbox_restart\n");
QThread::msleep(2500);
string_writeconfig("/tmp/in_usbms", "false");
quit_restart();
}

View file

@ -12,6 +12,7 @@ class usbms_splash : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit usbms_splash(QWidget *parent = nullptr);
~usbms_splash();
float sW;

View file

@ -13,6 +13,7 @@ class virtualkeyboard : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit virtualkeyboard(QWidget *parent = nullptr);
~virtualkeyboard();
bool shift;

View file

@ -13,6 +13,7 @@ class virtualkeypad : public QWidget
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit virtualkeypad(QWidget *parent = nullptr);
~virtualkeypad();

View file

@ -15,6 +15,7 @@ class wifiDialog : public QDialog
Q_OBJECT
public:
QString className = this->metaObject()->className();
explicit wifiDialog(QWidget *parent = nullptr);
~wifiDialog();
QString wifiNetworksList;