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
PIM
Kontact
Commits
656d95f4
Commit
656d95f4
authored
Apr 02, 2021
by
Nicolas Fella
Browse files
Port kcm_kontact to KPluginLoader
Instead of the deprecated KServiceTypeTrader
parent
8a81bf1e
Pipeline
#56438
passed with stage
in 13 minutes and 40 seconds
Changes
3
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
src/CMakeLists.txt
View file @
656d95f4
...
...
@@ -67,7 +67,6 @@ add_executable(kontact_bin ${kontact_bin_SRCS})
set_target_properties
(
kontact_bin PROPERTIES OUTPUT_NAME kontact
)
target_link_libraries
(
kontact_bin
KF5::Service
kontactprivate
KF5::KontactInterface
KF5::Crash
...
...
src/kcmkontact.cpp
View file @
656d95f4
...
...
@@ -14,7 +14,7 @@ using namespace Kontact;
#include <KAboutData>
#include <KLocalizedString>
#include <K
ServiceTypeTr
ader>
#include <K
PluginLo
ader>
#include <QComboBox>
#include <QCheckBox>
...
...
@@ -53,7 +53,6 @@ KcmKontact::KcmKontact(QWidget *parent)
pluginStartupLayout
->
addStretch
();
mPluginCombo
->
setEnabled
(
false
);
connect
(
forceStartupPluginCheckBox
,
&
QAbstractButton
::
toggled
,
mPluginCombo
,
&
QWidget
::
setEnabled
);
QCheckBox
*
showSideBarCheckbox
=
new
QCheckBox
(
Prefs
::
self
()
->
sideBarOpenItem
()
->
label
(),
this
);
...
...
@@ -69,30 +68,35 @@ void KcmKontact::load()
{
const
KConfigGroup
grp
(
Prefs
::
self
()
->
config
(),
"Plugins"
);
const
KService
::
List
offers
=
KServiceTypeTrader
::
self
()
->
query
(
QStringLiteral
(
"Kontact/Plugin"
),
QStringLiteral
(
"[X-KDE-KontactPluginVersion] == %1"
).
arg
(
KONTACT_PLUGIN_VERSION
));
const
QVector
<
KPluginMetaData
>
pluginMetaDatas
=
KPluginLoader
::
findPlugins
(
QStringLiteral
(
"kontact5"
),
[](
const
KPluginMetaData
&
data
)
{
return
data
.
rawData
().
value
(
QStringLiteral
(
"X-KDE-KontactPluginVersion"
)).
toInt
()
==
KONTACT_PLUGIN_VERSION
;
});
int
activeComponent
=
0
;
mPluginCombo
->
clear
();
mPluginList
.
clear
();
for
(
const
K
Service
::
Ptr
&
service
:
offer
s
)
{
for
(
const
K
PluginMetaData
&
plugin
:
pluginMetaData
s
)
{
// skip summary only plugins
QVariant
var
=
service
->
property
(
QStringLiteral
(
"X-KDE-KontactPluginHasPart"
));
if
(
var
.
isValid
()
&&
var
.
toBool
()
==
false
)
{
continue
;
if
(
plugin
.
rawData
().
contains
(
QLatin1String
(
"X-KDE-KontactPluginHasPart"
)))
{
bool
var
=
plugin
.
rawData
().
value
(
QStringLiteral
(
"X-KDE-KontactPluginHasPart"
)).
toBool
();
if
(
!
var
)
{
continue
;
}
}
mPluginCombo
->
addItem
(
service
->
name
());
mPluginList
.
append
(
service
);
mPluginCombo
->
addItem
(
plugin
.
name
());
mPluginList
.
append
(
plugin
);
// skip disabled plugins
const
QString
pluginName
=
service
->
property
(
QStringLiteral
(
"X-KDE-PluginInfo-Name"
)).
toString
();
const
QString
pluginName
=
plugin
.
pluginId
();
if
(
!
grp
.
readEntry
(
pluginName
+
QStringLiteral
(
"Enabled"
),
false
))
{
const
QStandardItemModel
*
qsm
=
qobject_cast
<
QStandardItemModel
*>
(
mPluginCombo
->
model
());
if
(
qsm
)
{
qsm
->
item
(
mPluginCombo
->
count
()
-
1
,
0
)
->
setEnabled
(
false
);
}
}
if
(
service
->
property
(
QStringLiteral
(
"X-KDE-PluginInfo-Name"
)).
toString
()
==
Prefs
::
self
()
->
activePlugin
())
{
if
(
pluginName
==
Prefs
::
self
()
->
activePlugin
())
{
activeComponent
=
mPluginList
.
count
()
-
1
;
}
}
...
...
@@ -103,9 +107,8 @@ void KcmKontact::load()
void
KcmKontact
::
save
()
{
const
KService
::
Ptr
ptr
=
mPluginList
.
at
(
mPluginCombo
->
currentIndex
());
const
QString
activePluginName
=
ptr
->
property
(
QStringLiteral
(
"X-KDE-PluginInfo-Name"
)).
toString
();
Prefs
::
self
()
->
setActivePlugin
(
activePluginName
);
const
KPluginMetaData
plugin
=
mPluginList
.
at
(
mPluginCombo
->
currentIndex
());
Prefs
::
self
()
->
setActivePlugin
(
plugin
.
pluginId
());
KCModule
::
save
();
}
...
...
src/kcmkontact.h
View file @
656d95f4
...
...
@@ -9,7 +9,8 @@
#pragma once
#include <KCModule>
#include <KService>
#include <KPluginMetaData>
class
QComboBox
;
class
QCheckBox
;
namespace
Kontact
...
...
@@ -27,7 +28,7 @@ public:
const
KAboutData
*
aboutData
()
const
override
;
private:
KService
::
List
mPluginList
;
QVector
<
KPluginMetaData
>
mPluginList
;
QComboBox
*
mPluginCombo
=
nullptr
;
QCheckBox
*
mShowSideBarCheckbox
=
nullptr
;
};
...
...
Write
Preview
Markdown
is supported
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