Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: How to add textbutton for context menu command to sort playlist? (Read 3905 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How to add textbutton for context menu command to sort playlist?

I'm trying to link text buttons like Title | Album | Rating | etc so when clicked they sort by the field. I can't use COMMAND:Edit/Sort/Randomize or any other sort field because it simply does not work. Is there a way to do it by ELPlaylist, how can I make a command to link to the sort context menu there? Please see screenshot.

For example this code can be used to make a button to access the context menu "Quicksearch for same/Year

$imagebutton($add($get(QS.button.left),74),$get(QS.button.top),15,15,$get_ps_global(image.path)'/icons/date_off.png',$get_ps_global(image.path)'/icons/date_on.png',CONTEXT:'Quicksearch for same/Year';REFRESH)

But ELPlaylists context menu above the main one on right click doesn't seem to work??


TLDR: Does anyone know how to make a sort by column like in the screenhsot work? It would make foobar2000 so much better and intuitive with large libraries.


How to add textbutton for context menu command to sort playlist?

Reply #1
i think your button doesn't work because ELplaylist is a 3rd party component. PSS can only execute menu commands that are part of foobar itself.

How to add textbutton for context menu command to sort playlist?

Reply #2
i think your button doesn't work because ELplaylist is a 3rd party component. PSS can only execute menu commands that are part of foobar itself.


That sucks big time, is there not some hack/cheat way to do it? Some sort component panel out there? Foobar should have a built in sort. 

How to add textbutton for context menu command to sort playlist?

Reply #3
standard buttons (in default UI - not sure about columns) and keyboard shortcuts should be able to run the edit>sort commands but you have to make sure your playlist has focus first.

How to add textbutton for context menu command to sort playlist?

Reply #4
standard buttons (in default UI - not sure about columns) and keyboard shortcuts should be able to run the edit>sort commands but you have to make sure your playlist has focus first.


Hmm that's not gonna work for me, it's annoying because facets has this feature and I think if CUI had it too then I wouldn't need to use DUI. I guess wsh panel mod is the only way to create this feature in columns ui?

How to add textbutton for context menu command to sort playlist?

Reply #5
yup, that'll do it.

How to add textbutton for context menu command to sort playlist?

Reply #6
So third party components can be accessed by wsh? Shame I don't have much experience of how to use it. Where would I start?

How to add textbutton for context menu command to sort playlist?

Reply #7
you can't access the ELplaylist only context commands but it can run the edit>sort commands. it can do this because it can give the playlist focus - unlike PSS. i've only tested this in default UI but it should work in columns UI as well. just edit the image path and sort command.

sample script:
Code: [Select]
img = gdi.Image(fb.ProfilePath + "path\\to\\image.png");

function on_paint(gr) {
    gr.DrawImage(img, 0, 0, img.Width, img.Height, 0, 0,img.Width, img.Height);
}

function on_mouse_lbtn_up(x, y) {
    plman.SetActivePlaylistContext();
    fb.RunMainMenuCommand("Edit/Sort/Reverse");
}


if you want a "hover" image, i can change the code for that.

How to add textbutton for context menu command to sort playlist?

Reply #8
Thanks marc! I get a crash with that code in columnsui, I entered the correct path img = gdi.Image(fb.ProfilePath + "images\\foonate\\sort.png");

Yes please that would be great I might use that, is there a way to do this with text? So clicking 'genre' will highlight the font? If not image is fine.

Edit

I found a way to do it using buttons, I forgot about these. I've set up text links under main menu command group with separators it works really well but the only problem is limited fields to sort by, anyway to add more fields like last added?

How to add textbutton for context menu command to sort playlist?

Reply #9
file>preferences>advanced>display>standard sort patterns.

name=sort pattern

make sure it's separated from the previous entry by a

;

How to add textbutton for context menu command to sort playlist?

Reply #10
Wow it worked! That is amazing thanks marc I looked there too but missed it, you're the only guy that has replied to my query and you've really helped me out. I have been wanting this for a long time after seeing facets. Now graphical browser and playlist can be sorted by most played and many other filters.

There is one more thing I can't get the sort fields to sort by ascending or descending when clicking most played or rated. This means all the top rated is at the bottom where you can't see it, is there anyway to reverse the sort like in the picture with five star at the top?

file path=%path_sort%;artist=%artist%|%date%;album artist=%album artist%;album=%album%|%discnumber%|%tracknumber%;track number=%discnumber%|%tracknumber%;title=%title%;date=%date%;added=%added%;genre=%genre%;rating=%rating%;play count=%play_count%;last played=%last_played%|%date%

Looking at that using %rating% GREATER 3 SORT DESCENDING BY %rating% doesn't work neither does SORT BY DESCENDING %rating%
The default queries have | for example artist=%artist%|%date% does that mean it's sorting by artist first then date?


How to add textbutton for context menu command to sort playlist?

Reply #11
query syntax won't work. you use that when querying the library/playlist usually via search dialogs.

you need to stick with standard title formatting when setting your sort patterns. reversing numbers is easy enough.

Code: [Select]
$sub(5,%rating%)


Quote
The default queries have | for example artist=%artist%|%date% does that mean it's sorting by artist first then date?


yup.

 

How to add textbutton for context menu command to sort playlist?

Reply #12
Awesome thanks again that worked. I didn't think of using the #sub code that's neat. So query syntax is for the whole library and standard formatting is for active playlists, I have both now I was going to remove the autoplaylists for most played, rated, last added etc but that does the whole library so it's still useful rather than having to select the entire library in filters.

I've settled on this so far.

Code: [Select]
length=%length%;file path=%path_sort%;artist=%artist%;album artist=%album artist%;album=%album%|%discnumber%|%tracknumber%;track number=%discnumber%|%tracknumber%;title=%title%;date=%date%;added=$sub(99999999999999,$replace(%added%,'-',,':',,' ',));rating=$sub(5,%rating%)|%album%;play count=$sub(999,%play_count%);last played=$sub(99999999999999,$replace(%last_played%,'-',,':',,' ',))


I don't think there is any other sort by fields I need, do you know any good ones?