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"
25
#include <KLocalizedString>
26
#include <KMessageBox>
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(
45
if(!khotkeysInterface->isValid()) {
46
QDBusError err = khotkeysInterface->lastError();
48
kError() << err.name() << ":" << err.message();
52
"<qt>" + i18n("Unable to contact khotkeys. Your changes are saved, but they could not be activated.") + "</qt>" );
55
khotkeys_present = khotkeysInterface->isValid();
59
void KHotKeys::cleanup()
61
if( khotkeys_inited && khotkeys_present ) {
65
khotkeys_inited = false;
68
bool KHotKeys::present()
70
if( !khotkeys_inited )
73
return khotkeys_present;
76
QString KHotKeys::getMenuEntryShortcut( const QString& entry_P )
78
if( !khotkeys_inited )
81
if( !khotkeys_present || !khotkeysInterface->isValid())
84
QDBusReply<QString> reply = khotkeysInterface->get_menuentry_shortcut(entry_P);
85
if (!reply.isValid()) {
86
kError() << reply.error();
94
QString KHotKeys::changeMenuEntryShortcut(
95
const QString& entry_P,
96
const QString shortcut_P )
98
if( !khotkeys_inited )
101
if( !khotkeys_present || !khotkeysInterface->isValid())
104
QDBusReply<QString> reply = khotkeysInterface->register_menuentry_shortcut(
108
if (!reply.isValid()) {
109
kError() << reply.error();