[prev in list] [next in list] [prev in thread] [next in thread]
List: kwin
Subject: [PATCH] bugs #182873 & 251297 - "window shortcut dialog"
From: Thomas =?iso-8859-1?q?L=FCbking?= <thomas.luebking () web ! de>
Date: 2010-09-15 19:07:59
Message-ID: 201009152107.59373.thomas.luebking () web ! de
[Download RAW message or body]
attached. comments? commit?
(there's a workaround that should actually be fixed in kdeui -
KKeySequenceWidget needs a focusproxy for its pushbutton)
Thomas
["fix_182873_and_251297.diff" (text/x-patch)]
Index: utils.h
===================================================================
--- utils.h (Revision 1174321)
+++ utils.h (Arbeitskopie)
@@ -22,6 +22,8 @@
#ifndef KWIN_UTILS_H
#define KWIN_UTILS_H
+class QLabel;
+
#include <config-workspace.h>
#include <config-X11.h>
#include <config-kwin.h>
@@ -364,6 +366,7 @@
private:
KKeySequenceWidget* widget;
QKeySequence _shortcut;
+ QLabel *warning;
};
#endif //KCMRULES
Index: utils.cpp
===================================================================
--- utils.cpp (Revision 1174321)
+++ utils.cpp (Arbeitskopie)
@@ -30,13 +30,16 @@
#include <unistd.h>
#ifndef KCMRULES
-
+#include <QLabel>
+#include <QVBoxLayout>
#include <kxerrorhandler.h>
#include <assert.h>
#include <kdebug.h>
#include <kglobalaccel.h>
+#include <klocale.h>
#include <kshortcut.h>
#include <kkeyserver.h>
+#include <KPushButton>
#include <X11/Xlib.h>
#include <X11/extensions/shape.h>
@@ -438,9 +441,13 @@
#ifndef KCMRULES
ShortcutDialog::ShortcutDialog( const QKeySequence& cut )
- : widget( new KKeySequenceWidget( this ))
- ,_shortcut(cut)
+ : _shortcut(cut)
{
+ QWidget *wstack = new QWidget( this );
+ wstack->setLayout( new QVBoxLayout( wstack ) );
+ wstack->layout()->addWidget( widget = new KKeySequenceWidget( wstack ) );
+ wstack->layout()->addWidget( warning = new QLabel( wstack ) );
+ warning->hide();
widget->setKeySequence( cut );
// To not check for conflicting shortcuts. The widget would use a message
@@ -454,7 +461,12 @@
widget, SIGNAL(keySequenceChanged(const QKeySequence&)),
SLOT(keySequenceChanged(const QKeySequence&)));
- setMainWidget( widget );
+ setMainWidget( wstack );
+ // NOTICE KKeySequenceWidget is broken and need to set a focus proxy.
+ QList<QPushButton*> btns = widget->findChildren<QPushButton*>();
+ if (!btns.isEmpty())
+ btns.at(0)->setFocus();
+ //--
// make it a popup, so that it has the grab
XSetWindowAttributes attrs;
@@ -492,13 +504,29 @@
void ShortcutDialog::keySequenceChanged(const QKeySequence &seq)
{
+ activateWindow(); // where is the kbd focus lost? cause of popup state?
+ if (_shortcut == seq)
+ return; // don't try to update the same
+
// Check if the key sequence is used currently
+ QString sc = seq.toString();
+ // NOTICE - seq.toString() & the entries in "conflicting" randomly get \
invalidated after the next call (if no sc has been set & conflicting \
isn't empty?!)
QList<KGlobalShortcutInfo> conflicting = \
KGlobalAccel::getGlobalShortcutsByKey(seq);
- if (!conflicting.isEmpty()) {
- kDebug(1212) << "TODO: Display conflicting shortcuts to user";
- // TODO: Inform the user somehow instead of just ignoring his wish
+ if (!conflicting.isEmpty())
+ {
+ const KGlobalShortcutInfo &conflict = conflicting.at(0);
+ warning->setText(i18n("<b>%1</b> is already in use").arg(sc));
+ warning->setToolTip(i18n("<b>%1</b> is used by %2 in \
%3").arg(sc).arg(conflict.friendlyName()).arg(conflict.componentFriendlyName())); + \
warning->show(); widget->setKeySequence(shortcut());
}
+ else if (seq != _shortcut)
+ {
+ warning->hide();
+ if ( KPushButton *ok = button( KDialog::Ok ) )
+ ok->setFocus();
+ }
+
_shortcut = seq;
}
_______________________________________________
kwin mailing list
kwin@kde.org
https://mail.kde.org/mailman/listinfo/kwin
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic