mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
kdeui: check the filter pointer before using it in KGlobalAccel
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
e19f1d01f5
commit
9a996146af
1 changed files with 50 additions and 39 deletions
|
@ -201,22 +201,24 @@ KGlobalAccelPrivate::~KGlobalAccelPrivate()
|
||||||
|
|
||||||
bool KGlobalAccelPrivate::doRegister(KAction *action)
|
bool KGlobalAccelPrivate::doRegister(KAction *action)
|
||||||
{
|
{
|
||||||
const QKeySequence keysequence = action->globalShortcut();
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
for (int i = 0; i < keysequence.count(); i++) {
|
if (filter) {
|
||||||
uint keyModX = 0;
|
const QKeySequence keysequence = action->globalShortcut();
|
||||||
int keyCodeX = 0;
|
for (int i = 0; i < keysequence.count(); i++) {
|
||||||
if (kGrabKey(keysequence[i], keyModX, keyCodeX)) {
|
uint keyModX = 0;
|
||||||
KGlobalAccelStruct shortcut;
|
int keyCodeX = 0;
|
||||||
shortcut.action = action;
|
if (kGrabKey(keysequence[i], keyModX, keyCodeX)) {
|
||||||
shortcut.keyModX = keyModX;
|
KGlobalAccelStruct shortcut;
|
||||||
shortcut.keyCodeX = keyCodeX;
|
shortcut.action = action;
|
||||||
filter->shortcuts.append(shortcut);
|
shortcut.keyModX = keyModX;
|
||||||
kDebug(s_kglobalaccelarea) << "grabbed shortcut" << shortcut.keyModX << shortcut.keyCodeX;
|
shortcut.keyCodeX = keyCodeX;
|
||||||
// grabbed one, that is success
|
filter->shortcuts.append(shortcut);
|
||||||
result = true;
|
kDebug(s_kglobalaccelarea) << "grabbed shortcut" << shortcut.keyModX << shortcut.keyCodeX;
|
||||||
} else {
|
// grabbed one, that is success
|
||||||
kWarning(s_kglobalaccelarea) << "could not grab shortcut" << keysequence[i] << action;
|
result = true;
|
||||||
|
} else {
|
||||||
|
kWarning(s_kglobalaccelarea) << "could not grab shortcut" << keysequence[i] << action;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -226,17 +228,19 @@ bool KGlobalAccelPrivate::remove(KAction *action)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
QMutableListIterator<KGlobalAccelStruct> iter(filter->shortcuts);
|
if (filter) {
|
||||||
while (iter.hasNext()) {
|
QMutableListIterator<KGlobalAccelStruct> iter(filter->shortcuts);
|
||||||
const KGlobalAccelStruct shortcut = iter.next();
|
while (iter.hasNext()) {
|
||||||
if (shortcut.action == action) {
|
const KGlobalAccelStruct shortcut = iter.next();
|
||||||
found = true;
|
if (shortcut.action == action) {
|
||||||
if (kUngrabKey(shortcut.keyModX, shortcut.keyCodeX)) {
|
found = true;
|
||||||
kDebug(s_kglobalaccelarea) << "ungrabbed shortcut" << shortcut.keyModX << shortcut.keyCodeX;
|
if (kUngrabKey(shortcut.keyModX, shortcut.keyCodeX)) {
|
||||||
iter.remove();
|
kDebug(s_kglobalaccelarea) << "ungrabbed shortcut" << shortcut.keyModX << shortcut.keyCodeX;
|
||||||
result = true;
|
iter.remove();
|
||||||
} else {
|
result = true;
|
||||||
kWarning(s_kglobalaccelarea) << "could not ungrab shortcut" << shortcut.keyModX << shortcut.keyCodeX;
|
} else {
|
||||||
|
kWarning(s_kglobalaccelarea) << "could not ungrab shortcut" << shortcut.keyModX << shortcut.keyCodeX;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -262,13 +266,15 @@ KGlobalAccel* KGlobalAccel::self()
|
||||||
QList<KGlobalShortcutInfo> KGlobalAccel::getGlobalShortcutsByKey(const QKeySequence &seq)
|
QList<KGlobalShortcutInfo> KGlobalAccel::getGlobalShortcutsByKey(const QKeySequence &seq)
|
||||||
{
|
{
|
||||||
QList<KGlobalShortcutInfo> result;
|
QList<KGlobalShortcutInfo> result;
|
||||||
foreach (const KGlobalAccelStruct &shortcut, d->filter->shortcuts) {
|
if (d->filter) {
|
||||||
if (shortcut.action->globalShortcut().matches(seq) != QKeySequence::NoMatch) {
|
foreach (const KGlobalAccelStruct &shortcut, d->filter->shortcuts) {
|
||||||
KGlobalShortcutInfo globalshortcutinfo;
|
if (shortcut.action->globalShortcut().matches(seq) != QKeySequence::NoMatch) {
|
||||||
globalshortcutinfo.componentFriendlyName = shortcut.action->d->componentData.aboutData()->programName();
|
KGlobalShortcutInfo globalshortcutinfo;
|
||||||
globalshortcutinfo.friendlyName = KGlobal::locale()->removeAcceleratorMarker(shortcut.action->text());
|
globalshortcutinfo.componentFriendlyName = shortcut.action->d->componentData.aboutData()->programName();
|
||||||
globalshortcutinfo.contextFriendlyName = shortcut.action->objectName();
|
globalshortcutinfo.friendlyName = KGlobal::locale()->removeAcceleratorMarker(shortcut.action->text());
|
||||||
result.append(globalshortcutinfo);
|
globalshortcutinfo.contextFriendlyName = shortcut.action->objectName();
|
||||||
|
result.append(globalshortcutinfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -276,12 +282,14 @@ QList<KGlobalShortcutInfo> KGlobalAccel::getGlobalShortcutsByKey(const QKeySeque
|
||||||
|
|
||||||
bool KGlobalAccel::isGlobalShortcutAvailable(const QKeySequence &seq, const QAction *exception)
|
bool KGlobalAccel::isGlobalShortcutAvailable(const QKeySequence &seq, const QAction *exception)
|
||||||
{
|
{
|
||||||
foreach (const KGlobalAccelStruct &shortcut, d->filter->shortcuts) {
|
if (d->filter) {
|
||||||
if (shortcut.action == exception) {
|
foreach (const KGlobalAccelStruct &shortcut, d->filter->shortcuts) {
|
||||||
continue;
|
if (shortcut.action == exception) {
|
||||||
}
|
continue;
|
||||||
if (shortcut.action->globalShortcut().matches(seq) != QKeySequence::NoMatch) {
|
}
|
||||||
return false;
|
if (shortcut.action->globalShortcut().matches(seq) != QKeySequence::NoMatch) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -289,6 +297,9 @@ bool KGlobalAccel::isGlobalShortcutAvailable(const QKeySequence &seq, const QAct
|
||||||
|
|
||||||
void KGlobalAccel::stealShortcutSystemwide(const QKeySequence &seq, const QAction *exception)
|
void KGlobalAccel::stealShortcutSystemwide(const QKeySequence &seq, const QAction *exception)
|
||||||
{
|
{
|
||||||
|
if (!d->filter) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
foreach (const KGlobalAccelStruct &shortcut, d->filter->shortcuts) {
|
foreach (const KGlobalAccelStruct &shortcut, d->filter->shortcuts) {
|
||||||
if (shortcut.action == exception) {
|
if (shortcut.action == exception) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Reference in a new issue