add more spacing
[personal-kdebase.git] / workspace / khotkeys / libkhotkeysprivate / actions / menuentry_action.cpp
blob3e580dba042bba3c1c4104c1f853ba171f6c7eba
1 /*
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.
20 #include "actions.h"
22 #include <KDE/KConfigGroup>
23 #include <KDE/KDebug>
24 #include <KDE/KUrl>
25 #include <KDE/KRun>
27 namespace KHotKeys {
29 MenuEntryAction::MenuEntryAction( ActionData* data_P, const QString& menuentry_P )
30 : CommandUrlAction( data_P, menuentry_P )
35 MenuEntryAction::MenuEntryAction( KConfigGroup& cfg_P, ActionData* data_P )
36 : CommandUrlAction( cfg_P, data_P )
41 void MenuEntryAction::cfg_write( KConfigGroup& cfg_P ) const
43 base::cfg_write( cfg_P );
44 cfg_P.writeEntry( "Type", "MENUENTRY" ); // overwrites value set in base::cfg_write()
48 KService::Ptr MenuEntryAction::service() const
50 if (!_service)
52 const_cast<MenuEntryAction *>(this)->_service = KService::serviceByStorageId(command_url());
54 return _service;
58 void MenuEntryAction::set_service( KService::Ptr service )
60 if (!service) return;
61 _service = service;
62 set_command_url(service->storageId());
66 void MenuEntryAction::execute()
68 (void) service();
69 if (!_service)
70 return;
71 kDebug() << "Starting service " << _service->desktopEntryName();
72 KRun::run( *_service, KUrl::List(), 0 );
73 timeout.setSingleShot( true );
74 timeout.start( 1000 ); // 1sec timeout
78 Action* MenuEntryAction::copy( ActionData* data_P ) const
80 return new MenuEntryAction( data_P, command_url());
84 const QString MenuEntryAction::description() const
86 (void) service();
87 return i18n( "Menu entry: " ) + (_service ? _service->comment() : QString());
91 } // namespace KHotKeys