2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Added Escape hotkey to clear selection in photo editor.

This commit is contained in:
23rd
2021-05-06 21:23:04 +03:00
parent 3ee3919d50
commit a93ec9c2c2
2 changed files with 10 additions and 3 deletions

View File

@@ -251,8 +251,15 @@ void ItemBase::actionDuplicate() {
}
}
void ItemBase::keyPressEvent(QKeyEvent *event) {
handleActionKey(event);
void ItemBase::keyPressEvent(QKeyEvent *e) {
if (e->key() == Qt::Key_Escape) {
if (const auto s = scene()) {
s->clearSelection();
s->clearFocus();
return;
}
}
handleActionKey(e);
}
void ItemBase::handleActionKey(not_null<QKeyEvent*> e) {

View File

@@ -61,7 +61,7 @@ protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void keyPressEvent(QKeyEvent *e) override;
using Action = void(ItemBase::*)();
void performForSelectedItems(Action action);