Solved Close window on empty list container
#1
The context is playlists. I restrict access to myplaylist.xml if no items are queued and boot the user if the list is cleared via the built-in function but this leaves individual deletions unaccounted for. Is it possible to somehow close/replace a window when numitems goes to zero?

I suspect not but no harm in asking.
Reply
#2
There's a neat trick you can do with custom dialogs and visibility conditions that might achieve what you're looking for:

Create a new file called custom_windowClose.xml and populate as below:

xml:

<?xml version="1.0" encoding="UTF-8"?>
<window type="dialog" id="1100">
    <onload> [do something here like window.activate(home) ]</onload>
    <visible>Window.IsActive(MyPlaylist.xml) + Integer.IsEqual(container.numitems,0)</visible>
    <controls></controls>
</window>

The idea is pretty self evident. The dialog is loaded and sits quietly in the background waiting for the visibility condition to be satisfied.

Note that I haven't tested the above, but it should be enough to point you in the right direction. Hope it helps!
Bitcoin donations: 1Hvo9rWzhAVbuPrshgaGZaD7qcLFTCPuiv
[Skin] Pellucid
[Skin] Maximinimalism
Reply
#3
I'm pretty sure it wont work as the container isn't in the custom dialog and it can't get its value from another window.
Reply
#4
Just add this to the button with the id="22" :
Code:
<onclick>close</onclick>

It's the clear button. Once it's triggered, the dialog is going to be closed.

You also can add this to the header of the myplaylist.xml
Code:
<onload condition="!Integer.IsGreater(Container(50).NumItems,0)">close</onload>

This will force close the window once is going to be openend (by the user, or automatically) if the list is empty.

To bypass animation glitches (depends on the used skin), you should also group all elements into a main group
Code:

        <control type="group">
            <visible>Integer.IsGreater(Container(50).NumItems,0)</visible>
.....
</control>

Example:
Code:

<?xml version="1.0" encoding="UTF-8"?>
<window>
    <defaultcontrol always="true">50</defaultcontrol>
    <onload condition="!Integer.IsGreater(Container(50).NumItems,0)">close</onload>
    <include>PropertyIncludes</include>
    <views>50</views>
    <controls>
        <control type="group">
            <visible>Integer.IsGreater(Container(50).NumItems,0)</visible>
            <!-- Content -->
            <include condition="Window.IsVisible(videoplaylist)">VideoPlaylistLayout</include>
            <include condition="Window.IsVisible(musicplaylist)">MusicPlaylistLayout</include>
        </control>
    </controls>
</window>
Main: Lancool II Mesh  - Ryzen 9 5900x - MSI x570 Unify - Zotac RTX 3080 AMP HOLO - 32GB Trident Z Neo 3600 CL16 -  EVO 960 M.2 250GB / EVO 940 250GB / MX100 512GB /  Crucial P1 2TB / WD Blue 3D Nand 2TB 
Sound: Saxx AS30 DSP - Beyer Dynamic Custom One Pro 
TV: Nvidia Shield 2019 Pro- Adalight 114x LEDs - Sony 65XG9505 - Kodi / Emby - Yamaha RX-V683 - Heco Victa 700/101/251a + Dynavoice Magic FX-4
Server: i3 Skylake - 8GB - OMV4 - 22TB Storage
Reply
#5
(2018-07-31, 08:02)sualfred Wrote: Just add this to the button with the id="22" :
Code:
<onclick>close</onclick>

Understood but the list can also be emptied with the delete key and dealing with that possibility is the crux of my question.
Reply
#6
Not tested it, but as far as I remember one of the buttons is going to have the focus once the list is cleared, isn't it?

Try to add a onfocus command to it.

Code:

            <onfocus condition="Integer.IsLess(Container.NumItems,1)">close</onfocus>
Main: Lancool II Mesh  - Ryzen 9 5900x - MSI x570 Unify - Zotac RTX 3080 AMP HOLO - 32GB Trident Z Neo 3600 CL16 -  EVO 960 M.2 250GB / EVO 940 250GB / MX100 512GB /  Crucial P1 2TB / WD Blue 3D Nand 2TB 
Sound: Saxx AS30 DSP - Beyer Dynamic Custom One Pro 
TV: Nvidia Shield 2019 Pro- Adalight 114x LEDs - Sony 65XG9505 - Kodi / Emby - Yamaha RX-V683 - Heco Victa 700/101/251a + Dynavoice Magic FX-4
Server: i3 Skylake - 8GB - OMV4 - 22TB Storage
Reply
#7
(2018-07-31, 12:31)sualfred Wrote: Not tested it, but as far as I remember one of the buttons is going to have the focus once the list is cleared, isn't it?

Try to add a onfocus command to it.

Code:

            <onfocus condition="Integer.IsLess(Container.NumItems,1)">close</onfocus>

I'm oh so close. This approach in combination with a hidden button in the focused layout of the list works for tracks queued manually but I get ejected prematurely when using party mode.
Reply
#8
Try to add "!MusicPartyMode.Enabled" to the condition.
Main: Lancool II Mesh  - Ryzen 9 5900x - MSI x570 Unify - Zotac RTX 3080 AMP HOLO - 32GB Trident Z Neo 3600 CL16 -  EVO 960 M.2 250GB / EVO 940 250GB / MX100 512GB /  Crucial P1 2TB / WD Blue 3D Nand 2TB 
Sound: Saxx AS30 DSP - Beyer Dynamic Custom One Pro 
TV: Nvidia Shield 2019 Pro- Adalight 114x LEDs - Sony 65XG9505 - Kodi / Emby - Yamaha RX-V683 - Heco Victa 700/101/251a + Dynavoice Magic FX-4
Server: i3 Skylake - 8GB - OMV4 - 22TB Storage
Reply
#9
This solved the race issue with party mode:

PHP Code:
<focusedlayout>
     <
control type="button" id="3000">
          <include>
HiddenButton</include>
          <
onfocus condition="Control.HasFocus(50) + 
              Integer.IsEqual(Container(50).NumItems,0)"
>Action(close)</onfocus>
     </
control>
</
focusedlayout

Thanks gentlemen for the thought-provoking suggestions!
Reply

Logout Mark Read Team Forum Stats Members Help
Close window on empty list container0