Skip to content

Commit

Permalink
Update AFK Timeout config UI
Browse files Browse the repository at this point in the history
  • Loading branch information
SaifAqqad committed Jan 20, 2024
1 parent 4133b6b commit 125ff96
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 120 deletions.
21 changes: 13 additions & 8 deletions src/MicMute.ahk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires AutoHotkey v1.1.36+
#Requires AutoHotkey v1.1.36+

;compiler directives
;@Ahk2Exe-Let Res = %A_ScriptDir%\resources
Expand Down Expand Up @@ -407,18 +407,23 @@ editConfig(){
}

checkIsIdle(){
static wasIdle:= 0
if (A_TimeIdlePhysical < current_profile.afkTimeout * 60000){
wasIdle:=0
static wasIdle := false
if (A_TimeIdlePhysical < current_profile.afkTimeout){
if (wasIdle)
util_log("[Main] Idling ended")
wasIdle := false
return
}

if(!wasIdle)
util_log("[Main] User is idle")
wasIdle:= 1
if (!wasIdle){
util_log("[Main] Detected idling for " current_profile.afkTimeout " ms")
wasIdle := true
}

; Ensure microphones are muted
for _i, mic in mic_controllers
if(!mic.isPushToTalk)
mic.setMuteState(1)
mic.setMuteState(true)
}

;checks for changes to the config file
Expand Down
4 changes: 2 additions & 2 deletions src/UI/Overlay.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,11 @@
if (!this.changedPos)
return

util_log("[Overlay] Position changed")

this.windowPosition.X := xPos := this.changedPos.x
this.windowPosition.Y := yPos := this.changedPos.y

util_log("[Overlay] Overlay position changed to: " xPos ", " yPos)

this.changedPos := ""
display := DisplayDevices.getByPosition(xPos, yPos)

Expand Down
37 changes: 35 additions & 2 deletions src/UI/config/UI.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ UI_setProfile(_neutron, p_profile){
ui_obj.doc.getElementById("OSDPos_y").value:= current_profile.OSDPos.y==-1? "" : current_profile.OSDPos.y
ui_obj.doc.getElementById("ForegroundAppsOnly").checked := current_profile.ForegroundAppsOnly
UI_onRefreshAppsList("")
ui_obj.doc.getElementById("afkTimeout").value:= !current_profile.afkTimeout? "" : current_profile.afkTimeout
UI_setAfkTimeoutValue(current_profile.afkTimeout)
ui_obj.doc.getElementById("PTTDelay").value:= current_profile.PTTDelay
UI_onUpdateDelay(current_profile.PTTDelay)
UI_onRefreshMicActions("")
Expand Down Expand Up @@ -189,6 +189,39 @@ UI_setHotkeyPanel(hotkey_panel, delay:=0){
UI_checkMicOptions()
}

UI_setAfkTimeoutValue(value){
valueInput := ui_obj.doc.getElementById("afkTimeout")
unitSelect := ui_obj.doc.getElementById("afkTimeoutUnit")

if (!value){
valueInput.value := ""
unitSelect.value := "m"
return
}

if (value >= 60000 && Mod(value, 60000) == 0){
valueInput.value := value / 60000
unitSelect.value := "m"
return
}

valueInput.value := value / 1000
unitSelect.value := "s"
}

UI_getAfkTimeoutValue(){
valueInput := ui_obj.doc.getElementById("afkTimeout")
unitSelect := ui_obj.doc.getElementById("afkTimeoutUnit")

if (!valueInput.value)
return 0

if (unitSelect.value == "m")
return valueInput.value * 60000

return valueInput.value * 1000
}

UI_updateHotkeyOption(option, isRootValue:=0){
elem:= ui_obj.doc.getElementById(option)
if(isRootValue){
Expand All @@ -212,7 +245,7 @@ UI_onSaveProfile(neutron, noReset:=0){
current_profile.OnscreenOverlay.UseCustomIcons:= ui_obj.doc.getElementById("OverlayUseCustomIcons").checked? 1 : 0
current_profile.OnscreenOverlay.Theme:= ui_obj.doc.getElementById("OverlayTheme").value
current_profile.OnscreenOverlay.Size:= ui_obj.doc.getElementById("OverlaySize").value
current_profile.afkTimeout:= (val:= ui_obj.doc.getElementById("afkTimeout").value)? val+0 : 0
current_profile.afkTimeout:= UI_getAfkTimeoutValue()
current_profile.LinkedApp:= ui_obj.doc.getElementById("LinkedApp").value
current_profile.ForegroundAppsOnly:= ui_obj.doc.getElementById("ForegroundAppsOnly").checked? 1 : 0
current_profile.PTTDelay:= ui_obj.doc.getElementById("PTTDelay").value+0
Expand Down
Loading

0 comments on commit 125ff96

Please sign in to comment.