12#include <KLocalizedString>
13#include <QApplication>
14#include <QMetaClassInfo>
15#include <QKeySequence>
19#include <QApplication>
41 : QAbstractListModel(parent), d(new
Private)
52 if (!index.isValid()) {
56 if (index.row() ==
d->
shortcuts.count() && role == Qt::DisplayRole) {
57 if (index.column() == 0) {
58 return i18n(
"Add shortcut...");
65 if (role == Qt::DisplayRole) {
66 switch (index.column()) {
113 else if (role == Qt::EditRole) {
127 switch (index.column()) {
132 return QVariant::fromValue(s);
147 if (parent.isValid()) {
161 if (orientation != Qt::Horizontal || role != Qt::DisplayRole) {
167 return i18nc(
"Type of shortcut",
"Type");
170 return i18nc(
"Input for shortcut",
"Input");
173 return i18nc(
"Action to trigger with shortcut",
"Action");
184 if (!index.isValid()) {
185 return Qt::ItemIsEnabled;
188 if (index.row() ==
d->
shortcuts.count() && index.column() != 0) {
189 return Qt::ItemIsEnabled;
193 return Qt::ItemIsEnabled | Qt::ItemIsEditable;
198 return Qt::ItemIsSelectable;
201 return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
215 if (!index.isValid() || role != Qt::EditRole) {
232 switch (index.column()) {
241 if (newData == oldData) {
247 const bool isConflictingShortcut = std::find_if(conflictingShortcuts.begin(),
248 conflictingShortcuts.end(),
250 return *oldData == *shortcut;
252 != conflictingShortcuts.end();
254 if (isConflictingShortcut) {
255 QMessageBox::warning(qApp->activeWindow(),
257 i18n(
"A conflict exists between two or more shortcuts."));
260 Q_EMIT dataChanged(index, index);
264 oldData->setKeys(newData->
keys());
265 oldData->setButtons(newData->
buttons());
266 oldData->setWheel(newData->
wheel());
278 Q_EMIT dataChanged(index, index);
292 beginRemoveRows(QModelIndex(), 0,
d->
shortcuts.count() - 1);
300 beginInsertRows(QModelIndex(), 0,
d->
shortcuts.count() - 1);
315 beginRemoveRows(QModelIndex(), 0,
d->
shortcuts.count() - 1);
323 beginInsertRows(QModelIndex(), 0,
d->
shortcuts.count() - 1);
336 if (row < 0 || row >=
d->
shortcuts.count() || count == 0) {
340 beginRemoveRows(parent, row, row + count - 1);
342 for (
int i = row; i <
d->
shortcuts.count() && count > 0; ++i, count--) {
359 if(s->
mode() == mode) {
float value(const T *src, size_t ch)
KisInputProfile * profile
QList< KisShortcutConfiguration * > shortcuts
KisShortcutConfiguration * temporaryShortcut
KisAbstractInputAction * action
int shortcutModeCount(uint mode)
void setProfile(KisInputProfile *profile)
void setAction(KisAbstractInputAction *action)
~KisActionShortcutsModel() override
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
KisActionShortcutsModel(QObject *parent=0)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
bool canRemoveRow(int row) const
KisInputProfile * profile() const
int columnCount(const QModelIndex &) const override
KisAbstractInputAction * action() const
void currentProfileChanged()
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
Qt::ItemFlags flags(const QModelIndex &index) const override
A class encapsulating all settings for a single shortcut.
MouseWheelMovement wheel() const
static QString keysToText(const QList< Qt::Key > &keys)
ShortcutType type() const
static QString shortcutTypeToText(ShortcutType type)
@ NativeGestureType
A macOS gesture.
@ MouseButtonType
A mouse button, possibly with key modifiers.
@ MouseWheelType
Mouse wheel movement, possibly with key modifiers.
@ TouchGestureType
A touch gesture.
@ KeyCombinationType
A list of keys that should be pressed.
Qt::MouseButtons buttons() const
static QString wheelInputToText(const QList< Qt::Key > &keys, MouseWheelMovement wheel)
QList< Qt::Key > keys() const
static QString nativeGestureToText(NativeGestureAction action)
void setAction(KisAbstractInputAction *newAction)
static QString touchGestureToText(TouchGestureAction action)
NativeGestureAction nativeGesture() const
TouchGestureAction touchGesture() const
static QString buttonsInputToText(const QList< Qt::Key > &keys, Qt::MouseButtons buttons)
QIcon loadIcon(const QString &name)