Bug 349513 - KstatusNotifierItem->actionCollection() - is currently useless.
Summary: KstatusNotifierItem->actionCollection() - is currently useless.
Status: RESOLVED FIXED
Alias: None
Product: frameworks-knotifications
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other All
: NOR minor
Target Milestone: ---
Assignee: Martin Klapetek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-23 01:52 UTC by Vovochka
Modified: 2015-07-01 08:05 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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