2
* Copyright (C) 2000 Matthias Elter <elter@kde.org>
3
* Lubos Lunak <l.lunak@email.cz>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
#include "khotkeys_interface.h"
26
#include "kmessagebox.h"
28
static bool khotkeys_present = false;
29
static bool khotkeys_inited = false;
30
static OrgKdeKhotkeysInterface *khotkeysInterface = NULL;
35
khotkeys_inited = true;
37
// Check if khotkeys is running
38
QDBusConnection bus = QDBusConnection::sessionBus();
39
khotkeysInterface = new OrgKdeKhotkeysInterface(
46
if(!khotkeysInterface->isValid())
48
err = khotkeysInterface->lastError();
51
kError() << err.name() << ":" << err.message();
55
"<qt>" + i18n("Unable to contact khotkeys. Your changes are saved, but they could not be activated.") + "</qt>" );
58
khotkeys_present = khotkeysInterface->isValid();
62
void KHotKeys::cleanup()
64
if( khotkeys_inited && khotkeys_present ) {
67
khotkeys_inited = false;
70
bool KHotKeys::present()
72
if( !khotkeys_inited )
74
return khotkeys_present;
77
QString KHotKeys::getMenuEntryShortcut( const QString& entry_P )
81
if( !khotkeys_inited )
84
if( !khotkeys_present || !khotkeysInterface->isValid())
87
QDBusReply<QString> reply = khotkeysInterface->get_menuentry_shortcut(entry_P);
88
if (!reply.isValid()) {
89
kError() << reply.error();
97
QString KHotKeys::changeMenuEntryShortcut(
98
const QString& entry_P,
99
const QString shortcut_P )
103
if( !khotkeys_inited )
106
if( !khotkeys_present || !khotkeysInterface->isValid())
109
QDBusReply<QString> reply = khotkeysInterface->register_menuentry_shortcut(
113
if (!reply.isValid()) {
114
kError() << reply.error();