Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Network
Konqueror
Commits
121d2ef5
Commit
121d2ef5
authored
Oct 17, 2021
by
Stefano Crocco
Committed by
David Faure
Oct 17, 2021
Browse files
Use browserExtension instead of relying on mimeTypes
parent
4f96b58e
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/konqrun.cpp
View file @
121d2ef5
...
...
@@ -25,6 +25,7 @@
#include
<KProtocolManager>
#include
<KApplicationTrader>
#include
<KJobWidgets>
#include
<KParts/PartLoader>
#include
<KService>
#include
<KMimeTypeTrader>
...
...
@@ -311,12 +312,16 @@ void KonqRun::init()
bool
KonqRun
::
usingWebEngine
()
const
{
if
(
m_pView
)
{
return
m_pView
->
part
()
->
componentName
()
==
"webenginepart"
;
//We need to find out if the user configured Konqueror to use WebEnginePart by default or not.
//If the current part can display html files, it could be a WebEnginePart, so we can check it.
//If the current part can't display html files, it will never be a webengine part, so it doesn't
//tell anything about user configuration. In this case, always check the preferred part.
KParts
::
ReadOnlyPart
*
part
=
m_pView
?
m_pView
->
part
()
:
nullptr
;
if
(
m_pView
->
isWebBrowsingPart
())
{
return
part
->
componentName
()
==
"webenginepart"
;
}
else
{
KService
::
Ptr
service
=
KMimeTypeTrader
::
self
()
->
preferredService
(
"text/html"
,
"KParts/ReadOnlyPart"
);
Q_ASSERT
(
service
);
return
service
->
desktopEntryName
()
==
"webenginepart"
;
QVector
<
KPluginMetaData
>
parts
=
KParts
::
PartLoader
::
partsForMimeType
(
"text/html"
);
return
!
parts
.
isEmpty
()
&&
parts
.
at
(
0
).
name
()
==
"WebEngine"
;
}
}
...
...
src/konqview.cpp
View file @
121d2ef5
...
...
@@ -1216,6 +1216,16 @@ bool KonqView::supportsMimeType(const QString &mimeType) const
return
false
;
}
bool
KonqView
::
isWebBrowsingPart
()
const
{
if
(
!
m_pPart
)
{
return
false
;
}
const
QString
partName
=
m_pPart
->
componentName
();
return
partName
==
QLatin1String
(
"webenginepart"
)
||
partName
==
QLatin1String
(
"khtml"
)
||
partName
==
QLatin1String
(
"kwebkitpart"
);
}
void
HistoryEntry
::
saveConfig
(
KConfigGroup
&
config
,
const
QString
&
prefix
,
const
KonqFrameBase
::
Options
&
options
)
{
if
(
options
&
KonqFrameBase
::
SaveUrls
)
{
...
...
src/konqview.h
View file @
121d2ef5
...
...
@@ -339,6 +339,18 @@ public:
*/
bool
supportsMimeType
(
const
QString
&
mimeType
)
const
;
/**
* Whether the view in this part is suitable for web browsing.
*
* @return @b true if the part is suitable for browsing and @b false otherwise
*
* @warning Unfortunately, as far as I know, there's no way to detect whether a part is
* suitable for browsing. This function works by hardcoding the component names of such
* parts (currently only khtml, kwebkitpart and webenginepart). If other browsing parts
* will be added, the list should be changed or another way must be found.
**/
bool
isWebBrowsingPart
()
const
;
// True if showing a directory
bool
showsDirectory
()
const
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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