From 99a145d5ee11d61c8579e91b7389506716bcff14 Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Sun, 19 Jun 2022 00:14:42 -0400 Subject: [PATCH] GUI user applications: More improvements --- apps.cpp | 42 ++++++++----- apps.h | 1 + apps.ui | 157 ++++++++++++++++++++++++---------------------- generaldialog.cpp | 2 +- userapps.cpp | 2 + userapps.ui | 16 ----- 6 files changed, 115 insertions(+), 105 deletions(-) diff --git a/apps.cpp b/apps.cpp index 1c86248..074f41e 100644 --- a/apps.cpp +++ b/apps.cpp @@ -35,6 +35,8 @@ apps::apps(QWidget *parent) : ui->reversiLaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); ui->g2048LaunchBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px"); + ui->noUserAppsAvailableLabel->hide(); + // Hiding KoBox apps button and label if X11 isn't enabled/wasn't started if(checkconfig("/external_root/boot/flags/X11_START") == false or checkconfig("/external_root/boot/flags/X11_STARTED") == false) { ui->label_5->hide(); @@ -68,6 +70,7 @@ apps::apps(QWidget *parent) : } ui->editUserAppsBtn->setProperty("type", "borderless"); + ui->editUserAppsBtn->setIcon(QIcon(":/resources/edit.png")); // Refresh because Qt shows the scrollbar for one second then hides it, leaving a mark on the eInk screen QTimer::singleShot(1750, this, SLOT(refreshScreenNative())); @@ -294,9 +297,12 @@ void apps::on_editUserAppsBtn_clicked() // Settings page showUserApps(userAppsSecondPage); emit showUserAppsEdit(userAppsSecondPage); + + QTimer::singleShot(500, this, SLOT(refreshScreenNative())); } else { userAppsSecondPage = false; + userAppsAvailable = false; // Launch page // It changed via updateJsonFileSlot, and now it writes it only once @@ -308,7 +314,7 @@ void apps::on_editUserAppsBtn_clicked() showUserApps(userAppsSecondPage); emit showUserAppsEdit(userAppsSecondPage); - QTimer::singleShot(1000, this, SLOT(refreshScreenNative())); + QTimer::singleShot(500, this, SLOT(refreshScreenNative())); } } @@ -319,20 +325,28 @@ void apps::showUserApps(bool showDisabledJson) if(jsonParseSuccess == true) { QString function = __func__; log(function + ": Main user applications' JSON is valid", className); QJsonArray jsonListArray = jsonDocument.object()["list"].toArray(); - for(QJsonValueRef refJsonObject: jsonListArray) { - QJsonObject appInfo = refJsonObject.toObject(); - if(appInfo["Enabled"].toBool() == true or showDisabledJson == true) { - userapps * newUserApp = new userapps; - newUserApp->provideInfo(appInfo); - connect(this, SIGNAL(clearAppsLayout()), newUserApp, SLOT(deleteLater())); - connect(this, SIGNAL(showUserAppsEdit(bool)), newUserApp, SLOT(changePageEnabling(bool))); - connect(this, SIGNAL(updateJsonFileSignal(QJsonDocument)), newUserApp, SLOT(updateJsonFileSlotUA(QJsonDocument))); - connect(newUserApp, SIGNAL(updateJsonFileSignalUA(QJsonDocument)), this, SLOT(updateJsonFileSlot(QJsonDocument))); - newUserApp->jsonDocument = jsonDocument; - newUserApp->jsonFilePath = jsonFile.fileName(); - ui->verticalLayout_4UserApps->addWidget(newUserApp); - } + for(QJsonValueRef refJsonObject: jsonListArray) { + QJsonObject appInfo = refJsonObject.toObject(); + if(appInfo["Enabled"].toBool() == true or showDisabledJson == true) { + userAppsAvailable = true; + userapps * newUserApp = new userapps; + newUserApp->provideInfo(appInfo); + connect(this, SIGNAL(clearAppsLayout()), newUserApp, SLOT(deleteLater())); + connect(this, SIGNAL(showUserAppsEdit(bool)), newUserApp, SLOT(changePageEnabling(bool))); + connect(this, SIGNAL(updateJsonFileSignal(QJsonDocument)), newUserApp, SLOT(updateJsonFileSlotUA(QJsonDocument))); + connect(newUserApp, SIGNAL(updateJsonFileSignalUA(QJsonDocument)), this, SLOT(updateJsonFileSlot(QJsonDocument))); + newUserApp->jsonDocument = jsonDocument; + newUserApp->jsonFilePath = jsonFile.fileName(); + ui->verticalLayout_4->addWidget(newUserApp); } + } + + if(userAppsAvailable == false) { + ui->noUserAppsAvailableLabel->show(); + } + else { + ui->noUserAppsAvailableLabel->hide(); + } } else { QString function = __func__; log(function + ": Main user applications' JSON file is invalid", className); diff --git a/apps.h b/apps.h index fc63e79..b208d77 100644 --- a/apps.h +++ b/apps.h @@ -52,6 +52,7 @@ private: QJsonDocument jsonDocument; bool jsonParseSuccess = false; bool userAppsSecondPage = false; + bool userAppsAvailable = false; signals: void refreshScreen(); diff --git a/apps.ui b/apps.ui index 2cc41d1..511501a 100644 --- a/apps.ui +++ b/apps.ui @@ -28,7 +28,10 @@ - + + 0 + + QFrame::NoFrame @@ -51,7 +54,7 @@ 0 0 428 - 542 + 510 @@ -72,11 +75,14 @@ + + 8 + 0 - 6 + 15 10 @@ -311,22 +317,6 @@ - - - - - 75 - true - - - - Built-in apps - - - Qt::AlignCenter - - - @@ -340,19 +330,6 @@ - - - - QFrame::Plain - - - 3 - - - Qt::Horizontal - - - @@ -373,6 +350,12 @@ 0 + + 10 + + + 10 + @@ -387,20 +370,30 @@ - - - - 75 - true - + + + 10 - - User apps + + 10 - - Qt::AlignCenter - - + + + + + 75 + true + + + + User apps + + + Qt::AlignCenter + + + + @@ -420,31 +413,9 @@ - - - 0 - 0 - - - - - 40 - 40 - - - - - ://resources/edit.png://resources/edit.png - - - - 34 - 34 - - @@ -476,17 +447,26 @@ - - - 10 + + + + + + + + + + Chivo + - - 2 + + +No user apps currently available - - 0 + + Qt::AlignCenter - + @@ -508,6 +488,35 @@ + + + + + 75 + true + + + + Built-in apps + + + Qt::AlignCenter + + + + + + + QFrame::Plain + + + 3 + + + Qt::Horizontal + + + diff --git a/generaldialog.cpp b/generaldialog.cpp index 877ec5d..ec1b5b8 100644 --- a/generaldialog.cpp +++ b/generaldialog.cpp @@ -274,7 +274,7 @@ void generalDialog::on_cancelBtn_clicked() global::userApps::launchApp = false; global::userApps::appCompatibilityLastContinueStatus = false; global::userApps::appCompatibilityText = ""; - global::userApps::appCompatibilityDialog = false; + global::userApps::appCompatibilityDialog = false; } generalDialog::close(); } diff --git a/userapps.cpp b/userapps.cpp index e3a4d21..3640a98 100644 --- a/userapps.cpp +++ b/userapps.cpp @@ -51,6 +51,8 @@ void userapps::provideInfo(QJsonObject jsonInfo) QString message = ": Warning: Icon not found: "; message.append(iconPath.fileName()); log(function + message, className); + ui->iconBtn->deleteLater(); + ui->gridLayout->deleteLater(); } execPath.setFileName("/" + jsonInfo["ExecPath"].toString()); diff --git a/userapps.ui b/userapps.ui index 4de0403..8a075b0 100644 --- a/userapps.ui +++ b/userapps.ui @@ -166,22 +166,6 @@ - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 5 - 0 - - - -