diff options
author | Ken Moore <ken@pcbsd.org> | 2015-03-24 08:01:29 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2015-03-24 08:01:29 -0400 |
commit | 120207ea7de7ca6e0973ececb4787e982feefcd1 (patch) | |
tree | 3c7dcdf0c2d182f25e5caf1531e13948376c7cd0 /libLumina | |
parent | Merge branch 'master' of github.com:pcbsd/lumina (diff) | |
parent | Add a new information file: DeveloperGuidelines.txt (diff) | |
download | lumina-120207ea7de7ca6e0973ececb4787e982feefcd1.tar.gz lumina-120207ea7de7ca6e0973ececb4787e982feefcd1.tar.bz2 lumina-120207ea7de7ca6e0973ececb4787e982feefcd1.zip |
Merge branch 'master' of github.com:pcbsd/lumina
Diffstat (limited to 'libLumina')
-rw-r--r-- | libLumina/LuminaOS-Debian.cpp | 5 | ||||
-rw-r--r-- | libLumina/LuminaOS-DragonFly.cpp | 5 | ||||
-rw-r--r-- | libLumina/LuminaOS-FreeBSD.cpp | 16 | ||||
-rw-r--r-- | libLumina/LuminaOS-Linux.cpp | 4 | ||||
-rw-r--r-- | libLumina/LuminaOS-OpenBSD.cpp | 17 | ||||
-rw-r--r-- | libLumina/LuminaOS-kFreeBSD.cpp | 6 | ||||
-rw-r--r-- | libLumina/LuminaOS-template.cpp | 5 | ||||
-rw-r--r-- | libLumina/LuminaOS.h | 3 | ||||
-rw-r--r-- | libLumina/LuminaThemes.cpp | 9 | ||||
-rw-r--r-- | libLumina/LuminaThemes.h | 3 | ||||
-rw-r--r-- | libLumina/LuminaUtils.cpp | 44 | ||||
-rw-r--r-- | libLumina/LuminaUtils.h | 10 | ||||
-rw-r--r-- | libLumina/LuminaX11.cpp | 99 | ||||
-rw-r--r-- | libLumina/LuminaX11.h | 16 | ||||
-rw-r--r-- | libLumina/LuminaXDG.cpp | 11 | ||||
-rw-r--r-- | libLumina/libLumina.pro | 2 |
16 files changed, 230 insertions, 25 deletions
diff --git a/libLumina/LuminaOS-Debian.cpp b/libLumina/LuminaOS-Debian.cpp index 8228d7c4..4f2032fa 100644 --- a/libLumina/LuminaOS-Debian.cpp +++ b/libLumina/LuminaOS-Debian.cpp @@ -193,4 +193,9 @@ int LOS::batterySecondsLeft(){ //Returns: estimated number of seconds remaining return 0; //not implemented yet for Linux } +//File Checksums +QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the input file + return QStringList(); +} + #endif diff --git a/libLumina/LuminaOS-DragonFly.cpp b/libLumina/LuminaOS-DragonFly.cpp index dd9320fc..35bff04c 100644 --- a/libLumina/LuminaOS-DragonFly.cpp +++ b/libLumina/LuminaOS-DragonFly.cpp @@ -171,4 +171,9 @@ int LOS::batterySecondsLeft(){ //Returns: estimated number of seconds remaining return LUtils::getCmdOutput("apm -t").join("").toInt(); } +//File Checksums +QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the input file + return QStringList(); +} + #endif diff --git a/libLumina/LuminaOS-FreeBSD.cpp b/libLumina/LuminaOS-FreeBSD.cpp index c58d2397..d454ce22 100644 --- a/libLumina/LuminaOS-FreeBSD.cpp +++ b/libLumina/LuminaOS-FreeBSD.cpp @@ -152,12 +152,12 @@ bool LOS::userHasShutdownAccess(){ //System Shutdown void LOS::systemShutdown(){ //start poweroff sequence - QProcess::startDetached("shutdown -p now"); + QProcess::startDetached("shutdown -po now"); } //System Restart void LOS::systemRestart(){ //start reboot sequence - QProcess::startDetached("shutdown -r now"); + QProcess::startDetached("shutdown -ro now"); } //Battery Availability @@ -183,4 +183,16 @@ int LOS::batterySecondsLeft(){ //Returns: estimated number of seconds remaining return LUtils::getCmdOutput("apm -t").join("").toInt(); } +//File Checksums +QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the input file + QStringList info = LUtils::getCmdOutput("md5 \""+filepaths.join("\" \"")+"\""); + for(int i=0; i<info.length(); i++){ + if( !info[i].contains(" = ") ){ info.removeAt(i); i--; } + else{ + //Strip out the extra information + info[i] = info[i].section(" = ",1,1); + } + } + return info; +} #endif diff --git a/libLumina/LuminaOS-Linux.cpp b/libLumina/LuminaOS-Linux.cpp index f0f427f4..7587a29b 100644 --- a/libLumina/LuminaOS-Linux.cpp +++ b/libLumina/LuminaOS-Linux.cpp @@ -190,4 +190,8 @@ int LOS::batterySecondsLeft(){ //Returns: estimated number of seconds remaining return 0; //not implemented yet for Linux } +//File Checksums +QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the input file + return QStringList(); +} #endif diff --git a/libLumina/LuminaOS-OpenBSD.cpp b/libLumina/LuminaOS-OpenBSD.cpp index 2c86995a..b6996795 100644 --- a/libLumina/LuminaOS-OpenBSD.cpp +++ b/libLumina/LuminaOS-OpenBSD.cpp @@ -190,4 +190,21 @@ int LOS::batterySecondsLeft(){ //Returns: estimated number of seconds remaining return (min * 60); } +//File Checksums +QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the input file + //on OpenBSD md5 has the following layout + //>md5 LuminaThemes.o LuminaUtils.o + //MD5 (LuminaThemes.o) = 50006505d9d7e54e5154eeb095555055 + //MD5 (LuminaUtils.o) = d490878ee8866e55e5af571b98b4d448 + + QStringList info = LUtils::getCmdOutput("md5 \""+filepaths.join("\" \"")+"\""); + for(int i=0; i<info.length(); i++){ + if( !info[i].contains(" = ") ){ info.removeAt(i); i--; } + else{ + //Strip out the extra information + info[i] = info[i].section(" = ",1,1); + } + } + return info; +} #endif diff --git a/libLumina/LuminaOS-kFreeBSD.cpp b/libLumina/LuminaOS-kFreeBSD.cpp index ab9f9827..16c8e6eb 100644 --- a/libLumina/LuminaOS-kFreeBSD.cpp +++ b/libLumina/LuminaOS-kFreeBSD.cpp @@ -153,6 +153,10 @@ int LOS::batterySecondsLeft(){ //Returns: estimated number of seconds remaining return 0; //not implemented yet for Linux } +//File Checksums +QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the input file + return QStringList(); +} + #endif #endif - diff --git a/libLumina/LuminaOS-template.cpp b/libLumina/LuminaOS-template.cpp index d481984f..c06b8b11 100644 --- a/libLumina/LuminaOS-template.cpp +++ b/libLumina/LuminaOS-template.cpp @@ -101,4 +101,9 @@ int LOS::batterySecondsLeft(){ //Returns: estimated number of seconds remaining return 0; //not implemented yet } +//File Checksums +QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the input file + return QStringList(); +} + #endif diff --git a/libLumina/LuminaOS.h b/libLumina/LuminaOS.h index e0eb2895..92a7dc7e 100644 --- a/libLumina/LuminaOS.h +++ b/libLumina/LuminaOS.h @@ -80,6 +80,9 @@ public: static bool batteryIsCharging(); //Battery Time Remaining static int batterySecondsLeft(); //Returns: estimated number of seconds remaining + + //Get the checksum for a file + static QStringList Checksums(QStringList filepaths); //Return: checksum of each input file (same order) }; #endif diff --git a/libLumina/LuminaThemes.cpp b/libLumina/LuminaThemes.cpp index 269af259..e4c13ae7 100644 --- a/libLumina/LuminaThemes.cpp +++ b/libLumina/LuminaThemes.cpp @@ -177,10 +177,14 @@ LuminaThemeEngine::LuminaThemeEngine(QApplication *app){ theme = current[0]; colors=current[1]; icons=current[2]; font=current[3]; fontsize=current[4]; application->setStyleSheet( LTHEME::assembleStyleSheet(theme, colors, font, fontsize) ); QIcon::setThemeName(icons); //make sure this sets set within this environment + syncTimer = new QTimer(this); + syncTimer->setSingleShot(true); + syncTimer->setInterval(500); //wait 1/2 second before re-loading the files watcher = new QFileSystemWatcher(this); watcher->addPath( QDir::homePath()+"/.lumina/themesettings.cfg" ); watcher->addPaths( QStringList() << theme << colors ); //also watch these files for changes connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(watcherChange()) ); + connect(syncTimer, SIGNAL(timeout()), this, SLOT(reloadFiles()) ); } LuminaThemeEngine::~LuminaThemeEngine(){ @@ -188,6 +192,11 @@ LuminaThemeEngine::~LuminaThemeEngine(){ } void LuminaThemeEngine::watcherChange(){ + if(syncTimer->isActive()){ syncTimer->stop(); } + syncTimer->start(); +} + +void LuminaThemeEngine::reloadFiles(){ QStringList current = LTHEME::currentSettings(); application->setStyleSheet( LTHEME::assembleStyleSheet(current[0], current[1], current[3], current[4]) ); diff --git a/libLumina/LuminaThemes.h b/libLumina/LuminaThemes.h index e4bbd208..9b5ad5bc 100644 --- a/libLumina/LuminaThemes.h +++ b/libLumina/LuminaThemes.h @@ -16,6 +16,7 @@ #include <QString> #include <QFile> #include <QDir> +#include <QTimer> class LTHEME{ public: @@ -63,9 +64,11 @@ private: QApplication *application; QFileSystemWatcher *watcher; QString theme,colors,icons, font, fontsize; //current settings + QTimer *syncTimer; private slots: void watcherChange(); + void reloadFiles(); signals: void updateIcons(); diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp index 9b8a1860..f7f5db74 100644 --- a/libLumina/LuminaUtils.cpp +++ b/libLumina/LuminaUtils.cpp @@ -144,6 +144,50 @@ void LUtils::LoadTranslation(QApplication *app, QString appname){ QTextCodec::setCodecForLocale( QTextCodec::codecForName(langEnc.toUtf8()) ); } +QStringList LUtils::listFavorites(){ + QStringList fav = LUtils::readFile(QDir::homePath()+"/.lumina/favorites/fav.list"); + return fav; +} + +bool LUtils::saveFavorites(QStringList list){ + return LUtils::writeFile(QDir::homePath()+"/.lumina/favorites/fav.list", list, true); +} + +bool LUtils::isFavorite(QString path){ + QStringList fav = LUtils::listFavorites(); + for(int i=0; i<fav.length(); i++){ + if(fav[i].endsWith("::::"+path)){ return true; } + } + return false; +} + +bool LUtils::addFavorite(QString path, QString name){ + //Generate the type of favorite this is + QFileInfo info(path); + QString type = "file"; + if(info.isDir()){ type="dir"; } + else if(info.suffix()=="desktop"){ type="app"; } + //Assign a name if none given + if(name.isEmpty()){ name = info.fileName(); } + //Now add it to the list + QStringList fav = LUtils::listFavorites(); + bool found = false; + for(int i=0; i<fav.length(); i++){ + if(fav[i].endsWith("::::"+path)){ fav[i] = name+"::::"+type+"::::"+path; } + } + if(!found){ fav << name+"::::"+type+"::::"+path; } + return LUtils::saveFavorites(fav); +} + +void LUtils::removeFavorite(QString path){ + QStringList fav = LUtils::listFavorites(); + bool changed = false; + for(int i=0; i<fav.length(); i++){ + if(fav[i].endsWith("::::"+path)){ fav.removeAt(i); i--; changed=true;} + } + if(changed){ LUtils::saveFavorites(fav); } +} + void LUtils::LoadSystemDefaults(bool skipOS){ //Will create the Lumina configuration files based on the current system template (if any) QStringList sysDefaults; diff --git a/libLumina/LuminaUtils.h b/libLumina/LuminaUtils.h index ee716167..d0c8b3ad 100644 --- a/libLumina/LuminaUtils.h +++ b/libLumina/LuminaUtils.h @@ -44,6 +44,16 @@ public: //Load a translation file for a Lumina Project static void LoadTranslation(QApplication *app, QString appname); + + //Various functions for the favorites sub-system + // Formatting Note: "<name>::::[dir/file/app]::::<path>" + // the <name> field might not be used for "app" flagged entries + static QStringList listFavorites(); + static bool saveFavorites(QStringList); + static bool isFavorite(QString path); + static bool addFavorite(QString path, QString name = ""); + static void removeFavorite(QString path); + //Load the default setup for the system static void LoadSystemDefaults(bool skipOS = false); diff --git a/libLumina/LuminaX11.cpp b/libLumina/LuminaX11.cpp index e73f124c..43d4e577 100644 --- a/libLumina/LuminaX11.cpp +++ b/libLumina/LuminaX11.cpp @@ -25,6 +25,7 @@ #include <xcb/xproto.h> #include <xcb/xcb_ewmh.h> #include <xcb/xcb_icccm.h> +#include <xcb/xcb_image.h> //===== WindowList() ======== @@ -425,6 +426,8 @@ bool LX11::EmbedWindow(WId win, WId container){ //qDebug() << "Embed Window:" << win << container; XReparentWindow(disp, win, container,0,0); XSync(disp, false); + //Map the window + XMapRaised(disp, win); //make it visible again and raise it to the top //Check that the window has _XEMBED_INFO //qDebug() << " - check for _XEMBED_INFO"; Atom embinfo = XInternAtom(disp, "_XEMBED_INFO",false); @@ -436,7 +439,7 @@ bool LX11::EmbedWindow(WId win, WId container){ return false; //Embedding error (no info?) } if(data){ XFree(data); } // clean up any data found - + //Now send the embed event to the app //qDebug() << " - send _XEMBED event"; XEvent ev; @@ -515,7 +518,7 @@ QString LX11::WindowVisibleIconName(WId win){ } // ===== WindowIcon() ===== -QIcon LX11::WindowIcon(WId win){ +/*QIcon LX11::WindowIcon(WId win){ //Use the _NET_WM_ICON value instead of the WMHints pixmaps // - the pixmaps are very unstable and erratic QIcon icon; @@ -544,11 +547,11 @@ QIcon LX11::WindowIcon(WId win){ XFree(data); } return icon; -} +}*/ // ===== WindowImage() ===== -QPixmap LX11::WindowImage(WId win, bool useleader){ +/*QPixmap LX11::WindowImage(WId win, bool useleader){ QPixmap pix; Display *disp = QX11Info::display(); WId leader = LX11::leaderWindow(win); //check for an alternate window that contains the image @@ -565,7 +568,7 @@ QPixmap LX11::WindowImage(WId win, bool useleader){ } //Return the pixmap return pix; -} +}*/ // ===== GetNumberOfDesktops() ===== int LX11::WindowDesktop(WId win){ @@ -1009,7 +1012,7 @@ LXCB::WINDOWSTATE LXCB::WindowState(WId win){ } // === WindowVisibleIconName() === -QString LXCB::WindowVisibleIconName(WId win){ //_WM_VISIBLE_ICON_NAME +QString LXCB::WindowVisibleIconName(WId win){ //_NET_WM_VISIBLE_ICON_NAME QString out; xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_visible_icon_name_unchecked(&EWMH, win); if(cookie.sequence == 0){ return out; } @@ -1021,7 +1024,7 @@ QString LXCB::WindowVisibleIconName(WId win){ //_WM_VISIBLE_ICON_NAME } // === WindowIconName() === -QString LXCB::WindowIconName(WId win){ //_WM_ICON_NAME +QString LXCB::WindowIconName(WId win){ //_NET_WM_ICON_NAME QString out; xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_icon_name_unchecked(&EWMH, win); if(cookie.sequence == 0){ return out; } @@ -1033,7 +1036,7 @@ QString LXCB::WindowIconName(WId win){ //_WM_ICON_NAME } // === WindowVisibleName() === -QString LXCB::WindowVisibleName(WId win){ //_WM_VISIBLE_NAME +QString LXCB::WindowVisibleName(WId win){ //_NET_WM_VISIBLE_NAME QString out; xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_visible_name_unchecked(&EWMH, win); if(cookie.sequence == 0){ return out; } @@ -1045,7 +1048,7 @@ QString LXCB::WindowVisibleName(WId win){ //_WM_VISIBLE_NAME } // === WindowName() === -QString LXCB::WindowName(WId win){ //_WM_NAME +QString LXCB::WindowName(WId win){ //_NET_WM_NAME QString out; xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_name_unchecked(&EWMH, win); if(cookie.sequence == 0){ return out; } @@ -1056,6 +1059,32 @@ QString LXCB::WindowName(WId win){ //_WM_NAME return out; } +// === OldWindowName() === +QString LXCB::OldWindowName(WId win){ //WM_NAME (old standard) + xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_name_unchecked(QX11Info::connection(), win); + xcb_icccm_get_text_property_reply_t reply; + if(1 == xcb_icccm_get_wm_name_reply(QX11Info::connection(), cookie, &reply, NULL) ){ + QString name = QString::fromLocal8Bit(reply.name); + xcb_icccm_get_text_property_reply_wipe(&reply); + return name; + }else{ + return ""; + } +} + +// === OldWindowIconName() === +QString LXCB::OldWindowIconName(WId win){ //WM_ICON_NAME (old standard) + xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_icon_name_unchecked(QX11Info::connection(), win); + xcb_icccm_get_text_property_reply_t reply; + if(1 == xcb_icccm_get_wm_icon_name_reply(QX11Info::connection(), cookie, &reply, NULL) ){ + QString name = QString::fromLocal8Bit(reply.name); + xcb_icccm_get_text_property_reply_wipe(&reply); + return name; + }else{ + return ""; + } +} + // === WindowIsMaximized() === bool LXCB::WindowIsMaximized(WId win){ //See if the _NET_WM_STATE_MAXIMIZED_[VERT/HORZ] flags are set on the window @@ -1074,6 +1103,56 @@ bool LXCB::WindowIsMaximized(WId win){ return false; } +// === WindowIcon() === +QIcon LXCB::WindowIcon(WId win){ + //Fetch the _NET_WM_ICON for the window and return it as a QIcon + QIcon icon; + xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_icon_unchecked(&EWMH, win); + xcb_ewmh_get_wm_icon_reply_t reply; + if(1 == xcb_ewmh_get_wm_icon_reply(&EWMH, cookie, &reply, NULL)){ + xcb_ewmh_wm_icon_iterator_t iter = xcb_ewmh_get_wm_icon_iterator(&reply); + //Just use the first + bool done =false; + while(!done){ + //Now convert the current data into a Qt image + // - first 2 elements are width and height (removed via XCB functions) + // - data in rows from left to right and top to bottom + QImage image(iter.width, iter.height, QImage::Format_ARGB32); //initial setup + uint* dat = iter.data; + //dat+=2; //remember the first 2 element offset + for(int i=0; i<image.byteCount()/4; ++i, ++dat){ + ((uint*)image.bits())[i] = *dat; + } + icon.addPixmap(QPixmap::fromImage(image)); //layer this pixmap onto the icon + //Now see if there are any more icons available + done = (iter.rem<1); //number of icons remaining + if(!done){ xcb_ewmh_get_wm_icon_next(&iter); } //get the next icon data + } + xcb_ewmh_get_wm_icon_reply_wipe(&reply); + } + return icon; +} + +// === WindowImage() === +QPixmap LXCB::WindowImage(WId win){ + QPixmap pix; + + //First get the size of the window + xcb_get_geometry_cookie_t cookie = xcb_get_geometry_unchecked(QX11Info::connection(), win); + xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(QX11Info::connection(), cookie, NULL); + if(reply == 0){ return pix; } //could not determine window geometry + //Now get the image + xcb_image_t *img = xcb_image_get(QX11Info::connection(), win, 0, 0, reply->width, reply->height, (uint32_t) AllPlanes, XCB_IMAGE_FORMAT_Z_PIXMAP); + if(img!=0){ + //Now convert the image into a QPixmap + pix.convertFromImage( QImage( (const uchar*) img->data, img->width, img->height, img->stride, QImage::Format_ARGB32_Premultiplied) ); + //Clean up the xcb_image structure + xcb_image_destroy(img); + } + //Return the pixmap + return pix; +} + // === SetAsSticky() === void LXCB::SetAsSticky(WId win){ //Need to send a client message event for the window so the WM picks it up @@ -1295,4 +1374,4 @@ void LXCB::MoveResizeWindow(WId win, QRect geom){ xcb_ewmh_set_workarea(&EWMH, 0, desks, dareas); //_NET_WORKAREA //Make sure to clear that reply xcb_ewmh_get_workarea_reply_wipe(&work); -}*/
\ No newline at end of file +}*/ diff --git a/libLumina/LuminaX11.h b/libLumina/LuminaX11.h index ef6fa676..62146ebe 100644 --- a/libLumina/LuminaX11.h +++ b/libLumina/LuminaX11.h @@ -91,8 +91,8 @@ public: static QString WindowVisibleName(WId); // long name (translated) static QString WindowIconName(WId); // short name (untranslated) static QString WindowVisibleIconName(WId); // short name (translated) - static QIcon WindowIcon(WId); // Icon for the window - static QPixmap WindowImage(WId win, bool useleader=true); // Image for the window + //static QIcon WindowIcon(WId); // Icon for the window + //static QPixmap WindowImage(WId win, bool useleader=true); // Image for the window static int WindowDesktop(WId); // Which virtual desktop the window is on static WINDOWSTATE GetWindowState(WId win); //State of activity static WId leaderWindow(WId); //Get the main window if this one is a redirect @@ -133,11 +133,15 @@ public: unsigned int WindowWorkspace(WId); //The workspace the window is on QRect WindowGeometry(WId, bool includeFrame = true); //the geometry of the window (frame excluded) WINDOWSTATE WindowState(WId win); //Visible state of window - QString WindowVisibleIconName(WId win); //_WM_VISIBLE_ICON_NAME - QString WindowIconName(WId win); //_WM_ICON_NAME - QString WindowVisibleName(WId win); //_WM_VISIBLE_NAME - QString WindowName(WId win); //_WM_NAME + QString WindowVisibleIconName(WId win); //_NET_WM_VISIBLE_ICON_NAME + QString WindowIconName(WId win); //_NET_WM_ICON_NAME + QString WindowVisibleName(WId win); //_NET_WM_VISIBLE_NAME + QString WindowName(WId win); //_NET_WM_NAME + QString OldWindowName(WId win); //WM_NAME (old standard) + QString OldWindowIconName(WId win); //WM_ICON_NAME (old standard) bool WindowIsMaximized(WId win); + QIcon WindowIcon(WId win); //_NET_WM_ICON + QPixmap WindowImage(WId win); //Pull the image directly from the window //Window Modification void SetAsSticky(WId); //Stick to all workspaces diff --git a/libLumina/LuminaXDG.cpp b/libLumina/LuminaXDG.cpp index 48abb40a..e4839480 100644 --- a/libLumina/LuminaXDG.cpp +++ b/libLumina/LuminaXDG.cpp @@ -20,7 +20,7 @@ XDGDesktop LXDG::loadDesktopFile(QString filePath, bool& ok){ DF.isHidden=false; DF.useTerminal=false; DF.startupNotify=false; - DF.type = XDGDesktop::BAD; + DF.type = XDGDesktop::APP; DF.filePath = filePath; DF.exec = DF.tryexec = ""; // just to make sure this is initialized //Check input file path validity @@ -83,7 +83,7 @@ XDGDesktop LXDG::loadDesktopFile(QString filePath, bool& ok){ if(val.toLower()=="application"){ DF.type = XDGDesktop::APP; } else if(val.toLower()=="link"){ DF.type = XDGDesktop::LINK; } else if(val.toLower()=="dir"){ DF.type = XDGDesktop::DIR; } - else{ DF.type = XDGDesktop::BAD; } + else{ DF.type = XDGDesktop::BAD; } //Unknown type } } //end reading file file.close(); @@ -255,10 +255,11 @@ QString LXDG::getDesktopExec(XDGDesktop app){ out = app.exec; } //Now perform any of the XDG flag substitutions as appropriate (9/2014 standards) - if(out.contains("%i")){ out.replace("%i", "--icon \'"+app.icon+"\'"); } + if(out.contains("%i") && !app.icon.isEmpty() ){ out.replace("%i", "--icon \'"+app.icon+"\'"); } if(out.contains("%c")){ - if(!app.name.isEmpty()){ out.replace("%c", ""+app.name+""); } - else if(!app.genericName.isEmpty()){ out.replace(" %c ", ""+app.genericName+""); } + if(!app.name.isEmpty()){ out.replace("%c", "\'"+app.name+"\'"); } + else if(!app.genericName.isEmpty()){ out.replace("%c", "\'"+app.genericName+"\'"); } + else{ out.replace("%c", "\'"+app.filePath.section("/",-1).section(".desktop",0,0)+"\'"); } } if(out.contains("%k")){ out.replace("%k", "\'"+app.filePath+"\'"); } return out; diff --git a/libLumina/libLumina.pro b/libLumina/libLumina.pro index 7606210b..e0963fc6 100644 --- a/libLumina/libLumina.pro +++ b/libLumina/libLumina.pro @@ -42,7 +42,7 @@ SOURCES += LuminaXDG.cpp \ INCLUDEPATH += $$PREFIX/include -LIBS += -lX11 -lXrender -lXcomposite -lxcb -lxcb-ewmh -lxcb-icccm +LIBS += -lX11 -lXrender -lXcomposite -lxcb -lxcb-ewmh -lxcb-icccm -lxcb-image include.path=$$PREFIX/include/ include.files=LuminaXDG.h \ |