aboutsummaryrefslogtreecommitdiff
path: root/lumina-open/main.cpp
diff options
context:
space:
mode:
authorKen Moore <moorekou@gmail.com>2015-09-18 09:00:09 -0400
committerKen Moore <moorekou@gmail.com>2015-09-18 09:00:09 -0400
commit707dc1df0df762dcd3a4d7a5264a11b3f088bb69 (patch)
treeb97e68689066c4e02348de73703a438d3c51f893 /lumina-open/main.cpp
parentAdd my work-in-progress for a lumina-terminal application. This is *not* read... (diff)
downloadlumina-707dc1df0df762dcd3a4d7a5264a11b3f088bb69.tar.gz
lumina-707dc1df0df762dcd3a4d7a5264a11b3f088bb69.tar.bz2
lumina-707dc1df0df762dcd3a4d7a5264a11b3f088bb69.zip
Clean up a little bit of the URL syntax handling in lumina-open. Now it will better handle inputs which are provided in the "file://" syntax.
Diffstat (limited to 'lumina-open/main.cpp')
-rw-r--r--lumina-open/main.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/lumina-open/main.cpp b/lumina-open/main.cpp
index 2b042f61..eb0cb92c 100644
--- a/lumina-open/main.cpp
+++ b/lumina-open/main.cpp
@@ -199,9 +199,11 @@ void getCMD(int argc, char ** argv, QString& binary, QString& args, QString& pat
}
//Make sure that it is a valid file/URL
bool isFile=false; bool isUrl=false;
+ //Quick check/replacement for the URL syntax of a file
+ if(inFile.startsWith("file://")){ inFile.remove(0,7); }
+ //Now check what type of file this is
if(QFile::exists(inFile)){ isFile=true; }
else if(QFile::exists(QDir::currentPath()+"/"+inFile)){isFile=true; inFile = QDir::currentPath()+"/"+inFile;} //account for relative paths
- else if(QUrl(inFile).isValid() && !inFile.startsWith("/") ){ isUrl=true; }
if( !isFile && !isUrl ){ ShowErrorDialog( argc, argv, QString(QObject::tr("Invalid file or URL: %1")).arg(inFile) ); }
//Determing the type of file (extension)
QString extension;
@@ -282,12 +284,13 @@ void getCMD(int argc, char ** argv, QString& binary, QString& args, QString& pat
if( (cmd.contains("%f") || cmd.contains("%F") ) ){
//Apply any special field replacements for the desired format
inFile.replace("%20"," ");
+ if(inFile.startsWith("file://")){ inFile.remove(0,7); } //chop that URL prefix off the front (should have happened earlier - just make sure)
//Now replace the field codes
cmd.replace("%f","\""+inFile+"\"");
cmd.replace("%F","\""+inFile+"\"");
}else if( (cmd.contains("%U") || cmd.contains("%u")) ){
//Apply any special field replacements for the desired format
- if(!inFile.contains("://")){ inFile.prepend("file:"); } //local file - add the extra flag
+ if(!inFile.contains("://")){ inFile.prepend("file://"); } //local file - add the extra flag
inFile.replace(" ", "%20");
//Now replace the field codes
cmd.replace("%u","\""+inFile+"\"");
bgstack15