diff options
Diffstat (limited to 'lumina-open')
-rw-r--r-- | lumina-open/LFileDialog.cpp | 7 | ||||
-rw-r--r-- | lumina-open/main.cpp | 10 |
2 files changed, 11 insertions, 6 deletions
diff --git a/lumina-open/LFileDialog.cpp b/lumina-open/LFileDialog.cpp index d35a0fc7..234a48b7 100644 --- a/lumina-open/LFileDialog.cpp +++ b/lumina-open/LFileDialog.cpp @@ -33,11 +33,12 @@ LFileDialog::~LFileDialog(){ // ---------- void LFileDialog::setFileInfo(QString filename, QString extension, bool isFile){ //Set the labels for the file + qDebug() << "SetFileInfo:" << filename << extension << isFile; ui->label_file->setText( this->fontMetrics().elidedText( filename, Qt::ElideMiddle, 300 ) ); bool shownetwork = false; if(isFile){ ui->label_extension->setText( "("+extension+")"); } else if(extension=="email"){ ui->label_extension->setText( QString(tr("(Email Link)")) ); shownetwork = true; } - else if(extension=="webbrowser"){ ui->label_extension->setText( QString(tr("(Internet URL)")) ); shownetwork = true; } + else if(extension.startsWith("x-scheme-handler/")){ ui->label_extension->setText( QString(tr("(Internet URL - %1)")).arg(extension.section("/",-1)) ); shownetwork = true; } else{ui->label_extension->setText("("+extension+" link)"); } fileEXT = extension; //NOTE: this is the mime-type for the file now, not the extension generateAppList(shownetwork); @@ -46,7 +47,11 @@ void LFileDialog::setFileInfo(QString filename, QString extension, bool isFile){ //static functions QString LFileDialog::getDefaultApp(QString extension){ QSettings::setPath(QSettings::NativeFormat, QSettings::UserScope, QDir::homePath()+"/.lumina"); + if(extension.contains("/")){ + return LXDG::findDefaultAppForMime(extension); + }else{ return QSettings("LuminaDE", "lumina-open").value("default/"+extension,"").toString(); + } } void LFileDialog::setDefaultApp(QString extension, QString appFile){ diff --git a/lumina-open/main.cpp b/lumina-open/main.cpp index 8f98e342..dcec7269 100644 --- a/lumina-open/main.cpp +++ b/lumina-open/main.cpp @@ -105,7 +105,7 @@ QString cmdFromUser(int argc, char **argv, QString inFile, QString extension, QS else if(i+1==matches.length()){ extension = matches[0]; } } }else{ defApp = LFileDialog::getDefaultApp(extension); } - + //qDebug() << "extension:" << extension << "defApp:" << defApp; if( !defApp.isEmpty() && !showDLG ){ bool ok = false; if(defApp.endsWith(".desktop")){ @@ -129,7 +129,7 @@ QString cmdFromUser(int argc, char **argv, QString inFile, QString extension, QS LFileDialog::setDefaultApp(extension, ""); } //Final catch: directory given - no valid default found - use lumina-fm - if(extension=="directory" && !showDLG){ return "lumina-fm"; } + if(extension=="inode/directory" && !showDLG){ return "lumina-fm"; } //No default set -- Start up the application selection dialog LTHEME::LoadCustomEnvSettings(); QApplication App(argc, argv); @@ -137,7 +137,7 @@ QString cmdFromUser(int argc, char **argv, QString inFile, QString extension, QS LUtils::LoadTranslation(&App,"lumina-open"); LFileDialog w; - if(extension=="email" || extension=="webbrowser"){ + if(extension=="email" || extension.startsWith("x-scheme-handler/")){ //URL w.setFileInfo(inFile, extension, false); }else{ @@ -235,12 +235,12 @@ void getCMD(int argc, char ** argv, QString& binary, QString& args, QString& pat QFileInfo info(inFile); extension=info.suffix(); //qDebug() << " - Extension:" << extension; - if(info.isDir()){ extension="directory"; } + if(info.isDir()){ extension="inode/directory"; } else if(info.isExecutable() && extension.isEmpty()){ extension="binary"; } else if(extension!="desktop"){ extension="mimetype"; } //flag to check for mimetype default based on file } else if(isUrl && inFile.startsWith("mailto:")){ extension = "email"; } - else if(isUrl){ extension = "webbrowser"; } + else if(isUrl){ extension = "x-scheme-handler/"+inFile.section("://",0,0); } //webbrowser"; } //qDebug() << "Input:" << inFile << isFile << isUrl << extension; //if not an application - find the right application to open the file QString cmd; |