Revert "feat: trying to add clipboard, requires changing from canvas object"
This reverts commit 6315bc003d.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
Icon = "resources/images/icon.png"
|
||||
Name = "Computer Info"
|
||||
ID = "ryanehamil.computerinfo"
|
||||
Version = "1.3.1"
|
||||
Version = "1.2.1"
|
||||
Build = 6
|
||||
|
||||
[Development]
|
||||
|
||||
2
main.go
2
main.go
@@ -16,7 +16,7 @@ func main() {
|
||||
|
||||
w.Resize(fyne.NewSize(800, 200))
|
||||
|
||||
w.SetContent(computerinfo.CanvasObject())
|
||||
w.SetContent(computerinfo.Container())
|
||||
|
||||
w.ShowAndRun()
|
||||
}
|
||||
|
||||
@@ -2,65 +2,69 @@ package computerinfo
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
fyneLayout "fyne.io/fyne/v2/layout"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"github.com/ryanehamil/computerinfo/src/utils"
|
||||
)
|
||||
|
||||
// CustomTappableLabel is a label that supports tapping
|
||||
type CustomTappableLabel struct {
|
||||
widget.Label
|
||||
}
|
||||
|
||||
// NewCustomTappableLabel creates a new tappable label
|
||||
func NewCustomTappableLabel(text string) *CustomTappableLabel {
|
||||
label := &CustomTappableLabel{
|
||||
Label: widget.Label{
|
||||
Text: text,
|
||||
TextStyle: fyne.TextStyle{Bold: true},
|
||||
},
|
||||
}
|
||||
label.ExtendBaseWidget(label)
|
||||
return label
|
||||
}
|
||||
|
||||
// Tapped is called when the label is tapped
|
||||
func (l *CustomTappableLabel) Tapped(_ *fyne.PointEvent) {
|
||||
fyne.CurrentApp().Driver().AllWindows()[0].Clipboard().SetContent(l.Text)
|
||||
}
|
||||
|
||||
// TappedSecondary is called when the label is right-clicked (not used here)
|
||||
func (l *CustomTappableLabel) TappedSecondary(_ *fyne.PointEvent) {}
|
||||
|
||||
// obj_ComputerName returns a canvas object containing the computer name text
|
||||
func obj_ComputerName() fyne.CanvasObject {
|
||||
// Get the computer name from the utils package
|
||||
computername := utils.GetComputerName()
|
||||
label := NewCustomTappableLabel(computername)
|
||||
|
||||
// Create a new text label with the computer name
|
||||
label := canvas.NewText(computername, theme.TextColor())
|
||||
label.TextSize = 100
|
||||
label.TextStyle = fyne.TextStyle{Bold: true}
|
||||
label.Alignment = fyne.TextAlignCenter
|
||||
// label.TextSize = 100
|
||||
|
||||
// Return the label as a canvas object
|
||||
return label
|
||||
}
|
||||
|
||||
// obj_IPAddress returns a slice of canvas objects containing the IP addresses of the computer
|
||||
func obj_IPAddress() []fyne.CanvasObject {
|
||||
ipAddresses := utils.GetIPAddress()
|
||||
labels := []fyne.CanvasObject{}
|
||||
|
||||
for _, ip := range ipAddresses {
|
||||
container.NewHBox()
|
||||
label := NewCustomTappableLabel(ip)
|
||||
// Get the IP addresses of the computer
|
||||
ipaddress := utils.GetIPAddress()
|
||||
|
||||
// Loop over the IP addresses and create a label for each one
|
||||
for _, ip := range ipaddress {
|
||||
label := canvas.NewText(ip, theme.TextColor())
|
||||
label.TextSize = 20
|
||||
label.TextStyle = fyne.TextStyle{Bold: true}
|
||||
label.Alignment = fyne.TextAlignCenter
|
||||
// label.TextSize = 20
|
||||
labels = append(labels, label)
|
||||
}
|
||||
|
||||
// Return the slice of labels as canvas objects
|
||||
return labels
|
||||
}
|
||||
|
||||
// allObjects returns a slice of canvas objects containing both the computer name and IP addresses
|
||||
func allObjects() []fyne.CanvasObject {
|
||||
return append([]fyne.CanvasObject{
|
||||
return []fyne.CanvasObject{
|
||||
// Get the computer name canvas object
|
||||
obj_ComputerName(),
|
||||
}, obj_IPAddress()...)
|
||||
// Create a VBox container containing the IP addresses
|
||||
container.NewVBox(
|
||||
obj_IPAddress()...,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func CanvasObject() fyne.CanvasObject {
|
||||
return container.NewVBox(allObjects()...)
|
||||
// Container creates a container object for the window
|
||||
func Container() fyne.CanvasObject {
|
||||
// Create a vertical layout
|
||||
verticalLayout := fyneLayout.NewVBoxLayout()
|
||||
|
||||
// Create a new container using the vertical layout and the canvas objects
|
||||
cont := container.New(verticalLayout, allObjects()...)
|
||||
cont.Resize(fyne.NewSize(200, 200))
|
||||
|
||||
// Return the container
|
||||
return cont
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user