KXmlGui

kshortcutseditor.cpp
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 1998 Mark Donohoe <[email protected]>
4  SPDX-FileCopyrightText: 1997 Nicolas Hadacek <[email protected]>
5  SPDX-FileCopyrightText: 1998 Matthias Ettrich <[email protected]>
6  SPDX-FileCopyrightText: 2001 Ellis Whitehead <[email protected]>
7  SPDX-FileCopyrightText: 2006 Hamish Rodda <[email protected]>
8  SPDX-FileCopyrightText: 2007 Roberto Raggi <[email protected]>
9  SPDX-FileCopyrightText: 2007 Andreas Hartmetz <[email protected]>
10  SPDX-FileCopyrightText: 2008 Michael Jansen <[email protected]>
11 
12  SPDX-License-Identifier: LGPL-2.0-or-later
13 */
14 
15 #include "config-xmlgui.h"
16 
17 #include "kshortcutseditor.h"
18 
19 // The following is needed for KShortcutsEditorPrivate and QTreeWidgetHack
20 #include "kshortcutsdialog_p.h"
21 #include "debug.h"
22 
23 #include <QAction>
24 #include <QHeaderView>
25 #include <QList>
26 #include <QObject>
27 #include <QTimer>
28 #include <QTextDocument>
29 #include <QTextTable>
30 #include <QTextCursor>
31 #include <QTextTableFormat>
32 #include <QPrinter>
33 #include <QPrintDialog>
34 
35 #include <kconfig.h>
36 #include <kconfiggroup.h>
37 #if HAVE_GLOBALACCEL
38 # include <kglobalaccel.h>
39 #endif
40 #include <kmessagebox.h>
41 #include "kactioncollection.h"
42 #include "kactioncategory.h"
43 #include <ktreewidgetsearchline.h>
44 
45 //---------------------------------------------------------------------
46 // KShortcutsEditor
47 //---------------------------------------------------------------------
48 
50  LetterShortcuts allowLetterShortcuts)
51  : QWidget(parent)
52  , d(new KShortcutsEditorPrivate(this))
53 {
54  d->initGUI(actionType, allowLetterShortcuts);
55  addCollection(collection);
56 }
57 
59  : QWidget(parent)
60  , d(new KShortcutsEditorPrivate(this))
61 {
62  d->initGUI(actionType, allowLetterShortcuts);
63 }
64 
66 
68 {
69  // Iterate over all items
71 
72  for (; (*it); ++it) {
73  KShortcutsEditorItem *item = dynamic_cast<KShortcutsEditorItem *>(*it);
74  if (item && item->isModified()) {
75  return true;
76  }
77  }
78  return false;
79 }
80 
82 {
83  d->delegate->contractAll();
84  d->ui.list->clear();
85  d->actionCollections.clear();
87 }
88 
90 {
91  // KXmlGui add action collections unconditionally. If some plugin doesn't
92  // provide actions we don't want to create empty subgroups.
93  if (collection->isEmpty()) {
94  return;
95  }
96 
97  // We add a bunch of items. Prevent the treewidget from permanently
98  // updating.
99  setUpdatesEnabled(false);
100 
101  d->actionCollections.append(collection);
102  // Forward our actionCollections to the delegate which does the conflict
103  // checking.
104  d->delegate->setCheckActionCollections(d->actionCollections);
105  QString displayTitle = title;
106  if (displayTitle.isEmpty()) {
107  // Use the programName (Translated).
108  displayTitle = collection->componentDisplayName();
109  }
110 
111  QTreeWidgetItem *hier[3];
112  hier[KShortcutsEditorPrivate::Root] = d->ui.list->invisibleRootItem();
113  hier[KShortcutsEditorPrivate::Program] = d->findOrMakeItem(hier[KShortcutsEditorPrivate::Root], displayTitle);
114  hier[KShortcutsEditorPrivate::Action] = nullptr;
115 
116  // Set to remember which actions we have seen.
117  QSet<QAction *> actionsSeen;
118 
119  // Add all categories in their own subtree below the collections root node
120  const QList<KActionCategory *> categories = collection->findChildren<KActionCategory *>();
121  for (KActionCategory *category : categories) {
122  hier[KShortcutsEditorPrivate::Action] = d->findOrMakeItem(hier[KShortcutsEditorPrivate::Program], category->text());
123  const auto categoryActions = category->actions();
124  for (QAction *action : categoryActions) {
125  // Set a marker that we have seen this action
126  actionsSeen.insert(action);
127  d->addAction(action, hier, KShortcutsEditorPrivate::Action);
128  }
129  }
130 
131  // The rest of the shortcuts is added as a direct shild of the action
132  // collections root node
133  const auto collectionActions = collection->actions();
134  for (QAction *action : collectionActions) {
135  if (actionsSeen.contains(action)) {
136  continue;
137  }
138 
139  d->addAction(action, hier, KShortcutsEditorPrivate::Program);
140  }
141 
142  // sort the list
143  d->ui.list->sortItems(Name, Qt::AscendingOrder);
144 
145  // reenable updating
146  setUpdatesEnabled(true);
147 
149 }
150 
152 {
153  d->clearConfiguration();
154 }
155 
156 #if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0)
158 {
159  d->importConfiguration(config);
160 }
161 #endif
162 
164 {
165  d->importConfiguration(config);
166 }
167 
168 #if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 0)
170 {
171  exportConfiguration(static_cast<KConfigBase *>(config));
172 }
173 #endif
174 
176 {
177  Q_ASSERT(config);
178  if (!config) {
179  return;
180  }
181 
182  if (d->actionTypes & KShortcutsEditor::GlobalAction) {
183  QString groupName(QStringLiteral("Global Shortcuts"));
184  KConfigGroup group(config, groupName);
185  for (KActionCollection *collection : qAsConst(d->actionCollections)) {
186  collection->exportGlobalShortcuts(&group, true);
187  }
188  }
189  if (d->actionTypes & ~KShortcutsEditor::GlobalAction) {
190  QString groupName(QStringLiteral("Shortcuts"));
191  KConfigGroup group(config, groupName);
192  for (KActionCollection *collection : qAsConst(d->actionCollections)) {
193  collection->writeSettings(&group, true);
194  }
195  }
196 }
197 
199 {
200  for (KActionCollection *collection : qAsConst(d->actionCollections)) {
201  collection->writeSettings(config);
202  }
203 }
204 
205 //slot
207 {
208  for (int i = 0; i < d->ui.list->columnCount(); i++) {
209  d->ui.list->resizeColumnToContents(i);
210  }
211 }
212 
214 {
215  for (QTreeWidgetItemIterator it(d->ui.list); (*it); ++it) {
216  if (KShortcutsEditorItem *item = dynamic_cast<KShortcutsEditorItem *>(*it)) {
217  item->commit();
218  }
219  }
220 }
221 
223 {
225  // we have to call commit. If we wouldn't do that the changes would be
226  // undone on deletion! That would lead to weird problems. Changes to
227  // Global Shortcuts would vanish completely. Changes to local shortcuts
228  // would vanish for this session.
229  commit();
230 }
231 
232 #if KXMLGUI_BUILD_DEPRECATED_SINCE(5, 75)
234 {
235  undo();
236 }
237 #endif
238 
240 {
241  //This function used to crash sometimes when invoked by clicking on "cancel"
242  //with Qt 4.2.something. Apparently items were deleted too early by Qt.
243  //It seems to work with 4.3-ish Qt versions. Keep an eye on this.
244  for (QTreeWidgetItemIterator it(d->ui.list); (*it); ++it) {
245  if (KShortcutsEditorItem *item = dynamic_cast<KShortcutsEditorItem *>(*it)) {
246  item->undo();
247  }
248  }
249 }
250 
251 //We ask the user here if there are any conflicts, as opposed to undo().
252 //They don't do the same thing anyway, this just not to confuse any readers.
253 //slot
255 {
256  d->allDefault();
257 }
258 
260 {
261  d->printShortcuts();
262 }
263 
265 {
266  return d->actionTypes;
267 }
268 
270 {
271  d->setActionTypes(actionTypes);
272 }
273 
274 //---------------------------------------------------------------------
275 // KShortcutsEditorPrivate
276 //---------------------------------------------------------------------
277 
278 KShortcutsEditorPrivate::KShortcutsEditorPrivate(KShortcutsEditor *q)
279  : q(q),
280  delegate(nullptr)
281 {}
282 
283 void KShortcutsEditorPrivate::initGUI(KShortcutsEditor::ActionTypes types, KShortcutsEditor::LetterShortcuts allowLetterShortcuts)
284 {
285  actionTypes = types;
286 
287  ui.setupUi(q);
288  q->layout()->setContentsMargins(0, 0, 0, 0);
289  ui.searchFilter->searchLine()->setTreeWidget(ui.list); // Plug into search line
290  ui.list->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
291  ui.list->header()->hideSection(ShapeGesture); //mouse gestures didn't make it in time...
292  ui.list->header()->hideSection(RockerGesture);
293 #if HAVE_GLOBALACCEL
294  bool hideGlobals = !(actionTypes & KShortcutsEditor::GlobalAction);
295 #else
296  bool hideGlobals = true;
297 #endif
298 
299  if (hideGlobals) {
300  ui.list->header()->hideSection(GlobalPrimary);
301  ui.list->header()->hideSection(GlobalAlternate);
302  } else if (!(actionTypes & ~KShortcutsEditor::GlobalAction)) {
303  ui.list->header()->hideSection(LocalPrimary);
304  ui.list->header()->hideSection(LocalAlternate);
305  }
306 
307  // Create the Delegate. It is responsible for the KKeySeqeunceWidgets that
308  // really change the shortcuts.
309  delegate = new KShortcutsEditorDelegate(
310  ui.list,
311  allowLetterShortcuts == KShortcutsEditor::LetterShortcutsAllowed);
312 
313  ui.list->setItemDelegate(delegate);
314  ui.list->setSelectionBehavior(QAbstractItemView::SelectItems);
315  ui.list->setSelectionMode(QAbstractItemView::SingleSelection);
316  //we have our own editing mechanism
317  ui.list->setEditTriggers(QAbstractItemView::NoEditTriggers);
318  ui.list->setAlternatingRowColors(true);
319 
320  //TODO listen to changes to global shortcuts
321  QObject::connect(delegate, SIGNAL(shortcutChanged(QVariant,QModelIndex)),
322  q, SLOT(capturedShortcut(QVariant,QModelIndex)));
323  //hide the editor widget chen its item becomes hidden
324  QObject::connect(ui.searchFilter->searchLine(), &KTreeWidgetSearchLine::hiddenChanged,
325  delegate, &KShortcutsEditorDelegate::hiddenBySearchLine);
326 
327  ui.searchFilter->setFocus();
328 }
329 
330 void KShortcutsEditorPrivate::setActionTypes(KShortcutsEditor::ActionTypes types)
331 {
332  if (actionTypes == types) {
333  return;
334  }
335  actionTypes = types;
336 
337  // show/hide the sections based on new selection
338  QHeaderView *header = ui.list->header();
340  header->showSection(GlobalPrimary);
341  header->showSection(GlobalAlternate);
342  } else {
343  header->hideSection(GlobalPrimary);
344  header->hideSection(GlobalAlternate);
345  }
346  if (actionTypes & ~KShortcutsEditor::GlobalAction) {
347  header->showSection(LocalPrimary);
348  header->showSection(LocalAlternate);
349  } else {
350  header->hideSection(LocalPrimary);
351  header->hideSection(LocalAlternate);
352  }
353 }
354 
355 bool KShortcutsEditorPrivate::addAction(QAction *action, QTreeWidgetItem *hier[], hierarchyLevel level)
356 {
357  // If the action name starts with unnamed- spit out a warning and ignore
358  // it. That name will change at will and will break loading and writing
359  QString actionName = action->objectName();
360  if (actionName.isEmpty() || actionName.startsWith(QLatin1String("unnamed-"))) {
361  qCCritical(DEBUG_KXMLGUI) << "Skipping action without name " << action->text() << "," << actionName << "!";
362  return false;
363  }
364 
365  const QVariant value = action->property("isShortcutConfigurable");
366  if (!value.isValid() || value.toBool()) {
367  new KShortcutsEditorItem((hier[level]), action);
368  return true;
369  }
370 
371  return false;
372 }
373 
374 void KShortcutsEditorPrivate::allDefault()
375 {
376  for (QTreeWidgetItemIterator it(ui.list); (*it); ++it) {
377  if (!(*it)->parent() || (*it)->type() != ActionItem) {
378  continue;
379  }
380 
381  KShortcutsEditorItem *item = static_cast<KShortcutsEditorItem *>(*it);
382  QAction *act = item->m_action;
383 
384  QList<QKeySequence> defaultShortcuts = act->property("defaultShortcuts").value<QList<QKeySequence> >();
385  if (act->shortcuts() != defaultShortcuts) {
386  QKeySequence primary = defaultShortcuts.isEmpty() ? QKeySequence() : defaultShortcuts.at(0);
387  QKeySequence alternate = defaultShortcuts.size() <= 1 ? QKeySequence() : defaultShortcuts.at(1);
388  changeKeyShortcut(item, LocalPrimary, primary);
389  changeKeyShortcut(item, LocalAlternate, alternate);
390  }
391 
392 #if HAVE_GLOBALACCEL
393  if (KGlobalAccel::self()->shortcut(act) != KGlobalAccel::self()->defaultShortcut(act)) {
394  QList<QKeySequence> defaultShortcut = KGlobalAccel::self()->defaultShortcut(act);
395  changeKeyShortcut(item, GlobalPrimary, primarySequence(defaultShortcut));
396  changeKeyShortcut(item, GlobalAlternate, alternateSequence(defaultShortcut));
397  }
398 #endif
399  }
400 }
401 
402 //static
403 KShortcutsEditorItem *KShortcutsEditorPrivate::itemFromIndex(QTreeWidget *const w,
404  const QModelIndex &index)
405 {
406  QTreeWidgetItem *item = static_cast<QTreeWidgetHack *>(w)->itemFromIndex(index);
407  if (item && item->type() == ActionItem) {
408  return static_cast<KShortcutsEditorItem *>(item);
409  }
410  return nullptr;
411 }
412 
413 QTreeWidgetItem *KShortcutsEditorPrivate::findOrMakeItem(QTreeWidgetItem *parent, const QString &name)
414 {
415  for (int i = 0; i < parent->childCount(); i++) {
416  QTreeWidgetItem *child = parent->child(i);
417  if (child->text(0) == name) {
418  return child;
419  }
420  }
421  QTreeWidgetItem *ret = new QTreeWidgetItem(parent, NonActionItem);
422  ret->setText(0, name);
423  ui.list->expandItem(ret);
424  ret->setFlags(ret->flags() & ~Qt::ItemIsSelectable);
425  return ret;
426 }
427 
428 //private slot
429 void KShortcutsEditorPrivate::capturedShortcut(const QVariant &newShortcut, const QModelIndex &index)
430 {
431  //dispatch to the right handler
432  if (!index.isValid()) {
433  return;
434  }
435  int column = index.column();
436  KShortcutsEditorItem *item = itemFromIndex(ui.list, index);
437  Q_ASSERT(item);
438 
439  if (column >= LocalPrimary && column <= GlobalAlternate) {
440  changeKeyShortcut(item, column, newShortcut.value<QKeySequence>());
441  }
442 }
443 
444 void KShortcutsEditorPrivate::changeKeyShortcut(KShortcutsEditorItem *item, uint column, const QKeySequence &capture)
445 {
446  // The keySequence we get is cleared by KKeySequenceWidget. No conflicts.
447  if (capture == item->keySequence(column)) {
448  return;
449  }
450 
451  item->setKeySequence(column, capture);
452  Q_EMIT q->keyChange();
453  //force view update
454  item->setText(column, capture.toString(QKeySequence::NativeText));
455 }
456 
457 void KShortcutsEditorPrivate::clearConfiguration()
458 {
459  for (QTreeWidgetItemIterator it(ui.list); (*it); ++it) {
460  if (!(*it)->parent()) {
461  continue;
462  }
463 
464  KShortcutsEditorItem *item = static_cast<KShortcutsEditorItem *>(*it);
465 
466  changeKeyShortcut(item, LocalPrimary, QKeySequence());
467  changeKeyShortcut(item, LocalAlternate, QKeySequence());
468 
469  changeKeyShortcut(item, GlobalPrimary, QKeySequence());
470  changeKeyShortcut(item, GlobalAlternate, QKeySequence());
471  }
472 }
473 
474 void KShortcutsEditorPrivate::importConfiguration(KConfigBase *config)
475 {
476  Q_ASSERT(config);
477  if (!config) {
478  return;
479  }
480 
481  KConfigGroup globalShortcutsGroup(config, QStringLiteral("Global Shortcuts"));
482  if ((actionTypes & KShortcutsEditor::GlobalAction) && globalShortcutsGroup.exists()) {
483 
484  for (QTreeWidgetItemIterator it(ui.list); (*it); ++it) {
485 
486  if (!(*it)->parent()) {
487  continue;
488  }
489 
490  KShortcutsEditorItem *item = static_cast<KShortcutsEditorItem *>(*it);
491  const QString actionId = item->data(Id).toString();
492  if (!globalShortcutsGroup.hasKey(actionId))
493  continue;
494 
495  QList<QKeySequence> sc = QKeySequence::listFromString(globalShortcutsGroup.readEntry(actionId, QString()));
496  changeKeyShortcut(item, GlobalPrimary, primarySequence(sc));
497  changeKeyShortcut(item, GlobalAlternate, alternateSequence(sc));
498  }
499  }
500 
501  if (actionTypes & ~KShortcutsEditor::GlobalAction) {
502  const KConfigGroup localShortcutsGroup(config, QStringLiteral("Shortcuts"));
503  for (QTreeWidgetItemIterator it(ui.list); (*it); ++it) {
504 
505  if (!(*it)->parent()) {
506  continue;
507  }
508  KShortcutsEditorItem *item = static_cast<KShortcutsEditorItem *>(*it);
509  const QString actionId = item->data(Id).toString();
510  if (!localShortcutsGroup.hasKey(actionId))
511  continue;
512 
513  QList<QKeySequence> sc = QKeySequence::listFromString(localShortcutsGroup.readEntry(actionId, QString()));
514  changeKeyShortcut(item, LocalPrimary, primarySequence(sc));
515  changeKeyShortcut(item, LocalAlternate, alternateSequence(sc));
516  }
517  }
518 }
519 
520 /*TODO for the printShortcuts function
521 Nice to have features (which I'm not sure I can do before may due to
522 more important things):
523 
524 - adjust the general page borders, IMHO they're too wide
525 
526 - add a custom printer options page that allows to filter out all
527  actions that don't have a shortcut set to reduce this list. IMHO this
528  should be optional as people might want to simply print all and when
529  they find a new action that they assign a shortcut they can simply use
530  a pen to fill out the empty space
531 
532 - find a way to align the Main/Alternate/Global entries in the shortcuts
533  column without adding borders. I first did this without a nested table
534  but instead simply added 3 rows and merged the 3 cells in the Action
535  name and description column, but unfortunately I didn't find a way to
536  remove the borders between the 6 shortcut cells.
537 */
538 void KShortcutsEditorPrivate::printShortcuts() const
539 {
540 // One cant print on wince
541 #ifndef _WIN32_WCE
542  QTreeWidgetItem *root = ui.list->invisibleRootItem();
543  QTextDocument doc;
544 
546 
547  QTextCursor cursor(&doc);
548  cursor.beginEditBlock();
549  QTextCharFormat headerFormat;
551  headerFormat.setFontWeight(QFont::Bold);
552  cursor.insertText(i18nc("header for an applications shortcut list", "Shortcuts for %1",
554  headerFormat);
555  QTextCharFormat componentFormat;
556  componentFormat.setProperty(QTextFormat::FontSizeAdjustment, 2);
557  componentFormat.setFontWeight(QFont::Bold);
558  QTextBlockFormat componentBlockFormat = cursor.blockFormat();
559  componentBlockFormat.setTopMargin(16);
560  componentBlockFormat.setBottomMargin(16);
561 
562  QTextTableFormat tableformat;
563  tableformat.setHeaderRowCount(1);
564  tableformat.setCellPadding(4.0);
565  tableformat.setCellSpacing(0);
567  tableformat.setBorder(0.5);
568 
569  const QPair<QString, ColumnDesignation> shortcutTitleToColumnMap[] = {
570  qMakePair(i18n("Main:"), LocalPrimary),
571  qMakePair(i18n("Alternate:"), LocalAlternate),
572  qMakePair(i18n("Global:"), GlobalPrimary),
573  qMakePair(i18n("Global alternate:"), GlobalAlternate),
574  };
575 
576  for (int i = 0; i < root->childCount(); i++) {
577  QTreeWidgetItem *item = root->child(i);
578  cursor.insertBlock(componentBlockFormat, componentFormat);
579  cursor.insertText(item->text(0));
580 
581  QTextTable *table = cursor.insertTable(1, 3);
582  table->setFormat(tableformat);
583  int currow = 0;
584 
585  QTextTableCell cell = table->cellAt(currow, 0);
586  QTextCharFormat format = cell.format();
587  format.setFontWeight(QFont::Bold);
588  cell.setFormat(format);
589  cell.firstCursorPosition().insertText(i18n("Action Name"));
590 
591  cell = table->cellAt(currow, 1);
592  cell.setFormat(format);
593  cell.firstCursorPosition().insertText(i18n("Shortcuts"));
594 
595  cell = table->cellAt(currow, 2);
596  cell.setFormat(format);
597  cell.firstCursorPosition().insertText(i18n("Description"));
598  currow++;
599 
600  for (QTreeWidgetItemIterator it(item); *it; ++it) {
601  if ((*it)->type() != ActionItem) {
602  continue;
603  }
604 
605  KShortcutsEditorItem *editoritem = static_cast<KShortcutsEditorItem *>(*it);
606  table->insertRows(table->rows(), 1);
607  QVariant data = editoritem->data(Name, Qt::DisplayRole);
608  table->cellAt(currow, 0).firstCursorPosition().insertText(data.toString());
609 
610  QTextTable *shortcutTable = nullptr;
611  for (const auto &shortcutTitleToColumn : shortcutTitleToColumnMap) {
612  data = editoritem->data(shortcutTitleToColumn.second, Qt::DisplayRole);
613  QString key = data.value<QKeySequence>().toString();
614 
615  if (!key.isEmpty()) {
616  if (!shortcutTable) {
617  shortcutTable = table->cellAt(currow, 1).firstCursorPosition().insertTable(1, 2);
618  QTextTableFormat shortcutTableFormat = tableformat;
619  shortcutTableFormat.setCellSpacing(0.0);
620  shortcutTableFormat.setHeaderRowCount(0);
621  shortcutTableFormat.setBorder(0.0);
622  shortcutTable->setFormat(shortcutTableFormat);
623  } else {
624  shortcutTable->insertRows(shortcutTable->rows(), 1);
625  }
626  shortcutTable->cellAt(shortcutTable->rows() - 1, 0).firstCursorPosition().insertText(shortcutTitleToColumn.first);
627  shortcutTable->cellAt(shortcutTable->rows() - 1, 1).firstCursorPosition().insertText(key);
628  }
629  }
630 
631  QAction *action = editoritem->m_action;
632  cell = table->cellAt(currow, 2);
633  format = cell.format();
635  cell.setFormat(format);
636  cell.firstCursorPosition().insertHtml(action->whatsThis());
637 
638  currow++;
639  }
641  }
642  cursor.endEditBlock();
643 
644  QPrinter printer;
645  QPrintDialog *dlg = new QPrintDialog(&printer, q);
646  if (dlg->exec() == QDialog::Accepted) {
647  doc.print(&printer);
648  }
649  delete dlg;
650 #endif
651 }
652 
653 #include "moc_kshortcutseditor.cpp"
QLayout * layout() const const
void undoChanges()
Undo all change made since the last commit().
Categorize actions for KShortcutsEditor.
void importConfiguration(KConfigBase *config)
Import the settings from configuration config.
A container for a set of QAction objects.
QTextCursor firstCursorPosition() const const
void setContentsMargins(int left, int top, int right, int bottom)
int rows() const const
QCursor cursor() const const
void setProperty(int propertyId, const QVariant &value)
QList< QKeySequence > listFromString(const QString &str, QKeySequence::SequenceFormat format)
void insertHtml(const QString &html)
QTreeWidgetItem * child(int index) const const
void showSection(int logicalIndex)
const T & at(int i) const const
QList< QKeySequence > shortcuts() const const
T value() const const
void commit()
Commit the changes without saving.
void setCellSpacing(qreal spacing)
void setFormat(const QTextCharFormat &format)
ActionTypes actionTypes() const
QSet::iterator insert(const T &value)
void setHeaderRowCount(int count)
bool movePosition(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode, int n)
int size() const const
void printShortcuts() const
Opens a printing dialog to print all the shortcuts.
void hiddenChanged(QTreeWidgetItem *, bool)
QList< T > findChildren(const QString &name, Qt::FindChildOptions options) const const
void setFlags(Qt::ItemFlags flags)
bool isValid() const const
void insertBlock()
void clearCollections()
Removes all action collections from the editor.
QVariant property(const char *name) const const
void setBorder(qreal width)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
bool exists() const
void setUpdatesEnabled(bool enable)
void endEditBlock()
void insertText(const QString &text)
bool isEmpty() const const
DisplayRole
bool isEmpty() const const
QList< QAction * > actions() const
Returns the list of QActions which belong to this action collection.
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const const
Actions which are triggered by any keypress in the windowing system.
void setFormat(const QTextTableFormat &format)
void save()
Save the changes.
Widget for configuration of KAccel and KGlobalAccel.
void keyChange()
Emitted when an action&#39;s shortcut has been changed.
void setDefaultFont(const QFont &font)
void undo()
Undo all change made since the last commit().
bool isModified() const
Are the unsaved changes?
void resizeColumns()
Resize columns to width required.
void setBottomMargin(qreal margin)
void hideSection(int logicalIndex)
void beginEditBlock()
void allDefault()
Set all shortcuts to their default values (bindings).
bool contains(const T &value) const const
bool hasKey(const QString &key) const
void setTopMargin(qreal margin)
QTextCharFormat format() const const
Letter shortcuts are allowed.
void setFontWeight(int weight)
void addCollection(KActionCollection *, const QString &title=QString())
Insert an action collection, i.e.
QTextTable * insertTable(int rows, int columns, const QTextTableFormat &format)
QString i18n(const char *text, const TYPE &arg...)
QString componentDisplayName() const
The display name for the associated component.
static KGlobalAccel * self()
QFont systemFont(QFontDatabase::SystemFont type)
void writeConfiguration(KConfigGroup *config=nullptr) const
Write the current settings to the config object.
Qt::ItemFlags flags() const const
virtual int exec() override
QString toString(QKeySequence::SequenceFormat format) const const
QTextTableCell cellAt(int row, int column) const const
AscendingOrder
void insertRows(int index, int rows)
bool isEmpty() const
Returns whether the action collection is empty or not.
void setText(int column, const QString &text)
void setCellPadding(qreal padding)
int column() const const
bool toBool() const const
bool isValid() const const
int type() const const
void print(QPagedPaintDevice *printer) const const
QList< QKeySequence > defaultShortcut(const QAction *action) const
void setBorderStyle(QTextFrameFormat::BorderStyle style)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void setActionTypes(ActionTypes actionTypes)
Sets the types of actions to display in this widget.
QObject * parent() const const
int childCount() const const
void clearConfiguration()
Removes all configured shortcuts.
QChar * data()
QString toString() const const
T readEntry(const QString &key, const T &aDefault) const
QString text(int column) const const
QString applicationDisplayName()
virtual ~KShortcutsEditor()
Destructor.
void exportConfiguration(KConfigBase *config) const
Export the current setting to configuration config.
QTextBlockFormat blockFormat() const const
Q_EMITQ_EMIT
KShortcutsEditor(KActionCollection *collection, QWidget *parent, ActionTypes actionTypes=AllActions, LetterShortcuts allowLetterShortcuts=LetterShortcutsAllowed)
Constructor.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Jan 20 2021 22:54:31 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.