kpowercontrol: reset the overlay icon when setting the profile does not fail

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-04-21 02:20:02 +03:00
parent f847278b75
commit a9b2e3cd92

View file

@ -60,7 +60,7 @@ KPowerControl::KPowerControl(QObject* parent)
m_menu->addSeparator();
} else {
setOverlayIconByName("dialog-error");
showMessage(i18n("Power management"), i18n("Power manager is not activer"), "dialog-error");
showMessage(i18n("Power management"), i18n("Power manager is not active"), "dialog-error");
}
m_helpmenu = new KHelpMenu(associatedWidget(), KGlobal::mainComponent().aboutData());
@ -75,6 +75,7 @@ void KPowerControl::slotChangeProfile()
{
KAction* profileaction = qobject_cast<KAction*>(sender());
if (m_powermanager.setProfile(profileaction->iconText())) {
setOverlayIconByName(QString());
// do not wait for the signal to be emited
slotProfileChanged(profileaction->iconText());
} else {
@ -85,11 +86,11 @@ void KPowerControl::slotChangeProfile()
void KPowerControl::slotProfileChanged(const QString &profile)
{
const QString profile_objectname = QString::fromLatin1("profile_%1").arg(profile);
const QString profileobjectname = QString::fromLatin1("profile_%1").arg(profile);
foreach (QAction* qaction, actionCollection()->actions()) {
const QString qactionobjectname = qaction->objectName();
if (qactionobjectname.startsWith(QLatin1String("profile_"))) {
qaction->setChecked(qactionobjectname == profile_objectname);
qaction->setChecked(qactionobjectname == profileobjectname);
}
}
}