mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
generic: replace MIME name checks with method calls
for flexibility Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
3cf815c995
commit
c2d19af39f
2 changed files with 4 additions and 5 deletions
|
@ -62,12 +62,11 @@ QString urlMimeType(const KUrl& url)
|
|||
if (url.isEmpty()) {
|
||||
return "unknown";
|
||||
}
|
||||
// Try a simple guess, using extension for remote urls
|
||||
// Check for local files
|
||||
QString mimeType = KMimeType::findByUrl(url)->name();
|
||||
if (mimeType == "application/octet-stream") {
|
||||
if (mimeType == KMimeType::defaultMimeType()) {
|
||||
kDebug() << "KMimeType::findByUrl() failed to find mimetype for" << url << ". Falling back to KIO::stat().";
|
||||
// No luck, look deeper. This can happens with http urls if the filename
|
||||
// does not provide any extension.
|
||||
// No luck, look deeper
|
||||
KIO::UDSEntry statentry;
|
||||
KIO::NetAccess::stat(url, statentry, KApplication::kApplication()->activeWindow());
|
||||
mimeType = statentry.stringValue(KIO::UDSEntry::UDS_MIME_TYPE);
|
||||
|
|
|
@ -1982,7 +1982,7 @@ Document::OpenResult Document::openDocument( const QString & docFile, const KUrl
|
|||
qstdin.open( stdin, QIODevice::ReadOnly );
|
||||
filedata = qstdin.readAll();
|
||||
mime = KMimeType::findByContent( filedata );
|
||||
if ( !mime || mime->name() == QLatin1String( "application/octet-stream" ) )
|
||||
if ( !mime || mime->isDefault() )
|
||||
return OpenError;
|
||||
document_size = filedata.size();
|
||||
triedMimeFromFileContent = true;
|
||||
|
|
Loading…
Add table
Reference in a new issue