not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / khotkeys / libkhotkeysprivate / khotkeysglobal.cpp
blob2d1921d54da91c89a7b42947b607ca7d69979685
1 /****************************************************************************
3 KHotKeys
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"
15 #include <kdebug.h>
16 #include <kstandarddirs.h>
17 #include <klibloader.h>
19 #include "input.h"
20 #include "windows.h"
21 #include "triggers/triggers.h"
22 #include "triggers/gestures.h"
23 #include "voices.h"
24 #include "shortcuts_handler.h"
26 // FIXME: SOUND
27 // #include "soundrecorder.h"
29 namespace KHotKeys
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 );
45 if (!windows_handler)
47 windows_handler = new Windows( active_P, owner_P );
49 if (!gesture_handler)
51 gesture_handler = new Gesture( active_P, owner_P );
53 // FIXME: SOUND
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();
75 ++it )
76 if( path_P.indexOf( *it ) == 0 )
78 QString ret = path_P;
79 ret.remove( 0, (*it).length());
80 if( ret[ 0 ] == '/' )
81 ret.remove( 0, 1 );
82 return ret;
84 return path_P;
87 static int have_arts = -1;
89 bool haveArts()
91 return false;
92 // FIXME: SOUND
93 #if 0
94 if( have_arts == -1 )
96 have_arts = 0;
97 KLibrary* arts = KLibLoader::self()->library( QLatin1String("khotkeys_arts") );
98 if( arts == NULL )
99 kDebug() << "Couldn't load khotkeys_arts:" << KLibLoader::self()->lastErrorMessage();
100 if( arts != NULL && SoundRecorder::init( arts ))
101 have_arts = 1;
103 return have_arts != 0;
104 #endif
107 void disableArts()
109 have_arts = 0;
112 } // namespace KHotKeys