~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to khotkeys/libkhotkeysprivate/triggers/voice_trigger.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
 
3
   Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
 
4
 
 
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.
 
8
 
 
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.
 
13
 
 
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.
 
18
*/
 
19
 
 
20
#include "triggers.h"
 
21
#include "action_data.h"
 
22
#include "voices.h"
 
23
#include "windows.h"
 
24
 
 
25
#include <KDE/KConfigGroup>
 
26
#include <KDE/KDebug>
 
27
 
 
28
namespace KHotKeys {
 
29
 
 
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 )
 
32
    {
 
33
    _voicesignature[0]=signature1_P;
 
34
    _voicesignature[1]=signature2_P;
 
35
    }
 
36
 
 
37
Voice_trigger::Voice_trigger( KConfigGroup& cfg_P, ActionData* data_P )
 
38
    : Trigger( cfg_P, data_P )
 
39
    {
 
40
    _voicecode = cfg_P.readEntry( "Name" );
 
41
    _voicesignature[0].read( cfg_P , "Signature1" );
 
42
    _voicesignature[1].read( cfg_P , "Signature2" );
 
43
    }
 
44
 
 
45
Voice_trigger::~Voice_trigger()
 
46
    {
 
47
    voice_handler->unregister_handler( this );
 
48
    }
 
49
 
 
50
void Voice_trigger::cfg_write( KConfigGroup& cfg_P ) const
 
51
    {
 
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" );
 
57
    }
 
58
 
 
59
Trigger* Voice_trigger::copy( ActionData* data_P ) const
 
60
    {
 
61
    kDebug() << "Voice_trigger::copy()";
 
62
    return new Voice_trigger( data_P ? data_P : data, voicecode(), voicesignature(1) , voicesignature(2) );
 
63
    }
 
64
 
 
65
const QString Voice_trigger::description() const
 
66
    {
 
67
    return i18n( "Voice trigger: " ) + voicecode();
 
68
    }
 
69
 
 
70
void Voice_trigger::handle_Voice(  )
 
71
    {
 
72
        windows_handler->set_action_window( 0 ); // use active window
 
73
        data->execute();
 
74
 
 
75
    }
 
76
 
 
77
void Voice_trigger::activate( bool activate_P )
 
78
    {
 
79
    if( activate_P && khotkeys_active())
 
80
        voice_handler->register_handler( this );
 
81
    else
 
82
        voice_handler->unregister_handler( this );
 
83
    }
 
84
 
 
85
} // namespace KHotKeys
 
86