add more spacing
[personal-kdebase.git] / workspace / khotkeys / kcm_hotkeys / simple_action_data_widget.cpp
bloba950bddca88a3e21c90c2de4cfcfd1433f3e70d7
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 "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"
27 #include <KDE/KDebug>
30 SimpleActionDataWidget::SimpleActionDataWidget( QWidget *parent )
31 : HotkeysWidgetBase( parent )
32 ,currentTrigger(0)
33 ,currentAction(0)
35 // We add ourself to the layout
36 QWidget *widget = new QWidget;
37 ui.setupUi(widget);
38 widget->layout()->setContentsMargins(0,0,0,0);
39 layout()->addWidget(widget);
43 SimpleActionDataWidget::~SimpleActionDataWidget()
45 delete currentTrigger;
46 delete currentAction;
50 bool SimpleActionDataWidget::isChanged() const
52 return ( currentTrigger && currentTrigger->isChanged() )
53 || ( currentAction && currentAction->isChanged() )
54 || Base::isChanged();
58 void SimpleActionDataWidget::doCopyFromObject()
60 Base::doCopyFromObject();
62 if (currentTrigger)
64 currentTrigger->copyFromObject();
67 if (currentAction)
69 currentAction->copyFromObject();
75 void SimpleActionDataWidget::doCopyToObject()
77 Base::doCopyToObject();
79 if (currentTrigger)
81 currentTrigger->copyToObject();
84 if (currentAction)
86 currentAction->copyToObject();
91 void SimpleActionDataWidget::setActionData( KHotKeys::SimpleActionData* pData )
93 _data = 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) );
104 break;
106 default:
107 kDebug() << "Unknown trigger type";
111 Q_ASSERT( ui.triggerBox->layout() );
112 if (currentTrigger )
114 connect(
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) );
129 break;
131 case KHotKeys::Action::DBusActionType:
132 currentAction = new DbusActionWidget( static_cast<KHotKeys::DBusAction*>(act) );
133 break;
135 case KHotKeys::Action::CommandUrlActionType:
136 currentAction = new CommandUrlActionWidget( static_cast<KHotKeys::CommandUrlAction*>(act) );
137 break;
139 default:
140 kDebug() << "Unknown action type";
144 Q_ASSERT( ui.actionBox->layout() );
145 if (currentAction )
147 connect(
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"