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

KDEUI

  • 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
24class KShortcutWidgetPrivate
25{
26public:
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
41KShortcutWidget::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
54KShortcutWidget::~KShortcutWidget()
55{
56 delete d;
57}
58
59
60void KShortcutWidget::setModifierlessAllowed(bool allow)
61{
62 d->ui.priEditor->setModifierlessAllowed(allow);
63 d->ui.altEditor->setModifierlessAllowed(allow);
64}
65
66
67bool KShortcutWidget::isModifierlessAllowed()
68{
69 return d->ui.priEditor->isModifierlessAllowed();
70}
71
72
73void KShortcutWidget::setClearButtonsShown(bool show)
74{
75 d->ui.priEditor->setClearButtonShown(show);
76 d->ui.altEditor->setClearButtonShown(show);
77}
78
79
80KShortcut 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
89void KShortcutWidget::setCheckActionList(const QList<QAction*> &checkList)
90{
91 d->ui.priEditor->setCheckActionList(checkList);
92 d->ui.altEditor->setCheckActionList(checkList);
93}
94#endif
95
96void KShortcutWidget::setCheckActionCollections(const QList<KActionCollection *>& actionCollections)
97{
98 d->ui.priEditor->setCheckActionCollections(actionCollections);
99 d->ui.altEditor->setCheckActionCollections(actionCollections);
100}
101
102//slot
103void KShortcutWidget::applyStealShortcut()
104{
105 d->ui.priEditor->applyStealShortcut();
106 d->ui.altEditor->applyStealShortcut();
107}
108
109
110//slot
111void 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
126void KShortcutWidget::clearShortcut()
127{
128 setShortcut(KShortcut());
129}
130
131
132//private slot
133void KShortcutWidgetPrivate::priKeySequenceChanged(const QKeySequence &seq)
134{
135 cut.setPrimary(seq);
136 if (!holdChangedSignal)
137 emit q->shortcutChanged(cut);
138}
139
140
141//private slot
142void 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
Definition: kshortcutwidget.h:32
KShortcutWidget::setCheckActionCollections
void setCheckActionCollections(const QList< KActionCollection * > &actionCollections)
Set a list of action collections to check against for conflictuous shortcut.
Definition: kshortcutwidget.cpp:96
KShortcutWidget::shortcutChanged
void shortcutChanged(const KShortcut &cut)
KShortcutWidget::KShortcutWidget
KShortcutWidget(QWidget *parent=0)
Definition: kshortcutwidget.cpp:41
KShortcutWidget::setShortcut
void setShortcut(const KShortcut &cut)
Definition: kshortcutwidget.cpp:111
KShortcutWidget::clearShortcut
void clearShortcut()
Definition: kshortcutwidget.cpp:126
KShortcutWidget::setClearButtonsShown
void setClearButtonsShown(bool show)
Definition: kshortcutwidget.cpp:73
KShortcutWidget::shortcut
KShortcut shortcut() const
Definition: kshortcutwidget.cpp:80
KShortcutWidget::setCheckActionList
void setCheckActionList(const QList< QAction * > &checkList)
Definition: kshortcutwidget.cpp:89
KShortcutWidget::~KShortcutWidget
~KShortcutWidget()
Definition: kshortcutwidget.cpp:54
KShortcutWidget::setModifierlessAllowed
void setModifierlessAllowed(bool allow)
Definition: kshortcutwidget.cpp:60
KShortcutWidget::isModifierlessAllowed
bool isModifierlessAllowed()
Definition: kshortcutwidget.cpp:67
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
KShortcut
Represents a keyboard shortcut.
Definition: kshortcut.h:58
KShortcut::setPrimary
void setPrimary(const QKeySequence &keySeq)
Set the primary key sequence of this shortcut to the given key sequence.
Definition: kshortcut.cpp:184
KShortcut::primary
QKeySequence primary() const
Returns the primary key sequence of this shortcut.
Definition: kshortcut.cpp:134
KShortcut::setAlternate
void setAlternate(const QKeySequence &keySeq)
Set the alternate key sequence of this shortcut to the given key sequence.
Definition: kshortcut.cpp:189
KShortcut::alternate
QKeySequence alternate() const
Returns the alternate key sequence of this shortcut.
Definition: kshortcut.cpp:139
QList
QWidget
kiconloader.h
kshortcutwidget.h
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
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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