[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwin
Subject:    Re: [PATCH] bugs #182873 & 251297 - "window shortcut dialog"
From:       Thomas =?utf-8?q?L=C3=BCbking?= <thomas.luebking () web ! de>
Date:       2010-09-15 19:42:15
Message-ID: 201009152142.15385.thomas.luebking () web ! de
[Download RAW message or body]

Am Wednesday 15 September 2010 schrieben Sie:
> On Wednesday 15 September 2010 21:07:59 Thomas Lübking wrote:
> > (there's a workaround that should actually be fixed in kdeui -
> > KKeySequenceWidget needs a focusproxy for its pushbutton)
> 
> If possible, please fix this in kdeui, instead of adding a workaround.
ewww... i forsee me blowing up things...
ok, it's just a oneliner - should be safe ;-)

-> attached


["fix_182873_and_251297.diff" (text/x-patch)]

Index: kdelibs/kdeui/widgets/kkeysequencewidget.cpp
===================================================================
--- kdelibs/kdeui/widgets/kkeysequencewidget.cpp	(Revision 1175748)
+++ kdelibs/kdeui/widgets/kkeysequencewidget.cpp	(Arbeitskopie)
@@ -291,6 +291,7 @@
    d(new KKeySequenceWidgetPrivate(this))
 {
     d->init();
+    setFocusProxy( d->keyButton );
     connect(d->keyButton, SIGNAL(clicked()), this, SLOT(captureKeySequence()));
     connect(d->clearButton, SIGNAL(clicked()), this, SLOT(clearKeySequence()));
     connect(&d->modifierlessTimeout, SIGNAL(timeout()), this, \
                SLOT(doneRecording()));
Index: kdebase/workspace/kwin/utils.cpp
===================================================================
--- kdebase/workspace/kwin/utils.cpp	(Revision 1175747)
+++ kdebase/workspace/kwin/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,13 @@
         widget, SIGNAL(keySequenceChanged(const QKeySequence&)),
         SLOT(keySequenceChanged(const QKeySequence&)));
 
-    setMainWidget( widget );
+    setMainWidget( wstack );
+    // NOTICE KKeySequenceWidget is broken and need to set a focus proxy.
+    widget->setFocus();
+//     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 +505,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;
     }
 
Index: kdebase/workspace/kwin/utils.h
===================================================================
--- kdebase/workspace/kwin/utils.h	(Revision 1175747)
+++ kdebase/workspace/kwin/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



_______________________________________________
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