add more spacing
[personal-kdebase.git] / workspace / khotkeys / kcm_hotkeys / actions / menuentry_action_widget.cpp
blob6871e27ef83877f183fff473df3183132a05ac85
1 /*
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"
22 #include <KDE/KDebug>
23 #include <KDE/KOpenWithDialog>
27 MenuentryActionWidget::MenuentryActionWidget( KHotKeys::MenuEntryAction *action, QWidget *parent )
28 : ActionWidgetBase(action, parent )
30 ui.setupUi(this);
32 connect(
33 ui.applicationButton, SIGNAL(clicked()),
34 this, SLOT(selectApplicationClicked()) );
36 connect(
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()
63 Q_ASSERT(action());
64 KService::Ptr service = action()->service();
66 if (service)
68 ui.application->setText( service->name() );
70 else
72 ui.application->setText("");
77 void MenuentryActionWidget::doCopyToObject()
79 Q_ASSERT(action());
81 action()->set_service( KService::serviceByName( ui.application->text() ));
85 bool MenuentryActionWidget::isChanged() const
87 Q_ASSERT(action());
89 bool changed;
91 // There could be no service set, so be careful!
92 if (action()->service())
94 changed = ui.application->text() != action()->service()->name();
96 else
98 // No service set. If the string is not empty something changed.
99 changed = ! ui.application->text().isEmpty();
102 return changed;
106 void MenuentryActionWidget::selectApplicationClicked()
108 KOpenWithDialog dlg;
109 dlg.exec();
111 KService::Ptr service = dlg.service();
113 if (service)
115 ui.application->setText( service->name() );
120 #include "moc_menuentry_action_widget.cpp"