add more spacing
[personal-kdebase.git] / workspace / khotkeys / libkhotkeysprivate / triggers / gesture_trigger.cpp
bloba60cedf8ea76c4456a9a5a4b036757e350db6f9d
1 /*
2 Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
3 Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include "triggers/triggers.h"
21 #include "action_data/action_data.h"
22 #include "triggers/gestures.h"
23 #include "windows.h"
25 #include <KDE/KConfigGroup>
26 #include <KDE/KDebug>
28 namespace KHotKeys {
31 GestureTrigger::GestureTrigger( ActionData* data_P, const QString &gesturecode_P )
32 : Trigger( data_P ), _gesturecode( gesturecode_P )
37 GestureTrigger::GestureTrigger( KConfigGroup& cfg_P, ActionData* data_P )
38 : Trigger( cfg_P, data_P )
40 _gesturecode = cfg_P.readEntry( "Gesture" );
44 GestureTrigger::~GestureTrigger()
46 gesture_handler->unregister_handler( this, SLOT( handle_gesture( const QString&, WId )));
50 void GestureTrigger::activate( bool activate_P )
52 if( activate_P )
53 gesture_handler->register_handler( this, SLOT( handle_gesture( const QString&, WId )));
54 else
55 gesture_handler->unregister_handler( this, SLOT( handle_gesture( const QString&, WId )));
59 void GestureTrigger::cfg_write( KConfigGroup& cfg_P ) const
61 base::cfg_write( cfg_P );
62 cfg_P.writeEntry( "Gesture", gesturecode());
63 cfg_P.writeEntry( "Type", "GESTURE" ); // overwrites value set in base::cfg_write()
67 Trigger* GestureTrigger::copy( ActionData* data_P ) const
69 kDebug() << "GestureTrigger::copy()";
70 return new GestureTrigger( data_P ? data_P : data, gesturecode());
74 const QString GestureTrigger::description() const
76 return i18n( "Gesture trigger: " ) + gesturecode();
80 const QString& GestureTrigger::gesturecode() const
82 return _gesturecode;
86 void GestureTrigger::handle_gesture( const QString &gesture_P, WId window_P )
88 if( gesturecode() == gesture_P )
90 windows_handler->set_action_window( window_P );
91 data->execute();
96 } // namespace KHotKeys