From 92d7e66118ea52d1a1ef8e3f3c56f164a5e7ca1e Mon Sep 17 00:00:00 2001 From: eshanized Date: Thu, 2 Jan 2025 07:28:27 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20docs:=20add=20clear=20documentat?= =?UTF-8?q?ion=20and=20explanation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qt/snigdhaosblackbox.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/qt/snigdhaosblackbox.cpp b/qt/snigdhaosblackbox.cpp index 7893f7d..e483572 100644 --- a/qt/snigdhaosblackbox.cpp +++ b/qt/snigdhaosblackbox.cpp @@ -236,22 +236,41 @@ void SnigdhaOSBlackbox::doApply() { } void SnigdhaOSBlackbox::populateSelectWidget() { + // Check if the select widget already has more than one tab. + // If so, there's no need to populate it again, so exit early. if (ui->selectWidget_tabs->count() > 1) { return; } + // Retrieve the current desktop session environment variable. auto desktop = qEnvironmentVariable("XDG_DESKTOP_SESSION"); + + // Set the visibility of the GNOME-related checkbox based on the desktop session. + // The checkbox is visible only if the current session is GNOME. ui->checkBox_GNOME->setVisible(desktop == "gnome"); + // Variable to track whether the current device is a desktop. bool isDesktop = false; + + // Attempt to read the chassis type from the system's DMI data. auto chassis = QFile("/sys/class/dmi/id/chassis_type"); - if (chassis.open(QFile::ReadOnly)) { + if (chassis.open(QFile::ReadOnly)) { // Open the file in read-only mode. + // List of chassis types that correspond to desktop systems. QStringList list = { "3", "4", "6", "7", "23", "24" }; + + // Create a text stream to read data from the file. QTextStream in(&chassis); + + // Check if the read chassis type matches any in the list. isDesktop = list.contains(in.readLine()); } + + // Set the visibility of the Performance checkbox based on whether + // the system is identified as a desktop. ui->checkBox_Performance->setVisible(isDesktop); + // Populate the select widget with entries from the specified file. + // In this case, it's populating from "webapp.txt" with the label "WEBAPP". populateSelectWidget("/usr/lib/snigdhaos-blackbox/webapp.txt", "WEBAPP"); }