diff options
Diffstat (limited to 'src-qt5/core')
-rw-r--r-- | src-qt5/core/libLumina/LuminaXDG.cpp | 2 | ||||
-rw-r--r-- | src-qt5/core/libLumina/RootWindow.cpp | 2 | ||||
-rw-r--r-- | src-qt5/core/libLumina/XDGMime.cpp | 3 | ||||
-rw-r--r-- | src-qt5/core/lumina-desktop-unified/LSession.cpp | 44 | ||||
-rw-r--r-- | src-qt5/core/lumina-desktop-unified/LSession.h | 4 | ||||
-rw-r--r-- | src-qt5/core/lumina-desktop-unified/global-objects.h | 1 | ||||
-rw-r--r-- | src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp | 50 | ||||
-rw-r--r-- | src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h | 2 |
8 files changed, 81 insertions, 27 deletions
diff --git a/src-qt5/core/libLumina/LuminaXDG.cpp b/src-qt5/core/libLumina/LuminaXDG.cpp index dea1938b..c1e7e199 100644 --- a/src-qt5/core/libLumina/LuminaXDG.cpp +++ b/src-qt5/core/libLumina/LuminaXDG.cpp @@ -445,6 +445,7 @@ bool XDGDesktop::setAutoStarted(bool autostart){ } void XDGDesktop::addToMenu(QMenu *topmenu){ + if(!this->isValid()){ return; } if(actions.isEmpty()){ //Just a single entry point - no extra actions QAction *act = new QAction(this->name, topmenu); @@ -617,6 +618,7 @@ void XDGDesktopList::populateMenu(QMenu *topmenu, bool byCategory){ menu->setIcon(LXDG::findIcon(icon,"")); QList<XDGDesktop*> appL = APPS.value(cats[i]); for( int a=0; a<appL.length(); a++){ appL[a]->addToMenu(menu); } + topmenu->addMenu(menu); } //end loop over cats }else{ QList<XDGDesktop*> APPS = this->apps(false, false); diff --git a/src-qt5/core/libLumina/RootWindow.cpp b/src-qt5/core/libLumina/RootWindow.cpp index 996b8e01..952e246b 100644 --- a/src-qt5/core/libLumina/RootWindow.cpp +++ b/src-qt5/core/libLumina/RootWindow.cpp @@ -10,7 +10,7 @@ #include <QScreen> #include <QDebug> -#define DEBUG 1 +#define DEBUG 0 // === PUBLIC === RootWindow::RootWindow() : QWidget(0, Qt::Window | Qt::BypassWindowManagerHint | Qt::WindowStaysOnBottomHint){ diff --git a/src-qt5/core/libLumina/XDGMime.cpp b/src-qt5/core/libLumina/XDGMime.cpp index 3983f6b5..cbbeff75 100644 --- a/src-qt5/core/libLumina/XDGMime.cpp +++ b/src-qt5/core/libLumina/XDGMime.cpp @@ -12,6 +12,9 @@ static QStringList mimeglobs; static qint64 mimechecktime; QString XDGMime::fromFileName(QString filename){ + if(QFile::exists(filename) && QFileInfo(filename).isDir()){ + return "inode/directory"; + } //Convert a filename into a mimetype return findAppMimeForFile(filename.section("/",-1),false); } diff --git a/src-qt5/core/lumina-desktop-unified/LSession.cpp b/src-qt5/core/lumina-desktop-unified/LSession.cpp index b7ea2fe1..e820e97b 100644 --- a/src-qt5/core/lumina-desktop-unified/LSession.cpp +++ b/src-qt5/core/lumina-desktop-unified/LSession.cpp @@ -11,7 +11,7 @@ #include "BootSplash.h" #ifndef DEBUG -#define DEBUG 0 +#define DEBUG 1 #endif //Initialize all the global objects to null pointers @@ -53,8 +53,8 @@ LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lu Lumina::EVThread = new QThread(); Lumina::NWS->moveToThread(Lumina::EVThread); Lumina::EVThread->start(); - Lumina::ROOTWIN = new RootWindow(); Lumina::APPLIST = XDGDesktopList::instance(); + Lumina::ROOTWIN = new RootWindow(); Lumina::SHORTCUTS = new LShortcutEvents(); //this can be moved to it's own thread eventually as well setupGlobalConnections(); @@ -134,7 +134,7 @@ void LSession::setupSession(){ Lumina::ROOTWIN->start(); Lumina::NWS->setRoot_numberOfWorkspaces(QStringList() << "one" << "two"); Lumina::NWS->setRoot_currentWorkspace(0); - + if(DEBUG){ qDebug() << " - Create Desktop Context Menu"; } DesktopContextMenu *cmenu = new DesktopContextMenu(Lumina::ROOTWIN); connect(cmenu, SIGNAL(showLeaveDialog()), this, SLOT(StartLogout()) ); cmenu->start(); @@ -384,10 +384,28 @@ void LSession::StartReboot(bool skipupdates){ } void LSession::LaunchApplication(QString exec){ + qDebug() << "Launch Application:" << exec; ExternalProcess::launch(exec); } +void LSession::LaunchDesktopApplication(QString app, QString action){ + qDebug() << "Launch Desktop Application:" << app << action; + XDGDesktop *xdg = Lumina::APPLIST->findAppFile(app); + bool cleanup = false; + if(xdg==0){ + xdg = new XDGDesktop(app); + cleanup = true; + } + if(xdg->isValid()){ + QString exec = xdg->generateExec(QStringList(), action); + ExternalProcess::launch(exec, QStringList(), xdg->startupNotify); + } + + if(cleanup && xdg!=0){ xdg->deleteLater(); } +} + void LSession::LaunchStandardApplication(QString app, QStringList args){ + qDebug() << "Launch Standard Application:" << app << args; //Find/replace standardized apps with thier mimetypes if(app.startsWith("--")){ app = "application/"+app.section("--",-1).simplified(); } //First see if this is a mimetype with a default application @@ -395,24 +413,18 @@ void LSession::LaunchStandardApplication(QString app, QStringList args){ QString mimeapp = XDGMime::findDefaultAppForMime(app); if(!mimeapp.isEmpty()){ app = mimeapp; } } - if(app.endsWith(".desktop")){ + if(!app.endsWith(".desktop")){ + //actual command/binary - just launch it + ExternalProcess::launch(app, args, false); // do not use startup notify cursor + }else{ //Get the XDGDesktop structure XDGDesktop *desk = 0; bool cleanup = false; if(app.startsWith("/") && QFile::exists(app)){ desk = new XDGDesktop(app); cleanup = true; } - if(!desk->isValid()){ + if(desk==0 || !desk->isValid()){ //Need to find the app within the current list - QHash<QString, XDGDesktop*>applist = Lumina::APPLIST->files; if(cleanup){ desk->deleteLater(); desk = 0; cleanup = false; } app = app.section("/",-1); //make sure this is a relative path - QStringList list = applist.keys().filter("/"+app); - if(!list.filter(QDir::homePath()).isEmpty()){ desk = applist[list.filter(QDir::homePath()).first()]; } //prefer user-override files - if(desk==0 || !desk->isValid()){ - desk = 0; - for(int i=0; i<list.length() && desk==0; i++){ - XDGDesktop *tmp = applist[list[i]]; - if(tmp->isValid()){ desk = tmp; } - } - } + desk = Lumina::APPLIST->findAppFile(app); } if(desk!=0 && desk->isValid()){ //Got the application - go ahead and assemble the startup command @@ -420,8 +432,6 @@ void LSession::LaunchStandardApplication(QString app, QStringList args){ ExternalProcess::launch(exec, QStringList(), desk->startupNotify); } if(cleanup){ desk->deleteLater(); } - }else{ - ExternalProcess::launch(app, args, false); // do not use startup notify cursor } } diff --git a/src-qt5/core/lumina-desktop-unified/LSession.h b/src-qt5/core/lumina-desktop-unified/LSession.h index 85cc050c..61da559b 100644 --- a/src-qt5/core/lumina-desktop-unified/LSession.h +++ b/src-qt5/core/lumina-desktop-unified/LSession.h @@ -15,6 +15,9 @@ public: LSession(int &argc, char **argv); ~LSession(); + static LSession* instance(){ + return ( static_cast<LSession*>(QApplication::instance()) ); + } private: void CleanupSession(); void setupGlobalConnections(); @@ -33,6 +36,7 @@ public slots: void StartShutdown(bool skipupdates = false); void StartReboot(bool skipupdates = false); void LaunchApplication(QString exec); + void LaunchDesktopApplication(QString app, QString action = ""); void LaunchStandardApplication(QString app, QStringList args = QStringList()); void reloadIconTheme(); //will emit the IconThemeChanged signal when ready diff --git a/src-qt5/core/lumina-desktop-unified/global-objects.h b/src-qt5/core/lumina-desktop-unified/global-objects.h index 474412eb..0c990dc6 100644 --- a/src-qt5/core/lumina-desktop-unified/global-objects.h +++ b/src-qt5/core/lumina-desktop-unified/global-objects.h @@ -25,6 +25,7 @@ #include "src-screensaver/LScreenSaver.h" //#include "src-WM/LWindowManager.h" +#include "LSession.h" //Any special defines for settings/testing #define ANIMTIME 80 //animation time in milliseconds diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp index ec470d48..9206506d 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp @@ -24,14 +24,19 @@ void DesktopContextMenu::UpdateMenu(bool fast){ QStringList items = DesktopSettings::instance()->value(DesktopSettings::ContextMenu, "itemlist", QStringList()<< "terminal" << "filemanager" << "line" << "applications" << "windowlist" << "settings" << "lockdesktop").toStringList(); usewinmenu=false; for(int i=0; i<items.length(); i++){ - if(items[i]=="terminal"){ this->addAction(LXDG::findIcon("utilities-terminal",""), tr("Terminal"))->setWhatsThis("lumina-open -terminal"); } + if(items[i]=="terminal"){ this->addAction(LXDG::findIcon("utilities-terminal",""), tr("Terminal"))->setWhatsThis("--terminal"); } else if(items[i]=="lockdesktop"){ this->addAction(LXDG::findIcon("system-lock-screen",""), tr("Lock Session"), this, SIGNAL(LockSession()) ); } - else if(items[i]=="filemanager"){ this->addAction( LXDG::findIcon("user-home",""), tr("Browse Files"))->setWhatsThis("lumina-open \""+QDir::homePath()+"\""); } - else if(items[i]=="applications"){ this->addMenu( appMenu ); } - else if(items[i]=="line"){ this->addSeparator(); } + else if(items[i]=="filemanager"){ this->addAction( LXDG::findIcon("user-home",""), tr("Browse Files"))->setWhatsThis(QDir::homePath()); } + else if(items[i]=="applications"){ + if(appMenu==0){ updateAppMenu(); } + this->addMenu( appMenu ); + }else if(items[i]=="line"){ this->addSeparator(); } //else if(items[i]=="settings"){ this->addMenu( LSession::handle()->settingsMenu() ); } - else if(items[i]=="windowlist"){ updateWinMenu(); this->addMenu( winMenu); usewinmenu=true; } - else if(items[i].startsWith("app::::") && items[i].endsWith(".desktop")){ + else if(items[i]=="windowlist"){ + if(winMenu==0){ updateWinMenu(); } + this->addMenu( winMenu); + usewinmenu=true; + }else if(items[i].startsWith("app::::") && items[i].endsWith(".desktop")){ //Custom *.desktop application QString file = items[i].section("::::",1,1).simplified(); //Try to use the pre-loaded app entry for this @@ -67,13 +72,14 @@ DesktopContextMenu::DesktopContextMenu(QWidget *parent) : QMenu(parent){ } appMenu = 0; winMenu = 0; + usewinmenu = false; workspaceLabel = new QLabel(0); wkspaceact = new QWidgetAction(0); wkspaceact->setDefaultWidget(workspaceLabel); connect(this, SIGNAL(triggered(QAction*)), this, SLOT(LaunchAction(QAction*)) ); //Connect to a couple global objects - connect(XDGDesktopList::instance(), SIGNAL(appsUpdated()), this, SLOT(updateAppMenu()) ); connect(this, SIGNAL(aboutToShow()), this, SLOT(UpdateMenu()) ); //this will do a "fast" update + qDebug() << "Done Creating Context Menu"; } DesktopContextMenu::~DesktopContextMenu(){ @@ -85,6 +91,7 @@ DesktopContextMenu::~DesktopContextMenu(){ void DesktopContextMenu::start(){ connect(DesktopSettings::instance(), SIGNAL(FileModified(DesktopSettings::File)), this, SLOT(SettingsChanged(DesktopSettings::File)) ); connect(this, SIGNAL(LockSession()), Lumina::SS, SLOT(LockScreenNow()) ); + connect(XDGDesktopList::instance(), SIGNAL(appsUpdated()), this, SLOT(updateAppMenu()) ); UpdateMenu(false); //Still need to connect to some "workspaceChanged(int)" signal } @@ -95,7 +102,29 @@ void DesktopContextMenu::LaunchAction(QAction *act){ if(act->whatsThis().isEmpty() || act->parent()!=this ){ return; } qDebug() << "Launch Menu Action:" << act->whatsThis(); QString cmd = act->whatsThis(); - ExternalProcess::launch(cmd); + if(cmd.startsWith("-action ")){ + LaunchApp(act); //forward this to the XDGDesktop parser + }else if(cmd.startsWith("--") || cmd.endsWith(".desktop")){ + LSession::instance()->LaunchStandardApplication(cmd); + }else if(QFile::exists(cmd)){ + QString mime = XDGMime::fromFileName(cmd); + LSession::instance()->LaunchStandardApplication(mime, QStringList() << cmd); + } +} + +void DesktopContextMenu::LaunchApp(QAction *act){ + + // The "whatsThis() field is set by the XDGDesktop object/format + if(act->whatsThis().isEmpty()){ return; } + QString action, file; + QString wt = act->whatsThis(); + if(wt.startsWith("-action")){ + action = wt.section(" ",1,1); action=action.remove("\""); + file = wt.section(" ",2,-1); file=file.remove("\""); + } + else{ file = wt; } + LSession::instance()->LaunchDesktopApplication(file, action); + } void DesktopContextMenu::showMenu(const QPoint &pt){ @@ -103,18 +132,21 @@ void DesktopContextMenu::showMenu(const QPoint &pt){ } void DesktopContextMenu::updateAppMenu(){ + //qDebug() << "Update App Menu"; if(appMenu==0){ appMenu = new QMenu(this); appMenu->setTitle( tr("Applications")); appMenu->setIcon( LXDG::findIcon("system-run","") ); + connect(appMenu, SIGNAL(triggered(QAction*)), this, SLOT(LaunchApp(QAction*)) ); } + //qDebug() << "Populate App Menu"; XDGDesktopList::instance()->populateMenu(appMenu); } void DesktopContextMenu::updateWinMenu(){ + //qDebug() << "Update Win Menu"; if(winMenu==0){ winMenu = new QMenu(this); winMenu->setTitle( tr("Task Manager") ); } } - diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h b/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h index 31daa0a8..ee6fdcc9 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h @@ -29,6 +29,8 @@ public: private slots: void LaunchAction(QAction *act); + void LaunchApp(QAction *act); + void showMenu(const QPoint&); void updateAppMenu(); |