add more spacing
[personal-kdebase.git] / workspace / khotkeys / kcm_hotkeys / triggers / shortcut_trigger_widget.cpp
blob7736203a4f04acf312ad12d561b8d751fc1860c3
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 "shortcut_trigger_widget.h"
22 #include "action_data/action_data.h"
23 #include "triggers/triggers.h"
25 #include <QtGui/QKeySequence>
27 #include <KDE/KDebug>
30 ShortcutTriggerWidget::ShortcutTriggerWidget( KHotKeys::ShortcutTrigger *trigger, QWidget *parent )
31 : TriggerWidgetBase(trigger, parent)
33 shortcut_action_ui.setupUi(this);
35 shortcut_action_ui.shortcut->setCheckForConflictsAgainst(
36 // Don't know why that is necessary but it doesn't compile
37 // without.
38 KKeySequenceWidget::ShortcutTypes(
39 KKeySequenceWidget::GlobalShortcuts
40 | KKeySequenceWidget::StandardShortcuts ));
42 connect(
43 shortcut_action_ui.shortcut, SIGNAL(keySequenceChanged(QKeySequence)),
44 _changedSignals, SLOT(map()) );
45 _changedSignals->setMapping(shortcut_action_ui.shortcut, "shortcut" );
47 // If the global shortcuts is changed outside of the dialog just copy the
48 // new key sequencence. It doesn't matter if the user changed the sequence
49 // here.
50 connect(
51 trigger, SIGNAL(globalShortcutChanged(const QKeySequence&)),
52 this, SLOT(_k_globalShortcutChanged(const QKeySequence&)) );
54 copyFromObject();
58 ShortcutTriggerWidget::~ShortcutTriggerWidget()
63 KHotKeys::ShortcutTrigger *ShortcutTriggerWidget::trigger()
65 return static_cast<KHotKeys::ShortcutTrigger*>(_trigger);
69 const KHotKeys::ShortcutTrigger *ShortcutTriggerWidget::trigger() const
71 return static_cast<const KHotKeys::ShortcutTrigger*>(_trigger);
75 void ShortcutTriggerWidget::doCopyFromObject()
77 Q_ASSERT(trigger());
78 shortcut_action_ui.shortcut->setKeySequence( trigger()->shortcut().primary() );
82 void ShortcutTriggerWidget::doCopyToObject()
84 Q_ASSERT(trigger());
85 trigger()->set_key_sequence( shortcut_action_ui.shortcut->keySequence());
89 bool ShortcutTriggerWidget::isChanged() const
91 Q_ASSERT(trigger());
92 return trigger()->shortcut().primary() != shortcut_action_ui.shortcut->keySequence();
96 void ShortcutTriggerWidget::_k_globalShortcutChanged(const QKeySequence &seq)
98 shortcut_action_ui.shortcut->setKeySequence(seq);
102 #include "moc_shortcut_trigger_widget.cpp"