Improve logging; add 'Univers (u001)' font in Reader

This commit is contained in:
Nicolas Mailloux 2022-04-10 21:37:33 -04:00
parent 8b6a1ed5c1
commit dd69ec95b5
12 changed files with 63 additions and 44 deletions

View file

@ -78,7 +78,7 @@ void apps::exitSlot() {
void apps::on_scribbleLaunchBtn_clicked()
{
log("Launching external Scribble app ...", className);
log("Launching external Scribble app", className);
QProcess process;
process.startDetached("scribble", QStringList());
qApp->quit();
@ -86,7 +86,7 @@ void apps::on_scribbleLaunchBtn_clicked()
void apps::on_lightmapsLaunchBtn_clicked()
{
log("Launching external LightMaps app ...", className);
log("Launching external LightMaps app", className);
QProcess process;
process.startDetached("lightmaps", QStringList());
qApp->quit();
@ -94,7 +94,7 @@ void apps::on_lightmapsLaunchBtn_clicked()
void apps::on_savedWordsLaunchBtn_clicked()
{
log("Launching Saved Words app ...", className);
log("Launching Saved Words app", className);
savedWordsWindow = new savedwords();
savedWordsWindow->setAttribute(Qt::WA_DeleteOnClose);
savedWordsWindow->showFullScreen();
@ -102,7 +102,7 @@ void apps::on_savedWordsLaunchBtn_clicked()
void apps::on_calendarLaunchBtn_clicked()
{
log("Launching Calendar app ...", className);
log("Launching Calendar app", className);
calendarWindow = new calendarApp();
calendarWindow->setAttribute(Qt::WA_DeleteOnClose);
calendarWindow->showFullScreen();
@ -110,7 +110,7 @@ void apps::on_calendarLaunchBtn_clicked()
void apps::on_calculatorLaunchBtn_clicked()
{
log("Launching external Calculator app ...", className);
log("Launching external Calculator app", className);
QProcess process;
process.startDetached("calculator", QStringList());
qApp->quit();
@ -118,7 +118,7 @@ void apps::on_calculatorLaunchBtn_clicked()
void apps::on_koboxAppsOpenButton_clicked()
{
log("Showing KoBox Apps Dialog ...", className);
log("Showing KoBox Apps Dialog", className);
koboxAppsDialogWindow = new koboxAppsDialog();
connect(koboxAppsDialogWindow, SIGNAL(showToast(QString)), SLOT(showToastNative(QString)));
koboxAppsDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
@ -127,7 +127,7 @@ void apps::on_koboxAppsOpenButton_clicked()
void apps::on_vncLaunchBtn_clicked()
{
log("Showing VNC dialog ...", className);
log("Showing VNC dialog", className);
global::keyboard::keyboardDialog = true;
global::keyboard::vncDialog = true;
global::keyboard::keyboardText = "";
@ -143,7 +143,7 @@ void apps::refreshScreenNative() {
void apps::on_reversiLaunchBtn_clicked()
{
log("Launching external Reversi app ...", className);
log("Launching external Reversi app", className);
QProcess process;
process.startDetached("qreversi", QStringList());
qApp->quit();
@ -151,7 +151,7 @@ void apps::on_reversiLaunchBtn_clicked()
void apps::on_g2048LaunchBtn_clicked()
{
log("Launching external 2048 app ...", className);
log("Launching external 2048 app", className);
QProcess process;
process.startDetached("2048", QStringList());
qApp->quit();

View file

@ -76,6 +76,8 @@ bookInfoDialog::bookInfoDialog(QWidget *parent) :
}
}
log("Setting up book info dialog, ID: " + QString::number(global::library::bookId) + ", title: " + global::library::bookTitle, className);
// Centering dialog
this->adjustSize();
QRect screenGeometry = QGuiApplication::screens()[0]->geometry();
@ -106,6 +108,7 @@ void bookInfoDialog::on_getBtn_clicked()
global::toast::modalToast = true;
global::toast::indefiniteToast = true;
log("Downloading book, ID: " + QString::number(global::library::bookId) + ", title: " + global::library::bookTitle, className);
emit showToast("Downloading");
QTimer::singleShot(500, this, SLOT(waitForBookFetch()));
@ -116,12 +119,14 @@ void bookInfoDialog::waitForBookFetch() {
if(QFile::exists("/inkbox/gutenberg/getBookDone")) {
if(checkconfig("/inkbox/gutenberg/getBookDone") == true) {
emit closeIndefiniteToast();
QString function = __func__; log(function + ": Download successful", className);
emit showToast("Download successful");
QFile::remove("/inkbox/gutenberg/getBookDone");
break;
}
else {
emit closeIndefiniteToast();
QString function = __func__; log(function + ": Download failed", className);
emit showToast("Download failed");
QFile::remove("/inkbox/gutenberg/getBookDone");
break;

View file

@ -151,7 +151,7 @@ namespace {
if(global::logger::status == true) {
QDebug logger = qDebug();
logger.noquote();
logger << QDateTime::currentDateTime().toString("dd/MM/yyyy @ hh:mm:ss") << "|" << className + ":" << message;
logger << QDateTime::currentDateTime().toString("dd/MM/yyyy @ hh:mm:ss") << "|" << className + ":" << message.trimmed();
}
}
bool checkconfig(QString file) {
@ -404,7 +404,7 @@ namespace {
}
}
void poweroff(bool splash) {
log("Powering off ...", "functions");
log("Powering off", "functions");
if(splash == true) {
QString prog ("/sbin/poweroff");
QStringList args;
@ -424,7 +424,7 @@ namespace {
}
}
void reboot(bool splash) {
log("Rebooting ...", "functions");
log("Rebooting", "functions");
if(splash == true) {
QString prog ("/sbin/reboot");
QStringList args;
@ -536,12 +536,12 @@ namespace {
}
void resetKoboxUserData() {
log("Resetting KoBox user data ...", "functions");
log("Resetting KoBox user data", "functions");
global::kobox::resetKoboxUserDataBool = true;
reboot(true);
}
QString findEpubMetadata(QString book_file, QString metadata) {
log("Finding ePUB metadata ...", "functions");
log("Finding ePUB metadata, query: " + metadata, "functions");
setDefaultWorkDir();
QString prog ("sh");
QStringList args;
@ -636,7 +636,7 @@ namespace {
}
}
bool connectToNetwork(QString essid, QString passphrase) {
log("Connecting to network " + essid + " ...", "functions");
log("Connecting to network " + essid, "functions");
std::string essid_str = essid.toStdString();
std::string passphrase_str = passphrase.toStdString();
string_writeconfig("/run/wifi_network_essid", essid_str);

View file

@ -249,6 +249,7 @@ void libraryWidget::syncCatalog() {
global::toast::modalToast = true;
global::toast::indefiniteToast = true;
bool syncDone = false;
log("Gutenberg sync in progress", className);
showToast("Sync in progress");
string_writeconfig("/opt/ibxd", "gutenberg_sync\n");
@ -258,12 +259,12 @@ void libraryWidget::syncCatalog() {
if(syncDone == false) {
if(QFile::exists("/inkbox/gutenbergSyncDone") == true) {
if(checkconfig("/inkbox/gutenbergSyncDone") == true) {
qDebug() << "Gutenberg sync successfully completed";
log("syncCatalog(): Gutenberg sync successfully completed", className);
toastWindow->close();
setupView();
}
else {
qDebug() << "Gutenberg sync encountered an error";
log("syncCatalog(): Gutenberg sync encountered an error", className);
toastWindow->close();
showToast("Error");
QFile::remove("/external_root/opt/storage/gutenberg/last_sync");

View file

@ -506,7 +506,7 @@ MainWindow::MainWindow(QWidget *parent)
string_checkconfig_ro("/external_root/opt/isa/changelog");
updatemsg = updatemsg.append(checkconfig_str_val);
updatemsg = updatemsg.append("</font>");
log("Showing update changelog ...", className);
log("Showing update changelog", className);
QMessageBox::information(this, tr("Information"), updatemsg);
string_writeconfig("/external_root/opt/update/inkbox_updated", "false");
@ -585,7 +585,7 @@ MainWindow::~MainWindow()
}
void MainWindow::openUpdateDialog() {
log("Showing Update dialog ...", className);
log("Showing Update dialog", className);
global::mainwindow::updateDialog = true;
// Write to a temporary file to show an "Update" prompt
string_writeconfig("/inkbox/updateDialog", "true");
@ -599,7 +599,7 @@ void MainWindow::openUpdateDialog() {
}
void MainWindow::openLowBatteryDialog() {
log("Showing Low Battery Dialog ...", className);
log("Showing Low Battery Dialog", className);
global::mainwindow::lowBatteryDialog = true;
global::battery::batteryAlertLock = true;
@ -609,7 +609,7 @@ void MainWindow::openLowBatteryDialog() {
}
void MainWindow::openUsbmsDialog() {
log("Showing USB Mass Storage dialog ...", className);
log("Showing USB Mass Storage dialog", className);
global::usbms::showUsbmsDialog = false;
global::usbms::usbmsDialog = true;
@ -630,7 +630,7 @@ void MainWindow::openCriticalBatteryAlertWindow() {
void MainWindow::on_settingsBtn_clicked()
{
log("Opening Settings Chooser widget ...", className);
log("Opening Settings Chooser widget", className);
resetFullWindowException = true;
resetWindow(false);
if(global::mainwindow::tabSwitcher::settingsChooserWidgetSelected != true) {
@ -658,7 +658,7 @@ void MainWindow::on_settingsBtn_clicked()
void MainWindow::on_appsBtn_clicked()
{
log("Opening Apps widget ...", className);
log("Opening Apps widget", className);
resetFullWindowException = true;
resetWindow(false);
if(global::mainwindow::tabSwitcher::appsWidgetSelected != true) {
@ -697,7 +697,7 @@ void MainWindow::on_searchBtn_clicked()
void MainWindow::on_quitBtn_clicked()
{
log("Opening Quit widget ...", className);
log("Opening Quit widget", className);
quitWindow = new quit();
quitWindow->setAttribute(Qt::WA_DeleteOnClose);
quitWindow->showFullScreen();
@ -737,7 +737,7 @@ void MainWindow::on_book4Btn_clicked()
void MainWindow::on_brightnessBtn_clicked()
{
log("Showing Brightness Dialog ...", className);
log("Showing Brightness Dialog", className);
brightnessDialogWindow = new brightnessDialog();
brightnessDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
brightnessDialogWindow->show();
@ -745,7 +745,7 @@ void MainWindow::on_brightnessBtn_clicked()
void MainWindow::on_homeBtn_clicked()
{
log("Showing home screen ...", className);
log("Showing home screen", className);
global::mainwindow::tabSwitcher::repaint = true;
resetFullWindowException = true;
resetWindow(true);
@ -896,7 +896,7 @@ void MainWindow::refreshScreen() {
}
void MainWindow::setupSearchDialog() {
log("Launching Search dialog ...", className);
log("Launching Search dialog", className);
if(global::forbidOpenSearchDialog == false) {
global::keyboard::keyboardDialog = true;
global::keyboard::searchDialog = true;
@ -1001,7 +1001,7 @@ void MainWindow::setWifiIcon() {
}
void MainWindow::openWifiDialog() {
log("Opening Wi-Fi connection interface ...", className);
log("Opening Wi-Fi connection interface", className);
if(checkconfig("/external_root/run/was_connected_to_wifi") == true and wifiIconClickedWhileReconnecting == false) {
showToast("Reconnection in progress\nTap again to cancel");
wifiIconClickedWhileReconnecting = true;
@ -1064,7 +1064,7 @@ void MainWindow::openUpdateDialogOTA(bool open) {
}
void MainWindow::launchOtaUpdater() {
log("Launching OTA updater ...", className);
log("Launching OTA updater", className);
otaManagerWindow = new otaManager(this);
connect(otaManagerWindow, SIGNAL(canOtaUpdate(bool)), SLOT(openUpdateDialogOTA(bool)));
otaManagerWindow->setAttribute(Qt::WA_DeleteOnClose);
@ -1086,7 +1086,7 @@ void MainWindow::openBookFile(QString book, bool relativePath) {
}
void MainWindow::openReaderFramework() {
log("Launching Reader Framework ...", className);
log("Launching Reader Framework", className);
readerWindow = new reader();
readerWindow->setAttribute(Qt::WA_DeleteOnClose);
connect(readerWindow, SIGNAL(openBookFile(QString, bool)), SLOT(openBookFile(QString, bool)));
@ -1094,7 +1094,7 @@ void MainWindow::openReaderFramework() {
}
void MainWindow::checkForUpdate() {
log("Checking for available updates ...", className);
log("Checking for available updates", className);
if(checkconfig("/mnt/onboard/onboard/.inkbox/can_update") == true) {
if(checkconfig("/tmp/cancelUpdateDialog") == false) {
// I'm sorry.
@ -1102,7 +1102,7 @@ void MainWindow::checkForUpdate() {
QTimer::singleShot(2000, this, SLOT(openUpdateDialog()));
}
else {
QString function = __func__; log(function + ": Not showing update dialog, user dismissed it ...", className);
QString function = __func__; log(function + ": Not showing update dialog, user dismissed it", className);
}
}
else {
@ -1111,7 +1111,7 @@ void MainWindow::checkForUpdate() {
}
void MainWindow::openEncfsRepackDialog() {
log("Showing encrypted storage repack dialog ...", className);
log("Showing encrypted storage repack dialog", className);
global::encfs::repackDialog = true;
global::usbms::showUsbmsDialog = false;
global::usbms::usbmsDialog = false;
@ -1121,7 +1121,7 @@ void MainWindow::openEncfsRepackDialog() {
void MainWindow::on_libraryButton_clicked()
{
log("Launching Online Library ...", className);
log("Launching Online Library", className);
if(testPing() == 0 or global::deviceID == "emu\n") {
resetFullWindowException = false;
resetWindow(false);

View file

@ -13,7 +13,7 @@ otaManager::otaManager(QWidget *parent) :
ui->setupUi(this);
QThread::msleep(500);
if(global::otaUpdate::downloadOta == false) {
log("Checking for available OTA update ...", className);
log("Checking for available OTA update", className);
string_writeconfig("/opt/ibxd", "ota_update_check\n");
QTimer * otaCheckTimer = new QTimer(this);
otaCheckTimer->setInterval(100);
@ -35,7 +35,7 @@ otaManager::otaManager(QWidget *parent) :
otaCheckTimer->start();
}
else {
log("Downloading OTA update ...", className);
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);

View file

@ -66,7 +66,7 @@ void quit::on_pushButton_2_clicked()
void quit::on_pushButton_4_clicked()
{
log("Restarting InkBox ...", className);
log("Restarting InkBox", className);
QProcess process;
process.startDetached("inkbox", QStringList());
qApp->quit();
@ -79,7 +79,7 @@ void quit::on_backBtn_clicked()
void quit::on_pushButton_3_clicked()
{
log("Suspending ...", className);
log("Suspending", className);
// inotifywait waits for a MODIFY event, so we just do it instead of evtest and the power button
string_writeconfig("/external_root/tmp/power", "KEY_POWER");
}

View file

@ -269,6 +269,10 @@ reader::reader(QWidget *parent) :
else if(checkconfig_str_val == "Ibarra Real Nova") {
setIbarraFont();
}
else if(checkconfig_str_val == "u001") {
ui->text->setFont(QFont("u001"));
ui->fontChooser->setCurrentText("Univers (u001)");
}
else {
QFont config_font(checkconfig_str_val);
ui->text->setFont(config_font);
@ -1262,7 +1266,7 @@ void reader::on_fontChooser_currentIndexChanged(const QString &arg1)
string_writeconfig(".config/04-book/font", "Libertinus Serif");
}
if(arg1 == "Crimson Pro") {
// As adding Crimson Pro to the default fonts bundled along with the Qt libs breaks the general Inter homogeneity, it is incorporated on-demand here.
// As adding Crimson Pro to the default fonts bundled along with the Qt libs breaks the general u001/Inter homogeneity, it is incorporated on-demand here.
setCrimsonProFont();
string_writeconfig(".config/04-book/font", "Crimson Pro");
}
@ -1274,6 +1278,10 @@ void reader::on_fontChooser_currentIndexChanged(const QString &arg1)
setIbarraFont();
string_writeconfig(".config/04-book/font", "Ibarra Real Nova");
}
if(arg1 == "Univers (u001)") {
ui->text->setFont(QFont("u001"));
string_writeconfig(".config/04-book/font", "u001");
}
}
void reader::on_alignLeftBtn_clicked()

View file

@ -607,6 +607,11 @@
</item>
<item row="0" column="1">
<widget class="QComboBox" name="fontChooser">
<item>
<property name="text">
<string>Univers (u001)</string>
</property>
</item>
<item>
<property name="text">
<string>Inter</string>

View file

@ -69,7 +69,7 @@ settingsChooser::~settingsChooser()
void settingsChooser::on_inkboxSettingsBtn_clicked()
{
log("Launching InkBox Settings ...", className);
log("Launching InkBox Settings", className);
settingsWindow = new settings();
settingsWindow->setAttribute(Qt::WA_DeleteOnClose);
connect(settingsWindow, SIGNAL(showToast(QString)), SLOT(showToastNative(QString)));
@ -79,7 +79,7 @@ void settingsChooser::on_inkboxSettingsBtn_clicked()
void settingsChooser::on_koboxSettingsBtn_clicked()
{
log("Launching KoBox Settings ...", className);
log("Launching KoBox Settings", className);
koboxSettingsWindow = new koboxSettings();
koboxSettingsWindow->setAttribute(Qt::WA_DeleteOnClose);
koboxSettingsWindow->showFullScreen();

View file

@ -11,7 +11,7 @@ toast::toast(QWidget *parent) :
ui(new Ui::toast)
{
ui->setupUi(this);
log("Displaying message " + global::toast::message, className);
log("Displaying message '" + global::toast::message + "'", className);
if(global::toast::modalToast == true) {
global::toast::modalToast = false;

View file

@ -66,7 +66,7 @@ usbms_splash::usbms_splash(QWidget *parent) :
void usbms_splash::usbms_launch()
{
log("Entering USBMS session ...", className);
log("Entering USBMS session", className);
string_writeconfig("/tmp/in_usbms", "true");
QTimer::singleShot(1500, this, SLOT(brightnessDown()));
@ -117,7 +117,7 @@ void usbms_splash::usbms_launch()
qApp->quit();
}
else {
log("Exiting USBMS session ...", className);
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"));