• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • sources
  • kde-4.12
  • kdelibs
  • kdeui
  • widgets
kshortcutwidget.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2007 Andreas Hartmetz <ahartmetz@gmail.com>
3 
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.
8 
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.
13 
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.
18 */
19 
20 #include "kshortcutwidget.h"
21 #include "kiconloader.h"
22 #include "ui_kshortcutwidget.h"
23 
24 class KShortcutWidgetPrivate
25 {
26 public:
27  KShortcutWidgetPrivate(KShortcutWidget *q) : q(q) {}
28 
29 //private slots
30  void priKeySequenceChanged(const QKeySequence &);
31  void altKeySequenceChanged(const QKeySequence &);
32 
33 //members
34  KShortcutWidget *const q;
35  Ui::KShortcutWidget ui;
36  KShortcut cut;
37  bool holdChangedSignal;
38 };
39 
40 
41 KShortcutWidget::KShortcutWidget(QWidget *parent)
42  : QWidget(parent),
43  d(new KShortcutWidgetPrivate(this))
44 {
45  d->holdChangedSignal = false;
46  d->ui.setupUi(this);
47  connect(d->ui.priEditor, SIGNAL(keySequenceChanged(QKeySequence)),
48  this, SLOT(priKeySequenceChanged(QKeySequence)));
49  connect(d->ui.altEditor, SIGNAL(keySequenceChanged(QKeySequence)),
50  this, SLOT(altKeySequenceChanged(QKeySequence)));
51 }
52 
53 
54 KShortcutWidget::~KShortcutWidget()
55 {
56  delete d;
57 }
58 
59 
60 void KShortcutWidget::setModifierlessAllowed(bool allow)
61 {
62  d->ui.priEditor->setModifierlessAllowed(allow);
63  d->ui.altEditor->setModifierlessAllowed(allow);
64 }
65 
66 
67 bool KShortcutWidget::isModifierlessAllowed()
68 {
69  return d->ui.priEditor->isModifierlessAllowed();
70 }
71 
72 
73 void KShortcutWidget::setClearButtonsShown(bool show)
74 {
75  d->ui.priEditor->setClearButtonShown(show);
76  d->ui.altEditor->setClearButtonShown(show);
77 }
78 
79 
80 KShortcut KShortcutWidget::shortcut() const
81 {
82  KShortcut ret;
83  ret.setPrimary(d->ui.priEditor->keySequence());
84  ret.setAlternate(d->ui.altEditor->keySequence());
85  return ret;
86 }
87 
88 #ifndef KDE_NO_DEPRECATED
89 void KShortcutWidget::setCheckActionList(const QList<QAction*> &checkList)
90 {
91  d->ui.priEditor->setCheckActionList(checkList);
92  d->ui.altEditor->setCheckActionList(checkList);
93 }
94 #endif
95 
96 void KShortcutWidget::setCheckActionCollections(const QList<KActionCollection *>& actionCollections)
97 {
98  d->ui.priEditor->setCheckActionCollections(actionCollections);
99  d->ui.altEditor->setCheckActionCollections(actionCollections);
100 }
101 
102 //slot
103 void KShortcutWidget::applyStealShortcut()
104 {
105  d->ui.priEditor->applyStealShortcut();
106  d->ui.altEditor->applyStealShortcut();
107 }
108 
109 
110 //slot
111 void KShortcutWidget::setShortcut(const KShortcut &newSc)
112 {
113  if (newSc == d->cut)
114  return;
115 
116  d->holdChangedSignal = true;
117  d->ui.priEditor->setKeySequence(newSc.primary());
118  d->ui.altEditor->setKeySequence(newSc.alternate());
119  d->holdChangedSignal = false;
120 
121  emit shortcutChanged(d->cut);
122 }
123 
124 
125 //slot
126 void KShortcutWidget::clearShortcut()
127 {
128  setShortcut(KShortcut());
129 }
130 
131 
132 //private slot
133 void KShortcutWidgetPrivate::priKeySequenceChanged(const QKeySequence &seq)
134 {
135  cut.setPrimary(seq);
136  if (!holdChangedSignal)
137  emit q->shortcutChanged(cut);
138 }
139 
140 
141 //private slot
142 void KShortcutWidgetPrivate::altKeySequenceChanged(const QKeySequence &seq)
143 {
144  cut.setAlternate(seq);
145  if (!holdChangedSignal)
146  emit q->shortcutChanged(cut);
147 }
148 
149 #include "kshortcutwidget.moc"
KShortcutWidget::~KShortcutWidget
~KShortcutWidget()
Definition: kshortcutwidget.cpp:54
KStandardAction::cut
KAction * cut(const QObject *recvr, const char *slot, QObject *parent)
Cut selected area and store it in the clipboard.
Definition: kstandardaction.cpp:294
QWidget
KShortcutWidget
Definition: kshortcutwidget.h:31
KShortcutWidget::setClearButtonsShown
void setClearButtonsShown(bool show)
Definition: kshortcutwidget.cpp:73
kiconloader.h
KShortcutWidget::clearShortcut
void clearShortcut()
Definition: kshortcutwidget.cpp:126
KShortcutWidget::isModifierlessAllowed
bool isModifierlessAllowed()
Definition: kshortcutwidget.cpp:67
KShortcut
Represents a keyboard shortcut.
Definition: kshortcut.h:57
KShortcutWidget::KShortcutWidget
KShortcutWidget(QWidget *parent=0)
Definition: kshortcutwidget.cpp:41
kshortcutwidget.h
KShortcut::alternate
QKeySequence alternate() const
Returns the alternate key sequence of this shortcut.
Definition: kshortcut.cpp:139
KShortcutWidget::applyStealShortcut
void applyStealShortcut()
Actually remove the shortcut that the user wanted to steal, from the action that was using it...
Definition: kshortcutwidget.cpp:103
KShortcutWidget::setCheckActionList
void setCheckActionList(const QList< QAction * > &checkList)
Definition: kshortcutwidget.cpp:89
KShortcut::setAlternate
void setAlternate(const QKeySequence &keySeq)
Set the alternate key sequence of this shortcut to the given key sequence.
Definition: kshortcut.cpp:189
KShortcutWidget::setCheckActionCollections
void setCheckActionCollections(const QList< KActionCollection * > &actionCollections)
Set a list of action collections to check against for conflictuous shortcut.
Definition: kshortcutwidget.cpp:96
KShortcut::setPrimary
void setPrimary(const QKeySequence &keySeq)
Set the primary key sequence of this shortcut to the given key sequence.
Definition: kshortcut.cpp:184
KShortcutWidget::setModifierlessAllowed
void setModifierlessAllowed(bool allow)
Definition: kshortcutwidget.cpp:60
KShortcutWidget::shortcutChanged
void shortcutChanged(const KShortcut &cut)
KShortcut::primary
QKeySequence primary() const
Returns the primary key sequence of this shortcut.
Definition: kshortcut.cpp:134
KShortcutWidget::setShortcut
void setShortcut(const KShortcut &cut)
Definition: kshortcutwidget.cpp:111
QList< QAction * >
KShortcutWidget::shortcut
KShortcut shortcut() const
Definition: kshortcutwidget.cpp:80
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:15 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal