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
Network
Konqueror
Commits
9b9b284b
Commit
9b9b284b
authored
Aug 02, 2022
by
Stefano Crocco
Browse files
Make various small changes
parent
ef88faed
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/konqfactory.cpp
View file @
9b9b284b
...
...
@@ -183,7 +183,7 @@ void KonqFactory::getOffers(const QString &serviceType, QVector<KPluginMetaData>
}
if
(
partServiceOffers
)
{
QVector
<
KPluginMetaData
>
offers
=
KParts
::
PartLoader
::
partsForMimeType
(
serviceType
);
const
QVector
<
KPluginMetaData
>
offers
=
KParts
::
PartLoader
::
partsForMimeType
(
serviceType
);
//If a part has both JSON metadata and a .desktop file, partsForMimeType return the plugin twice. To avoid this, we remove the duplicate entries
//We can't use std::unique because it requires the vector to be sorted but we can't do that because the entries are sorted according to user
...
...
@@ -191,7 +191,10 @@ void KonqFactory::getOffers(const QString &serviceType, QVector<KPluginMetaData>
//TODO: remove when .desktop files for parts aren't supported anymore (KF6)
QVector
<
KPluginMetaData
>
uniqueOffers
;
for
(
const
KPluginMetaData
&
md
:
offers
)
{
if
(
!
std
::
any_of
(
uniqueOffers
.
constBegin
(),
uniqueOffers
.
constEnd
(),
[
md
](
const
KPluginMetaData
&
md2
){
return
md
.
pluginId
()
==
md2
.
pluginId
();}))
{
auto
comparison
=
[
md
](
const
KPluginMetaData
&
md2
){
return
md
.
pluginId
()
==
md2
.
pluginId
();
};
if
(
!
std
::
any_of
(
uniqueOffers
.
constBegin
(),
uniqueOffers
.
constEnd
(),
comparison
))
{
uniqueOffers
.
append
(
md
);
}
}
...
...
src/konqguiclients.cpp
View file @
9b9b284b
...
...
@@ -48,14 +48,14 @@ PopupMenuGUIClient::PopupMenuGUIClient(const QVector<KPluginMetaData> &embedding
QList
<
QAction
*>
previewActions
;
if
(
embeddingServices
.
count
()
==
1
)
{
KPluginMetaData
service
=
embeddingServices
.
first
();
QAction
*
act
=
addEmbedding
Service
(
0
,
i18n
(
"Preview &in %1"
,
service
.
name
()),
service
);
QAction
*
act
=
addEmbedding
Plugin
(
0
,
i18n
(
"Preview &in %1"
,
service
.
name
()),
service
);
previewActions
.
append
(
act
);
}
else
if
(
embeddingServices
.
count
()
>
1
)
{
QVector
<
KPluginMetaData
>::
ConstIterator
it
=
embeddingServices
.
begin
();
const
QVector
<
KPluginMetaData
>::
ConstIterator
end
=
embeddingServices
.
end
();
int
idx
=
0
;
for
(;
it
!=
end
;
++
it
,
++
idx
)
{
QAction
*
act
=
addEmbedding
Service
(
idx
,
(
*
it
).
name
(),
*
it
);
QAction
*
act
=
addEmbedding
Plugin
(
idx
,
(
*
it
).
name
(),
*
it
);
previewActions
.
append
(
act
);
}
}
...
...
@@ -68,11 +68,11 @@ PopupMenuGUIClient::~PopupMenuGUIClient()
{
}
QAction
*
PopupMenuGUIClient
::
addEmbedding
Service
(
int
idx
,
const
QString
&
name
,
const
KPluginMetaData
&
service
)
QAction
*
PopupMenuGUIClient
::
addEmbedding
Plugin
(
int
idx
,
const
QString
&
name
,
const
KPluginMetaData
&
plugin
)
{
QAction
*
act
=
m_actionCollection
.
addAction
(
QByteArray
::
number
(
idx
));
act
->
setText
(
name
);
act
->
setIcon
(
QIcon
::
fromTheme
(
service
.
iconName
()));
act
->
setIcon
(
QIcon
::
fromTheme
(
plugin
.
iconName
()));
QObject
::
connect
(
act
,
&
QAction
::
triggered
,
this
,
&
PopupMenuGUIClient
::
slotOpenEmbedded
);
return
act
;
}
...
...
src/konqguiclients.h
View file @
9b9b284b
...
...
@@ -47,7 +47,7 @@ private slots:
void
slotOpenEmbedded
();
private:
QAction
*
addEmbedding
Service
(
int
idx
,
const
QString
&
name
,
const
KPluginMetaData
&
service
);
QAction
*
addEmbedding
Plugin
(
int
idx
,
const
QString
&
name
,
const
KPluginMetaData
&
plugin
);
KActionCollection
m_actionCollection
;
QVector
<
KPluginMetaData
>
m_embeddingServices
;
...
...
src/konqmainwindow.cpp
View file @
9b9b284b
...
...
@@ -40,6 +40,7 @@
#include
"konqurl.h"
#include
"konqbrowserinterface.h"
#include
"urlloader.h"
#include
"pluginmetadatautils.h"
#include
<konq_events.h>
#include
<konqpixmapprovider.h>
...
...
@@ -4704,7 +4705,7 @@ void KonqMainWindow::updateViewModeActions()
//If a view provide several actions, its metadata contains an X-Konqueror-Actions-File entry
//with the path of a .desktop file where the actions are described. The contents of this file
//are the same as the action-related part of the old part .desktop file
QString
actionDesktopFile
=
md
.
value
(
"X-Konqueror-Actions-File"
,
QString
()
);
QString
actionDesktopFile
=
md
.
value
(
"X-Konqueror-Actions-File"
);
if
(
!
actionDesktopFile
.
isEmpty
())
{
KDesktopFile
df
(
QStandardPaths
::
DataLocation
,
actionDesktopFile
);
...
...
@@ -4714,7 +4715,7 @@ void KonqMainWindow::updateViewModeActions()
KConfigGroup
grp
=
df
.
actionGroup
(
name
);
QString
text
=
grp
.
readEntry
(
"Name"
,
QString
());
QString
exec
=
grp
.
readEntry
(
"Exec"
,
QString
());
if
(
name
.
isEmpty
())
{
if
(
text
.
isEmpty
())
{
qCDebug
(
KONQUEROR_LOG
)
<<
"File"
<<
df
.
fileName
()
<<
"doesn't contain a
\"
name
\"
entry"
;
continue
;
}
...
...
@@ -5426,10 +5427,9 @@ void KonqMainWindow::updateProxyForWebEngine(bool updateProtocolManager)
KProtocolManager
::
reparseConfiguration
();
}
QVector
<
KPluginMetaData
>
parts
=
KParts
::
PartLoader
::
partsForMimeType
(
QStringLiteral
(
"text/html"
));
KPluginMetaData
part
=
!
parts
.
isEmpty
()
?
parts
.
first
()
:
KPluginMetaData
();
Q_ASSERT
(
part
.
isValid
());
const
bool
webengineIsDefault
=
part
.
pluginId
()
==
QStringLiteral
(
"webenginepart"
);
KPluginMetaData
part
=
preferredPart
(
QStringLiteral
(
"text/html"
));
Q_ASSERT
(
!
part
.
isValid
());
const
bool
webengineIsDefault
=
part
.
pluginId
()
==
QLatin1String
(
"webenginepart"
);
if
(
!
webengineIsDefault
)
{
return
;
}
...
...
src/pluginmetadatautils.cpp
View file @
9b9b284b
...
...
@@ -8,6 +8,8 @@
#include
"pluginmetadatautils.h"
#include
<KParts/PartLoader>
#include
<QStringLiteral>
KPluginMetaData
findPartById
(
const
QString
&
id
)
...
...
@@ -15,6 +17,15 @@ KPluginMetaData findPartById(const QString& id)
return
KPluginMetaData
::
findPluginById
(
QStringLiteral
(
"kf5/parts"
),
id
);
}
KPluginMetaData
preferredPart
(
const
QString
&
mimeType
)
{
QVector
<
KPluginMetaData
>
plugins
=
KParts
::
PartLoader
::
partsForMimeType
(
mimeType
);
if
(
!
plugins
.
isEmpty
())
{
return
plugins
.
first
();
}
else
{
return
KPluginMetaData
();
}
}
QDebug
operator
<<
(
QDebug
debug
,
const
KPluginMetaData
&
md
)
{
QDebugStateSaver
saver
(
debug
);
...
...
src/pluginmetadatautils.h
View file @
9b9b284b
...
...
@@ -15,6 +15,14 @@
KPluginMetaData
findPartById
(
const
QString
&
id
);
/**
* @brief Finds the meta data for the preferred part to display the given mime type
* @param mimeType the mime type
* @return the plugin meta data for the preferred part to display @p mimeType or an
* invalid @c KPluginMetaData if no part is available for the mime type
*/
KPluginMetaData
preferredPart
(
const
QString
&
mimeType
);
QDebug
operator
<<
(
QDebug
debug
,
const
KPluginMetaData
&
md
);
QDebug
operator
<<
(
QDebug
debug
,
const
QVector
<
KPluginMetaData
>
&
vec
);
...
...
src/urlloader.cpp
View file @
9b9b284b
...
...
@@ -33,15 +33,6 @@
#include
<QWebEngineProfile>
#include
<QFileDialog>
static
KPluginMetaData
preferredPart
(
const
QString
&
mimeType
)
{
QVector
<
KPluginMetaData
>
plugins
=
KParts
::
PartLoader
::
partsForMimeType
(
mimeType
);
if
(
!
plugins
.
isEmpty
())
{
return
plugins
.
first
();
}
else
{
return
KPluginMetaData
();
}
}
bool
UrlLoader
::
embedWithoutAskingToSave
(
const
QString
&
mimeType
)
{
static
QStringList
s_mimeTypes
;
...
...
@@ -202,7 +193,7 @@ bool UrlLoader::decideEmbedOrSave()
*/
if
(
m_dontPassToWebEnginePart
&&
m_part
.
pluginId
()
==
webEngineName
)
{
QVector
<
KPluginMetaData
>
parts
=
KParts
::
PartLoader
::
partsForMimeType
(
m_mimeType
);
auto
findPart
=
[
webEngineName
](
const
KPluginMetaData
&
md
){
return
md
.
pluginId
()
!=
webEngineName
;};
auto
findPart
=
[
&
webEngineName
](
const
KPluginMetaData
&
md
){
return
md
.
pluginId
()
!=
webEngineName
;};
QVector
<
KPluginMetaData
>::
const_iterator
partToUse
=
std
::
find_if
(
parts
.
constBegin
(),
parts
.
constEnd
(),
findPart
);
if
(
partToUse
!=
parts
.
constEnd
())
{
m_part
=
*
partToUse
;
...
...
src/urlloader.h
View file @
9b9b284b
...
...
@@ -65,6 +65,7 @@ public:
UrlLoader
(
KonqMainWindow
*
mainWindow
,
KonqView
*
view
,
const
QUrl
&
url
,
const
QString
&
mimeType
,
const
KonqOpenURLRequest
&
req
,
bool
trustedSource
,
bool
forceOpen
=
false
);
~
UrlLoader
();
/** @brief Enum describing the possible actions to be taken*/
enum
class
OpenUrlAction
{
UnknwonAction
,
/**< The action hasn't been decided yet */
...
...
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