KXmlGui

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

KDE's Doxygen guidelines are available online.