not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / khotkeys / libkhotkeysprivate / triggers / voice_trigger.cpp
blobfb61abf71aba175c07b4a115e90f7e39f43c13d7
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.h"
21 #include "action_data.h"
22 #include "voices.h"
23 #include "windows.h"
25 #include <KDE/KConfigGroup>
26 #include <KDE/KDebug>
28 namespace KHotKeys {
30 Voice_trigger::Voice_trigger( ActionData* data_P, const QString &Voicecode_P, const VoiceSignature& signature1_P, const VoiceSignature& signature2_P )
31 : Trigger( data_P ), _voicecode( Voicecode_P )
33 _voicesignature[0]=signature1_P;
34 _voicesignature[1]=signature2_P;
37 Voice_trigger::Voice_trigger( KConfigGroup& cfg_P, ActionData* data_P )
38 : Trigger( cfg_P, data_P )
40 _voicecode = cfg_P.readEntry( "Name" );
41 _voicesignature[0].read( cfg_P , "Signature1" );
42 _voicesignature[1].read( cfg_P , "Signature2" );
45 Voice_trigger::~Voice_trigger()
47 voice_handler->unregister_handler( this );
50 void Voice_trigger::cfg_write( KConfigGroup& cfg_P ) const
52 base::cfg_write( cfg_P );
53 cfg_P.writeEntry( "Name", voicecode());
54 cfg_P.writeEntry( "Type", "VOICE" ); // overwrites value set in base::cfg_write()
55 _voicesignature[0].write( cfg_P , "Signature1" );
56 _voicesignature[1].write( cfg_P , "Signature2" );
59 Trigger* Voice_trigger::copy( ActionData* data_P ) const
61 kDebug() << "Voice_trigger::copy()";
62 return new Voice_trigger( data_P ? data_P : data, voicecode(), voicesignature(1) , voicesignature(2) );
65 const QString Voice_trigger::description() const
67 return i18n( "Voice trigger: " ) + voicecode();
70 void Voice_trigger::handle_Voice( )
72 windows_handler->set_action_window( 0 ); // use active window
73 data->execute();
77 void Voice_trigger::activate( bool activate_P )
79 if( activate_P && khotkeys_active())
80 voice_handler->register_handler( this );
81 else
82 voice_handler->unregister_handler( this );
85 } // namespace KHotKeys