Add user setting: Hide Clock

#273
This commit is contained in:
1hitsong 2022-07-15 22:28:59 -04:00
parent ddb912d3b8
commit b728c4b224
9 changed files with 102 additions and 25 deletions

View File

@ -3,8 +3,10 @@ sub init()
' hide seperators till they're needed ' hide seperators till they're needed
leftSeperator = m.top.findNode("overlayLeftSeperator") leftSeperator = m.top.findNode("overlayLeftSeperator")
leftSeperator.visible = "false" leftSeperator.visible = "false"
rightSeperator = m.top.findNode("overlayRightSeperator") m.rightSeperator = m.top.findNode("overlayRightSeperator")
rightSeperator.visible = "false"
m.hideClock = get_user_setting("ui.design.hideclock") = "true"
' set font sizes ' set font sizes
optionText = m.top.findNode("overlayOptionsText") optionText = m.top.findNode("overlayOptionsText")
optionText.font.size = 20 optionText.font.size = 20
@ -12,20 +14,30 @@ sub init()
optionStar.font.size = 58 optionStar.font.size = 58
overlayMeridian = m.top.findNode("overlayMeridian") overlayMeridian = m.top.findNode("overlayMeridian")
overlayMeridian.font.size = 20 overlayMeridian.font.size = 20
' get system preference clock format (12/24hr)
di = CreateObject("roDeviceInfo")
m.clockFormat = di.GetClockFormat()
' grab current time
currentTime = CreateObject("roDateTime")
currentTime.ToLocalTime()
m.currentHours = currentTime.GetHours()
m.currentMinutes = currentTime.GetMinutes()
' start timer
m.currentTimeTimer = m.top.findNode("currentTimeTimer")
m.currentTimeTimer.control = "start"
m.currentTimeTimer.ObserveField("fire", "updateTime")
updateTimeDisplay() m.overlayRightGroup = m.top.findNode("overlayRightGroup")
m.overlayTimeGroup = m.top.findNode("overlayTimeGroup")
if not m.hideClock
' get system preference clock format (12/24hr)
di = CreateObject("roDeviceInfo")
m.clockFormat = di.GetClockFormat()
' grab current time
currentTime = CreateObject("roDateTime")
currentTime.ToLocalTime()
m.currentHours = currentTime.GetHours()
m.currentMinutes = currentTime.GetMinutes()
' start timer
m.currentTimeTimer = m.top.findNode("currentTimeTimer")
m.currentTimeTimer.control = "start"
m.currentTimeTimer.ObserveField("fire", "updateTime")
updateTimeDisplay()
end if
setClockVisibility()
end sub end sub
sub updateTitle() sub updateTitle()
@ -37,16 +49,33 @@ sub updateTitle()
end if end if
title = m.top.findNode("overlayTitle") title = m.top.findNode("overlayTitle")
title.text = m.top.title title.text = m.top.title
resetTime()
if not m.hideClock
resetTime()
end if
end sub
sub setClockVisibility()
if m.hideClock
m.overlayRightGroup.removeChild(m.overlayTimeGroup)
end if
end sub
sub setRightSeperatorVisibility()
if m.hideClock
m.top.removeChild(m.rightSeperator)
return
end if
if m.top.currentUser <> ""
m.rightSeperator.visible = "true"
else
m.rightSeperator.visible = "false"
end if
end sub end sub
sub updateUser() sub updateUser()
rightSeperator = m.top.findNode("overlayRightSeperator") setRightSeperatorVisibility()
if m.top.currentUser <> ""
rightSeperator.visible = "true"
else
rightSeperator.visible = "false"
end if
user = m.top.findNode("overlayCurrentUser") user = m.top.findNode("overlayCurrentUser")
user.text = m.top.currentUser user.text = m.top.currentUser
end sub end sub

View File

@ -19,7 +19,8 @@
id="overlayRightSeperator" id="overlayRightSeperator"
color="#666666" color="#666666"
width="2" width="2"
height="64"/> height="64"
visible="false"/>
<LayoutGroup id="overlayTimeGroup" layoutDirection="horiz" horizAlignment="right" itemSpacings="0" > <LayoutGroup id="overlayTimeGroup" layoutDirection="horiz" horizAlignment="right" itemSpacings="0" >
<Label id="overlayHours" font="font:MediumSystemFont" vertAlign="center" height="64" /> <Label id="overlayHours" font="font:MediumSystemFont" vertAlign="center" height="64" />
<Label font="font:MediumSystemFont" text=":" vertAlign="center" height="64" /> <Label font="font:MediumSystemFont" text=":" vertAlign="center" height="64" />
@ -45,4 +46,5 @@
<function name="resetTime" /> <function name="resetTime" />
</interface> </interface>
<script type="text/brightscript" uri="JFOverhang.brs" /> <script type="text/brightscript" uri="JFOverhang.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/config.brs" />
</component> </component>

View File

@ -8,6 +8,10 @@ sub init()
m.top.transcodeReasons = [] m.top.transcodeReasons = []
m.bufferCheckTimer.duration = 10 m.bufferCheckTimer.duration = 10
if get_user_setting("ui.design.hideclock") = "true"
clockNode = findNodeBySubtype(m.top, "clock")
clockNode[0].parent.removeChild(clockNode[0].node)
end if
end sub end sub
' '

View File

@ -24,6 +24,8 @@
</interface> </interface>
<script type="text/brightscript" uri="JFVideo.brs" /> <script type="text/brightscript" uri="JFVideo.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/misc.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/config.brs" />
<children> <children>
<timer id="playbackTimer" repeat="true" duration="30" /> <timer id="playbackTimer" repeat="true" duration="30" />
<timer id="bufferCheckTimer" repeat="true" /> <timer id="bufferCheckTimer" repeat="true" />

View File

@ -68,7 +68,9 @@ sub itemContentChanged()
if type(itemData.RunTimeTicks) = "LongInteger" if type(itemData.RunTimeTicks) = "LongInteger"
setFieldText("runtime", stri(getRuntime()) + " mins") setFieldText("runtime", stri(getRuntime()) + " mins")
setFieldText("ends-at", tr("Ends at %1").Replace("%1", getEndTime())) if get_user_setting("ui.design.hideclock") <> "true"
setFieldText("ends-at", tr("Ends at %1").Replace("%1", getEndTime()))
end if
end if end if
if itemData.genres.count() > 0 if itemData.genres.count() > 0

View File

@ -32,7 +32,9 @@ sub itemContentChanged()
if type(itemData.RunTimeTicks) = "LongInteger" if type(itemData.RunTimeTicks) = "LongInteger"
m.top.findNode("runtime").text = stri(getRuntime()).trim() + " mins" m.top.findNode("runtime").text = stri(getRuntime()).trim() + " mins"
m.top.findNode("endtime").text = tr("Ends at %1").Replace("%1", getEndTime()) if get_user_setting("ui.design.hideclock") <> "true"
m.top.findNode("endtime").text = tr("Ends at %1").Replace("%1", getEndTime())
end if
end if end if
if itemData.communityRating <> invalid if itemData.communityRating <> invalid

View File

@ -678,5 +678,15 @@
<translation>Cinema mode brings the theater experience straight to your living room with the ability to play custom intros before the main feature.</translation> <translation>Cinema mode brings the theater experience straight to your living room with the ability to play custom intros before the main feature.</translation>
<extracomment>Settings Menu - Description for option</extracomment> <extracomment>Settings Menu - Description for option</extracomment>
</message> </message>
<message>
<source>Hide Clock</source>
<translation>Hide Clock</translation>
<extracomment>Option Title in user setting screen</extracomment>
</message>
<message>
<source>Hides all clocks in Jellyfin. Jellyfin will need to be closed and reopened for change to take effect.</source>
<translation>Hides all clocks in Jellyfin. Jellyfin will need to be closed and reopened for change to take effect.</translation>
<extracomment>Settings Menu - Description for option</extracomment>
</message>
</context> </context>
</TS> </TS>

View File

@ -73,6 +73,13 @@
"title": "Design Elements", "title": "Design Elements",
"description": "Options that alter the design of Jellyfin.", "description": "Options that alter the design of Jellyfin.",
"children": [ "children": [
{
"title": "Hide Clock",
"description": "Hides all clocks in Jellyfin. Jellyfin will need to be closed and reopened for change to take effect.",
"settingName": "ui.design.hideclock",
"type": "bool",
"default": "false"
},
{ {
"title": "Use Splashscreen as Home Background", "title": "Use Splashscreen as Home Background",
"description": "Use generated splashscreen image as Jellyfin home background. Jellyfin will need to be closed and reopened for change to take effect.", "description": "Use generated splashscreen image as Jellyfin home background. Jellyfin will need to be closed and reopened for change to take effect.",

View File

@ -238,3 +238,22 @@ function versionChecker(versionToCheck as string, minVersionAccepted as string)
return leftHand >= rightHand return leftHand >= rightHand
end function end function
function findNodeBySubtype(node, subtype)
foundNodes = []
for each child in node.getChildren(-1, 0)
if lcase(child.subtype()) = "group"
return findNodeBySubtype(child, subtype)
end if
if lcase(child.subtype()) = lcase(subtype)
foundNodes.push({
node: child,
parent: node
})
end if
end for
return foundNodes
end function