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
Plasma
System Settings
Commits
e2951e44
Verified
Commit
e2951e44
authored
Feb 11, 2022
by
Fushan Wen
Browse files
fixup! app/SettingsBase: Only load current view on startup
parent
8afb5331
Pipeline
#136345
passed with stage
in 1 minute and 29 seconds
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
app/SettingsBase.cpp
View file @
e2951e44
...
...
@@ -246,33 +246,33 @@ void SettingsBase::initMenuList(MenuItem *parent)
parent
->
sortChildrenByWeight
();
}
bool
SettingsBase
::
loadCurrentView
()
BaseMode
*
SettingsBase
::
loadCurrentView
()
{
const
QString
viewToUse
=
m_mode
==
BaseMode
::
InfoCenter
?
QStringLiteral
(
"systemsettings_sidebar_mode"
)
:
BaseConfig
::
activeView
();
const
KPluginMetaData
*
const
plugin
=
std
::
find_if
(
m_plugins
.
cbegin
(),
m_plugins
.
cend
(),
[
&
viewToUse
](
const
KPluginMetaData
&
plugin
)
{
const
auto
plugin
It
=
std
::
find_if
(
m_plugins
.
cbegin
(),
m_plugins
.
cend
(),
[
&
viewToUse
](
const
KPluginMetaData
&
plugin
)
{
return
viewToUse
.
contains
(
plugin
.
pluginId
());
});
if
(
plugin
==
m_plugins
.
cend
())
{
return
false
;
if
(
plugin
It
==
m_plugins
.
cend
())
{
return
nullptr
;
}
const
auto
controllerResult
=
KPluginFactory
::
instantiatePlugin
<
BaseMode
>
(
*
plugin
,
this
,
{
m_mode
,
m_startupModule
,
m_startupModuleArgs
});
const
auto
controllerResult
=
KPluginFactory
::
instantiatePlugin
<
BaseMode
>
(
*
plugin
It
,
this
,
{
m_mode
,
m_startupModule
,
m_startupModuleArgs
});
if
(
!
controllerResult
)
{
qCWarning
(
SYSTEMSETTINGS_APP_LOG
)
<<
"Error loading plugin"
<<
controllerResult
.
errorText
;
return
false
;
return
nullptr
;
}
const
auto
controller
=
controllerResult
.
plugin
;
m_loadedViews
.
insert
(
viewToUse
,
controller
);
controller
->
init
(
*
plugin
);
controller
->
init
(
*
plugin
It
);
connect
(
controller
,
&
BaseMode
::
changeToolBarItems
,
this
,
&
SettingsBase
::
changeToolBar
);
connect
(
controller
,
&
BaseMode
::
actionsChanged
,
this
,
&
SettingsBase
::
updateViewActions
);
connect
(
searchText
,
&
KLineEdit
::
textChanged
,
controller
,
&
BaseMode
::
searchChanged
);
connect
(
controller
,
&
BaseMode
::
viewChanged
,
this
,
&
SettingsBase
::
viewChange
);
return
true
;
return
controller
;
}
bool
SettingsBase
::
queryClose
()
...
...
@@ -329,7 +329,7 @@ void SettingsBase::about()
void
SettingsBase
::
changePlugin
()
{
if
(
m_
loadedView
s
.
empty
())
{
// We should ensure we have a plugin available to choose
if
(
m_
plugin
s
.
empty
())
{
// We should ensure we have a plugin available to choose
KMessageBox
::
error
(
this
,
i18n
(
"System Settings was unable to find any views, and hence has nothing to display."
),
i18n
(
"No views found"
));
close
();
return
;
// Halt now!
...
...
@@ -344,13 +344,18 @@ void SettingsBase::changePlugin()
}
const
QString
viewToUse
=
m_mode
==
BaseMode
::
InfoCenter
?
QStringLiteral
(
"systemsettings_sidebar_mode"
)
:
BaseConfig
::
activeView
();
if
(
m_loadedViews
.
keys
().
contains
(
viewToUse
))
{
const
auto
it
=
m_loadedViews
.
constFind
(
viewToUse
);
if
(
it
!=
m_loadedViews
.
cend
())
{
// First the configuration entry
activeView
=
m_loadedViews
.
value
(
viewToUse
)
;
}
else
if
(
loadCurrentView
())
{
activeView
=
m_loadedViews
.
value
(
viewToUse
)
;
}
else
{
// Otherwise we activate the failsafe
activeView
=
*
it
;
}
else
if
(
auto
*
view
=
loadCurrentView
())
{
activeView
=
view
;
}
else
if
(
!
m_loadedViews
.
empty
())
{
// Otherwise we activate the failsafe
activeView
=
m_loadedViews
.
cbegin
().
value
();
}
else
{
qCWarning
(
SYSTEMSETTINGS_APP_LOG
)
<<
"System Settings was unable to load any views, and hence has nothing to display."
;
close
();
return
;
// Halt now!
}
if
(
stackedWidget
->
indexOf
(
activeView
->
mainWidget
())
==
-
1
)
{
...
...
app/SettingsBase.h
View file @
e2951e44
...
...
@@ -50,10 +50,10 @@ private Q_SLOTS:
private:
/**
* @return
@c true
if the current view is found in the plugin list and sucessfully loaded,
* @c
false
otherwise
* @return
the plugin controller
if the current view is found in the plugin list and suc
c
essfully loaded,
* @c
nullptr
otherwise
*/
bool
loadCurrentView
();
BaseMode
*
loadCurrentView
();
// The plugins
QVector
<
KPluginMetaData
>
m_plugins
;
...
...
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