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

« back to all changes in this revision

Viewing changes to khotkeys/libkhotkeysprivate/khotkeysglobal.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
 
 
3
 KHotKeys
 
4
 
 
5
 Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
 
6
 
 
7
 Distributed under the terms of the GNU General Public License version 2.
 
8
 
 
9
****************************************************************************/
 
10
 
 
11
#define _KHOTKEYSGLOBAL_CPP_
 
12
 
 
13
#include "khotkeysglobal.h"
 
14
 
 
15
#include <kdebug.h>
 
16
#include <kstandarddirs.h>
 
17
 
 
18
#include "input.h"
 
19
#include "windows_handler.h"
 
20
#include "triggers/triggers.h"
 
21
#include "triggers/gestures.h"
 
22
#include "voices.h"
 
23
#include "shortcuts_handler.h"
 
24
 
 
25
// FIXME: SOUND
 
26
// #include "soundrecorder.h"
 
27
 
 
28
namespace KHotKeys
 
29
{
 
30
 
 
31
QPointer<ShortcutsHandler> keyboard_handler = NULL;
 
32
QPointer<WindowsHandler> windows_handler = NULL;
 
33
 
 
34
static bool _khotkeys_active = false;
 
35
 
 
36
void init_global_data( bool active_P, QObject* owner_P )
 
37
    {
 
38
    // FIXME: get rid of that static_cast<>s. Don't know why they are there.
 
39
    // Make these singletons.
 
40
    if (!keyboard_handler)
 
41
        {
 
42
        keyboard_handler = new ShortcutsHandler( active_P ? ShortcutsHandler::Active : ShortcutsHandler::Configuration, owner_P );
 
43
        }
 
44
    if (!windows_handler)
 
45
        {
 
46
        windows_handler = new WindowsHandler( active_P, owner_P );
 
47
        }
 
48
    if (!gesture_handler)
 
49
        {
 
50
        gesture_handler = new Gesture( active_P, owner_P );
 
51
        }
 
52
// FIXME: SOUND
 
53
//    static_cast< void >( new Voice( active_P, owner_P ));
 
54
    khotkeys_set_active( false );
 
55
    }
 
56
    
 
57
void khotkeys_set_active( bool active_P )
 
58
    {
 
59
    _khotkeys_active = active_P;
 
60
    }
 
61
    
 
62
bool khotkeys_active()
 
63
    {
 
64
    return _khotkeys_active;
 
65
    }
 
66
    
 
67
// does the opposite of KStandardDirs::findResource() i.e. e.g.
 
68
// "/opt/kde2/share/applnk/System/konsole.desktop" -> "System/konsole.desktop"
 
69
QString get_menu_entry_from_path( const QString& path_P )
 
70
    {
 
71
    const QStringList dirs = KGlobal::dirs()->resourceDirs( "apps" );
 
72
    for( QStringList::ConstIterator it = dirs.constBegin();
 
73
         it != dirs.constEnd();
 
74
         ++it )
 
75
        if( path_P.indexOf( *it ) == 0 )
 
76
            {
 
77
            QString ret = path_P;
 
78
            ret.remove( 0, (*it).length());
 
79
            if( ret[ 0 ] == '/' )
 
80
                ret.remove( 0, 1 );
 
81
            return ret;
 
82
            }
 
83
    return path_P;
 
84
    }
 
85
 
 
86
} // namespace KHotKeys