diff options
author | Ken Moore <moorekou@gmail.com> | 2015-07-22 16:10:11 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2015-07-22 16:10:11 -0400 |
commit | b38f4f6ce26fd50cc7fac1d1b0c09ab22ee4e3ea (patch) | |
tree | 38bdba92c2ebd4bf462810c7ae7b5b58e42a231d /lumina-desktop/AppMenu.cpp | |
parent | Add support into libLumina for additional "Actions" listed in *.desktop files. (diff) | |
download | lumina-b38f4f6ce26fd50cc7fac1d1b0c09ab22ee4e3ea.tar.gz lumina-b38f4f6ce26fd50cc7fac1d1b0c09ab22ee4e3ea.tar.bz2 lumina-b38f4f6ce26fd50cc7fac1d1b0c09ab22ee4e3ea.zip |
Finish up the XDG "Actions" specification for *.desktop files, and integrate it into the AppMenu and UserButton. Also add a new flag to lumina-open so that we can specify which action to use when starting an app.
Diffstat (limited to 'lumina-desktop/AppMenu.cpp')
-rw-r--r-- | lumina-desktop/AppMenu.cpp | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/lumina-desktop/AppMenu.cpp b/lumina-desktop/AppMenu.cpp index 507f8f06..dec9422e 100644 --- a/lumina-desktop/AppMenu.cpp +++ b/lumina-desktop/AppMenu.cpp @@ -82,10 +82,31 @@ void AppMenu::updateAppList(){ connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(launchApp(QAction*)) ); QList<XDGDesktop> appL = APPS.value(cats[i]); for( int a=0; a<appL.length(); a++){ - QAction *act = new QAction(LXDG::findIcon(appL[a].icon, ""), appL[a].name, this); - act->setToolTip(appL[a].comment); - act->setWhatsThis(appL[a].filePath); - menu->addAction(act); + if(appL[a].actions.isEmpty()){ + //Just a single entry point - no extra actions + QAction *act = new QAction(LXDG::findIcon(appL[a].icon, ""), appL[a].name, this); + act->setToolTip(appL[a].comment); + act->setWhatsThis(appL[a].filePath); + menu->addAction(act); + }else{ + //This app has additional actions - make this a sub menu + // - first the main menu/action + QMenu *submenu = new QMenu(appL[a].name, this); + submenu->setIcon( LXDG::findIcon(appL[a].icon,"") ); + //This is the normal behavior - not a special sub-action (although it needs to be at the top of the new menu) + QAction *act = new QAction(LXDG::findIcon(appL[a].icon, ""), appL[a].name, this); + act->setToolTip(appL[a].comment); + act->setWhatsThis(appL[a].filePath); + submenu->addAction(act); + //Now add entries for every sub-action listed + for(int sa=0; sa<appL[a].actions.length(); sa++){ + QAction *sact = new QAction(LXDG::findIcon(appL[a].actions[sa].icon, appL[a].icon), appL[a].actions[sa].name, this); + sact->setToolTip(appL[a].comment); + sact->setWhatsThis("-action \""+appL[a].actions[sa].ID+"\" \""+appL[a].filePath+"\""); + submenu->addAction(sact); + } + menu->addMenu(submenu); + } } this->addMenu(menu); } @@ -121,5 +142,9 @@ void AppMenu::launchFileManager(){ void AppMenu::launchApp(QAction *act){ QString appFile = act->whatsThis(); - LSession::LaunchApplication("lumina-open \""+appFile+"\""); + if(appFile.startsWith("-action")){ + LSession::LaunchApplication("lumina-open "+appFile); //already has quotes put in place properly + }else{ + LSession::LaunchApplication("lumina-open \""+appFile+"\""); + } } |