From kwin Wed Oct 06 16:56:17 2010 From: Thomas =?utf-8?q?L=C3=BCbking?= Date: Wed, 06 Oct 2010 16:56:17 +0000 To: kwin Subject: [BUMP] [PATCH] bugs #182873 & 251297 - "window shortcut dialog" Message-Id: <201010061856.18104.thomas.luebking () web ! de> X-MARC-Message: https://marc.info/?l=kwin&m=128638453116048 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_yoKrM4TT6arh/8I" --Boundary-00=_yoKrM4TT6arh/8I Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The patch has the extension to the shortcutwidget as well as the fixes by setting the focus "correctly" and yell a warning.... --Boundary-00=_yoKrM4TT6arh/8I Content-Type: text/x-patch; charset="utf-8"; name="fix_182873_and_251297.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fix_182873_and_251297.diff" 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 #ifndef KCMRULES - +#include +#include #include #include #include #include +#include #include #include +#include #include #include @@ -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 btns = widget->findChildren(); +// 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 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("%1 is already in use").arg(sc)); + warning->setToolTip(i18n("%1 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 #include #include @@ -364,6 +366,7 @@ private: KKeySequenceWidget* widget; QKeySequence _shortcut; + QLabel *warning; }; #endif //KCMRULES --Boundary-00=_yoKrM4TT6arh/8I Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kwin mailing list kwin@kde.org https://mail.kde.org/mailman/listinfo/kwin --Boundary-00=_yoKrM4TT6arh/8I--