diff options
-rw-r--r-- | libLumina/LuminaUtils.cpp | 6 | ||||
-rw-r--r-- | libLumina/LuminaUtils.h | 6 | ||||
-rw-r--r-- | lumina-search/MainUI.cpp | 8 | ||||
-rw-r--r-- | lumina-search/Worker.cpp | 8 |
4 files changed, 23 insertions, 5 deletions
diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp index aa2336e3..6660f65c 100644 --- a/libLumina/LuminaUtils.cpp +++ b/libLumina/LuminaUtils.cpp @@ -87,7 +87,7 @@ bool LUtils::writeFile(QString filepath, QStringList contents, bool overwrite){ return ok; } -bool LUtils::isValidBinary(QString bin){ +bool LUtils::isValidBinary(QString& bin){ if(!bin.startsWith("/")){ //Relative path: search for it on the current "PATH" settings QStringList paths = QString(qgetenv("PATH")).split(":"); @@ -98,7 +98,9 @@ bool LUtils::isValidBinary(QString bin){ //bin should be the full path by now if(!bin.startsWith("/")){ return false; } QFileInfo info(bin); - return (info.exists() && info.isExecutable()); + bool good = (info.exists() && info.isExecutable()); + if(good){ bin = info.absoluteFilePath(); } + return good; } QStringList LUtils::listSubDirectories(QString dir, bool recursive){ diff --git a/libLumina/LuminaUtils.h b/libLumina/LuminaUtils.h index 960e6080..74a72465 100644 --- a/libLumina/LuminaUtils.h +++ b/libLumina/LuminaUtils.h @@ -36,7 +36,11 @@ public: static bool writeFile(QString filepath, QStringList contents, bool overwrite=false); //Check whether a file/path is a valid binary - static bool isValidBinary(QString bin); //full path or name only + static bool isValidBinary(QString& bin); //full path or name only + static bool isValidBinary(const char *bin){ + QString bins(bin); + return isValidBinary(bins); //overload for a "junk" binary variable input + } //List all the sub-directories of a parent dir (recursive) static QStringList listSubDirectories(QString dir, bool recursive = true); diff --git a/lumina-search/MainUI.cpp b/lumina-search/MainUI.cpp index 8f90d536..08356093 100644 --- a/lumina-search/MainUI.cpp +++ b/lumina-search/MainUI.cpp @@ -113,7 +113,7 @@ if(ui->radio_apps->isChecked()){ this->close(); } } void MainUI::LaunchItem(QListWidgetItem *item){ - QProcess::startDetached("lumina-open \""+item->whatsThis()+"\""); + QProcess::startDetached("lumina-open \""+item->whatsThis()+"\""); } void MainUI::searchTypeChanged(){ @@ -176,7 +176,11 @@ void MainUI::foundSearchItem(QString path){ it->setIcon( LXDG::findIcon("inode-directory","") ); it->setText( path.replace(QDir::homePath(), "~") ); }else{ - it->setIcon( LXDG::findMimeIcon(path.section("/",-1).section(".",-1)) ); + if(QFileInfo(path).isExecutable()){ + it->setIcon( LXDG::findIcon("application-x-executable","") ); + }else{ + it->setIcon( LXDG::findMimeIcon(path.section("/",-1).section(".",-1)) ); + } it->setText( path.section("/",-1) ); } diff --git a/lumina-search/Worker.cpp b/lumina-search/Worker.cpp index 5d874202..b414a72f 100644 --- a/lumina-search/Worker.cpp +++ b/lumina-search/Worker.cpp @@ -2,6 +2,7 @@ #include <QTimer> #include <LuminaXDG.h> +#include <LuminaUtils.h> Worker::Worker(QObject *parent) : QObject(parent){ //Get the list of all applications and save them in an easily-searchable form @@ -67,6 +68,12 @@ void Worker::beginsearch(){ if(stopsearch){ return; } emit FoundItem( tmp[i].section(":::4:::",1,1) ); } + //Check if this is a binary name + if(stopsearch){ return; } + if(LUtils::isValidBinary(sterm)){ + emit FoundItem(sterm); + return; + } //If items found, go ahead and stop now if(stopsearch){ return; } if(tmp.length()<1){ @@ -89,6 +96,7 @@ void Worker::beginsearch(){ emit FoundItem( tmp[i].section(":::4:::",1,1) ); } } + }else{ //Search through the user's home directory and look for a file/dir starting with that term if(!sterm.contains("*")){ |