Bug 349513

Summary: KstatusNotifierItem->actionCollection() - is currently useless.
Product: [Frameworks and Libraries] frameworks-knotifications Reporter: Vovochka <vovochka13>
Component: generalAssignee: Martin Klapetek <mklapetek>
Status: RESOLVED FIXED    
Severity: minor CC: kdelibs-bugs
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: All   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Vovochka 2015-06-23 01:52:21 UTC
In times of KDE4 method actionCollectino was returning a KActionCollection, so that there was a way to find an "quit" action.

Currently actionCollection method returns QList, so that there is no way to determine "quit" action.
Commonly it is needed to reconnect action trigger to a custom slot, cause by default KSNI "quit" action _always_ asks whether user wants to quit or not. many apps changes such behavior. With QList there is no way to find "quit" action in a list.

Possible solutions:
1) Add another actionCollection that will return internal QMap as is.
2) Add action(Qstring) method that will search for requested action in internal map.

Reproducible: Always
Comment 1 Martin Klapetek 2015-06-23 10:00:07 UTC
Thanks for the report

I think that the reason why it got removed was that the intended usage is meant to be this:

QAction *quitAction;
Q_FOREACH(QAction *action, ksni->actionCollection()) {
    if (action == KStandardAction::quit()) {
        quitAction = action;
    }
}

...wouldn't that work?
Comment 2 Martin Klapetek 2015-06-23 10:04:09 UTC
Actually ignore that, that wouldn't work.
Comment 3 Martin Klapetek 2015-06-23 10:07:49 UTC
What you can do however, in the meantime anyway, is to set

setStandardActionsEnabled(false);

which will not put a "quit" action in the menu and then add your own quit action by using

addAction(QString, QAction*);
Comment 4 Vovochka 2015-06-23 10:19:45 UTC
But this also will disable "minimizeRestore" action that has a little bit advanced logic.
I do not want to reimplement this logic too.

This makes standard actions from KSNI useless and unneeded. Don't you think so?
Comment 5 Martin Klapetek 2015-07-01 08:05:57 UTC
Git commit f8d29aa9108fa74c1a3666c1774779eb100325a9 by Martin Klapetek.
Committed on 01/07/2015 at 08:05.
Pushed by mklapetek into branch 'master'.

[ksni] Add method to retrieve action by its name

REVIEW: 124155

M  +5    -0    src/kstatusnotifieritem.cpp
M  +9    -0    src/kstatusnotifieritem.h

http://commits.kde.org/knotifications/f8d29aa9108fa74c1a3666c1774779eb100325a9