Skip to content

Commit

Permalink
📝 docs: add clear documentation and explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
eshanized committed Jan 2, 2025
1 parent 49820f8 commit 92d7e66
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion qt/snigdhaosblackbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down

0 comments on commit 92d7e66

Please sign in to comment.