From 702d651bad7892126fdf82499f25e6e418499366 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 30 Jun 2016 09:39:01 -0400 Subject: Finish up the new JSON recursive menu system as well as the test script for listing the contents of a directory recursively. --- src-qt5/core/lumina-desktop/JsonMenu.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src-qt5/core/lumina-desktop/JsonMenu.h') 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 #include +#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 -- cgit