diff options
-rwxr-xr-x | JsonMenu_Scripts/ls.json.sh | 2 | ||||
-rw-r--r-- | src-qt5/core/lumina-desktop/JsonMenu.h | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/JsonMenu_Scripts/ls.json.sh b/JsonMenu_Scripts/ls.json.sh index 7bd09e2d..5b4680ed 100755 --- a/JsonMenu_Scripts/ls.json.sh +++ b/JsonMenu_Scripts/ls.json.sh @@ -13,7 +13,7 @@ do if [ -d "${DIR}/${name}" ] ; then OUT="${OUT} \"${name}\" : { \"type\" : \"jsonmenu\", \"exec\" : \"${0} ${DIR}/${name}\", \"icon\":\"folder\"}" else - OUT="${OUT} \"${name}\" : { \"type\" : \"item\", \"icon\":\"unknown\", \"action\" : \"${name}\"}" + OUT="${OUT} \"${name}\" : { \"type\" : \"item\", \"icon\":\"unknown\", \"action\" : \"xdg-open ${DIR}/${name}\"}" fi done < /tmp/.tmp.lines.$$ rm /tmp/.tmp.lines.$$ diff --git a/src-qt5/core/lumina-desktop/JsonMenu.h b/src-qt5/core/lumina-desktop/JsonMenu.h index fbb80d28..87377a73 100644 --- a/src-qt5/core/lumina-desktop/JsonMenu.h +++ b/src-qt5/core/lumina-desktop/JsonMenu.h @@ -18,6 +18,7 @@ #include <LuminaUtils.h> #include <LuminaXDG.h> +#include "LSession.h" class JsonMenu : public QMenu{ Q_OBJECT @@ -28,6 +29,7 @@ public: JsonMenu(QString execpath, QWidget *parent = 0) : QMenu(parent){ exec = execpath; connect(this, SIGNAL(aboutToShow()), this, SLOT(updateMenu()) ); + connect(this, SIGNAL(triggered(QAction*)), this, SLOT(itemTriggered(QAction*)) ); } private slots: @@ -50,6 +52,7 @@ private slots: this->addMenu(menu); } } + void updateMenu(){ this->clear(); QJsonDocument doc = QJsonDocument::fromJson( LUtils::getCmdOutput(exec).join(" ").toLocal8Bit() ); @@ -64,5 +67,13 @@ private slots: } } } + + void itemTriggered(QAction *act){ + if(act->parent()!=this || act->whatsThis().isEmpty() ){ return; } //only handle direct child actions - needed for recursive nature of menu + QString cmd = act->whatsThis(); + QString bin = cmd.section(" ",0,0); + if( !LUtils::isValidBinary(bin) ){ cmd.prepend("lumina-open "); } + LSession::handle()->LaunchApplication(cmd); + } }; #endif |