Replies: 2 comments 5 replies
-
|
This is something we can do after we added some features and improved stability. Maybe with 1.2.0 or 1.3.0? |
Beta Was this translation helpful? Give feedback.
-
|
This is a PowerShell Script that creates a form from a Pros:
Cons:
The following example requires you to download the # Load required assemblies
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
# Create the main form
$form = New-Object System.Windows.Forms.Form
$form.Text = "Package Selection"
$form.Size = New-Object System.Drawing.Size(800,600)
$form.StartPosition = "CenterScreen"
# Path to your JSON file
$jsonPath = "C:\path\to\your\file.json" # <-- Replace with your actual JSON file path
# Function to display error messages in a message box
function Show-Error {
param (
[string]$message
)
[System.Windows.Forms.MessageBox]::Show($message, "Error", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error)
}
# Function to identify and display the problematic line in the JSON file
function Identify-JsonErrorLine {
param (
[string]$jsonContent,
[System.Management.Automation.ErrorRecord]$errorRecord,
[string]$jsonPath
)
$errorMessage = $errorRecord.Exception.Message
# Attempt to extract the position from the error message
if ($errorMessage -match 'position\s+(\d+)') {
$position = [int]$matches[1]
# Read the JSON file as an array of lines
$lines = Get-Content -Path $jsonPath
$currentPos = 0
$errorLine = 0
for ($i = 0; $i -lt $lines.Count; $i++) {
$lineLength = $lines[$i].Length + 1 # +1 for newline character
if (($currentPos + $lineLength) -ge $position) {
$errorLine = $i + 1 # Line numbers start at 1
break
}
$currentPos += $lineLength
}
if ($errorLine -gt 0 -and $errorLine -le $lines.Count) {
$problematicLine = $lines[$errorLine - 1]
# **Corrected Line Below: Using ${} to delimit variables**
Show-Error "JSON parsing failed at line ${errorLine}:`n${problematicLine}"
}
else {
Show-Error "JSON parsing failed, but the error position could not be mapped to a specific line.`nError Message: $errorMessage"
}
}
else {
# If position is not found in the error message, display the entire error
Show-Error "JSON parsing failed:`n$errorMessage"
}
}
# Read and parse the JSON file with enhanced error handling
try {
if (-Not (Test-Path -Path $jsonPath)) {
Show-Error "JSON file not found at path: $jsonPath"
exit
}
$jsonContent = Get-Content -Raw -Path $jsonPath
# Attempt to parse the JSON content
$packages = $jsonContent | ConvertFrom-Json
}
catch {
# If a parsing error occurs, identify and display the problematic line
Identify-JsonErrorLine -jsonContent $jsonContent -errorRecord $_ -jsonPath $jsonPath
exit
}
# If JSON is parsed successfully, proceed with the rest of the script
# Extract unique 'removal' categories
$removalCategories = $packages.psobject.properties | ForEach-Object { $_.Value.removal } | Sort-Object -Unique
# Initialize a ToolTip object
$toolTip = New-Object System.Windows.Forms.ToolTip
# Create a dropdown (ComboBox) for selecting categories
$comboBox = New-Object System.Windows.Forms.ComboBox
$comboBox.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
$comboBox.Location = New-Object System.Drawing.Point(10,10)
$comboBox.Size = New-Object System.Drawing.Size(200,25)
# Add categories to the ComboBox
$removalCategories | ForEach-Object { $comboBox.Items.Add($_) }
# Optionally, select the first category by default
if ($comboBox.Items.Count -gt 0) {
$comboBox.SelectedIndex = 0
}
$form.Controls.Add($comboBox)
# Create a scrollable panel to hold the checkboxes
$checkboxPanel = New-Object System.Windows.Forms.Panel
$checkboxPanel.Location = New-Object System.Drawing.Point(10, 50)
$checkboxPanel.Size = New-Object System.Drawing.Size(760, 500) # Adjust size as needed
$checkboxPanel.AutoScroll = $true
$checkboxPanel.BorderStyle = [System.Windows.Forms.BorderStyle]::FixedSingle
$form.Controls.Add($checkboxPanel)
# Function to populate the panel with checkboxes based on selected category
function Populate-Checkboxes {
param (
[string]$category
)
# Clear existing controls
$checkboxPanel.Controls.Clear()
# Initialize vertical position
$y = 10
# Iterate over each package and add checkboxes for the selected category
foreach ($packageProperty in $packages.psobject.properties) {
$packageName = $packageProperty.Name
$packageData = $packageProperty.Value
if ($packageData.removal -eq $category) {
$checkbox = New-Object System.Windows.Forms.CheckBox
$checkbox.Text = $packageName
$checkbox.AutoSize = $true
$checkbox.Location = New-Object System.Drawing.Point(10, $y)
# Set the tooltip, replacing '\n' with actual newlines
$description = $packageData.description -replace "\\n", "`n"
$toolTip.SetToolTip($checkbox, $description)
# Add the checkbox to the panel
$checkboxPanel.Controls.Add($checkbox)
# Increment y position for the next checkbox
$y += $checkbox.Height + 5
}
}
}
# Populate checkboxes for the initially selected category
if ($comboBox.SelectedItem) {
Populate-Checkboxes -category $comboBox.SelectedItem
}
# Add an event handler to update checkboxes when the selected category changes
$comboBox.add_SelectedIndexChanged({
$selectedCategory = $comboBox.SelectedItem
Populate-Checkboxes -category $selectedCategory
})
# Optionally, add a button to handle user actions (e.g., removal)
# $button = New-Object System.Windows.Forms.Button
# $button.Text = "Remove Selected Packages"
# $button.Location = New-Object System.Drawing.Point(220,10)
# $button.Size = New-Object System.Drawing.Size(200,25)
# $button.Add_Click({
# # Handle the removal logic here
# $selectedCategory = $comboBox.SelectedItem
# $selectedCheckboxes = $checkboxPanel.Controls | Where-Object { $_.Checked }
# if ($selectedCheckboxes.Count -eq 0) {
# [System.Windows.Forms.MessageBox]::Show("No packages selected for removal.", "Information", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information)
# } else {
# $packagesToRemove = $selectedCheckboxes | ForEach-Object { $_.Text }
# # Implement removal logic here
# [System.Windows.Forms.MessageBox]::Show("Selected packages to remove:`n" + ($packagesToRemove -join "`n"), "Packages to Remove", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information)
# }
# })
# $form.Controls.Add($button)
# Display the form
[void]$form.ShowDialog() |
Beta Was this translation helpful? Give feedback.



Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Intro
As of now, we use GH Releases to distribute executables, but what if we consider other formats?
They can be additions (more maintenance work) or replacements (easier, but less user freedom) to the existing method.
Flatpak
#628
We could distribute the app on FlatHub, which would make it more discoverable. We can also give users "peace of mind" thanks to sandboxing, which reduces the potential damage a bug/vulnerability could cause
AppImage
There's no point in this, other than easily including ADB (and all of its
platform-toolslibraries) in 1 file (udevrules can't be included, AFAIK), simplifying the setup instructions.These can be sandboxed too, but it's harder (for users), and there's no "permission manager"
UWP
Typically, these are distributed by Microsoft Store, but can be side-loaded by enabling some developer setting.
This format is strongly tied to MS Windows, which is not FLOSS at all
Outro
Thoughts? 🤔 (I'm asking users and devs alike)
Beta Was this translation helpful? Give feedback.
All reactions