Can't open files in Dolphin with a program set up with Q4Wine

So I have been having trouble opening files in Dolphin using a program I set up in Q4Wine. The program works fine when you open it and you can access all the various locations on all the drives. Only problem is when you try to open a file in Dolphin with it either by associating it with that file type or with ‘open with’ the file path isn’t being properly converted/passed to the program.

The default setup of Q4Wine with it would just result in the path being the .exe location and then the name of the file you tried to open. Tried messing about with the arguments in Q4Wine and also in the .desktop file which did result in the path changing sometimes, but I could never get it to work. In fact a lot of times it would pass the argument along WITH the file path to the program which makes me think it’s me just failing at getting the syntax/formatting correct. Read the documentation on Exec key and a bunch of other stuff, but still couldn’t seem to get it to work.

My guess is that it needs to have something like “winepath -w %f” somewhere for it to properly convert the file path to something the program can handle, but for the life of me I can’t figure out what kind of formatting/syntax I need to use.

Well as I thought it was me overlooking something simple, but I did eventually solve it for anyone interested here is how I solved it. Also if anyone has a better way of solving it I would love to know, but this works.

So I ended up making a shell script that looks sort of like this

> #!/bin/sh
> fp=$(winepath -w "$1")
> wine "Your Program's File Path Here" "$fp"

Then made it executable with chmod +x and used KDE Menu Editor to create an entry for it. Then from there you can associate whatever files you want with it. If you had previously setup the program in Q4Wine you will probably need to use winecfg to setup the program how you want. Hope this is helpful to someone out there because I feel like an idiot for how long this took for me to figure out.