2 Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
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 "menuentry_action_widget.h"
23 #include <KDE/KOpenWithDialog>
27 MenuentryActionWidget::MenuentryActionWidget( KHotKeys::MenuEntryAction
*action
, QWidget
*parent
)
28 : ActionWidgetBase(action
, parent
)
33 ui
.applicationButton
, SIGNAL(clicked()),
34 this, SLOT(selectApplicationClicked()) );
37 ui
.application
, SIGNAL(textChanged(QString
)),
38 _changedSignals
, SLOT(map()) );
39 _changedSignals
->setMapping(ui
.application
, "application" );
43 MenuentryActionWidget::~MenuentryActionWidget()
47 KHotKeys::MenuEntryAction
*MenuentryActionWidget::action()
49 Q_ASSERT(dynamic_cast<KHotKeys::MenuEntryAction
*>(_action
));
50 return static_cast<KHotKeys::MenuEntryAction
*>(_action
);
54 const KHotKeys::MenuEntryAction
*MenuentryActionWidget::action() const
56 Q_ASSERT(dynamic_cast<KHotKeys::MenuEntryAction
*>(_action
));
57 return static_cast<const KHotKeys::MenuEntryAction
*>(_action
);
61 void MenuentryActionWidget::doCopyFromObject()
64 KService::Ptr service
= action()->service();
68 ui
.application
->setText( service
->name() );
72 ui
.application
->setText("");
77 void MenuentryActionWidget::doCopyToObject()
81 action()->set_service( KService::serviceByName( ui
.application
->text() ));
85 bool MenuentryActionWidget::isChanged() const
91 // There could be no service set, so be careful!
92 if (action()->service())
94 changed
= ui
.application
->text() != action()->service()->name();
98 // No service set. If the string is not empty something changed.
99 changed
= ! ui
.application
->text().isEmpty();
106 void MenuentryActionWidget::selectApplicationClicked()
111 KService::Ptr service
= dlg
.service();
115 ui
.application
->setText( service
->name() );
120 #include "moc_menuentry_action_widget.cpp"