Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Graphics
Okular
Commits
01871fdf
Commit
01871fdf
authored
Aug 21, 2022
by
Albert Astals Cid
Browse files
Even more tweaks to opening "text" files
BUGS: 430538
BUGS: 456434
parent
656587ca
Pipeline
#225530
passed with stage
in 37 minutes and 41 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
part/part.cpp
View file @
01871fdf
...
...
@@ -1578,10 +1578,19 @@ bool Part::openFile()
mimes
<<
pathMime
<<
argMime
;
}
// text is super annoying because it always succeeds when opening so try to make sure
// that we don't set it as first mime unless we're really sure it is that.
// If it could be something else based on the content we try that first but only if that content itself
// is not text or if it's a supported text child like markdown
if
(
mimes
[
0
].
inherits
(
QStringLiteral
(
"text/plain"
)))
{
const
QMimeType
contentMime
=
db
.
mimeTypeForFile
(
fileNameToOpen
,
QMimeDatabase
::
MatchContent
);
if
(
contentMime
.
name
()
!=
QLatin1String
(
"text/plain"
))
{
if
(
!
contentMime
.
inherits
(
QStringLiteral
(
"text/plain"
))
)
{
mimes
.
prepend
(
contentMime
);
}
else
if
(
contentMime
.
name
()
!=
QLatin1String
(
"text/plain"
))
{
const
QStringList
supportedMimes
=
m_document
->
supportedMimeTypes
();
if
(
supportedMimes
.
contains
(
contentMime
.
name
()))
{
mimes
.
prepend
(
contentMime
);
}
}
}
}
else
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment