2
Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
3
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License version 2 as published by the Free Software Foundation.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
Boston, MA 02110-1301, USA.
21
#include "action_data/action_data.h"
23
#include <KDE/KConfigGroup>
25
#include <KDE/KMessageBox>
31
MenuEntryActionVisitor::~MenuEntryActionVisitor()
35
MenuEntryAction::MenuEntryAction( ActionData* data_P, const QString& menuentry_P )
36
: CommandUrlAction( data_P, menuentry_P )
41
void MenuEntryAction::accept(ActionVisitor& visitor)
43
if (MenuEntryActionVisitor *v = dynamic_cast<MenuEntryActionVisitor*>(&visitor))
49
kDebug() << "Visitor error";
54
void MenuEntryAction::cfg_write( KConfigGroup& cfg_P ) const
56
base::cfg_write( cfg_P );
57
cfg_P.writeEntry( "Type", "MENUENTRY" ); // overwrites value set in base::cfg_write()
61
KService::Ptr MenuEntryAction::service() const
65
const_cast<MenuEntryAction *>(this)->_service = KService::serviceByStorageId(command_url());
71
void MenuEntryAction::set_service( KService::Ptr service )
76
set_command_url(service->storageId());
80
set_command_url(QString());
85
void MenuEntryAction::execute()
91
i18n("No service configured."),
92
i18n("Input Action: %1", data->comment()));
96
if (!KRun::run( *service(), KUrl::List(), 0 ))
100
i18n("Failed to start service '%1'.", service()->name()),
101
i18n("Input Action: %1", data->comment()));
107
Action* MenuEntryAction::copy( ActionData* data_P ) const
109
return new MenuEntryAction( data_P, command_url());
113
const QString MenuEntryAction::description() const
115
return i18n( "Menu entry: " ) + (service() ? service()->comment() : QString());
119
} // namespace KHotKeys