diff options
Diffstat (limited to 'lumina-desktop')
-rw-r--r-- | lumina-desktop/AppMenu.cpp | 35 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp | 35 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/userbutton/UserItemWidget.h | 5 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/userbutton/UserWidget.cpp | 2 |
4 files changed, 68 insertions, 9 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+"\""); + } } diff --git a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp index ff77121e..76a0b4cf 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp +++ b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp @@ -6,6 +6,7 @@ //=========================================== #include "UserItemWidget.h" #include <LuminaUtils.h> +#include <QMenu> #define TEXTCUTOFF 165 UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, QString type, bool goback) : QFrame(parent){ @@ -19,11 +20,14 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, QString type, if(ok){ icon->setPixmap( LXDG::findIcon(item.icon, "preferences-system-windows-actions").pixmap(32,32) ); name->setText( this->fontMetrics().elidedText(item.name, Qt::ElideRight, TEXTCUTOFF) ); + setupActions(item); }else{ icon->setPixmap( LXDG::findIcon("unknown","").pixmap(32,32) ); name->setText( this->fontMetrics().elidedText(itemPath.section("/",-1), Qt::ElideRight, TEXTCUTOFF) ); + actButton->setVisible(false); } }else if(type=="dir"){ + actButton->setVisible(false); if(itemPath.endsWith("/")){ itemPath.chop(1); } if(goback){ icon->setPixmap( LXDG::findIcon("go-previous","").pixmap(32,32) ); @@ -33,6 +37,7 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, QString type, name->setText( this->fontMetrics().elidedText(itemPath.section("/",-1), Qt::ElideRight, TEXTCUTOFF) ); } }else{ + actButton->setVisible(false); if(itemPath.endsWith("/")){ itemPath.chop(1); } if(QFileInfo(itemPath).isDir()){ type = "dir"; @@ -75,9 +80,9 @@ UserItemWidget::UserItemWidget(QWidget *parent, XDGDesktop item) : QFrame(parent name->setText( this->fontMetrics().elidedText(item.name, Qt::ElideRight, TEXTCUTOFF) ); this->setWhatsThis(name->text()); icon->setWhatsThis(item.filePath); - //Now setup the button appropriately + //Now setup the buttons appropriately setupButton(); - + setupActions(item); } UserItemWidget::~UserItemWidget(){ @@ -93,12 +98,17 @@ void UserItemWidget::createWidget(){ button = new QToolButton(this); button->setIconSize( QSize(14,14) ); button->setAutoRaise(true); + actButton = new QToolButton(this); + actButton->setPopupMode(QToolButton::InstantPopup); + actButton->setFixedSize( QSize(17,34) ); + actButton->setArrowType(Qt::DownArrow); icon = new QLabel(this); icon->setFixedSize( QSize(34,34) ); name = new QLabel(this); //Add them to the layout this->setLayout(new QHBoxLayout()); this->layout()->setContentsMargins(1,1,1,1); + this->layout()->addWidget(actButton); this->layout()->addWidget(icon); this->layout()->addWidget(name); this->layout()->addWidget(button); @@ -138,6 +148,19 @@ void UserItemWidget::setupButton(bool disable){ } } +void UserItemWidget::setupActions(XDGDesktop app){ + if(app.actions.isEmpty()){ actButton->setVisible(false); return; } + //Actions Available - go ahead and list them all + actButton->setMenu( new QMenu(this) ); + for(int i=0; i<app.actions.length(); i++){ + QAction *act = new QAction(LXDG::findIcon(app.actions[i].icon, app.icon), app.actions[i].name, this); + act->setToolTip(app.actions[i].ID); + act->setWhatsThis(app.actions[i].ID); + actButton->menu()->addAction(act); + } + connect(actButton->menu(), SIGNAL(triggered(QAction*)), this, SLOT(actionClicked(QAction*)) ); +} + void UserItemWidget::buttonClicked(){ button->setVisible(false); if(button->whatsThis()=="add"){ @@ -161,3 +184,11 @@ void UserItemWidget::ItemClicked(){ if(!linkPath.isEmpty()){ emit RunItem(linkPath); } else{ emit RunItem(icon->whatsThis()); } } + +void UserItemWidget::actionClicked(QAction *act){ + actButton->menu()->hide(); + QString cmd = "lumina-open -action \""+act->whatsThis()+"\" \"%1\""; + if(!linkPath.isEmpty()){ cmd = cmd.arg(linkPath); } + else{ cmd = cmd.arg(icon->whatsThis()); } + emit RunItem(cmd); +}
\ No newline at end of file diff --git a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h index a65d3e83..b3c5aea7 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h +++ b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h @@ -18,6 +18,7 @@ #include <QDir> #include <QFile> #include <QMouseEvent> +#include <QAction> #include <LuminaXDG.h> @@ -30,17 +31,19 @@ public: ~UserItemWidget(); private: - QToolButton *button; + QToolButton *button, *actButton; QLabel *icon, *name; bool isDirectory, isShortcut; QString linkPath; void createWidget(); void setupButton(bool disable = false); + void setupActions(XDGDesktop); private slots: void buttonClicked(); void ItemClicked(); + void actionClicked(QAction*); protected: void mouseReleaseEvent(QMouseEvent *event){ diff --git a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp index 92f6178b..5d1a2bc9 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp +++ b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp @@ -188,7 +188,7 @@ void UserWidget::UpdateMenu(bool forceall){ void UserWidget::LaunchItem(QString path, bool fix){ if(!path.isEmpty()){ qDebug() << "Launch Application:" << path; - if(fix){ LSession::LaunchApplication("lumina-open \""+path+"\""); } + if( fix && !path.startsWith("lumina-open") ){ LSession::LaunchApplication("lumina-open \""+path+"\""); } else{ LSession::LaunchApplication(path); } emit CloseMenu(); //so the menu container will close } |