1 /****************************************************************************
5 Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
7 Distributed under the terms of the GNU General Public License version 2.
9 ****************************************************************************/
11 #define _KHOTKEYSGLOBAL_CPP_
13 #include "khotkeysglobal.h"
16 #include <kstandarddirs.h>
17 #include <klibloader.h>
21 #include "triggers/triggers.h"
22 #include "triggers/gestures.h"
24 #include "shortcuts_handler.h"
27 // #include "soundrecorder.h"
32 QPointer
<ShortcutsHandler
> keyboard_handler
= NULL
;
33 QPointer
<Windows
> windows_handler
= NULL
;
35 static bool _khotkeys_active
= false;
37 void init_global_data( bool active_P
, QObject
* owner_P
)
39 // FIXME: get rid of that static_cast<>s. Don't know why they are there.
40 // Make these singletons.
41 if (!keyboard_handler
)
43 keyboard_handler
= new ShortcutsHandler( active_P
? ShortcutsHandler::Active
: ShortcutsHandler::Configuration
, owner_P
);
47 windows_handler
= new Windows( active_P
, owner_P
);
51 gesture_handler
= new Gesture( active_P
, owner_P
);
54 // static_cast< void >( new Voice( active_P, owner_P ));
55 khotkeys_set_active( false );
58 void khotkeys_set_active( bool active_P
)
60 _khotkeys_active
= active_P
;
63 bool khotkeys_active()
65 return _khotkeys_active
;
68 // does the opposite of KStandardDirs::findResource() i.e. e.g.
69 // "/opt/kde2/share/applnk/System/konsole.desktop" -> "System/konsole.desktop"
70 QString
get_menu_entry_from_path( const QString
& path_P
)
72 const QStringList dirs
= KGlobal::dirs()->resourceDirs( "apps" );
73 for( QStringList::ConstIterator it
= dirs
.constBegin();
74 it
!= dirs
.constEnd();
76 if( path_P
.indexOf( *it
) == 0 )
79 ret
.remove( 0, (*it
).length());
87 static int have_arts
= -1;
97 KLibrary
* arts
= KLibLoader::self()->library( QLatin1String("khotkeys_arts") );
99 kDebug() << "Couldn't load khotkeys_arts:" << KLibLoader::self()->lastErrorMessage();
100 if( arts
!= NULL
&& SoundRecorder::init( arts
))
103 return have_arts
!= 0;
112 } // namespace KHotKeys