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 "simple_action_data_widget.h"
22 #include "actions/command_url_action_widget.h"
23 #include "actions/dbus_action_widget.h"
24 #include "actions/menuentry_action_widget.h"
25 #include "triggers/shortcut_trigger_widget.h"
30 SimpleActionDataWidget::SimpleActionDataWidget( QWidget
*parent
)
31 : HotkeysWidgetBase( parent
)
35 // We add ourself to the layout
36 QWidget
*widget
= new QWidget
;
38 widget
->layout()->setContentsMargins(0,0,0,0);
39 layout()->addWidget(widget
);
43 SimpleActionDataWidget::~SimpleActionDataWidget()
45 delete currentTrigger
;
50 bool SimpleActionDataWidget::isChanged() const
52 return ( currentTrigger
&& currentTrigger
->isChanged() )
53 || ( currentAction
&& currentAction
->isChanged() )
58 void SimpleActionDataWidget::doCopyFromObject()
60 Base::doCopyFromObject();
64 currentTrigger
->copyFromObject();
69 currentAction
->copyFromObject();
75 void SimpleActionDataWidget::doCopyToObject()
77 Base::doCopyToObject();
81 currentTrigger
->copyToObject();
86 currentAction
->copyToObject();
91 void SimpleActionDataWidget::setActionData( KHotKeys::SimpleActionData
* pData
)
95 // Now go and work on the trigger
96 delete currentTrigger
; currentTrigger
= 0;
98 if ( KHotKeys::Trigger
*trg
= data()->trigger() )
100 switch ( trg
->type() )
102 case KHotKeys::Trigger::ShortcutTriggerType
:
103 currentTrigger
= new ShortcutTriggerWidget( static_cast<KHotKeys::ShortcutTrigger
*>(trg
) );
107 kDebug() << "Unknown trigger type";
111 Q_ASSERT( ui
.triggerBox
->layout() );
115 currentTrigger
, SIGNAL(changed(bool)),
116 this, SLOT(slotChanged() ));
117 ui
.triggerBox
->layout()->addWidget(currentTrigger
);
120 // Now go and work on the trigger
121 delete currentAction
; currentAction
= 0;
123 if ( KHotKeys::Action
*act
= data()->action() )
125 switch ( act
->type() )
127 case KHotKeys::Action::MenuEntryActionType
:
128 currentAction
= new MenuentryActionWidget( static_cast<KHotKeys::MenuEntryAction
*>(act
) );
131 case KHotKeys::Action::DBusActionType
:
132 currentAction
= new DbusActionWidget( static_cast<KHotKeys::DBusAction
*>(act
) );
135 case KHotKeys::Action::CommandUrlActionType
:
136 currentAction
= new CommandUrlActionWidget( static_cast<KHotKeys::CommandUrlAction
*>(act
) );
140 kDebug() << "Unknown action type";
144 Q_ASSERT( ui
.actionBox
->layout() );
148 currentAction
, SIGNAL(changed(bool)),
149 this, SLOT(slotChanged() ));
150 ui
.actionBox
->layout()->addWidget(currentAction
);
153 Base::copyFromObject();
158 #include "moc_simple_action_data_widget.cpp"