aboutsummaryrefslogtreecommitdiff
path: root/lumina-open/main.cpp
diff options
context:
space:
mode:
authorKen Moore <ken@pcbsd.org>2014-12-31 08:39:34 -0500
committerKen Moore <ken@pcbsd.org>2014-12-31 08:39:34 -0500
commit9ab36f494e3d6e4cc7f2e5a757ebda8842486c5b (patch)
treeaa36841c8eef45368c9f0aee22a897efae92f800 /lumina-open/main.cpp
parentClean up how translations are loaded for all the Lumina utilities, and also a... (diff)
downloadlumina-9ab36f494e3d6e4cc7f2e5a757ebda8842486c5b.tar.gz
lumina-9ab36f494e3d6e4cc7f2e5a757ebda8842486c5b.tar.bz2
lumina-9ab36f494e3d6e4cc7f2e5a757ebda8842486c5b.zip
Be a little bit more careful about the handling of the "Exec=" field codes in *.desktop files. This seems to fix the occasional issue with KDE *.desktop shotcuts (okular in particular).
Diffstat (limited to 'lumina-open/main.cpp')
-rw-r--r--lumina-open/main.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/lumina-open/main.cpp b/lumina-open/main.cpp
index f87317e4..36d6c1ec 100644
--- a/lumina-open/main.cpp
+++ b/lumina-open/main.cpp
@@ -250,11 +250,29 @@ void getCMD(int argc, char ** argv, QString& binary, QString& args, QString& pat
cmd = cmdFromUser(argc, argv, inFile, extension, path, showDLG);
}
}
+ //Now assemble the exec string (replace file/url field codes as necessary)
+ if(useInputFile){
+ args = inFile; //just to keep them distinct internally
+ // NOTE: lumina-open is only designed for a single input file,
+ // so no need to distinguish between the list codes (uppercase)
+ // and the single-file codes (lowercase)
+ if(isFile && (cmd.contains("%f") || cmd.contains("%F") ) ){
+ cmd.replace("%f","\""+inFile+"\"");
+ cmd.replace("%F","\""+inFile+"\"");
+ }else if(isUrl && (cmd.contains("%U") || cmd.contains("%u")) ){
+ cmd.replace("%u","\""+inFile+"\"");
+ cmd.replace("%U","\""+inFile+"\"");
+ }else{
+ //No field codes (or improper field codes given - which is quite common)
+ // - Just tack the input file on the end and let the app handle it as necessary
+ cmd.append(" \""+inFile+"\"");
+ }
+ }
//qDebug() << "Found Command:" << cmd << "Extension:" << extension;
- //Clean up the command appropriately for output
+ //Clean up any leftover "Exec" field codes (should have already been replaced earlier)
if(cmd.contains("%")){cmd = cmd.remove("%U").remove("%u").remove("%F").remove("%f").remove("%i").remove("%c").remove("%k").simplified(); }
- binary = cmd;
- if(useInputFile){ args = inFile; }
+ binary = cmd; //pass this string to the calling function
+
}
int main(int argc, char **argv){
@@ -269,7 +287,7 @@ int main(int argc, char **argv){
//qDebug() << "Run CMD:" << cmd << args;
//Now run the command (move to execvp() later?)
if(cmd.isEmpty()){ return 0; } //no command to run (handled internally)
- if(!args.isEmpty()){ cmd.append(" \""+args+"\""); }
+ //if(!args.isEmpty()){ cmd.append(" "+args+""); }
//int retcode = system( cmd.toUtf8() );
qDebug() << "[lumina-open] Running Cmd:" << cmd;
QProcess *p = new QProcess();
bgstack15