Commit b1bbd053 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Really forbid deletion of required shortcuts

The shortcuts that are required by Krita should not only be disabled
for a change, but also should be forbidden to be deleted.
parent 66b93b7f
......@@ -220,6 +220,12 @@ Qt::ItemFlags KisActionShortcutsModel::flags(const QModelIndex &index) const
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
}
bool KisActionShortcutsModel::canRemoveRow(int row) const
{
KisShortcutConfiguration* config = d->shortcuts.at(row);
return !(d->action->isShortcutRequired(config->mode()) && d->shortcutModeCount(config->mode()) < 2);
}
bool KisActionShortcutsModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (!index.isValid() || role != Qt::EditRole) {
......
......@@ -97,6 +97,8 @@ public:
*/
KisInputProfile *profile() const;
bool canRemoveRow(int row) const;
public Q_SLOTS:
/**
* Set the action used as data constraint for this model.
......
......@@ -82,5 +82,9 @@ void KisInputConfigurationPageItem::setExpanded(bool expand)
void KisInputConfigurationPageItem::deleteShortcut()
{
m_shortcutsModel->removeRow(ui->shortcutsView->selectionModel()->currentIndex().row(), QModelIndex());
int row = ui->shortcutsView->selectionModel()->currentIndex().row();
if (m_shortcutsModel->canRemoveRow(row)) {
m_shortcutsModel->removeRow(row, QModelIndex());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment