add more spacing
[personal-kdebase.git] / workspace / khotkeys / libkhotkeysprivate / actions / activate_window_action.cpp
blob8f167659122db0003fff2226c775a8ba327db078
1 /*
2 Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #include "actions.h"
20 #include "windows.h"
22 #include <KDE/KConfigGroup>
24 // Has to be behind all qt related stuff. Else the build fails miserably
25 #include <X11/X.h>
27 namespace KHotKeys {
30 ActivateWindowAction::ActivateWindowAction( ActionData* data_P,
31 const Windowdef_list* window_P )
32 : Action( data_P ), _window( window_P )
37 ActivateWindowAction::ActivateWindowAction( KConfigGroup& cfg_P, ActionData* data_P )
38 : Action( cfg_P, data_P )
40 QString save_cfg_group = cfg_P.name();
41 KConfigGroup windowGroup( cfg_P.config(), save_cfg_group + "Window" );
42 _window = new Windowdef_list( windowGroup );
46 const Windowdef_list* ActivateWindowAction::window() const
48 return _window;
52 ActivateWindowAction::~ActivateWindowAction()
54 delete _window;
58 void ActivateWindowAction::cfg_write( KConfigGroup& cfg_P ) const
60 base::cfg_write( cfg_P );
61 cfg_P.writeEntry( "Type", "ACTIVATE_WINDOW" ); // overwrites value set in base::cfg_write()
62 KConfigGroup windowGroup( cfg_P.config(), cfg_P.name() + "Window" );
63 window()->cfg_write( windowGroup );
67 void ActivateWindowAction::execute()
69 if( window()->match( windows_handler->active_window()))
70 return; // is already active
71 WId win_id = windows_handler->find_window( window());
72 if( win_id != None )
73 windows_handler->activate_window( win_id );
77 const QString ActivateWindowAction::description() const
79 return i18n( "Activate window: " ) + window()->comment();
83 Action* ActivateWindowAction::copy( ActionData* data_P ) const
85 return new ActivateWindowAction( data_P, window()->copy());
88 } // namespace KHotKeys