mirror of https://github.com/jetkvm/kvm.git
Hide MAC and show hostname when IP address is available
This commit is contained in:
parent
969e900a15
commit
24fe664ad4
|
|
@ -41,10 +41,15 @@ func switchToMainScreen() {
|
||||||
|
|
||||||
func updateDisplay() {
|
func updateDisplay() {
|
||||||
if networkManager != nil {
|
if networkManager != nil {
|
||||||
nativeInstance.UpdateLabelIfChanged("home_info_ipv4_addr", networkManager.IPv4String())
|
nativeInstance.UpdateLabelAndChangeVisibility("home_info_ipv4_addr", networkManager.IPv4String())
|
||||||
nativeInstance.UpdateLabelAndChangeVisibility("home_info_ipv6_addr", networkManager.IPv6String())
|
nativeInstance.UpdateLabelAndChangeVisibility("home_info_ipv6_addr", networkManager.IPv6String())
|
||||||
nativeInstance.UpdateLabelIfChanged("home_info_mac_addr", networkManager.MACString())
|
nativeInstance.UpdateLabelIfChanged("home_info_mac_addr", networkManager.MACString())
|
||||||
nativeInstance.UpdateLabelIfChanged("home_info_hostname", networkManager.Hostname())
|
nativeInstance.UpdateLabelIfChanged("home_info_hostname", networkManager.Hostname())
|
||||||
|
|
||||||
|
// we either show the MAC address (if no IP yet) or the hostname (if either IPv4 or IPv6 are available)
|
||||||
|
hasIP := networkManager.IPv4Ready() || networkManager.IPv6Ready()
|
||||||
|
nativeInstance.ChangeVisibility("home_info_mac_addr", !hasIP)
|
||||||
|
nativeInstance.ChangeVisibility("home_info_hostname", hasIP)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _ = nativeInstance.UIObjHide("menu_btn_network")
|
_, _ = nativeInstance.UIObjHide("menu_btn_network")
|
||||||
|
|
@ -71,6 +76,7 @@ func updateDisplay() {
|
||||||
nativeInstance.UpdateLabelIfChanged("hdmi_status_label", "Disconnected")
|
nativeInstance.UpdateLabelIfChanged("hdmi_status_label", "Disconnected")
|
||||||
_, _ = nativeInstance.UIObjClearState("hdmi_status_label", "LV_STATE_CHECKED")
|
_, _ = nativeInstance.UIObjClearState("hdmi_status_label", "LV_STATE_CHECKED")
|
||||||
}
|
}
|
||||||
|
|
||||||
nativeInstance.UpdateLabelIfChanged("cloud_status_label", fmt.Sprintf("%d active", actionSessions))
|
nativeInstance.UpdateLabelIfChanged("cloud_status_label", fmt.Sprintf("%d active", actionSessions))
|
||||||
|
|
||||||
if networkManager != nil && networkManager.IsUp() {
|
if networkManager != nil && networkManager.IsUp() {
|
||||||
|
|
|
||||||
|
|
@ -117,14 +117,18 @@ func (n *Native) UpdateLabelIfChanged(objName string, newText string) {
|
||||||
// UpdateLabelAndChangeVisibility updates the label and changes the visibility of the object
|
// UpdateLabelAndChangeVisibility updates the label and changes the visibility of the object
|
||||||
func (n *Native) UpdateLabelAndChangeVisibility(objName string, newText string) {
|
func (n *Native) UpdateLabelAndChangeVisibility(objName string, newText string) {
|
||||||
n.UpdateLabelIfChanged(objName, newText)
|
n.UpdateLabelIfChanged(objName, newText)
|
||||||
|
n.ChangeVisibility(objName, newText != "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChangeVisibility shows or hides an object AND the container it is in
|
||||||
|
func (n *Native) ChangeVisibility(objName string, show bool) {
|
||||||
containerName := objName + "_container"
|
containerName := objName + "_container"
|
||||||
if newText == "" {
|
if show {
|
||||||
_, _ = n.UIObjHide(objName)
|
|
||||||
_, _ = n.UIObjHide(containerName)
|
|
||||||
} else {
|
|
||||||
_, _ = n.UIObjShow(objName)
|
_, _ = n.UIObjShow(objName)
|
||||||
_, _ = n.UIObjShow(containerName)
|
_, _ = n.UIObjShow(containerName)
|
||||||
|
} else {
|
||||||
|
_, _ = n.UIObjHide(objName)
|
||||||
|
_, _ = n.UIObjHide(containerName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1227,8 +1227,8 @@
|
||||||
"type": "LVGLLabelWidget",
|
"type": "LVGLLabelWidget",
|
||||||
"left": 0,
|
"left": 0,
|
||||||
"top": 0,
|
"top": 0,
|
||||||
"width": 174,
|
"width": 217,
|
||||||
"height": 25,
|
"height": 31,
|
||||||
"customInputs": [],
|
"customInputs": [],
|
||||||
"customOutputs": [],
|
"customOutputs": [],
|
||||||
"style": {
|
"style": {
|
||||||
|
|
@ -1251,7 +1251,7 @@
|
||||||
"checkedStateType": "literal",
|
"checkedStateType": "literal",
|
||||||
"disabledStateType": "literal",
|
"disabledStateType": "literal",
|
||||||
"states": "",
|
"states": "",
|
||||||
"useStyle": "LabelFontBold24",
|
"useStyle": "LabelFontBold30",
|
||||||
"localStyles": {
|
"localStyles": {
|
||||||
"objID": "e584be1c-d434-4f13-fb87-00665e4a53a9"
|
"objID": "e584be1c-d434-4f13-fb87-00665e4a53a9"
|
||||||
},
|
},
|
||||||
|
|
@ -1287,7 +1287,7 @@
|
||||||
"heightUnit": "content",
|
"heightUnit": "content",
|
||||||
"children": [],
|
"children": [],
|
||||||
"widgetFlags": "CLICK_FOCUSABLE|GESTURE_BUBBLE|PRESS_LOCK|SCROLLABLE|SCROLL_CHAIN_HOR|SCROLL_CHAIN_VER|SCROLL_ELASTIC|SCROLL_MOMENTUM|SCROLL_WITH_ARROW|SNAPPABLE",
|
"widgetFlags": "CLICK_FOCUSABLE|GESTURE_BUBBLE|PRESS_LOCK|SCROLLABLE|SCROLL_CHAIN_HOR|SCROLL_CHAIN_VER|SCROLL_ELASTIC|SCROLL_MOMENTUM|SCROLL_WITH_ARROW|SNAPPABLE",
|
||||||
"hiddenFlag": true,
|
"hiddenFlag": false,
|
||||||
"hiddenFlagType": "literal",
|
"hiddenFlagType": "literal",
|
||||||
"clickableFlagType": "literal",
|
"clickableFlagType": "literal",
|
||||||
"checkedStateType": "literal",
|
"checkedStateType": "literal",
|
||||||
|
|
@ -1335,6 +1335,7 @@
|
||||||
"heightUnit": "content",
|
"heightUnit": "content",
|
||||||
"children": [],
|
"children": [],
|
||||||
"widgetFlags": "CLICK_FOCUSABLE|GESTURE_BUBBLE|PRESS_LOCK|SCROLLABLE|SCROLL_CHAIN_HOR|SCROLL_CHAIN_VER|SCROLL_ELASTIC|SCROLL_MOMENTUM|SCROLL_WITH_ARROW|SNAPPABLE",
|
"widgetFlags": "CLICK_FOCUSABLE|GESTURE_BUBBLE|PRESS_LOCK|SCROLLABLE|SCROLL_CHAIN_HOR|SCROLL_CHAIN_VER|SCROLL_ELASTIC|SCROLL_MOMENTUM|SCROLL_WITH_ARROW|SNAPPABLE",
|
||||||
|
"hiddenFlag": false,
|
||||||
"hiddenFlagType": "literal",
|
"hiddenFlagType": "literal",
|
||||||
"clickableFlagType": "literal",
|
"clickableFlagType": "literal",
|
||||||
"checkedStateType": "literal",
|
"checkedStateType": "literal",
|
||||||
|
|
@ -1362,8 +1363,8 @@
|
||||||
"type": "LVGLLabelWidget",
|
"type": "LVGLLabelWidget",
|
||||||
"left": 0,
|
"left": 0,
|
||||||
"top": 0,
|
"top": 0,
|
||||||
"width": 60,
|
"width": 74,
|
||||||
"height": 18,
|
"height": 21,
|
||||||
"customInputs": [],
|
"customInputs": [],
|
||||||
"customOutputs": [],
|
"customOutputs": [],
|
||||||
"style": {
|
"style": {
|
||||||
|
|
@ -1393,7 +1394,8 @@
|
||||||
"MAIN": {
|
"MAIN": {
|
||||||
"DEFAULT": {
|
"DEFAULT": {
|
||||||
"pad_bottom": 2,
|
"pad_bottom": 2,
|
||||||
"pad_top": -1
|
"pad_top": -1,
|
||||||
|
"text_font": "FontBook20"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -318,7 +318,7 @@ void create_screen_home_screen() {
|
||||||
objects.home_info_ipv4_addr = obj;
|
objects.home_info_ipv4_addr = obj;
|
||||||
lv_obj_set_pos(obj, LV_PCT(0), LV_PCT(0));
|
lv_obj_set_pos(obj, LV_PCT(0), LV_PCT(0));
|
||||||
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||||
add_style_label_font_bold24(obj);
|
add_style_label_font_bold30(obj);
|
||||||
lv_label_set_text(obj, "169.254.169.254");
|
lv_label_set_text(obj, "169.254.169.254");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
@ -328,7 +328,6 @@ void create_screen_home_screen() {
|
||||||
lv_obj_set_pos(obj, LV_PCT(0), LV_PCT(0));
|
lv_obj_set_pos(obj, LV_PCT(0), LV_PCT(0));
|
||||||
lv_obj_set_size(obj, LV_PCT(100), LV_SIZE_CONTENT);
|
lv_obj_set_size(obj, LV_PCT(100), LV_SIZE_CONTENT);
|
||||||
lv_label_set_long_mode(obj, LV_LABEL_LONG_SCROLL_CIRCULAR);
|
lv_label_set_long_mode(obj, LV_LABEL_LONG_SCROLL_CIRCULAR);
|
||||||
lv_obj_add_flag(obj, LV_OBJ_FLAG_HIDDEN);
|
|
||||||
add_style_label_font16(obj);
|
add_style_label_font16(obj);
|
||||||
lv_obj_set_style_text_font(obj, &ui_font_font_book16, LV_PART_MAIN | LV_STATE_DEFAULT);
|
lv_obj_set_style_text_font(obj, &ui_font_font_book16, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
lv_obj_set_style_pad_top(obj, -1, LV_PART_MAIN | LV_STATE_DEFAULT);
|
lv_obj_set_style_pad_top(obj, -1, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
|
|
@ -354,6 +353,7 @@ void create_screen_home_screen() {
|
||||||
add_style_label_font16(obj);
|
add_style_label_font16(obj);
|
||||||
lv_obj_set_style_pad_bottom(obj, 2, LV_PART_MAIN | LV_STATE_DEFAULT);
|
lv_obj_set_style_pad_bottom(obj, 2, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
lv_obj_set_style_pad_top(obj, -1, LV_PART_MAIN | LV_STATE_DEFAULT);
|
lv_obj_set_style_pad_top(obj, -1, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
|
lv_obj_set_style_text_font(obj, &ui_font_font_book20, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
lv_label_set_text(obj, "JetKVM");
|
lv_label_set_text(obj, "JetKVM");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue