From 74937453bad18ddc9e0cd09cc953a47f621186c9 Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Mon, 14 Jun 2021 12:24:20 -0400 Subject: [PATCH] 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. --- functions.h | 22 ++++++++++++++-- generaldialog.cpp | 1 + generaldialog.ui | 4 +-- settings.cpp | 6 +++++ settings.ui | 64 +++++++++++++++++++++++------------------------ textwidget.cpp | 3 +++ textwidget.ui | 9 ++++++- 7 files changed, 72 insertions(+), 37 deletions(-) diff --git a/functions.h b/functions.h index c91de0e..f41e23c 100644 --- a/functions.h +++ b/functions.h @@ -58,6 +58,7 @@ namespace { QString checkconfig_str_val; QString deviceUID; QString batt_level; + QString kernelVersion; int batt_level_int; bool checked_box = false; bool checkconfig(QString file) { @@ -145,6 +146,7 @@ namespace { fhandler.close(); } void string_checkconfig(QString file) { + checkconfig_str_val = ""; QFile config(file); config.open(QIODevice::ReadWrite); QTextStream in (&config); @@ -152,6 +154,7 @@ namespace { config.close(); } void string_checkconfig_ro(QString file) { + checkconfig_str_val = ""; QFile config(file); config.open(QIODevice::ReadOnly); QTextStream in (&config); @@ -262,14 +265,29 @@ namespace { deviceUID = proc->readAllStandardOutput(); 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() { getUID(); - global::systemInfoText = "InkBox OS version "; + getKernelVersion(); + global::systemInfoText = "InkBox OS version "; string_checkconfig_ro("/external_root/opt/isa/version"); global::systemInfoText.append(checkconfig_str_val); - global::systemInfoText.append("Device UID: "); + global::systemInfoText.append(""); + global::systemInfoText.append("\nDevice UID: "); global::systemInfoText.append(deviceUID); global::systemInfoText.append("\n"); + global::systemInfoText.append("Kernel version: "); + global::systemInfoText.append(kernelVersion); + global::systemInfoText.append("\n"); } } #endif // FUNCTIONS_H diff --git a/generaldialog.cpp b/generaldialog.cpp index 65b26b3..bfb4a26 100644 --- a/generaldialog.cpp +++ b/generaldialog.cpp @@ -97,6 +97,7 @@ generalDialog::generalDialog(QWidget *parent) : else if(global::text::textBrowserDialog == true) { textwidgetWindow = new textwidget(); ui->headerLabel->setText("Information"); + ui->stackedWidget->setCurrentIndex(1); ui->mainStackedWidget->insertWidget(1, textwidgetWindow); ui->mainStackedWidget->setCurrentIndex(1); this->adjustSize(); diff --git a/generaldialog.ui b/generaldialog.ui index 82f1a02..14eaa8c 100644 --- a/generaldialog.ui +++ b/generaldialog.ui @@ -43,7 +43,7 @@ - 1 + 0 @@ -151,7 +151,7 @@ - 1 + 0 diff --git a/settings.cpp b/settings.cpp index c89f17a..a49ad98 100644 --- a/settings.cpp +++ b/settings.cpp @@ -653,4 +653,10 @@ void settings::on_showSystemInfoBtn_clicked() { getSystemInfo(); global::text::textBrowserContents = global::systemInfoText; + global::text::textBrowserDialog = true; + + // Show a system info dialog + generalDialogWindow = new generalDialog(); + generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose); + generalDialogWindow->show(); } diff --git a/settings.ui b/settings.ui index 5e07aed..fa9c5f5 100644 --- a/settings.ui +++ b/settings.ui @@ -163,7 +163,7 @@ OK - 1 + 0 @@ -731,6 +731,26 @@ OK 0 + + + + + 75 + true + + + + Update + + + + + + + System info + + + @@ -744,36 +764,6 @@ OK - - - - Update InkBox - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - System info - - - - - - - - 75 - true - - - - Update - - - @@ -787,7 +777,17 @@ OK - + + + + Update InkBox + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + diff --git a/textwidget.cpp b/textwidget.cpp index 78c9c14..0dbd307 100644 --- a/textwidget.cpp +++ b/textwidget.cpp @@ -17,6 +17,9 @@ textwidget::textwidget(QWidget *parent) : this->setStyleSheet(stylesheetFile.readAll()); stylesheetFile.close(); + if(global::text::textBrowserDialog == true) { + ui->textBrowser->setStyleSheet("font-size: 9pt"); + } ui->textBrowser->setText(global::text::textBrowserContents); } diff --git a/textwidget.ui b/textwidget.ui index fcc5b51..59a098d 100644 --- a/textwidget.ui +++ b/textwidget.ui @@ -29,7 +29,14 @@ - + + + + 50 + 50 + + +