diff options
author | Ken Moore <moorekou@gmail.com> | 2015-12-01 14:43:26 -0500 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2015-12-01 14:43:26 -0500 |
commit | dfec3ac55066d0265a5c8076c2f5fbeebe5eb56d (patch) | |
tree | 8da2458775ffd746fa5df123b949d814f2c0dfe9 | |
parent | Adjust the main lumina-desktop session a bit: (diff) | |
download | lumina-dfec3ac55066d0265a5c8076c2f5fbeebe5eb56d.tar.gz lumina-dfec3ac55066d0265a5c8076c2f5fbeebe5eb56d.tar.bz2 lumina-dfec3ac55066d0265a5c8076c2f5fbeebe5eb56d.zip |
Re-do the "App Menu" plugin a bit. Now it uses a self-contained menu with a "Leave" option at the bottom. We can add/change it more later as needed.
-rw-r--r-- | lumina-desktop/LDesktop.cpp | 2 | ||||
-rw-r--r-- | lumina-desktop/LSession.cpp | 4 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp | 104 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.h | 5 |
4 files changed, 100 insertions, 15 deletions
diff --git a/lumina-desktop/LDesktop.cpp b/lumina-desktop/LDesktop.cpp index 5771655b..d3cde4c1 100644 --- a/lumina-desktop/LDesktop.cpp +++ b/lumina-desktop/LDesktop.cpp @@ -293,7 +293,7 @@ void LDesktop::UpdateMenu(bool fast){ } //Now add the system quit options deskMenu->addSeparator(); - deskMenu->addAction(LXDG::findIcon("system-log-out",""), tr("Log Out"), this, SLOT(SystemLogout()) ); + deskMenu->addAction(LXDG::findIcon("system-log-out",""), tr("Leave"), this, SLOT(SystemLogout()) ); } void LDesktop::UpdateWinMenu(){ diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index 995c442d..e92dc5a4 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -698,9 +698,7 @@ void LSession::systemWindow(){ if(sysWindow==0){ sysWindow = new SystemWindow(); } else{ sysWindow->updateWindow(); } sysWindow->show(); - /*SystemWindow win; - win.exec();*/ - LSession::processEvents(); + //LSession::processEvents(); } //Play System Audio diff --git a/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp b/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp index c64f934b..928a93d9 100644 --- a/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp +++ b/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp @@ -13,14 +13,17 @@ LAppMenuPlugin::LAppMenuPlugin(QWidget *parent, QString id, bool horizontal) : L button = new QToolButton(this); button->setAutoRaise(true); button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - button->setMenu( LSession::handle()->applicationMenu() ); - connect(button->menu(), SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); + mainmenu = new QMenu(this); + button->setMenu( mainmenu ); button->setPopupMode(QToolButton::InstantPopup); this->layout()->setContentsMargins(0,0,0,0); this->layout()->addWidget(button); - + connect(mainmenu, SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); + connect(mainmenu, SIGNAL(triggered(QAction*)), this, SLOT(LaunchItem(QAction*)) ); + connect(LSession::handle()->applicationMenu(), SIGNAL(AppMenuUpdated()), this, SIGNAL(UpdateMenu())); QTimer::singleShot(0,this, SLOT(OrientationChange())); //Update icons/sizes + QTimer::singleShot(0,this, SLOT(UpdateMenu()) ); } LAppMenuPlugin::~LAppMenuPlugin(){ @@ -37,12 +40,95 @@ void LAppMenuPlugin::updateButtonVisuals(){ // ======================== // PRIVATE FUNCTIONS // ======================== -/*void LAppMenuPlugin::openMenu(){ - usermenu->UpdateMenu(); - menu->popup(this->mapToGlobal(QPoint(0,0))); +void LAppMenuPlugin::LaunchItem(QAction* item){ + QString appFile = item->whatsThis(); + if(appFile.startsWith("internal::")){ + appFile = appFile.section("::",1,50); //cut off the "internal" flag + if(appFile=="logout"){ LSession::handle()->systemWindow(); } + }else if(!appFile.isEmpty()){ + LSession::LaunchApplication("lumina-open "+appFile); + } } -void LAppMenuPlugin::closeMenu(){ - menu->hide(); -}*/ +void LAppMenuPlugin::UpdateMenu(){ + mainmenu->clear(); + QHash<QString, QList<XDGDesktop> > *HASH = LSession::handle()->applicationMenu()->currentAppHash(); + //Now Re-create the menu (orignally copied from the AppMenu class) + bool ok; //for checking inputs + //Add link to the file manager + QAction *tmpact = mainmenu->addAction( LXDG::findIcon("user-home", ""), tr("Browse Files") ); + tmpact->setWhatsThis("~"); + //--Look for the app store + XDGDesktop store = LXDG::loadDesktopFile(LOS::AppStoreShortcut(), ok); + if(ok){ + tmpact = mainmenu->addAction( LXDG::findIcon(store.icon, ""), tr("Install Applications") ); + tmpact->setWhatsThis("\""+store.filePath+"\""); + } + //--Look for the control panel + store = LXDG::loadDesktopFile(LOS::ControlPanelShortcut(), ok); + if(ok){ + tmpact = mainmenu->addAction( LXDG::findIcon(store.icon, ""), tr("Control Panel") ); + tmpact->setWhatsThis("\""+store.filePath+"\""); + } + mainmenu->addSeparator(); + //--Now create the sub-menus + QStringList cats = HASH->keys(); + cats.sort(); //make sure they are alphabetical + for(int i=0; i<cats.length(); i++){ + //Make sure they are translated and have the right icons + QString name, icon; + if(cats[i]=="All"){continue; } //skip this listing for the menu + else if(cats[i] == "Multimedia"){ name = tr("Multimedia"); icon = "applications-multimedia"; } + else if(cats[i] == "Development"){ name = tr("Development"); icon = "applications-development"; } + else if(cats[i] == "Education"){ name = tr("Education"); icon = "applications-education"; } + else if(cats[i] == "Game"){ name = tr("Games"); icon = "applications-games"; } + else if(cats[i] == "Graphics"){ name = tr("Graphics"); icon = "applications-graphics"; } + else if(cats[i] == "Network"){ name = tr("Network"); icon = "applications-internet"; } + else if(cats[i] == "Office"){ name = tr("Office"); icon = "applications-office"; } + else if(cats[i] == "Science"){ name = tr("Science"); icon = "applications-science"; } + else if(cats[i] == "Settings"){ name = tr("Settings"); icon = "preferences-system"; } + else if(cats[i] == "System"){ name = tr("System"); icon = "applications-system"; } + else if(cats[i] == "Utility"){ name = tr("Utility"); icon = "applications-utilities"; } + else if(cats[i] == "Wine"){ name = tr("Wine"); icon = "wine"; } + else{ name = tr("Unsorted"); icon = "applications-other"; } + + QMenu *menu = new QMenu(name, this); + menu->setIcon(LXDG::findIcon(icon,"")); + QList<XDGDesktop> appL = HASH->value(cats[i]); + for( int a=0; a<appL.length(); a++){ + 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, menu); + 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, menu); + 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, submenu); + 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); + } + }//end loop over apps within this category + mainmenu->addMenu(menu); + } //end loop over categories + //Now add any logout options + mainmenu->addSeparator(); + //QMenu *tmpmenu = mainmenu->addMenu(LXDG::findIcon("system-log-out",""), tr("Leave")); + tmpact =mainmenu->addAction(LXDG::findIcon("system-log-out"),tr("Leave")); + tmpact->setWhatsThis("internal::logout"); + +} diff --git a/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.h b/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.h index cd8d1c1e..36cd8605 100644 --- a/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.h +++ b/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.h @@ -30,12 +30,13 @@ public: private: QToolButton *button; + QMenu *mainmenu; void updateButtonVisuals(); private slots: - //void openMenu(); - //void closeMenu(); + void LaunchItem(QAction* item); + void UpdateMenu(); public slots: void OrientationChange(){ |