1 /* Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
3 This library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Library General Public
5 License as published by the Free Software Foundation; either
6 version 2 of the License, or (at your option) any later version.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #include "dbus_action_widget.h"
21 #include <KDE/KMessageBox>
24 DbusActionWidget::DbusActionWidget(
25 KHotKeys::DBusAction
*action
,
27 : Base(action
, parent
)
32 ui
.application
, SIGNAL(textChanged(QString
)),
33 _changedSignals
, SLOT(map()) );
34 _changedSignals
->setMapping(ui
.application
, "application" );
36 ui
.object
, SIGNAL(textChanged(QString
)),
37 _changedSignals
, SLOT(map()) );
38 _changedSignals
->setMapping(ui
.object
, "object" );
40 ui
.function
, SIGNAL(textChanged(QString
)),
41 _changedSignals
, SLOT(map()) );
42 _changedSignals
->setMapping(ui
.function
, "function" );
44 ui
.arguments
, SIGNAL(textChanged(QString
)),
45 _changedSignals
, SLOT(map()) );
46 _changedSignals
->setMapping(ui
.arguments
, "arguments" );
49 ui
.launchButton
, SIGNAL(clicked()),
50 this, SLOT(launchDbusBrowser()) );
52 ui
.execButton
, SIGNAL(clicked()),
53 this, SLOT(execCommand()) );
57 DbusActionWidget::~DbusActionWidget()
62 KHotKeys::DBusAction
*DbusActionWidget::action()
64 return static_cast<KHotKeys::DBusAction
*>(_action
);
68 const KHotKeys::DBusAction
*DbusActionWidget::action() const
70 return static_cast<const KHotKeys::DBusAction
*>(_action
);
74 void DbusActionWidget::doCopyFromObject()
77 ui
.application
->setText( action()->remote_application() );
78 ui
.object
->setText( action()->remote_object() );
79 ui
.function
->setText( action()->called_function() );
80 ui
.arguments
->setText( action()->arguments() );
84 void DbusActionWidget::doCopyToObject()
87 action()->set_remote_application( ui
.application
->text() );
88 action()->set_remote_object( ui
.object
->text() );
89 action()->set_called_function( ui
.function
->text() );
90 action()->set_arguments( ui
.arguments
->text() );
94 void DbusActionWidget::execCommand() const
96 KHotKeys::DBusAction
action(
98 ui
.application
->text(),
101 ui
.arguments
->text() );
103 // TODO: Error handling
108 bool DbusActionWidget::isChanged() const
111 return ui
.application
->text() != action()->remote_application()
112 || ui
.object
->text() != action()->remote_object()
113 || ui
.function
->text() != action()->called_function()
114 || ui
.arguments
->text() != action()->arguments();
118 void DbusActionWidget::launchDbusBrowser() const
120 if( KRun::runCommand( "qdbusviewer", window()) == 0 )
122 KMessageBox::sorry( window(), i18n( "Failed to run qdbusviewer" ));
127 #include "moc_dbus_action_widget.cpp"