From ae0bac5c42c4fd1c907962da917dcda3d16fd3aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 30 Jun 2009 19:11:02 +0000 Subject: [PATCH] New mode for present windows effect: selecting all windows of same class as active window. svn path=/trunk/KDE/kdebase/workspace/; revision=989722 --- effects/presentwindows/presentwindows.cpp | 25 +++++++++++++++++++ effects/presentwindows/presentwindows.h | 7 +++++- .../presentwindows/presentwindows_config.cpp | 5 ++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/effects/presentwindows/presentwindows.cpp b/effects/presentwindows/presentwindows.cpp index 89d2ae40fe..894ba34a51 100644 --- a/effects/presentwindows/presentwindows.cpp +++ b/effects/presentwindows/presentwindows.cpp @@ -84,6 +84,12 @@ PresentWindowsEffect::PresentWindowsEffect() shortcutAll = b->globalShortcut(); connect( b, SIGNAL( triggered(bool) ), this, SLOT( toggleActiveAllDesktops() )); connect( b, SIGNAL( globalShortcutChanged(QKeySequence) ), this, SLOT( globalShortcutChangedAll(QKeySequence))); + KAction* c = ( KAction* )actionCollection->addAction( "ExposeClass" ); + c->setText( i18n( "Toggle Present Windows (Window class)" )); + c->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F7 )); + connect( c, SIGNAL( triggered(bool) ), this, SLOT( toggleActiveClass() )); + connect( c, SIGNAL( globalShortcutChanged(QKeySequence) ), this, SLOT( globalShortcutChangedClass(QKeySequence))); + shortcutClass = c->globalShortcut(); reconfigure( ReconfigureAll ); } @@ -154,6 +160,13 @@ const void* PresentWindowsEffect::proxy() const return &m_proxy; } +void PresentWindowsEffect::toggleActiveClass() +{ + m_mode = ModeWindowClass; + m_class = effects->activeWindow()->windowClass(); + setActive( !m_activated ); +} + //----------------------------------------------------------------------------- // Screen painting @@ -522,6 +535,11 @@ void PresentWindowsEffect::grabbedKeyboardEvent( QKeyEvent *e ) toggleActiveAllDesktops(); return; } + if( m_mode == ModeWindowClass && shortcutClass.contains( e->key() + e->modifiers() ) ) + { + toggleActiveClass(); + return; + } switch( e->key() ) { // Wrap only if not auto-repeating @@ -1556,6 +1574,8 @@ bool PresentWindowsEffect::isSelectableWindow( EffectWindow *w ) return w->isOnDesktop( m_desktop ); case ModeWindowGroup: return m_selectedWindows.contains( w ); + case ModeWindowClass: + return m_class == w->windowClass(); } if( !m_tabBoxEnabled && m_ignoreMinimized && w->isMinimized() ) return false; @@ -1776,6 +1796,11 @@ void PresentWindowsEffect::globalShortcutChangedAll( const QKeySequence& seq ) shortcutAll = KShortcut( seq ); } +void PresentWindowsEffect::globalShortcutChangedClass( const QKeySequence& seq ) + { + shortcutClass = KShortcut( seq ); + } + } // namespace #include "presentwindows.moc" diff --git a/effects/presentwindows/presentwindows.h b/effects/presentwindows/presentwindows.h index 8a7d9dae82..60b726986e 100644 --- a/effects/presentwindows/presentwindows.h +++ b/effects/presentwindows/presentwindows.h @@ -95,7 +95,8 @@ class PresentWindowsEffect ModeAllDesktops, // Shows windows of all desktops ModeCurrentDesktop, // Shows windows on current desktop ModeSelectedDesktop, // Shows windows of selected desktop via property (m_desktop) - ModeWindowGroup // Shows windows selected via property + ModeWindowGroup, // Shows windows selected via property + ModeWindowClass // Shows all windows of same class as selected class }; enum WindowMouseAction { @@ -119,11 +120,13 @@ class PresentWindowsEffect void setActive( bool active, bool closingTab = false ); // HACK: closingTab shouldn't be needed void toggleActive() { m_mode = ModeCurrentDesktop; setActive( !m_activated ); } void toggleActiveAllDesktops() { m_mode = ModeAllDesktops; setActive( !m_activated ); } + void toggleActiveClass(); // slots for global shortcut changed // needed to toggle the effect void globalShortcutChanged( const QKeySequence& seq ); void globalShortcutChangedAll( const QKeySequence& seq ); + void globalShortcutChangedClass( const QKeySequence& seq ); protected: // Window rearranging @@ -184,6 +187,7 @@ class PresentWindowsEffect int m_desktop; EffectWindowList m_selectedWindows; EffectWindow *m_managerWindow; + QString m_class; // Window data WindowMotionManager m_motionManager; @@ -200,6 +204,7 @@ class PresentWindowsEffect // Shortcut - needed to toggle the effect KShortcut shortcut; KShortcut shortcutAll; + KShortcut shortcutClass; // Atoms // Present windows for all windows of given desktop diff --git a/effects/presentwindows/presentwindows_config.cpp b/effects/presentwindows/presentwindows_config.cpp index 136313a927..35783cf3ad 100644 --- a/effects/presentwindows/presentwindows_config.cpp +++ b/effects/presentwindows/presentwindows_config.cpp @@ -64,6 +64,11 @@ PresentWindowsEffectConfig::PresentWindowsEffectConfig(QWidget* parent, const QV b->setProperty( "isConfigurationAction", true ); b->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F9 )); + KAction* c = ( KAction* )m_actionCollection->addAction( "ExposeClass" ); + c->setText( i18n( "Toggle Present Windows (Window class)" )); + c->setProperty( "isConfigurationAction", true ); + c->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F7 )); + m_ui->shortcutEditor->addCollection( m_actionCollection ); connect( m_ui->layoutCombo, SIGNAL( currentIndexChanged( int )), this, SLOT( changed() ));