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.
22 #include <KDE/KConfigGroup>
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
52 const_cast<MenuEntryAction
*>(this)->_service
= KService::serviceByStorageId(command_url());
58 void MenuEntryAction::set_service( KService::Ptr service
)
62 set_command_url(service
->storageId());
66 void MenuEntryAction::execute()
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
87 return i18n( "Menu entry: " ) + (_service
? _service
->comment() : QString());
91 } // namespace KHotKeys