• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • sources
  • kde-4.14
  • kdelibs
  • kdeui
  • shortcuts
kglobalaccel.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org>
3  Copyright (C) 2006 Hamish Rodda <rodda@kde.org>
4  Copyright (C) 2007 Andreas Hartmetz <ahartmetz@gmail.com>
5  Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 
23 #include "kglobalaccel.h"
24 #include "kglobalaccel_p.h"
25 
26 #include <memory>
27 
28 #include <QtDBus/QDBusInterface>
29 #include <QtDBus/QDBusMetaType>
30 #ifdef Q_WS_X11
31 #include <QtGui/QX11Info>
32 #include <netwm_def.h>
33 #endif
34 
35 #include <kdebug.h>
36 #include <ktoolinvocation.h>
37 #include <kaboutdata.h>
38 #include <kcomponentdata.h>
39 #include "kaction.h"
40 #include "kaction_p.h"
41 #include "kmessagebox.h"
42 #include "kshortcut.h"
43 
44 org::kde::kglobalaccel::Component *KGlobalAccelPrivate::getComponent(const QString &componentUnique, bool remember = false)
45 {
46  // Check if we already have this component
47  if (components.contains(componentUnique)) {
48  return components[componentUnique];
49  }
50 
51  // Connect to the kglobalaccel daemon
52  org::kde::KGlobalAccel kglobalaccel(
53  "org.kde.kglobalaccel",
54  "/kglobalaccel",
55  QDBusConnection::sessionBus());
56  if (!kglobalaccel.isValid()) {
57  kDebug() << "Failed to connect to the kglobalaccel daemon" << QDBusConnection::sessionBus().lastError();
58  return NULL;
59  }
60 
61  // Get the path for our component. We have to do that because
62  // componentUnique is probably not a valid dbus object path
63  QDBusReply<QDBusObjectPath> reply = kglobalaccel.getComponent(componentUnique);
64  if (!reply.isValid()) {
65 
66  if (reply.error().name() == "org.kde.kglobalaccel.NoSuchComponent") {
67  // No problem. The component doesn't exists. That's normal
68  return NULL;
69  }
70 
71  // An unknown error.
72  kDebug() << "Failed to get dbus path for component " << componentUnique << reply.error();
73  return NULL;
74  }
75 
76  // Now get the component
77  org::kde::kglobalaccel::Component *component = new org::kde::kglobalaccel::Component(
78  "org.kde.kglobalaccel",
79  reply.value().path(),
80  QDBusConnection::sessionBus(),
81  q);
82 
83  // No component no cleaning
84  if (!component->isValid()) {
85  kDebug() << "Failed to get component" << componentUnique << QDBusConnection::sessionBus().lastError();
86  return NULL;
87  }
88 
89  if (remember)
90  {
91  // Connect to the signals we are interested in.
92  q->connect(component, SIGNAL(globalShortcutPressed(QString,QString,qlonglong)),
93  SLOT(_k_invokeAction(QString,QString,qlonglong)));
94 
95  components[componentUnique] = component;
96  }
97 
98  return component;
99 }
100 
101 
102 
103 KGlobalAccelPrivate::KGlobalAccelPrivate(KGlobalAccel *q)
104  : isUsingForeignComponentName(false),
105 #ifndef KDE_NO_DEPRECATED
106  enabled(true),
107 #endif
108  iface("org.kde.kglobalaccel", "/kglobalaccel", QDBusConnection::sessionBus()),
109  q(q)
110 {
111  // Make sure kded is running. The iface declaration above somehow
112  // works anyway.
113  QDBusConnectionInterface* bus = QDBusConnection::sessionBus().interface();
114  if (!bus->isServiceRegistered("org.kde.kglobalaccel")) {
115  QString error;
116  int ret = KToolInvocation::startServiceByDesktopPath(
117  "kglobalaccel.desktop",
118  QStringList(),
119  &error);
120 
121  if (ret > 0) {
122  kError() << "Couldn't start kglobalaccel from kglobalaccel.desktop: " << error << endl;
123  }
124  }
125  QDBusServiceWatcher *watcher = new QDBusServiceWatcher(iface.service(),
126  QDBusConnection::sessionBus(),
127  QDBusServiceWatcher::WatchForOwnerChange,
128  q);
129  q->connect(watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)),
130  q, SLOT(_k_serviceOwnerChanged(QString,QString,QString)));
131 }
132 
133 
134 void KGlobalAccelPrivate::readComponentData(const KComponentData &componentData)
135 {
136  Q_ASSERT(!componentData.componentName().isEmpty());
137 
138  mainComponent = componentData;
139  if (componentData.aboutData()->programName().isEmpty()) {
140  kDebug(123) << componentData.componentName() << " has empty programName()";
141  }
142 }
143 
144 
145 KGlobalAccel::KGlobalAccel()
146  : d(new KGlobalAccelPrivate(this))
147 {
148  qDBusRegisterMetaType<QList<int> >();
149  qDBusRegisterMetaType<QList<QStringList> >();
150  qDBusRegisterMetaType<KGlobalShortcutInfo>();
151  qDBusRegisterMetaType<QList<KGlobalShortcutInfo> >();
152 
153  connect(&d->iface, SIGNAL(yourShortcutGotChanged(QStringList,QList<int>)),
154  SLOT(_k_shortcutGotChanged(QStringList,QList<int>)));
155 
156  if (KGlobal::hasMainComponent()) {
157  d->readComponentData( KGlobal::mainComponent() );
158  }
159 
160 }
161 
162 
163 KGlobalAccel::~KGlobalAccel()
164 {
165  delete d;
166 }
167 
168 
169 void KGlobalAccel::activateGlobalShortcutContext(
170  const QString &contextUnique,
171  const QString &contextFriendly,
172  const KComponentData &component)
173 {
174  Q_UNUSED(contextFriendly);
175  // TODO: provide contextFriendly
176  self()->d->iface.activateGlobalShortcutContext(component.aboutData()->programName(), contextUnique);
177 }
178 
179 
180 // static
181 bool KGlobalAccel::cleanComponent(const QString &componentUnique)
182 {
183  org::kde::kglobalaccel::Component* component = self()->getComponent(componentUnique);
184  if (!component) return false;
185 
186  return component->cleanUp();
187 }
188 
189 
190 // static
191 bool KGlobalAccel::isComponentActive(const QString &componentUnique)
192 {
193  org::kde::kglobalaccel::Component* component = self()->getComponent(componentUnique);
194  if (!component) return false;
195 
196  return component->isActive();
197 }
198 
199 
200 #ifndef KDE_NO_DEPRECATED
201 bool KGlobalAccel::isEnabled() const
202 {
203  return d->enabled;
204 }
205 #endif
206 
207 
208 org::kde::kglobalaccel::Component *KGlobalAccel::getComponent(const QString &componentUnique)
209 {
210  return d->getComponent(componentUnique);
211 }
212 
213 
214 #ifndef KDE_NO_DEPRECATED
215 void KGlobalAccel::setEnabled(bool enabled)
216 {
217  d->enabled = enabled;
218 }
219 #endif
220 
221 
222 #ifndef KDE_NO_DEPRECATED
223 void KGlobalAccel::overrideMainComponentData(const KComponentData &kcd)
224 {
225  d->readComponentData(kcd);
226  d->isUsingForeignComponentName = true;
227 }
228 #endif
229 
230 
231 KGlobalAccel *KGlobalAccel::self()
232 {
233  K_GLOBAL_STATIC(KGlobalAccel, s_instance)
234  return s_instance;
235 }
236 
237 
238 void KGlobalAccelPrivate::doRegister(KAction *action)
239 {
240  if (!action || action->objectName().isEmpty()) {
241  return;
242  }
243 
244  const bool isRegistered = actions.contains(action);
245  if (isRegistered)
246  return;
247 
248  // Under configuration mode - deprecated - we ignore the component given
249  // from the action and use our own.
250  if (isUsingForeignComponentName) {
251  action->d->componentData = mainComponent;
252  }
253  QStringList actionId = makeActionId(action);
254 
255  nameToAction.insertMulti(actionId.at(KGlobalAccel::ActionUnique), action);
256  actions.insert(action);
257  iface.doRegister(actionId);
258 }
259 
260 
261 void KGlobalAccelPrivate::remove(KAction *action, Removal removal)
262 {
263  if (!action || action->objectName().isEmpty()) {
264  return;
265  }
266 
267  const bool isRegistered = actions.contains(action);
268  if (!isRegistered) {
269  return;
270  }
271 
272  QStringList actionId = makeActionId(action);
273 
274  nameToAction.remove(actionId.at(KGlobalAccel::ActionUnique), action);
275  actions.remove(action);
276 
277  if (removal == UnRegister) {
278  // Complete removal of the shortcut is requested
279  // (forgetGlobalShortcut)
280  iface.unRegister(actionId);
281  } else {
282  // If the action is a configurationAction wen only remove it from our
283  // internal registry. That happened above.
284  if (!action->property("isConfigurationAction").toBool()) {
285  // If it's a session shortcut unregister it.
286  action->objectName().startsWith(QLatin1String("_k_session:"))
287  ? iface.unRegister(actionId)
288  : iface.setInactive(actionId);
289  }
290  }
291 }
292 
293 
294 void KGlobalAccelPrivate::updateGlobalShortcut(KAction *action, uint flags)
295 {
296  // No action or no objectname -> Do nothing
297  // KAction::setGlobalShortcut informs the user
298  if (!action || action->objectName().isEmpty()) {
299  return;
300  }
301 
302  QStringList actionId = makeActionId(action);
303  const KShortcut activeShortcut = action->globalShortcut();
304  const KShortcut defaultShortcut = action->globalShortcut(KAction::DefaultShortcut);
305 
306  uint setterFlags = 0;
307  if (flags & KAction::NoAutoloading) {
308  setterFlags |= NoAutoloading;
309  }
310 
311  if (flags & KAction::ActiveShortcut) {
312  bool isConfigurationAction = isUsingForeignComponentName
313  || action->property("isConfigurationAction").toBool();
314  uint activeSetterFlags = setterFlags;
315 
316  // setPresent tells kglobalaccel that the shortcut is active
317  if (!isConfigurationAction) {
318  activeSetterFlags |= SetPresent;
319  }
320 
321  // Sets the shortcut, returns the active/real keys
322  const QList<int> result = iface.setShortcut(
323  actionId,
324  intListFromShortcut(activeShortcut),
325  activeSetterFlags);
326 
327  // Make sure we get informed about changes in the component by kglobalaccel
328  getComponent(componentUniqueForAction(action), true);
329 
330  // Create a shortcut from the result
331  const KShortcut scResult(shortcutFromIntList(result));
332 
333  if (isConfigurationAction && (flags & KAction::NoAutoloading)) {
334  // If this is a configuration action and we have set the shortcut,
335  // inform the real owner of the change.
336  // Note that setForeignShortcut will cause a signal to be sent to applications
337  // even if it did not "see" that the shortcut has changed. This is Good because
338  // at the time of comparison (now) the action *already has* the new shortcut.
339  // We called setShortcut(), remember?
340  // Also note that we will see our own signal so we may not need to call
341  // setActiveGlobalShortcutNoEnable - _k_shortcutGotChanged() does it.
342  // In practice it's probably better to get the change propagated here without
343  // DBus delay as we do below.
344  iface.setForeignShortcut(actionId, result);
345  }
346  if (scResult != activeShortcut) {
347  // If kglobalaccel returned a shortcut that differs from the one we
348  // sent, use that one. There must have been clashes or some other problem.
349  action->d->setActiveGlobalShortcutNoEnable(scResult);
350  }
351  }
352 
353  if (flags & KAction::DefaultShortcut) {
354  iface.setShortcut(actionId, intListFromShortcut(defaultShortcut),
355  setterFlags | IsDefault);
356  }
357 }
358 
359 
360 QStringList KGlobalAccelPrivate::makeActionId(const KAction *action)
361 {
362  QStringList ret(componentUniqueForAction(action)); // Component Unique Id ( see actionIdFields )
363  Q_ASSERT(!ret.at(KGlobalAccel::ComponentUnique).isEmpty());
364  Q_ASSERT(!action->objectName().isEmpty());
365  ret.append(action->objectName()); // Action Unique Name
366  ret.append(componentFriendlyForAction(action)); // Component Friendly name
367  const QString actionText = KGlobal::locale()->removeAcceleratorMarker(action->text());
368  ret.append(actionText); // Action Friendly Name
369  return ret;
370 }
371 
372 
373 QList<int> KGlobalAccelPrivate::intListFromShortcut(const KShortcut &cut)
374 {
375  QList<int> ret;
376  ret.append(cut.primary()[0]);
377  ret.append(cut.alternate()[0]);
378  while (!ret.isEmpty() && ret.last() == 0)
379  ret.removeLast();
380  return ret;
381 }
382 
383 
384 KShortcut KGlobalAccelPrivate::shortcutFromIntList(const QList<int> &list)
385 {
386  KShortcut ret;
387  if (list.count() > 0)
388  ret.setPrimary(list[0]);
389  if (list.count() > 1)
390  ret.setAlternate(list[1]);
391  return ret;
392 }
393 
394 
395 QString KGlobalAccelPrivate::componentUniqueForAction(const KAction *action)
396 {
397  Q_ASSERT(action->d->componentData.isValid());
398  return action->d->componentData.componentName();
399 }
400 
401 
402 QString KGlobalAccelPrivate::componentFriendlyForAction(const KAction *action)
403 {
404  Q_ASSERT(action->d->componentData.isValid());
405  return action->d->componentData.aboutData()->programName();
406 }
407 
408 
409 void KGlobalAccelPrivate::_k_invokeAction(
410  const QString &componentUnique,
411  const QString &actionUnique,
412  qlonglong timestamp)
413 {
414  // If overrideMainComponentData() is active the app can only have
415  // configuration actions.
416  if (isUsingForeignComponentName ) {
417  return;
418  }
419 
420  KAction *action = 0;
421  QList<KAction *> candidates = nameToAction.values(actionUnique);
422  foreach (KAction *const a, candidates) {
423  if (componentUniqueForAction(a) == componentUnique) {
424  action = a;
425  }
426  }
427 
428  // We do not trigger if
429  // - there is no action
430  // - the action is not enabled
431  // - the action is an configuration action
432  if (!action || !action->isEnabled() || action->property("isConfigurationAction").toBool()) {
433  return;
434  }
435 
436 #ifdef Q_WS_X11
437  // Update this application's X timestamp if needed.
438  // TODO The 100%-correct solution should probably be handling this action
439  // in the proper place in relation to the X events queue in order to avoid
440  // the possibility of wrong ordering of user events.
441  if( NET::timestampCompare(timestamp, QX11Info::appTime()) > 0)
442  QX11Info::setAppTime(timestamp);
443  if( NET::timestampCompare(timestamp, QX11Info::appUserTime()) > 0)
444  QX11Info::setAppUserTime(timestamp);
445 #else
446  Q_UNUSED(timestamp);
447 #endif
448 
449  action->trigger();
450 }
451 
452 
453 void KGlobalAccelPrivate::_k_shortcutGotChanged(const QStringList &actionId,
454  const QList<int> &keys)
455 {
456  KAction *action = nameToAction.value(actionId.at(KGlobalAccel::ActionUnique));
457  if (!action)
458  return;
459 
460  action->d->setActiveGlobalShortcutNoEnable(shortcutFromIntList(keys));
461 }
462 
463 void KGlobalAccelPrivate::_k_serviceOwnerChanged(const QString &name, const QString &oldOwner,
464  const QString &newOwner)
465 {
466  Q_UNUSED(oldOwner);
467  if (name == QLatin1String("org.kde.kglobalaccel") && !newOwner.isEmpty()) {
468  // kglobalaccel was restarted
469  kDebug(123) << "detected kglobalaccel restarting, re-registering all shortcut keys";
470  reRegisterAll();
471  }
472 }
473 
474 void KGlobalAccelPrivate::reRegisterAll()
475 {
476  //### Special case for isUsingForeignComponentName?
477 
478  //We clear all our data, assume that all data on the other side is clear too,
479  //and register each action as if it just was allowed to have global shortcuts.
480  //If the kded side still has the data it doesn't matter because of the
481  //autoloading mechanism. The worst case I can imagine is that an action's
482  //shortcut was changed but the kded side died before it got the message so
483  //autoloading will now assign an old shortcut to the action. Particularly
484  //picky apps might assert or misbehave.
485  QSet<KAction *> allActions = actions;
486  nameToAction.clear();
487  actions.clear();
488  foreach(KAction *const action, allActions) {
489  doRegister(action);
490  updateGlobalShortcut(action, KAction::Autoloading | KAction::ActiveShortcut);
491  }
492 }
493 
494 
495 #ifndef KDE_NO_DEPRECATED
496 QList<QStringList> KGlobalAccel::allMainComponents()
497 {
498  return d->iface.allMainComponents();
499 }
500 #endif
501 
502 
503 #ifndef KDE_NO_DEPRECATED
504 QList<QStringList> KGlobalAccel::allActionsForComponent(const QStringList &actionId)
505 {
506  return d->iface.allActionsForComponent(actionId);
507 }
508 #endif
509 
510 
511 //static
512 #ifndef KDE_NO_DEPRECATED
513 QStringList KGlobalAccel::findActionNameSystemwide(const QKeySequence &seq)
514 {
515  return self()->d->iface.action(seq[0]);
516 }
517 #endif
518 
519 
520 QList<KGlobalShortcutInfo> KGlobalAccel::getGlobalShortcutsByKey(const QKeySequence &seq)
521 {
522  return self()->d->iface.getGlobalShortcutsByKey(seq[0]);
523 }
524 
525 
526 bool KGlobalAccel::isGlobalShortcutAvailable(const QKeySequence &seq, const QString &comp)
527 {
528  return self()->d->iface.isGlobalShortcutAvailable(seq[0], comp);
529 }
530 
531 
532 //static
533 #ifndef KDE_NO_DEPRECATED
534 bool KGlobalAccel::promptStealShortcutSystemwide(QWidget *parent, const QStringList &actionIdentifier,
535  const QKeySequence &seq)
536 {
537  if (actionIdentifier.size() < 4) {
538  return false;
539  }
540  QString title = i18n("Conflict with Global Shortcut");
541  QString message = i18n("The '%1' key combination has already been allocated "
542  "to the global action \"%2\" in %3.\n"
543  "Do you want to reassign it from that action to the current one?",
544  seq.toString(), actionIdentifier.at(KGlobalAccel::ActionFriendly),
545  actionIdentifier.at(KGlobalAccel::ComponentFriendly));
546 
547  return KMessageBox::warningContinueCancel(parent, message, title, KGuiItem(i18n("Reassign")))
548  == KMessageBox::Continue;
549 }
550 #endif
551 
552 
553 //static
554 bool KGlobalAccel::promptStealShortcutSystemwide(
555  QWidget *parent,
556  const QList<KGlobalShortcutInfo> &shortcuts,
557  const QKeySequence &seq)
558 {
559  if (shortcuts.isEmpty()) {
560  // Usage error. Just say no
561  return false;
562  }
563 
564  QString component = shortcuts[0].componentFriendlyName();
565 
566  QString message;
567  if (shortcuts.size()==1) {
568  message = i18n("The '%1' key combination is registered by application %2 for action %3:",
569  seq.toString(),
570  component,
571  shortcuts[0].friendlyName());
572  } else {
573  QString actionList;
574  Q_FOREACH(const KGlobalShortcutInfo &info, shortcuts) {
575  actionList += i18n("In context '%1' for action '%2'\n",
576  info.contextFriendlyName(),
577  info.friendlyName());
578  }
579  message = i18n("The '%1' key combination is registered by application %2.\n%3",
580  seq.toString(),
581  component,
582  actionList);
583  }
584 
585  QString title = i18n("Conflict With Registered Global Shortcut");
586 
587  return KMessageBox::warningContinueCancel(parent, message, title, KGuiItem(i18n("Reassign")))
588  == KMessageBox::Continue;
589 }
590 
591 
592 //static
593 void KGlobalAccel::stealShortcutSystemwide(const QKeySequence &seq)
594 {
595  //get the shortcut, remove seq, and set the new shortcut
596  const QStringList actionId = self()->d->iface.action(seq[0]);
597  if (actionId.size() < 4) // not a global shortcut
598  return;
599  QList<int> sc = self()->d->iface.shortcut(actionId);
600 
601  for (int i = 0; i < sc.count(); i++)
602  if (sc[i] == seq[0])
603  sc[i] = 0;
604 
605  self()->d->iface.setForeignShortcut(actionId, sc);
606 }
607 
608 #include "kglobalaccel.moc"
609 
QAction::text
text
message
void message(KMessage::MessageType messageType, const QString &text, const QString &caption=QString())
i18n
QString i18n(const char *text)
QWidget
KStandardAction::cut
KAction * cut(const QObject *recvr, const char *slot, QObject *parent)
Cut selected area and store it in the clipboard.
Definition: kstandardaction.cpp:294
QString::append
QString & append(QChar ch)
KMessageBox::Continue
Definition: kmessagebox.h:74
kdebug.h
QDBusReply
QDBusConnection::interface
QDBusConnectionInterface * interface() const
K_GLOBAL_STATIC
#define K_GLOBAL_STATIC(TYPE, NAME)
QList::at
const T & at(int i) const
QDBusError::name
QString name() const
KDE_NO_DEPRECATED
#define KDE_NO_DEPRECATED
KGlobalShortcutInfo
Definition: kglobalshortcutinfo.h:35
KStandardAction::name
const char * name(StandardAction id)
This will return the internal name of a given standard action.
Definition: kstandardaction.cpp:223
KGlobalAccel::cleanComponent
static bool cleanComponent(const QString &componentUnique)
Clean the shortcuts for component componentUnique.
Definition: kglobalaccel.cpp:181
kError
static QDebug kError(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
kshortcut.h
Defines platform-independent classes for keyboard shortcut handling.
QDBusConnection
QDBusReply::isValid
bool isValid() const
QDBusConnection::sessionBus
QDBusConnection sessionBus()
KComponentData::aboutData
const KAboutData * aboutData() const
KAction::globalShortcut
KShortcut globalShortcut
Definition: kaction.h:222
KAction::DefaultShortcut
The shortcut is a default shortcut - it becomes active when somebody decides to reset shortcuts to de...
Definition: kaction.h:238
QDBusConnectionInterface::isServiceRegistered
QDBusReply< bool > isServiceRegistered(const QString &serviceName) const
ktoolinvocation.h
kDebug
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
QX11Info::setAppTime
void setAppTime(unsigned long time)
KGlobalAccel::isEnabled
bool isEnabled() const
No effect.
Definition: kglobalaccel.cpp:201
KGlobalAccel::ComponentUnique
Components Unique Name (ID)
Definition: kglobalaccel.h:57
QList::size
int size() const
QAction::trigger
void trigger()
QX11Info::appTime
unsigned long appTime()
KShortcut
Represents a keyboard shortcut.
Definition: kshortcut.h:57
NET::timestampCompare
static int timestampCompare(unsigned long time1, unsigned long time2)
Compares two X timestamps, taking into account wrapping and 64bit architectures.
Definition: netwm.cpp:4735
KToolInvocation::startServiceByDesktopPath
static int startServiceByDesktopPath(const QString &_name, const QString &URL, QString *error=0, QString *serviceName=0, int *pid=0, const QByteArray &startup_id=QByteArray(), bool noWait=false)
QList::count
int count(const T &value) const
QList::append
void append(const T &value)
KStandardGuiItem::remove
KGuiItem remove()
Returns the 'Remove' gui item.
Definition: kstandardguiitem.cpp:289
QObject::property
QVariant property(const char *name) const
QDBusReply::value
Type value() const
KGuiItem
An abstract class for GUI data such as ToolTip and Icon.
Definition: kguiitem.h:36
QX11Info::appUserTime
unsigned long appUserTime()
QDBusConnectionInterface
QList::isEmpty
bool isEmpty() const
QObject::objectName
objectName
QString::isEmpty
bool isEmpty() const
QSet
KComponentData::componentName
QString componentName() const
QString
QList< int >
KGlobalAccel::ActionUnique
Actions Unique Name(ID)
Definition: kglobalaccel.h:58
QStringList
KGlobalAccel::findActionNameSystemwide
static QStringList findActionNameSystemwide(const QKeySequence &seq)
Definition: kglobalaccel.cpp:513
kaction.h
KAction::Autoloading
Look up the action in global settings (using its main component's name and text()) and set the shortc...
Definition: kaction.h:251
KShortcut::alternate
QKeySequence alternate() const
Returns the alternate key sequence of this shortcut.
Definition: kshortcut.cpp:139
KGlobalShortcutInfo::friendlyName
QString friendlyName
Definition: kglobalshortcutinfo.h:42
KGlobal::locale
KLocale * locale()
KLocale::removeAcceleratorMarker
QString removeAcceleratorMarker(const QString &label) const
KAboutData::programName
QString programName() const
KGlobalAccel::getGlobalShortcutsByKey
static QList< KGlobalShortcutInfo > getGlobalShortcutsByKey(const QKeySequence &seq)
Returns a list of global shortcuts registered for the shortcut .
Definition: kglobalaccel.cpp:520
KGlobalAccel::self
static KGlobalAccel * self()
Returns (and creates if necessary) the singleton instance.
Definition: kglobalaccel.cpp:231
KGlobalAccel::overrideMainComponentData
void overrideMainComponentData(const KComponentData &componentData)
Set the KComponentData for which to manipulate shortcuts.
Definition: kglobalaccel.cpp:223
KAction::ActiveShortcut
The shortcut will immediately become active but may be reset to "default".
Definition: kaction.h:235
QKeySequence::toString
QString toString(SequenceFormat format) const
QLatin1String
KShortcut::setAlternate
void setAlternate(const QKeySequence &keySeq)
Set the alternate key sequence of this shortcut to the given key sequence.
Definition: kshortcut.cpp:189
QKeySequence
KGlobalAccel::ActionFriendly
Actions Friendly Translated Name.
Definition: kglobalaccel.h:60
KGlobalAccel::activateGlobalShortcutContext
static void activateGlobalShortcutContext(const QString &contextUnique, const QString &contextFriendly, const KComponentData &component=KGlobal::mainComponent())
Set global shortcut context.
Definition: kglobalaccel.cpp:169
KGlobalShortcutInfo::contextFriendlyName
QString contextFriendlyName
Definition: kglobalshortcutinfo.h:48
KAction
Class to encapsulate user-driven action or event.
Definition: kaction.h:216
QList::last
T & last()
QList::removeLast
void removeLast()
mainComponent
const KComponentData & mainComponent()
KGlobal::hasMainComponent
bool hasMainComponent()
KGlobalAccel::setEnabled
void setEnabled(bool enabled)
No effect.
Definition: kglobalaccel.cpp:215
netwm_def.h
QVariant::toBool
bool toBool() const
KShortcut::setPrimary
void setPrimary(const QKeySequence &keySeq)
Set the primary key sequence of this shortcut to the given key sequence.
Definition: kshortcut.cpp:184
KGlobalAccel::promptStealShortcutSystemwide
static bool promptStealShortcutSystemwide(QWidget *parent, const QList< KGlobalShortcutInfo > &shortcuts, const QKeySequence &seq)
Show a messagebox to inform the user that a global shorcut is already occupied, and ask to take it aw...
Definition: kglobalaccel.cpp:554
kaboutdata.h
kglobalaccel.h
QDBusConnection::lastError
QDBusError lastError() const
KShortcut::primary
QKeySequence primary() const
Returns the primary key sequence of this shortcut.
Definition: kshortcut.cpp:134
QSet::clear
void clear()
kcomponentdata.h
kmessagebox.h
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
KGlobalAccel::stealShortcutSystemwide
static void stealShortcutSystemwide(const QKeySequence &seq)
Take away the given shortcut from the named action it belongs to.
Definition: kglobalaccel.cpp:593
KGlobalAccel::isComponentActive
static bool isComponentActive(const QString &componentName)
Check if component is active.
Definition: kglobalaccel.cpp:191
QDBusReply::error
const QDBusError & error()
KGlobalAccel::isGlobalShortcutAvailable
static bool isGlobalShortcutAvailable(const QKeySequence &seq, const QString &component=QString())
Check if the shortcut is available for the component.
Definition: kglobalaccel.cpp:526
KMessageBox::warningContinueCancel
static int warningContinueCancel(QWidget *parent, const QString &text, const QString &caption=QString(), const KGuiItem &buttonContinue=KStandardGuiItem::cont(), const KGuiItem &buttonCancel=KStandardGuiItem::cancel(), const QString &dontAskAgainName=QString(), Options options=Notify)
Display a "warning" dialog.
Definition: kmessagebox.cpp:644
QX11Info::setAppUserTime
void setAppUserTime(unsigned long time)
KGlobalAccel::ComponentFriendly
Components Friendly Translated Name.
Definition: kglobalaccel.h:59
KGlobalAccel
Configurable global shortcut support.
Definition: kglobalaccel.h:46
KAction::NoAutoloading
Prevent autoloading of saved global shortcut for action.
Definition: kaction.h:253
KComponentData
QAction::isEnabled
bool isEnabled() const
QDBusServiceWatcher
KGlobalAccel::allActionsForComponent
QList< QStringList > allActionsForComponent(const QStringList &actionId)
Definition: kglobalaccel.cpp:504
KGlobalAccel::allMainComponents
QList< QStringList > allMainComponents()
Return the unique and common names of all main components that have global shortcuts.
Definition: kglobalaccel.cpp:496
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal