Done with system info dialog

Works well, will have strange formatting is no InkBox version is known,
probably due to checkconfig_str_val being null if no  value is detected.
This commit is contained in:
Nicolas Mailloux 2021-06-14 12:24:20 -04:00
parent 762489bb6b
commit 74937453ba
7 changed files with 72 additions and 37 deletions

View file

@ -58,6 +58,7 @@ namespace {
QString checkconfig_str_val; QString checkconfig_str_val;
QString deviceUID; QString deviceUID;
QString batt_level; QString batt_level;
QString kernelVersion;
int batt_level_int; int batt_level_int;
bool checked_box = false; bool checked_box = false;
bool checkconfig(QString file) { bool checkconfig(QString file) {
@ -145,6 +146,7 @@ namespace {
fhandler.close(); fhandler.close();
} }
void string_checkconfig(QString file) { void string_checkconfig(QString file) {
checkconfig_str_val = "";
QFile config(file); QFile config(file);
config.open(QIODevice::ReadWrite); config.open(QIODevice::ReadWrite);
QTextStream in (&config); QTextStream in (&config);
@ -152,6 +154,7 @@ namespace {
config.close(); config.close();
} }
void string_checkconfig_ro(QString file) { void string_checkconfig_ro(QString file) {
checkconfig_str_val = "";
QFile config(file); QFile config(file);
config.open(QIODevice::ReadOnly); config.open(QIODevice::ReadOnly);
QTextStream in (&config); QTextStream in (&config);
@ -262,14 +265,29 @@ namespace {
deviceUID = proc->readAllStandardOutput(); deviceUID = proc->readAllStandardOutput();
deviceUID = deviceUID.left(256); deviceUID = deviceUID.left(256);
} }
void getKernelVersion() {
QString prog ("uname");
QStringList args;
args << "-r";
QProcess *proc = new QProcess();
proc->start(prog, args);
proc->waitForFinished();
kernelVersion = proc->readAllStandardOutput();
}
void getSystemInfo() { void getSystemInfo() {
getUID(); getUID();
global::systemInfoText = "InkBox OS version "; getKernelVersion();
global::systemInfoText = "<b>InkBox OS version ";
string_checkconfig_ro("/external_root/opt/isa/version"); string_checkconfig_ro("/external_root/opt/isa/version");
global::systemInfoText.append(checkconfig_str_val); global::systemInfoText.append(checkconfig_str_val);
global::systemInfoText.append("Device UID: "); global::systemInfoText.append("</b>");
global::systemInfoText.append("\n<b>Device UID:</b> ");
global::systemInfoText.append(deviceUID); global::systemInfoText.append(deviceUID);
global::systemInfoText.append("\n"); global::systemInfoText.append("\n");
global::systemInfoText.append("<b>Kernel version:</b> ");
global::systemInfoText.append(kernelVersion);
global::systemInfoText.append("\n");
} }
} }
#endif // FUNCTIONS_H #endif // FUNCTIONS_H

View file

@ -97,6 +97,7 @@ generalDialog::generalDialog(QWidget *parent) :
else if(global::text::textBrowserDialog == true) { else if(global::text::textBrowserDialog == true) {
textwidgetWindow = new textwidget(); textwidgetWindow = new textwidget();
ui->headerLabel->setText("Information"); ui->headerLabel->setText("Information");
ui->stackedWidget->setCurrentIndex(1);
ui->mainStackedWidget->insertWidget(1, textwidgetWindow); ui->mainStackedWidget->insertWidget(1, textwidgetWindow);
ui->mainStackedWidget->setCurrentIndex(1); ui->mainStackedWidget->setCurrentIndex(1);
this->adjustSize(); this->adjustSize();

View file

@ -43,7 +43,7 @@
<item row="8" column="0"> <item row="8" column="0">
<widget class="QStackedWidget" name="stackedWidget"> <widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="page"> <widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
@ -151,7 +151,7 @@
<item row="6" column="0"> <item row="6" column="0">
<widget class="QStackedWidget" name="mainStackedWidget"> <widget class="QStackedWidget" name="mainStackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="page_3"> <widget class="QWidget" name="page_3">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">

View file

@ -653,4 +653,10 @@ void settings::on_showSystemInfoBtn_clicked()
{ {
getSystemInfo(); getSystemInfo();
global::text::textBrowserContents = global::systemInfoText; global::text::textBrowserContents = global::systemInfoText;
global::text::textBrowserDialog = true;
// Show a system info dialog
generalDialogWindow = new generalDialog();
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
generalDialogWindow->show();
} }

View file

@ -163,7 +163,7 @@ OK
<item row="26" column="0"> <item row="26" column="0">
<widget class="QStackedWidget" name="stackedWidget"> <widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="page"> <widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
@ -731,6 +731,26 @@ OK
<property name="verticalSpacing"> <property name="verticalSpacing">
<number>0</number> <number>0</number>
</property> </property>
<item row="1" column="2">
<widget class="QPushButton" name="updateBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Update</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>System info</string>
</property>
</widget>
</item>
<item row="0" column="1"> <item row="0" column="1">
<spacer name="horizontalSpacer_6"> <spacer name="horizontalSpacer_6">
<property name="orientation"> <property name="orientation">
@ -744,36 +764,6 @@ OK
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="0">
<widget class="QLabel" name="updateLabel">
<property name="text">
<string>Update InkBox</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>System info</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="updateBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Update</string>
</property>
</widget>
</item>
<item row="1" column="1"> <item row="1" column="1">
<spacer name="horizontalSpacer_10"> <spacer name="horizontalSpacer_10">
<property name="orientation"> <property name="orientation">
@ -787,7 +777,17 @@ OK
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="2"> <item row="1" column="0">
<widget class="QLabel" name="updateLabel">
<property name="text">
<string>Update InkBox</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="showSystemInfoBtn"> <widget class="QPushButton" name="showSystemInfoBtn">
<property name="font"> <property name="font">
<font> <font>

View file

@ -17,6 +17,9 @@ textwidget::textwidget(QWidget *parent) :
this->setStyleSheet(stylesheetFile.readAll()); this->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close(); stylesheetFile.close();
if(global::text::textBrowserDialog == true) {
ui->textBrowser->setStyleSheet("font-size: 9pt");
}
ui->textBrowser->setText(global::text::textBrowserContents); ui->textBrowser->setText(global::text::textBrowserContents);
} }

View file

@ -29,7 +29,14 @@
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTextBrowser" name="textBrowser"/> <widget class="QTextEdit" name="textBrowser">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>50</horstretch>
<verstretch>50</verstretch>
</sizepolicy>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>