This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Play All Media Button for Dolphin

Tags: None
(comma "," separated)
yu3ib7TgK9i
Registered Member
Posts
7
Karma
0

Play All Media Button for Dolphin

Wed May 03, 2017 9:48 pm
Hi,

Is it possible to have a "Play All" button in the top Dolphin toolbar, similar to Windows Explorer's toolbar, for media?

Thanks.
User avatar
Rog131
Registered Member
Posts
828
Karma
10
Earlier: New Idea for Dolphin: adding "play all" button - viewtopic.php?f=88&p=380003


Yes, it is possible to add a 'Play All' button to the Dolphin toolbar but you will need to patch the Dolphin.


Example with the Dophin 17.04.3.

Editing the src/dolphinmainwindow.cpp and src/dolphinmainwindow.h.

As a patch:

Code: Select all
diff -U 3 -H -d -r -N -- "a/src/dolphinmainwindow.cpp" "b/src/dolphinmainwindow.cpp"
--- a/src/dolphinmainwindow.cpp    2017-07-10 01:33:40.000000000 +0300
+++ b/src/dolphinmainwindow.cpp    2017-08-05 18:56:58.818793292 +0300
@@ -796,6 +796,27 @@
     }
 }
 
+void DolphinMainWindow::playAll()
+{
+    QString dir(QDir::homePath());
+
+    KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
+    KJobWidgets::setWindow(statJob, this);
+    statJob->exec();
+    QUrl url = statJob->mostLocalUrl();
+
+    if (url.isLocalFile()) {
+        dir = url.toLocalFile();
+    }
+   
+    QUrl dirUrl = dir;
+
+    QString command(QStringLiteral("playall \""));
+    command.append(dirUrl.toDisplayString(QUrl::PreferLocalFile));
+    command.append('\"');
+    KRun::runCommand(command, QStringLiteral("Play All"), QStringLiteral("playall"), this);
+}
+
 void DolphinMainWindow::updateControlMenu()
 {
     QMenu* menu = qobject_cast<QMenu*>(sender());
@@ -1129,6 +1150,12 @@
         connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal);
     }
 
+    // setup 'Play All' button
+    QAction* playAll = actionCollection()->addAction(QStringLiteral("play_all"));
+    playAll->setText(i18nc("@action:inmenu Tools", "Play All"));
+    playAll->setIcon(QIcon::fromTheme(QStringLiteral("system-run")));
+    connect(playAll, &QAction::triggered, this, &DolphinMainWindow::playAll);
+
     // setup 'Settings' menu
     KToggleAction* showMenuBar = KStandardAction::showMenubar(0, 0, actionCollection());
     connect(showMenuBar, &KToggleAction::triggered,                   // Fixes #286822
diff -U 3 -H -d -r -N -- "a/src/dolphinmainwindow.h" "b/src/dolphinmainwindow.h"
--- a/src/dolphinmainwindow.h   2017-07-10 01:33:40.000000000 +0300
+++ b/src/dolphinmainwindow.h   2017-08-05 18:59:32.302131552 +0300
@@ -424,6 +424,9 @@
      * Is called when the view has finished loading the directory.
      */
     void slotDirectoryLoadingCompleted();
+   
+    /** Start media player and play all media files */
+    void playAll();
 
 private:
     void setupActions();


Compilig the patched Dolphin. More of the building trained Dolphins: viewtopic.php?f=225&t=136907


Adding a helper file to make the mediaplayer change a bit easier - /usr/local/bin/playall:

Code: Select all
#!/bin/sh
# Usage: playall directory

# Play with the VLC:
vlc "$1"

#Play with the SMPlayer:
#smplayer "$1"

#Play with the QMPlayer:
#QMPlay2 "$1"


The Dolphin executes 'playall /path/to/directory' and the playall executes the wanted media player (VLC, SMPlayer, QMPlay2, ...).
Image


Testing with the VLC:

Image

Same as an youtube clip: https://youtu.be/bGWrFQqrYV0
User avatar
Rog131
Registered Member
Posts
828
Karma
10
10 extra custom buttons for the Dolphin

A wish - Bug 384798 - KFind launcher for the toolbar : https://bugs.kde.org/show_bug.cgi?id=384798

Editing the 'Play All' button code a bit and copying it nine times. Now there is ten extra buttons for the Dolphin:

Image

The user can rename the button and change the icon with the Dolphin settings.

Image

The Dolphin is executing the script file (myextrabuttons) and the script file is connecting the buttons to the right action:

Image

Sample 'myextrabuttons' file:
Code: Select all
#!/bin/sh

# variables:
# $1 is button number
# $2 is path
# $3 is selected items string

case "$1" in

    0)
    vlc "$2"
    exit
    ;;

    1)
    kfind "$2"&
    exit
    ;;
     
    2)
    konsole --hold -e echo "Button: $1, Path: $2, Selected: $3"
    exit
    ;;
     
    *)
#   case trap
    exit
     
esac


Testing...
Image


Extra buttons patch (Dolphin 17.08.1): https://pastebin.com/SJJ4zUrP
User avatar
ngraham
Registered Member
Posts
124
Karma
0
OS
These are great ideas. Do you think you could re-work this code to add a generic "Custom command" button that the user could populate with their own commands, and then submit that as a patch to phabricator.kde.org?
User avatar
firef
Registered Member
Posts
25
Karma
0
OS

generic user button for Dolphin

Fri Oct 02, 2020 4:46 am
would be nice to have such a generic button.

several people, including me, suggested adding a KFind button, and finally we have one. Bliss! :*
User avatar
nillmorais
Registered Member
Posts
2
Karma
0
OS
Hi,
is it possible to apply this patch nowadays? I tried with git version, but it gave an error.
dzon
Registered Member
Posts
493
Karma
3
Been requested on numerous occasions. I posted about this this last week. The devs should include a custom button option altogether, not only a media play one. Would solve the csd and such as well. You can make service menus till kingdom come, but a toolbar option, which would be great, is a total nono. But hey, there's hope. It's only been 5-6 years. Guess useless and already existing stuff like a buggy floating panel or halfbaked selection coloring is more important. Funny really that you can do this stuff with fm's like pcmanfm-qt, nemo, caja.....let's not even mention spacefm. So, for now, in the "highly" configurable dolphin, pride of the plasma desktop ( quoting here), service menus are your only option. Made this enqueue one for....https://imgur.com/a/5p9EGjG
It's not what you're looking for but you get the idea. Imagine you could do a bunch on the toolbar, not only buttons but even cascading dropdown menus. Unfortunately...

[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=video/*;audio/*
Actions=enqueueAudacious;enqueueSMplayer;enqueueDeadbeef
X-KDE-Submenu=Enqueue
Icon=amarok_lyrics
X-KDE-Priority=TopLevel

[Desktop Action enqueueAudacious]
Exec=audacious --enqueue %U
Name=Enqueue With Audacious
Icon=amarok_lyrics

[Desktop Action enqueueSMplayer]
Exec=QT_STYLE_OVERRIDE=kvantum smplayer -add-to-playlist %U
Name=Enqueue With SMplayer
Icon=smplayer

[Desktop Action enqueueDeadbeef]
Exec=/opt/deadbeef/bin/deadbeef --queue %F
Name=Enqueue With Deadbeef
Icon=deadbeef


This realm's name is Maya. And she speaks Hertz. But Ahamkara makes a fuzz about it.
User avatar
nillmorais
Registered Member
Posts
2
Karma
0
OS
Thanks for answering.
Yes, I had already thought of the service menu solution, which I am currently using.
But I'm surprised, the creator of this topic managed it at some point, in version 17.04.3.
Will I need to downgrade to accomplish this?
I just need to add a button with a custom action on the toolbar, isn't it possible with a patch in the source code before compiling?
dzon
Registered Member
Posts
493
Karma
3
I suppose. But frankly, I'm very reluctant myself. Thing with kde is a high rewriting of codes. Not sure if it would break the entire thing. Myself, I'd stick with a servicemenu or...a desktop application which you could put on a panel. I posted the other day something about that concerning csd.https://forum.kde.org/viewtopic.php?f=66&t=176756
Such a panel button is fairly easy to do if you don't want to use a servicemenu and you can probably set it to be used in other applications than dolphin. I mean, if you look at some of the screenshots I posted, you'll notice there's this laptop like icon on my panel. It's alt+<. I use it since I use a lot of ssb's but it's also applicable for anything that uses that shortcut to go back. I'm a keyboard hater ;). Doesn't have to be a single option btw. You can add a bunch of media related options to such a file. Like, for example, what I did with konsole: https://imgur.com/a/AGeCzXi
It's just an idea. Myself I tried the code before and ended up with an error as well. I guess I'll leave the possibility of a configurable toolbar button up to the kde devs.


This realm's name is Maya. And she speaks Hertz. But Ahamkara makes a fuzz about it.
dzon
Registered Member
Posts
493
Karma
3
I quickly made an idea for such an application. It does "select all" and "play with audacious". Of course, such a servicemenu is the same command. https://imgur.com/a/SRZ5C6N
Although I have to say that, although the service command works fine, the desktop app has issues. I'm not sure whether it's due to audacious or not but as a desktop app, the playlist doesn't get erased to start newly selected files.

This one:

[Desktop Entry]
Comment=
Exec=xdotool key ctrl+a && xdotool exec audacious -p
GenericName=Select and play
Icon=music-note-16th
Name=SelectPlay
NoDisplay=false
Path[$e]=
StartupNotify=true
Terminal=0
TerminalOptions=
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=


This realm's name is Maya. And she speaks Hertz. But Ahamkara makes a fuzz about it.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]