Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Gregor Mi

---
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/122249/
---

(Updated March 13, 2015, 7:27 p.m.)


Review request for KDE Base Apps, Martin Gräßlin and John Tapsell.


Changes
---

Simplify the KeyboardShortcutUtil::findGlobalShortcutByComponentAndActionName 
method by using KGlobalAccel API.
Unfortunately, at least on my machine, this simplified code disables the 
shortcut. Pressing the displayed shortcut has no effect until Plasma session 
relogin.


Repository: libksysguard


Description
---

Current situation:
The End Process... button has a tooltip which says To target a specific 
window to kill, press Ctrl+Alt+Esc at any time. The keyboard shortcut is 
hardcoded.

RR:
Add a drop down menu to the End Process... button with one action:
i18n(Kill a specific window... (Global shortcut: %1), killWindowShortcut)


Diffs (updated)
-

  tests/keyboardshortcututiltest.cpp PRE-CREATION 
  tests/CMakeLists.txt 967b03fae1e460bfb22e1a07ef05cf7b49412546 
  processui/keyboardshortcututil.cpp PRE-CREATION 
  processui/CMakeLists.txt 7f87b85e0201e63d69070a71203bbb34851a79c6 
  tests/keyboardshortcututiltest.h PRE-CREATION 
  processui/ksysguardprocesslist.cpp 450ca600b8aed7ca611ec638610b6c524c96080c 
  processui/keyboardshortcututil.h PRE-CREATION 
  processui/ProcessWidgetUI.ui e50f55cf1813b00d49b1716023df487ffbd536e3 
  CMakeLists.txt 5352e70f6f37daae76c1b3e2c1c9f149d235e3cd 

Diff: https://git.reviewboard.kde.org/r/122249/diff/


Testing
---


File Attachments


New End Process button with drop down arrow
  
https://git.reviewboard.kde.org/media/uploaded/files/2015/01/28/16301e88-e21b-4358-9a63-a85dae5722bd__screenshot_default1.png
Drop down shows Kill Window
  
https://git.reviewboard.kde.org/media/uploaded/files/2015/01/28/58df12c5-7350-4bb0-b602-c5716caa9836__screenshot_default2.png


Thanks,

Gregor Mi



Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Gregor Mi

---
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/122249/
---

(Updated March 13, 2015, 7:29 p.m.)


Review request for KDE Base Apps, Martin Gräßlin and John Tapsell.


Repository: libksysguard


Description (updated)
---

Current situation:
The End Process... button has a tooltip which says To target a specific 
window to kill, press Ctrl+Alt+Esc at any time. The keyboard shortcut is 
hardcoded.

New:
Replace the End Process... button with a drop-down button and a action named 
Kill a specific window...


Diffs
-

  tests/keyboardshortcututiltest.cpp PRE-CREATION 
  tests/CMakeLists.txt 967b03fae1e460bfb22e1a07ef05cf7b49412546 
  processui/keyboardshortcututil.cpp PRE-CREATION 
  processui/CMakeLists.txt 7f87b85e0201e63d69070a71203bbb34851a79c6 
  tests/keyboardshortcututiltest.h PRE-CREATION 
  processui/ksysguardprocesslist.cpp 450ca600b8aed7ca611ec638610b6c524c96080c 
  processui/keyboardshortcututil.h PRE-CREATION 
  processui/ProcessWidgetUI.ui e50f55cf1813b00d49b1716023df487ffbd536e3 
  CMakeLists.txt 5352e70f6f37daae76c1b3e2c1c9f149d235e3cd 

Diff: https://git.reviewboard.kde.org/r/122249/diff/


Testing
---


File Attachments


New End Process button with drop down arrow
  
https://git.reviewboard.kde.org/media/uploaded/files/2015/01/28/16301e88-e21b-4358-9a63-a85dae5722bd__screenshot_default1.png
Drop down shows Kill Window
  
https://git.reviewboard.kde.org/media/uploaded/files/2015/01/28/58df12c5-7350-4bb0-b602-c5716caa9836__screenshot_default2.png


Thanks,

Gregor Mi



Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Gregor Mi


 On March 2, 2015, 7:47 a.m., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp
 
 Gregor Mi wrote:
 I tried this:
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGroup(default); // needed?
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.addAction(Kill Window);
 killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  ac.actions().count();
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
 /*
 CONSOLE OUTPUT:
 1
 0
 */
 
 Martin Gräßlin wrote:
 I think you need to register killWindowAction with KGlobalAccel in some 
 way so that it loads the configured shortcut.
 
 Gregor Mi wrote:
 I found out how to prepare the QAction without KActionCollection.
 
 auto killWindowAction  = new QAction(nullptr);
 killWindowAction-setProperty(componentName, kwin); // see impl of 
 KActionCollection
 killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 // killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 // qDebug()  ac.actions().count(); // -- 1
 qDebug()  KGlobalAccel::self()-isComponentActive(kwin); // -- true
 qDebug()  KGlobalAccel::self()-allActionsForComponent({ kwin 
 }).count(); // (deprecated) -- 152
 qDebug()  KGlobalAccel::self()-hasShortcut(killWindowAction); // -- 
 false
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count(); // 
 -- 0
 qDebug()  
 KGlobalAccel::self()-defaultShortcut(killWindowAction).count(); // -- 0
 delete killWindowAction;
 
 Open issues:
 1. Is it necessary to specify the shortcut context (default) somewhere?
 2. How to tell KGlobalAccel to load the shortcuts for the given action.
 
 Gregor Mi wrote:
 Issue 1.: *not* necessary, see 
 kde/workspace/plasma-workspace/kglobalaccel/component.h, line 98
 
 Martin Gräßlin wrote:
 concerning 2: see 
 http://api.kde.org/frameworks-api/frameworks5-apidocs/kglobalaccel/html/classKGlobalAccel.html#a66ce504227e7e563f24de4c6b26b0395
 
 shortcut context is (I think) not needed.
 
 Gregor Mi wrote:
 I read the API documentation about setShortcut and frankly I do not fully 
 understand it. It seems counter-intuitive to me to call that method in order 
 to *load* the shortcut.
 
 Martin Gräßlin wrote:
 yes the API is weird. But it's really like it: if one doesn't pass 
 NoAutloading the shortcut gets loaded.
 
 Gregor Mi wrote:
 yes, you are right, it is really working like this:
 
 KActionCollection ac(nullptr, kwin);
 auto killWindowAction  = ac.addAction(Kill Window);
 //killWindowAction-setProperty(componentName, kwin); // see impl 
 of KActionCollection
 //killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 

Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Thomas Lübking


 On März 2, 2015, 7:47 vorm., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp
 
 Gregor Mi wrote:
 I tried this:
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGroup(default); // needed?
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.addAction(Kill Window);
 killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  ac.actions().count();
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
 /*
 CONSOLE OUTPUT:
 1
 0
 */
 
 Martin Gräßlin wrote:
 I think you need to register killWindowAction with KGlobalAccel in some 
 way so that it loads the configured shortcut.
 
 Gregor Mi wrote:
 I found out how to prepare the QAction without KActionCollection.
 
 auto killWindowAction  = new QAction(nullptr);
 killWindowAction-setProperty(componentName, kwin); // see impl of 
 KActionCollection
 killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 // killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 // qDebug()  ac.actions().count(); // -- 1
 qDebug()  KGlobalAccel::self()-isComponentActive(kwin); // -- true
 qDebug()  KGlobalAccel::self()-allActionsForComponent({ kwin 
 }).count(); // (deprecated) -- 152
 qDebug()  KGlobalAccel::self()-hasShortcut(killWindowAction); // -- 
 false
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count(); // 
 -- 0
 qDebug()  
 KGlobalAccel::self()-defaultShortcut(killWindowAction).count(); // -- 0
 delete killWindowAction;
 
 Open issues:
 1. Is it necessary to specify the shortcut context (default) somewhere?
 2. How to tell KGlobalAccel to load the shortcuts for the given action.
 
 Gregor Mi wrote:
 Issue 1.: *not* necessary, see 
 kde/workspace/plasma-workspace/kglobalaccel/component.h, line 98
 
 Martin Gräßlin wrote:
 concerning 2: see 
 http://api.kde.org/frameworks-api/frameworks5-apidocs/kglobalaccel/html/classKGlobalAccel.html#a66ce504227e7e563f24de4c6b26b0395
 
 shortcut context is (I think) not needed.
 
 Gregor Mi wrote:
 I read the API documentation about setShortcut and frankly I do not fully 
 understand it. It seems counter-intuitive to me to call that method in order 
 to *load* the shortcut.
 
 Martin Gräßlin wrote:
 yes the API is weird. But it's really like it: if one doesn't pass 
 NoAutloading the shortcut gets loaded.
 
 Gregor Mi wrote:
 yes, you are right, it is really working like this:
 
 KActionCollection ac(nullptr, kwin);
 auto killWindowAction  = ac.addAction(Kill Window);
 //killWindowAction-setProperty(componentName, kwin); // see impl 
 of KActionCollection
 //killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 

Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Gregor Mi


 On March 2, 2015, 7:47 a.m., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp
 
 Gregor Mi wrote:
 I tried this:
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGroup(default); // needed?
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.addAction(Kill Window);
 killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  ac.actions().count();
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
 /*
 CONSOLE OUTPUT:
 1
 0
 */
 
 Martin Gräßlin wrote:
 I think you need to register killWindowAction with KGlobalAccel in some 
 way so that it loads the configured shortcut.
 
 Gregor Mi wrote:
 I found out how to prepare the QAction without KActionCollection.
 
 auto killWindowAction  = new QAction(nullptr);
 killWindowAction-setProperty(componentName, kwin); // see impl of 
 KActionCollection
 killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 // killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 // qDebug()  ac.actions().count(); // -- 1
 qDebug()  KGlobalAccel::self()-isComponentActive(kwin); // -- true
 qDebug()  KGlobalAccel::self()-allActionsForComponent({ kwin 
 }).count(); // (deprecated) -- 152
 qDebug()  KGlobalAccel::self()-hasShortcut(killWindowAction); // -- 
 false
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count(); // 
 -- 0
 qDebug()  
 KGlobalAccel::self()-defaultShortcut(killWindowAction).count(); // -- 0
 delete killWindowAction;
 
 Open issues:
 1. Is it necessary to specify the shortcut context (default) somewhere?
 2. How to tell KGlobalAccel to load the shortcuts for the given action.
 
 Gregor Mi wrote:
 Issue 1.: *not* necessary, see 
 kde/workspace/plasma-workspace/kglobalaccel/component.h, line 98
 
 Martin Gräßlin wrote:
 concerning 2: see 
 http://api.kde.org/frameworks-api/frameworks5-apidocs/kglobalaccel/html/classKGlobalAccel.html#a66ce504227e7e563f24de4c6b26b0395
 
 shortcut context is (I think) not needed.
 
 Gregor Mi wrote:
 I read the API documentation about setShortcut and frankly I do not fully 
 understand it. It seems counter-intuitive to me to call that method in order 
 to *load* the shortcut.
 
 Martin Gräßlin wrote:
 yes the API is weird. But it's really like it: if one doesn't pass 
 NoAutloading the shortcut gets loaded.
 
 Gregor Mi wrote:
 yes, you are right, it is really working like this:
 
 KActionCollection ac(nullptr, kwin);
 auto killWindowAction  = ac.addAction(Kill Window);
 //killWindowAction-setProperty(componentName, kwin); // see impl 
 of KActionCollection
 //killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 

Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Gregor Mi


 On March 2, 2015, 7:47 a.m., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp
 
 Gregor Mi wrote:
 I tried this:
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGroup(default); // needed?
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.addAction(Kill Window);
 killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  ac.actions().count();
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
 /*
 CONSOLE OUTPUT:
 1
 0
 */
 
 Martin Gräßlin wrote:
 I think you need to register killWindowAction with KGlobalAccel in some 
 way so that it loads the configured shortcut.
 
 Gregor Mi wrote:
 I found out how to prepare the QAction without KActionCollection.
 
 auto killWindowAction  = new QAction(nullptr);
 killWindowAction-setProperty(componentName, kwin); // see impl of 
 KActionCollection
 killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 // killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 // qDebug()  ac.actions().count(); // -- 1
 qDebug()  KGlobalAccel::self()-isComponentActive(kwin); // -- true
 qDebug()  KGlobalAccel::self()-allActionsForComponent({ kwin 
 }).count(); // (deprecated) -- 152
 qDebug()  KGlobalAccel::self()-hasShortcut(killWindowAction); // -- 
 false
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count(); // 
 -- 0
 qDebug()  
 KGlobalAccel::self()-defaultShortcut(killWindowAction).count(); // -- 0
 delete killWindowAction;
 
 Open issues:
 1. Is it necessary to specify the shortcut context (default) somewhere?
 2. How to tell KGlobalAccel to load the shortcuts for the given action.
 
 Gregor Mi wrote:
 Issue 1.: *not* necessary, see 
 kde/workspace/plasma-workspace/kglobalaccel/component.h, line 98
 
 Martin Gräßlin wrote:
 concerning 2: see 
 http://api.kde.org/frameworks-api/frameworks5-apidocs/kglobalaccel/html/classKGlobalAccel.html#a66ce504227e7e563f24de4c6b26b0395
 
 shortcut context is (I think) not needed.
 
 Gregor Mi wrote:
 I read the API documentation about setShortcut and frankly I do not fully 
 understand it. It seems counter-intuitive to me to call that method in order 
 to *load* the shortcut.
 
 Martin Gräßlin wrote:
 yes the API is weird. But it's really like it: if one doesn't pass 
 NoAutloading the shortcut gets loaded.
 
 Gregor Mi wrote:
 yes, you are right, it is really working like this:
 
 KActionCollection ac(nullptr, kwin);
 auto killWindowAction  = ac.addAction(Kill Window);
 //killWindowAction-setProperty(componentName, kwin); // see impl 
 of KActionCollection
 //killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 

Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Gregor Mi


 On March 2, 2015, 7:47 a.m., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp
 
 Gregor Mi wrote:
 I tried this:
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGroup(default); // needed?
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.addAction(Kill Window);
 killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  ac.actions().count();
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
 /*
 CONSOLE OUTPUT:
 1
 0
 */
 
 Martin Gräßlin wrote:
 I think you need to register killWindowAction with KGlobalAccel in some 
 way so that it loads the configured shortcut.
 
 Gregor Mi wrote:
 I found out how to prepare the QAction without KActionCollection.
 
 auto killWindowAction  = new QAction(nullptr);
 killWindowAction-setProperty(componentName, kwin); // see impl of 
 KActionCollection
 killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 // killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 // qDebug()  ac.actions().count(); // -- 1
 qDebug()  KGlobalAccel::self()-isComponentActive(kwin); // -- true
 qDebug()  KGlobalAccel::self()-allActionsForComponent({ kwin 
 }).count(); // (deprecated) -- 152
 qDebug()  KGlobalAccel::self()-hasShortcut(killWindowAction); // -- 
 false
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count(); // 
 -- 0
 qDebug()  
 KGlobalAccel::self()-defaultShortcut(killWindowAction).count(); // -- 0
 delete killWindowAction;
 
 Open issues:
 1. Is it necessary to specify the shortcut context (default) somewhere?
 2. How to tell KGlobalAccel to load the shortcuts for the given action.
 
 Gregor Mi wrote:
 Issue 1.: *not* necessary, see 
 kde/workspace/plasma-workspace/kglobalaccel/component.h, line 98
 
 Martin Gräßlin wrote:
 concerning 2: see 
 http://api.kde.org/frameworks-api/frameworks5-apidocs/kglobalaccel/html/classKGlobalAccel.html#a66ce504227e7e563f24de4c6b26b0395
 
 shortcut context is (I think) not needed.
 
 Gregor Mi wrote:
 I read the API documentation about setShortcut and frankly I do not fully 
 understand it. It seems counter-intuitive to me to call that method in order 
 to *load* the shortcut.
 
 Martin Gräßlin wrote:
 yes the API is weird. But it's really like it: if one doesn't pass 
 NoAutloading the shortcut gets loaded.
 
 Gregor Mi wrote:
 yes, you are right, it is really working like this:
 
 KActionCollection ac(nullptr, kwin);
 auto killWindowAction  = ac.addAction(Kill Window);
 //killWindowAction-setProperty(componentName, kwin); // see impl 
 of KActionCollection
 //killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 

Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Thomas Lübking


 On März 2, 2015, 7:47 vorm., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp
 
 Gregor Mi wrote:
 I tried this:
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGroup(default); // needed?
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.addAction(Kill Window);
 killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  ac.actions().count();
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
 /*
 CONSOLE OUTPUT:
 1
 0
 */
 
 Martin Gräßlin wrote:
 I think you need to register killWindowAction with KGlobalAccel in some 
 way so that it loads the configured shortcut.
 
 Gregor Mi wrote:
 I found out how to prepare the QAction without KActionCollection.
 
 auto killWindowAction  = new QAction(nullptr);
 killWindowAction-setProperty(componentName, kwin); // see impl of 
 KActionCollection
 killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 // killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 // qDebug()  ac.actions().count(); // -- 1
 qDebug()  KGlobalAccel::self()-isComponentActive(kwin); // -- true
 qDebug()  KGlobalAccel::self()-allActionsForComponent({ kwin 
 }).count(); // (deprecated) -- 152
 qDebug()  KGlobalAccel::self()-hasShortcut(killWindowAction); // -- 
 false
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count(); // 
 -- 0
 qDebug()  
 KGlobalAccel::self()-defaultShortcut(killWindowAction).count(); // -- 0
 delete killWindowAction;
 
 Open issues:
 1. Is it necessary to specify the shortcut context (default) somewhere?
 2. How to tell KGlobalAccel to load the shortcuts for the given action.
 
 Gregor Mi wrote:
 Issue 1.: *not* necessary, see 
 kde/workspace/plasma-workspace/kglobalaccel/component.h, line 98
 
 Martin Gräßlin wrote:
 concerning 2: see 
 http://api.kde.org/frameworks-api/frameworks5-apidocs/kglobalaccel/html/classKGlobalAccel.html#a66ce504227e7e563f24de4c6b26b0395
 
 shortcut context is (I think) not needed.
 
 Gregor Mi wrote:
 I read the API documentation about setShortcut and frankly I do not fully 
 understand it. It seems counter-intuitive to me to call that method in order 
 to *load* the shortcut.
 
 Martin Gräßlin wrote:
 yes the API is weird. But it's really like it: if one doesn't pass 
 NoAutloading the shortcut gets loaded.
 
 Gregor Mi wrote:
 yes, you are right, it is really working like this:
 
 KActionCollection ac(nullptr, kwin);
 auto killWindowAction  = ac.addAction(Kill Window);
 //killWindowAction-setProperty(componentName, kwin); // see impl 
 of KActionCollection
 //killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 

Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Gregor Mi


 On March 2, 2015, 7:47 a.m., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp
 
 Gregor Mi wrote:
 I tried this:
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGroup(default); // needed?
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.addAction(Kill Window);
 killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  ac.actions().count();
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
 /*
 CONSOLE OUTPUT:
 1
 0
 */
 
 Martin Gräßlin wrote:
 I think you need to register killWindowAction with KGlobalAccel in some 
 way so that it loads the configured shortcut.
 
 Gregor Mi wrote:
 I found out how to prepare the QAction without KActionCollection.
 
 auto killWindowAction  = new QAction(nullptr);
 killWindowAction-setProperty(componentName, kwin); // see impl of 
 KActionCollection
 killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 // killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 // qDebug()  ac.actions().count(); // -- 1
 qDebug()  KGlobalAccel::self()-isComponentActive(kwin); // -- true
 qDebug()  KGlobalAccel::self()-allActionsForComponent({ kwin 
 }).count(); // (deprecated) -- 152
 qDebug()  KGlobalAccel::self()-hasShortcut(killWindowAction); // -- 
 false
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count(); // 
 -- 0
 qDebug()  
 KGlobalAccel::self()-defaultShortcut(killWindowAction).count(); // -- 0
 delete killWindowAction;
 
 Open issues:
 1. Is it necessary to specify the shortcut context (default) somewhere?
 2. How to tell KGlobalAccel to load the shortcuts for the given action.
 
 Gregor Mi wrote:
 Issue 1.: *not* necessary, see 
 kde/workspace/plasma-workspace/kglobalaccel/component.h, line 98
 
 Martin Gräßlin wrote:
 concerning 2: see 
 http://api.kde.org/frameworks-api/frameworks5-apidocs/kglobalaccel/html/classKGlobalAccel.html#a66ce504227e7e563f24de4c6b26b0395
 
 shortcut context is (I think) not needed.
 
 Gregor Mi wrote:
 I read the API documentation about setShortcut and frankly I do not fully 
 understand it. It seems counter-intuitive to me to call that method in order 
 to *load* the shortcut.
 
 Martin Gräßlin wrote:
 yes the API is weird. But it's really like it: if one doesn't pass 
 NoAutloading the shortcut gets loaded.
 
 Gregor Mi wrote:
 yes, you are right, it is really working like this:
 
 KActionCollection ac(nullptr, kwin);
 auto killWindowAction  = ac.addAction(Kill Window);
 //killWindowAction-setProperty(componentName, kwin); // see impl 
 of KActionCollection
 //killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 

Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Gregor Mi

---
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/122249/
---

(Updated March 13, 2015, 10:08 p.m.)


Review request for KDE Base Apps, Martin Gräßlin and John Tapsell.


Changes
---

Fix the global shortcut gets unset issue by using a new method: 
KGlobalAccel::loadShortcutFromGlobalSettings


Repository: libksysguard


Description
---

Current situation:
The End Process... button has a tooltip which says To target a specific 
window to kill, press Ctrl+Alt+Esc at any time. The keyboard shortcut is 
hardcoded.

New:
Replace the End Process... button with a drop-down button and a action named 
Kill a specific window...


Diffs (updated)
-

  CMakeLists.txt 5352e70f6f37daae76c1b3e2c1c9f149d235e3cd 
  processui/CMakeLists.txt 7f87b85e0201e63d69070a71203bbb34851a79c6 
  processui/ProcessWidgetUI.ui e50f55cf1813b00d49b1716023df487ffbd536e3 
  processui/keyboardshortcututil.h PRE-CREATION 
  processui/keyboardshortcututil.cpp PRE-CREATION 
  processui/ksysguardprocesslist.cpp 450ca600b8aed7ca611ec638610b6c524c96080c 
  tests/CMakeLists.txt 967b03fae1e460bfb22e1a07ef05cf7b49412546 
  tests/keyboardshortcututiltest.h PRE-CREATION 
  tests/keyboardshortcututiltest.cpp PRE-CREATION 

Diff: https://git.reviewboard.kde.org/r/122249/diff/


Testing
---


File Attachments


New End Process button with drop down arrow
  
https://git.reviewboard.kde.org/media/uploaded/files/2015/01/28/16301e88-e21b-4358-9a63-a85dae5722bd__screenshot_default1.png
Drop down shows Kill Window
  
https://git.reviewboard.kde.org/media/uploaded/files/2015/01/28/58df12c5-7350-4bb0-b602-c5716caa9836__screenshot_default2.png


Thanks,

Gregor Mi



Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Gregor Mi


 On March 2, 2015, 7:47 a.m., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp
 
 Gregor Mi wrote:
 I tried this:
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGroup(default); // needed?
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.addAction(Kill Window);
 killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  ac.actions().count();
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
 /*
 CONSOLE OUTPUT:
 1
 0
 */
 
 Martin Gräßlin wrote:
 I think you need to register killWindowAction with KGlobalAccel in some 
 way so that it loads the configured shortcut.
 
 Gregor Mi wrote:
 I found out how to prepare the QAction without KActionCollection.
 
 auto killWindowAction  = new QAction(nullptr);
 killWindowAction-setProperty(componentName, kwin); // see impl of 
 KActionCollection
 killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 // killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 // qDebug()  ac.actions().count(); // -- 1
 qDebug()  KGlobalAccel::self()-isComponentActive(kwin); // -- true
 qDebug()  KGlobalAccel::self()-allActionsForComponent({ kwin 
 }).count(); // (deprecated) -- 152
 qDebug()  KGlobalAccel::self()-hasShortcut(killWindowAction); // -- 
 false
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count(); // 
 -- 0
 qDebug()  
 KGlobalAccel::self()-defaultShortcut(killWindowAction).count(); // -- 0
 delete killWindowAction;
 
 Open issues:
 1. Is it necessary to specify the shortcut context (default) somewhere?
 2. How to tell KGlobalAccel to load the shortcuts for the given action.
 
 Gregor Mi wrote:
 Issue 1.: *not* necessary, see 
 kde/workspace/plasma-workspace/kglobalaccel/component.h, line 98
 
 Martin Gräßlin wrote:
 concerning 2: see 
 http://api.kde.org/frameworks-api/frameworks5-apidocs/kglobalaccel/html/classKGlobalAccel.html#a66ce504227e7e563f24de4c6b26b0395
 
 shortcut context is (I think) not needed.
 
 Gregor Mi wrote:
 I read the API documentation about setShortcut and frankly I do not fully 
 understand it. It seems counter-intuitive to me to call that method in order 
 to *load* the shortcut.
 
 Martin Gräßlin wrote:
 yes the API is weird. But it's really like it: if one doesn't pass 
 NoAutloading the shortcut gets loaded.
 
 Gregor Mi wrote:
 yes, you are right, it is really working like this:
 
 KActionCollection ac(nullptr, kwin);
 auto killWindowAction  = ac.addAction(Kill Window);
 //killWindowAction-setProperty(componentName, kwin); // see impl 
 of KActionCollection
 //killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 

Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Gregor Mi


 On March 2, 2015, 7:47 a.m., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp
 
 Gregor Mi wrote:
 I tried this:
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGroup(default); // needed?
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.addAction(Kill Window);
 killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  ac.actions().count();
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
 /*
 CONSOLE OUTPUT:
 1
 0
 */
 
 Martin Gräßlin wrote:
 I think you need to register killWindowAction with KGlobalAccel in some 
 way so that it loads the configured shortcut.
 
 Gregor Mi wrote:
 I found out how to prepare the QAction without KActionCollection.
 
 auto killWindowAction  = new QAction(nullptr);
 killWindowAction-setProperty(componentName, kwin); // see impl of 
 KActionCollection
 killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 // killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 // qDebug()  ac.actions().count(); // -- 1
 qDebug()  KGlobalAccel::self()-isComponentActive(kwin); // -- true
 qDebug()  KGlobalAccel::self()-allActionsForComponent({ kwin 
 }).count(); // (deprecated) -- 152
 qDebug()  KGlobalAccel::self()-hasShortcut(killWindowAction); // -- 
 false
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count(); // 
 -- 0
 qDebug()  
 KGlobalAccel::self()-defaultShortcut(killWindowAction).count(); // -- 0
 delete killWindowAction;
 
 Open issues:
 1. Is it necessary to specify the shortcut context (default) somewhere?
 2. How to tell KGlobalAccel to load the shortcuts for the given action.
 
 Gregor Mi wrote:
 Issue 1.: *not* necessary, see 
 kde/workspace/plasma-workspace/kglobalaccel/component.h, line 98
 
 Martin Gräßlin wrote:
 concerning 2: see 
 http://api.kde.org/frameworks-api/frameworks5-apidocs/kglobalaccel/html/classKGlobalAccel.html#a66ce504227e7e563f24de4c6b26b0395
 
 shortcut context is (I think) not needed.
 
 Gregor Mi wrote:
 I read the API documentation about setShortcut and frankly I do not fully 
 understand it. It seems counter-intuitive to me to call that method in order 
 to *load* the shortcut.
 
 Martin Gräßlin wrote:
 yes the API is weird. But it's really like it: if one doesn't pass 
 NoAutloading the shortcut gets loaded.
 
 Gregor Mi wrote:
 yes, you are right, it is really working like this:
 
 KActionCollection ac(nullptr, kwin);
 auto killWindowAction  = ac.addAction(Kill Window);
 //killWindowAction-setProperty(componentName, kwin); // see impl 
 of KActionCollection
 //killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 

Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Gregor Mi


 On March 2, 2015, 7:47 a.m., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp
 
 Gregor Mi wrote:
 I tried this:
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGroup(default); // needed?
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.addAction(Kill Window);
 killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  ac.actions().count();
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
 /*
 CONSOLE OUTPUT:
 1
 0
 */
 
 Martin Gräßlin wrote:
 I think you need to register killWindowAction with KGlobalAccel in some 
 way so that it loads the configured shortcut.
 
 Gregor Mi wrote:
 I found out how to prepare the QAction without KActionCollection.
 
 auto killWindowAction  = new QAction(nullptr);
 killWindowAction-setProperty(componentName, kwin); // see impl of 
 KActionCollection
 killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 // killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 // qDebug()  ac.actions().count(); // -- 1
 qDebug()  KGlobalAccel::self()-isComponentActive(kwin); // -- true
 qDebug()  KGlobalAccel::self()-allActionsForComponent({ kwin 
 }).count(); // (deprecated) -- 152
 qDebug()  KGlobalAccel::self()-hasShortcut(killWindowAction); // -- 
 false
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count(); // 
 -- 0
 qDebug()  
 KGlobalAccel::self()-defaultShortcut(killWindowAction).count(); // -- 0
 delete killWindowAction;
 
 Open issues:
 1. Is it necessary to specify the shortcut context (default) somewhere?
 2. How to tell KGlobalAccel to load the shortcuts for the given action.
 
 Gregor Mi wrote:
 Issue 1.: *not* necessary, see 
 kde/workspace/plasma-workspace/kglobalaccel/component.h, line 98
 
 Martin Gräßlin wrote:
 concerning 2: see 
 http://api.kde.org/frameworks-api/frameworks5-apidocs/kglobalaccel/html/classKGlobalAccel.html#a66ce504227e7e563f24de4c6b26b0395
 
 shortcut context is (I think) not needed.
 
 Gregor Mi wrote:
 I read the API documentation about setShortcut and frankly I do not fully 
 understand it. It seems counter-intuitive to me to call that method in order 
 to *load* the shortcut.
 
 Martin Gräßlin wrote:
 yes the API is weird. But it's really like it: if one doesn't pass 
 NoAutloading the shortcut gets loaded.
 
 Gregor Mi wrote:
 yes, you are right, it is really working like this:
 
 KActionCollection ac(nullptr, kwin);
 auto killWindowAction  = ac.addAction(Kill Window);
 //killWindowAction-setProperty(componentName, kwin); // see impl 
 of KActionCollection
 //killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 

Re: Review request: QBluez

2015-03-13 Thread David Rosca
 Do you expect the bluez-qt branch of bluedevil to be ready to merge before 
 Plasma 5.3 freeze on Thu 9 April?

Currently, this branch is old and still using old name qbluez. I will
update it and work on it in next days to make it
ready for Plasma 5.3.

David

On Thu, Mar 12, 2015 at 8:26 PM, Jonathan Riddell j...@jriddell.org wrote:
 On Thu, Mar 12, 2015 at 08:23:22PM +0100, David Rosca wrote:
 Done. It's in kdereview now:
 https://projects.kde.org/projects/kdereview/bluez-qt

 Woo, lovely. Best post to plasma-devel about that (it's been posted around 
 lots already but best to cover all the bases I guess.)

 Do you expect the bluez-qt branch of bluedevil to be ready to merge before 
 Plasma 5.3 freeze on Thu 9 April?

 Jonathan



Re: Review Request 122922: Remove two asserts from kzip.cpp

2015-03-13 Thread Boudewijn Rempt

---
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/122922/
---

(Updated March 13, 2015, 8:34 a.m.)


Status
--

This change has been marked as submitted.


Review request for kdelibs.


Bugs: 343214
http://bugs.kde.org/show_bug.cgi?id=343214


Repository: kdelibs


Description
---

These asserts should never hit, return false is much safer. I'll submit the 
same patch for karchive.


Diffs
-

  kdecore/io/kzip.cpp 26ee9a7 

Diff: https://git.reviewboard.kde.org/r/122922/diff/


Testing
---

Tested with Krita in circumstances descibed in the bug.


Thanks,

Boudewijn Rempt



KDE Frameworks 5.8 released

2015-03-13 Thread David Faure
New frameworks:
* KPeople, provides access to all contacts and the people who hold them
* KXmlRpcClient, interaction with XMLRPC services

### General

* A number of build fixes for compiling with the upcoming Qt 5.5

### KActivities

* Resources scoring service is now finalized

### KArchive

* Stop failing on ZIP files with redundant data descriptors

### KCMUtils

* Restore KCModule::setAuthAction

### KCoreAddons

* KPluginMetadata: add support for Hidden key

### KDeclarative

* Prefer exposing lists to QML with QJsonArray
* Handle non default devicePixelRatios in images
* Expose hasUrls in DeclarativeMimeData
* Allow users to configure how many horizontal lines are drawn

### KDocTools

* Fix the build on MacOSX when using Homebrew
* Better styling of media objects (images, ...) in documentation
* Encode invalid chars in paths used in XML DTDs, avoiding errors

### KGlobalAccel

* Activation timestamp set as dynamic property on triggered QAction.

### KIconThemes

* Fix QIcon::fromTheme(xxx, someFallback) would not return the fallback

### KImageFormats

* Make PSD image reader endianess-agnostic.

### KIO

* Deprecate UDSEntry::listFields and add the UDSEntry::fields method which 
returns a QVector without costly conversion.
* Sync bookmarkmanager only if change was by this process (bug 343735)
* Fix startup of kssld5 dbus service
* Implement quota-used-bytes and quota-available-bytes from RFC 4331 to enable 
free space information in http ioslave.

### KNotifications

* Delay the audio init until actually needed
* Fix notification config not applying instantly
* Fix audio notifications stopping after first file played

### KNotifyConfig

* Add optional dependency on QtSpeech to reenable speaking notifications.

### KService

* KPluginInfo: support stringlists as properties

### KTextEditor

* Add word count statistics in statusbar
* vimode: fix crash when removing last line in Visual Line mode

### KWidgetsAddons

* Make KRatingWidget cope with devicePixelRatio

### KWindowSystem

* KSelectionWatcher and KSelectionOwner can be used without depending on 
QX11Info.
* KXMessages can be used without depending on QX11Info

### NetworkManagerQt

* Add new properties and methods from NetworkManager 1.0.0

 Plasma framework

* Fix plasmapkg2 for translated systems
* Improve tooltip layout
* Make it possible to let plasmoids to load scripts outside the plasma package
...

### Buildsystem changes (extra-cmake-modules)

* Extend ecm_generate_headers macro to also support CamelCase.h headers


-- 
David Faure, fa...@kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5



Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Martin Gräßlin


 On March 2, 2015, 8:47 a.m., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp
 
 Gregor Mi wrote:
 I tried this:
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGroup(default); // needed?
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.addAction(Kill Window);
 killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  ac.actions().count();
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
 /*
 CONSOLE OUTPUT:
 1
 0
 */

I think you need to register killWindowAction with KGlobalAccel in some way so 
that it loads the configured shortcut.


- Martin


---
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/122249/#review76861
---


On Feb. 27, 2015, 2:18 a.m., Gregor Mi wrote:
 
 ---
 This is an automatically generated e-mail. To reply, visit:
 https://git.reviewboard.kde.org/r/122249/
 ---
 
 (Updated Feb. 27, 2015, 2:18 a.m.)
 
 
 Review request for KDE Base Apps, Martin Gräßlin and John Tapsell.
 
 
 Repository: libksysguard
 
 
 Description
 ---
 
 Current situation:
 The End Process... button has a tooltip which says To target a specific 
 window to kill, press Ctrl+Alt+Esc at any time. The keyboard shortcut is 
 hardcoded.
 
 RR:
 Add a drop down menu to the End Process... button with one action:
 i18n(Kill a specific window... (Global shortcut: %1), killWindowShortcut)
 
 
 Diffs
 -
 
   processui/CMakeLists.txt 7f87b85e0201e63d69070a71203bbb34851a79c6 
   processui/ProcessWidgetUI.ui e50f55cf1813b00d49b1716023df487ffbd536e3 
   processui/keyboardshortcututil.h PRE-CREATION 
   processui/keyboardshortcututil.cpp PRE-CREATION 
   processui/ksysguardprocesslist.cpp 450ca600b8aed7ca611ec638610b6c524c96080c 
   tests/CMakeLists.txt 967b03fae1e460bfb22e1a07ef05cf7b49412546 
   tests/keyboardshortcututiltest.h PRE-CREATION 
   tests/keyboardshortcututiltest.cpp PRE-CREATION 
 
 Diff: https://git.reviewboard.kde.org/r/122249/diff/
 
 
 Testing
 ---
 
 
 File Attachments
 
 
 New End Process button with drop down arrow
   
 https://git.reviewboard.kde.org/media/uploaded/files/2015/01/28/16301e88-e21b-4358-9a63-a85dae5722bd__screenshot_default1.png
 Drop down shows Kill Window
   
 https://git.reviewboard.kde.org/media/uploaded/files/2015/01/28/58df12c5-7350-4bb0-b602-c5716caa9836__screenshot_default2.png
 
 
 Thanks,
 
 Gregor Mi
 




Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Gregor Mi


 On March 2, 2015, 7:47 a.m., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp

I tried this:

KActionCollection ac(nullptr, kwin);
ac.setConfigGroup(default); // needed?
ac.setConfigGlobal(true);
auto killWindowAction  = ac.addAction(Kill Window);
killWindowAction-setProperty(isConfigurationAction, true); // neded?
qDebug()  ac.actions().count();
qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
/*
CONSOLE OUTPUT:
1
0
*/


- Gregor


---
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/122249/#review76861
---


On Feb. 27, 2015, 1:18 a.m., Gregor Mi wrote:
 
 ---
 This is an automatically generated e-mail. To reply, visit:
 https://git.reviewboard.kde.org/r/122249/
 ---
 
 (Updated Feb. 27, 2015, 1:18 a.m.)
 
 
 Review request for KDE Base Apps, Martin Gräßlin and John Tapsell.
 
 
 Repository: libksysguard
 
 
 Description
 ---
 
 Current situation:
 The End Process... button has a tooltip which says To target a specific 
 window to kill, press Ctrl+Alt+Esc at any time. The keyboard shortcut is 
 hardcoded.
 
 RR:
 Add a drop down menu to the End Process... button with one action:
 i18n(Kill a specific window... (Global shortcut: %1), killWindowShortcut)
 
 
 Diffs
 -
 
   processui/CMakeLists.txt 7f87b85e0201e63d69070a71203bbb34851a79c6 
   processui/ProcessWidgetUI.ui e50f55cf1813b00d49b1716023df487ffbd536e3 
   processui/keyboardshortcututil.h PRE-CREATION 
   processui/keyboardshortcututil.cpp PRE-CREATION 
   processui/ksysguardprocesslist.cpp 450ca600b8aed7ca611ec638610b6c524c96080c 
   tests/CMakeLists.txt 967b03fae1e460bfb22e1a07ef05cf7b49412546 
   tests/keyboardshortcututiltest.h PRE-CREATION 
   tests/keyboardshortcututiltest.cpp PRE-CREATION 
 
 Diff: https://git.reviewboard.kde.org/r/122249/diff/
 
 
 Testing
 ---
 
 
 File Attachments
 
 
 New End Process button with drop down arrow
   
 https://git.reviewboard.kde.org/media/uploaded/files/2015/01/28/16301e88-e21b-4358-9a63-a85dae5722bd__screenshot_default1.png
 Drop down shows Kill Window
   
 https://git.reviewboard.kde.org/media/uploaded/files/2015/01/28/58df12c5-7350-4bb0-b602-c5716caa9836__screenshot_default2.png
 
 
 Thanks,
 
 Gregor Mi
 




Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Gregor Mi


 On March 2, 2015, 7:47 a.m., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp
 
 Gregor Mi wrote:
 I tried this:
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGroup(default); // needed?
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.addAction(Kill Window);
 killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  ac.actions().count();
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
 /*
 CONSOLE OUTPUT:
 1
 0
 */
 
 Martin Gräßlin wrote:
 I think you need to register killWindowAction with KGlobalAccel in some 
 way so that it loads the configured shortcut.

I found out how to prepare the QAction without KActionCollection.

auto killWindowAction  = new QAction(nullptr);
killWindowAction-setProperty(componentName, kwin); // see impl of 
KActionCollection
killWindowAction-setObjectName(Kill Window); // see impl of KActionCollection
// killWindowAction-setProperty(isConfigurationAction, true); // neded?
qDebug()  killWindowAction-objectName(); // -- Kill Window
// qDebug()  ac.actions().count(); // -- 1
qDebug()  KGlobalAccel::self()-isComponentActive(kwin); // -- true
qDebug()  KGlobalAccel::self()-allActionsForComponent({ kwin }).count(); 
// (deprecated) -- 152
qDebug()  KGlobalAccel::self()-hasShortcut(killWindowAction); // -- false
qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count(); // -- 0
qDebug()  KGlobalAccel::self()-defaultShortcut(killWindowAction).count(); // 
-- 0
delete killWindowAction;

Open issues:
1. Is it necessary to specify the shortcut context (default) somewhere?
2. How to tell KGlobalAccel to load the shortcuts for the given action.


- Gregor


---
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/122249/#review76861
---


On Feb. 27, 2015, 1:18 a.m., Gregor Mi wrote:
 
 ---
 This is an automatically generated e-mail. To reply, visit:
 https://git.reviewboard.kde.org/r/122249/
 ---
 
 (Updated Feb. 27, 2015, 1:18 a.m.)
 
 
 Review request for KDE Base Apps, Martin Gräßlin and John Tapsell.
 
 
 Repository: libksysguard
 
 
 Description
 ---
 
 Current situation:
 The End Process... button has a tooltip which says To target a specific 
 window to kill, press Ctrl+Alt+Esc at any time. The keyboard shortcut is 
 hardcoded.
 
 RR:
 Add a drop down menu to the End Process... button with one action:
 i18n(Kill a specific window... (Global shortcut: %1), killWindowShortcut)
 
 
 Diffs
 -
 
   processui/CMakeLists.txt 7f87b85e0201e63d69070a71203bbb34851a79c6 
   processui/ProcessWidgetUI.ui e50f55cf1813b00d49b1716023df487ffbd536e3 
   processui/keyboardshortcututil.h PRE-CREATION 
   

Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Gregor Mi


 On March 2, 2015, 7:47 a.m., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp
 
 Gregor Mi wrote:
 I tried this:
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGroup(default); // needed?
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.addAction(Kill Window);
 killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  ac.actions().count();
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
 /*
 CONSOLE OUTPUT:
 1
 0
 */
 
 Martin Gräßlin wrote:
 I think you need to register killWindowAction with KGlobalAccel in some 
 way so that it loads the configured shortcut.
 
 Gregor Mi wrote:
 I found out how to prepare the QAction without KActionCollection.
 
 auto killWindowAction  = new QAction(nullptr);
 killWindowAction-setProperty(componentName, kwin); // see impl of 
 KActionCollection
 killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 // killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 // qDebug()  ac.actions().count(); // -- 1
 qDebug()  KGlobalAccel::self()-isComponentActive(kwin); // -- true
 qDebug()  KGlobalAccel::self()-allActionsForComponent({ kwin 
 }).count(); // (deprecated) -- 152
 qDebug()  KGlobalAccel::self()-hasShortcut(killWindowAction); // -- 
 false
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count(); // 
 -- 0
 qDebug()  
 KGlobalAccel::self()-defaultShortcut(killWindowAction).count(); // -- 0
 delete killWindowAction;
 
 Open issues:
 1. Is it necessary to specify the shortcut context (default) somewhere?
 2. How to tell KGlobalAccel to load the shortcuts for the given action.

Issue 1.: *not* necessary, see 
kde/workspace/plasma-workspace/kglobalaccel/component.h, line 98


- Gregor


---
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/122249/#review76861
---


On Feb. 27, 2015, 1:18 a.m., Gregor Mi wrote:
 
 ---
 This is an automatically generated e-mail. To reply, visit:
 https://git.reviewboard.kde.org/r/122249/
 ---
 
 (Updated Feb. 27, 2015, 1:18 a.m.)
 
 
 Review request for KDE Base Apps, Martin Gräßlin and John Tapsell.
 
 
 Repository: libksysguard
 
 
 Description
 ---
 
 Current situation:
 The End Process... button has a tooltip which says To target a specific 
 window to kill, press Ctrl+Alt+Esc at any time. The keyboard shortcut is 
 hardcoded.
 
 RR:
 Add a drop down menu to the End Process... button with one action:
 i18n(Kill a specific window... (Global shortcut: %1), killWindowShortcut)
 
 
 Diffs
 -
 
   

Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Martin Gräßlin


 On March 2, 2015, 8:47 a.m., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp
 
 Gregor Mi wrote:
 I tried this:
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGroup(default); // needed?
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.addAction(Kill Window);
 killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  ac.actions().count();
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
 /*
 CONSOLE OUTPUT:
 1
 0
 */
 
 Martin Gräßlin wrote:
 I think you need to register killWindowAction with KGlobalAccel in some 
 way so that it loads the configured shortcut.
 
 Gregor Mi wrote:
 I found out how to prepare the QAction without KActionCollection.
 
 auto killWindowAction  = new QAction(nullptr);
 killWindowAction-setProperty(componentName, kwin); // see impl of 
 KActionCollection
 killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 // killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 // qDebug()  ac.actions().count(); // -- 1
 qDebug()  KGlobalAccel::self()-isComponentActive(kwin); // -- true
 qDebug()  KGlobalAccel::self()-allActionsForComponent({ kwin 
 }).count(); // (deprecated) -- 152
 qDebug()  KGlobalAccel::self()-hasShortcut(killWindowAction); // -- 
 false
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count(); // 
 -- 0
 qDebug()  
 KGlobalAccel::self()-defaultShortcut(killWindowAction).count(); // -- 0
 delete killWindowAction;
 
 Open issues:
 1. Is it necessary to specify the shortcut context (default) somewhere?
 2. How to tell KGlobalAccel to load the shortcuts for the given action.
 
 Gregor Mi wrote:
 Issue 1.: *not* necessary, see 
 kde/workspace/plasma-workspace/kglobalaccel/component.h, line 98

concerning 2: see 
http://api.kde.org/frameworks-api/frameworks5-apidocs/kglobalaccel/html/classKGlobalAccel.html#a66ce504227e7e563f24de4c6b26b0395

shortcut context is (I think) not needed.


- Martin


---
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/122249/#review76861
---


On Feb. 27, 2015, 2:18 a.m., Gregor Mi wrote:
 
 ---
 This is an automatically generated e-mail. To reply, visit:
 https://git.reviewboard.kde.org/r/122249/
 ---
 
 (Updated Feb. 27, 2015, 2:18 a.m.)
 
 
 Review request for KDE Base Apps, Martin Gräßlin and John Tapsell.
 
 
 Repository: libksysguard
 
 
 Description
 ---
 
 Current situation:
 The End Process... button has a tooltip which says To target a specific 
 window to kill, press Ctrl+Alt+Esc at any time. The 

Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Martin Gräßlin


 On March 2, 2015, 8:47 a.m., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp
 
 Gregor Mi wrote:
 I tried this:
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGroup(default); // needed?
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.addAction(Kill Window);
 killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  ac.actions().count();
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
 /*
 CONSOLE OUTPUT:
 1
 0
 */
 
 Martin Gräßlin wrote:
 I think you need to register killWindowAction with KGlobalAccel in some 
 way so that it loads the configured shortcut.
 
 Gregor Mi wrote:
 I found out how to prepare the QAction without KActionCollection.
 
 auto killWindowAction  = new QAction(nullptr);
 killWindowAction-setProperty(componentName, kwin); // see impl of 
 KActionCollection
 killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 // killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 // qDebug()  ac.actions().count(); // -- 1
 qDebug()  KGlobalAccel::self()-isComponentActive(kwin); // -- true
 qDebug()  KGlobalAccel::self()-allActionsForComponent({ kwin 
 }).count(); // (deprecated) -- 152
 qDebug()  KGlobalAccel::self()-hasShortcut(killWindowAction); // -- 
 false
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count(); // 
 -- 0
 qDebug()  
 KGlobalAccel::self()-defaultShortcut(killWindowAction).count(); // -- 0
 delete killWindowAction;
 
 Open issues:
 1. Is it necessary to specify the shortcut context (default) somewhere?
 2. How to tell KGlobalAccel to load the shortcuts for the given action.
 
 Gregor Mi wrote:
 Issue 1.: *not* necessary, see 
 kde/workspace/plasma-workspace/kglobalaccel/component.h, line 98
 
 Martin Gräßlin wrote:
 concerning 2: see 
 http://api.kde.org/frameworks-api/frameworks5-apidocs/kglobalaccel/html/classKGlobalAccel.html#a66ce504227e7e563f24de4c6b26b0395
 
 shortcut context is (I think) not needed.
 
 Gregor Mi wrote:
 I read the API documentation about setShortcut and frankly I do not fully 
 understand it. It seems counter-intuitive to me to call that method in order 
 to *load* the shortcut.

yes the API is weird. But it's really like it: if one doesn't pass NoAutloading 
the shortcut gets loaded.


- Martin


---
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/122249/#review76861
---


On Feb. 27, 2015, 2:18 a.m., Gregor Mi wrote:
 
 ---
 This is an automatically generated e-mail. To reply, visit:
 https://git.reviewboard.kde.org/r/122249/
 

Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Gregor Mi


 On March 2, 2015, 7:47 a.m., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp
 
 Gregor Mi wrote:
 I tried this:
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGroup(default); // needed?
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.addAction(Kill Window);
 killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  ac.actions().count();
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
 /*
 CONSOLE OUTPUT:
 1
 0
 */
 
 Martin Gräßlin wrote:
 I think you need to register killWindowAction with KGlobalAccel in some 
 way so that it loads the configured shortcut.
 
 Gregor Mi wrote:
 I found out how to prepare the QAction without KActionCollection.
 
 auto killWindowAction  = new QAction(nullptr);
 killWindowAction-setProperty(componentName, kwin); // see impl of 
 KActionCollection
 killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 // killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 // qDebug()  ac.actions().count(); // -- 1
 qDebug()  KGlobalAccel::self()-isComponentActive(kwin); // -- true
 qDebug()  KGlobalAccel::self()-allActionsForComponent({ kwin 
 }).count(); // (deprecated) -- 152
 qDebug()  KGlobalAccel::self()-hasShortcut(killWindowAction); // -- 
 false
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count(); // 
 -- 0
 qDebug()  
 KGlobalAccel::self()-defaultShortcut(killWindowAction).count(); // -- 0
 delete killWindowAction;
 
 Open issues:
 1. Is it necessary to specify the shortcut context (default) somewhere?
 2. How to tell KGlobalAccel to load the shortcuts for the given action.
 
 Gregor Mi wrote:
 Issue 1.: *not* necessary, see 
 kde/workspace/plasma-workspace/kglobalaccel/component.h, line 98
 
 Martin Gräßlin wrote:
 concerning 2: see 
 http://api.kde.org/frameworks-api/frameworks5-apidocs/kglobalaccel/html/classKGlobalAccel.html#a66ce504227e7e563f24de4c6b26b0395
 
 shortcut context is (I think) not needed.
 
 Gregor Mi wrote:
 I read the API documentation about setShortcut and frankly I do not fully 
 understand it. It seems counter-intuitive to me to call that method in order 
 to *load* the shortcut.
 
 Martin Gräßlin wrote:
 yes the API is weird. But it's really like it: if one doesn't pass 
 NoAutloading the shortcut gets loaded.

yes, you are right, it is really working like this:

KActionCollection ac(nullptr, kwin);
auto killWindowAction  = ac.addAction(Kill Window);
//killWindowAction-setProperty(componentName, kwin); // see impl of 
KActionCollection
//killWindowAction-setObjectName(Kill Window); // see impl of 
KActionCollection
qDebug()  killWindowAction-objectName(); // -- Kill Window
qDebug()  KGlobalAccel::self()-hasShortcut(killWindowAction); 

Re: Review Request 122249: libksysguard: add Kill Window to End Process button and show correct keyboard shortcut

2015-03-13 Thread Gregor Mi


 On March 2, 2015, 7:47 a.m., Martin Gräßlin wrote:
  processui/keyboardshortcututil.cpp, line 46
  https://git.reviewboard.kde.org/r/122249/diff/6/?file=351945#file351945line46
 
  This looks to complicated. It should be much easier to do with the 
  KGlobalAccel API:
  * create a KActionCollection for component kwin
  * add a QAction with the shortcut name you want
  * ask KGlobalAccel to load the shortcut for it.
 
 Gregor Mi wrote:
 Thanks for the hint but I am not sure of how to use the API in such a 
 way. I tried two things:
 
 1)
 org::kde::KGlobalAccel kglobalaccel(org.kde.kglobalaccel, 
 /kglobalaccel, bus);
 
 auto kwinActions = 
 kglobalaccel.allActionsForComponent(QStringList(kwin));
 Q_FOREACH(auto aaa, kwinActions.value()) {
 //qDebug()  aaa; // (kwin, Kill Window, KWin, Kill 
 Window)
 }
 Then I wonder how to feed the QStringList to a KActionCollection.
 
 2)
 KActionCollection ac(nullptr, QString());
 ac.setComponentName(kwin);
 // ac.importGlobalShortcuts();
 Q_FOREACH(auto bbb, ac.actions()) {
 if (bbb-text() == Kill Window) {
 qDebug()  bbb;
 }
 }
 But the ac.actions() list is empty.
 
 Which of the two ways should be used?
 
 Thomas Lübking wrote:
 tried this?
 ---
 KActionCollection ac(this, kwin);
 ac.setConfigGlobal(true);
 QAction *act  = ac.action(Kill Window);
 
 Gregor Mi wrote:
 I have no QObject* as parent. Can this be the cause?
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.action(Kill Window);
 qDebug()  ac.actions().count();
 qDebug()  killWindowAction;
 /*
 RESULT:
 0
 QObject(0x0)
 */
 
 Thomas Lübking wrote:
 You'd have qApp, but I don't actually think so.
 
 Martin Gräßlin wrote:
 try: ac.addAction instead of ac.action
 
 For reference code look at e.g. 
 kwin/effects/desktopgrid/desktopgrid_config.cpp
 
 Gregor Mi wrote:
 I tried this:
 
 KActionCollection ac(nullptr, kwin);
 ac.setConfigGroup(default); // needed?
 ac.setConfigGlobal(true);
 auto killWindowAction  = ac.addAction(Kill Window);
 killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  ac.actions().count();
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count();
 /*
 CONSOLE OUTPUT:
 1
 0
 */
 
 Martin Gräßlin wrote:
 I think you need to register killWindowAction with KGlobalAccel in some 
 way so that it loads the configured shortcut.
 
 Gregor Mi wrote:
 I found out how to prepare the QAction without KActionCollection.
 
 auto killWindowAction  = new QAction(nullptr);
 killWindowAction-setProperty(componentName, kwin); // see impl of 
 KActionCollection
 killWindowAction-setObjectName(Kill Window); // see impl of 
 KActionCollection
 // killWindowAction-setProperty(isConfigurationAction, true); // neded?
 qDebug()  killWindowAction-objectName(); // -- Kill Window
 // qDebug()  ac.actions().count(); // -- 1
 qDebug()  KGlobalAccel::self()-isComponentActive(kwin); // -- true
 qDebug()  KGlobalAccel::self()-allActionsForComponent({ kwin 
 }).count(); // (deprecated) -- 152
 qDebug()  KGlobalAccel::self()-hasShortcut(killWindowAction); // -- 
 false
 qDebug()  KGlobalAccel::self()-shortcut(killWindowAction).count(); // 
 -- 0
 qDebug()  
 KGlobalAccel::self()-defaultShortcut(killWindowAction).count(); // -- 0
 delete killWindowAction;
 
 Open issues:
 1. Is it necessary to specify the shortcut context (default) somewhere?
 2. How to tell KGlobalAccel to load the shortcuts for the given action.
 
 Gregor Mi wrote:
 Issue 1.: *not* necessary, see 
 kde/workspace/plasma-workspace/kglobalaccel/component.h, line 98
 
 Martin Gräßlin wrote:
 concerning 2: see 
 http://api.kde.org/frameworks-api/frameworks5-apidocs/kglobalaccel/html/classKGlobalAccel.html#a66ce504227e7e563f24de4c6b26b0395
 
 shortcut context is (I think) not needed.

I read the API documentation about setShortcut and frankly I do not fully 
understand it. It seems counter-intuitive to me to call that method in order to 
*load* the shortcut.


- Gregor


---
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/122249/#review76861
---


On Feb. 27, 2015, 1:18 a.m., Gregor Mi wrote:
 
 ---
 This is an automatically generated e-mail. To reply, visit:
 https://git.reviewboard.kde.org/r/122249/
 ---
 
 (Updated Feb. 27, 2015, 1:18 a.m.)
 
 
 Review request for KDE Base Apps, Martin Gräßlin and