GUI user applications: More improvements

This commit is contained in:
Nicolas Mailloux 2022-06-19 00:14:42 -04:00
parent c5ec3f3560
commit 99a145d5ee
6 changed files with 115 additions and 105 deletions

View file

@ -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()));
}
}
@ -322,6 +328,7 @@ void apps::showUserApps(bool showDisabledJson)
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()));
@ -330,9 +337,16 @@ void apps::showUserApps(bool showDisabledJson)
connect(newUserApp, SIGNAL(updateJsonFileSignalUA(QJsonDocument)), this, SLOT(updateJsonFileSlot(QJsonDocument)));
newUserApp->jsonDocument = jsonDocument;
newUserApp->jsonFilePath = jsonFile.fileName();
ui->verticalLayout_4UserApps->addWidget(newUserApp);
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);

1
apps.h
View file

@ -52,6 +52,7 @@ private:
QJsonDocument jsonDocument;
bool jsonParseSuccess = false;
bool userAppsSecondPage = false;
bool userAppsAvailable = false;
signals:
void refreshScreen();

133
apps.ui
View file

@ -28,7 +28,10 @@
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0">
<property name="topMargin">
<number>0</number>
</property>
<item row="5" column="0">
<widget class="QScrollArea" name="scrollArea">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
@ -51,7 +54,7 @@
<x>0</x>
<y>0</y>
<width>428</width>
<height>542</height>
<height>510</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -72,11 +75,14 @@
</property>
<item>
<layout class="QGridLayout" name="gridLayout_3">
<property name="topMargin">
<number>8</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>6</number>
<number>15</number>
</property>
<property name="verticalSpacing">
<number>10</number>
@ -311,22 +317,6 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<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="8" column="0">
<widget class="QLabel" name="calendarLabel">
<property name="font">
@ -340,19 +330,6 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<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>
</layout>
</item>
<item>
@ -373,6 +350,12 @@
<property name="spacing">
<number>0</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -387,6 +370,14 @@
</spacer>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="font">
<font>
@ -402,6 +393,8 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
@ -420,31 +413,9 @@
</item>
<item>
<widget class="QPushButton" name="editUserAppsBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="://resources/edit.png">
<normaloff>://resources/edit.png</normaloff>://resources/edit.png</iconset>
</property>
<property name="iconSize">
<size>
<width>34</width>
<height>34</height>
</size>
</property>
</widget>
</item>
<item>
@ -476,17 +447,26 @@
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4UserApps">
<property name="spacing">
<number>10</number>
<layout class="QGridLayout" name="gridLayout_4"/>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4"/>
</item>
<item>
<widget class="QLabel" name="noUserAppsAvailableLabel">
<property name="font">
<font>
<family>Chivo</family>
</font>
</property>
<property name="topMargin">
<number>2</number>
<property name="text">
<string>
No user apps currently available</string>
</property>
<property name="rightMargin">
<number>0</number>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
@ -508,6 +488,35 @@
</widget>
</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>
<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>
</layout>
</item>
</layout>

View file

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

View file

@ -166,22 +166,6 @@
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="appNameLabel">
<property name="sizePolicy">