diff options
author | Ken Moore <moorekou@gmail.com> | 2016-03-11 11:09:51 -0500 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2016-03-11 11:09:51 -0500 |
commit | cdc5e2e146ac7bbe68731b3090225fc84e3a1b5d (patch) | |
tree | 6050ba0e59a072216b5177c14d0e51d08e27530c /lumina-open | |
parent | Clean up some random gnome icon paths in the lumina-fileinfo mainUI.ui file. (diff) | |
download | lumina-cdc5e2e146ac7bbe68731b3090225fc84e3a1b5d.tar.gz lumina-cdc5e2e146ac7bbe68731b3090225fc84e3a1b5d.tar.bz2 lumina-cdc5e2e146ac7bbe68731b3090225fc84e3a1b5d.zip |
Significant update to mime-type handling.
1) Register/use the "inode/directory" mimetype for the default file manager.
2) Register/use the "x-scheme-handler/http[s]" mimetypes for the default web browser
Note: Still have not found valid mimetypes for the default terminal/email apps yet - so those still use the alternate lumina settings.
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; |