Use the new session shortcut feature for kwins "Window Shorcut" feature.

@Lubos: Please have a look at commit 863096 too. I accidently commited a
part of this part there. Please have a look at the todo "Add the window
title" and possibly implement it. That would look much nicer in the global
shortcuts kcm.

Btw. There are two shortcuts dialogs in kwin. I haven't change the other
one (kwinrules) because it look it works better with KKeySequenceWidget
doing the message box.

CCMAIL:l.lunak@kde.org

svn path=/trunk/KDE/kdebase/workspace/; revision=863292
This commit is contained in:
Michael Jansen 2008-09-21 18:03:59 +00:00
parent 2a6e11fc59
commit d6df278f49
2 changed files with 29 additions and 1 deletions

View file

@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kxerrorhandler.h> #include <kxerrorhandler.h>
#include <assert.h> #include <assert.h>
#include <kdebug.h> #include <kdebug.h>
#include <kglobalaccel.h>
#include <kshortcut.h> #include <kshortcut.h>
#include <kkeyserver.h> #include <kkeyserver.h>
@ -41,6 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <X11/extensions/shape.h> #include <X11/extensions/shape.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <QX11Info> #include <QX11Info>
#include <QtGui/QKeySequence>
#include <stdio.h> #include <stdio.h>
@ -408,9 +410,21 @@ bool isLocalMachine( const QByteArray& host )
#ifndef KCMRULES #ifndef KCMRULES
ShortcutDialog::ShortcutDialog( const QKeySequence& cut ) ShortcutDialog::ShortcutDialog( const QKeySequence& cut )
: widget( new KKeySequenceWidget( this )) : widget( new KKeySequenceWidget( this ))
,_shortcut(cut)
{ {
widget->setKeySequence( cut ); widget->setKeySequence( cut );
// To not check for conflicting shortcuts. The widget would use a message
// box which brings down kwin.
widget->setCheckForConflictsAgainst(KKeySequenceWidget::None);
// Listen to changed shortcuts
connect(
widget, SIGNAL(keySequenceChanged(const QKeySequence&)),
SLOT(keySequenceChanged(const QKeySequence&)));
setMainWidget( widget ); setMainWidget( widget );
// make it a popup, so that it has the grab // make it a popup, so that it has the grab
XSetWindowAttributes attrs; XSetWindowAttributes attrs;
attrs.override_redirect = True; attrs.override_redirect = True;
@ -445,9 +459,20 @@ void ShortcutDialog::done( int r )
emit dialogDone( r == Accepted ); emit dialogDone( r == Accepted );
} }
void ShortcutDialog::keySequenceChanged(const QKeySequence &seq)
{
// Check if the key sequence is used currently
QStringList conflicting = KGlobalAccel::findActionNameSystemwide(seq);
if (!conflicting.isEmpty()) {
// TODO: Inform the user somehow instead of just ignoring his wish
widget->setKeySequence(shortcut());
}
_shortcut = seq;
}
QKeySequence ShortcutDialog::shortcut() const QKeySequence ShortcutDialog::shortcut() const
{ {
return widget->keySequence(); return _shortcut;
} }
#endif //KCMRULES #endif //KCMRULES

View file

@ -326,12 +326,15 @@ class ShortcutDialog
ShortcutDialog( const QKeySequence& cut ); ShortcutDialog( const QKeySequence& cut );
virtual void accept(); virtual void accept();
QKeySequence shortcut() const; QKeySequence shortcut() const;
public Q_SLOTS:
void keySequenceChanged(const QKeySequence &seq);
signals: signals:
void dialogDone( bool ok ); void dialogDone( bool ok );
protected: protected:
virtual void done( int r ); virtual void done( int r );
private: private:
KKeySequenceWidget* widget; KKeySequenceWidget* widget;
QKeySequence _shortcut;
}; };
#endif //KCMRULES #endif //KCMRULES