Skip to content

Commit

Permalink
Re-enabled Space for toggling layer visibility
Browse files Browse the repository at this point in the history
Also added Ctrl+Space as shortcut for toggling whether the current layer
is locked.

These shortcuts only work while the layer list is focused.
  • Loading branch information
bjorn committed Mar 20, 2018
1 parent 690c7f7 commit 0de0f20
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/tiled/layerdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "layerdock.h"

#include "changelayer.h"
#include "layer.h"
#include "layermodel.h"
#include "map.h"
Expand Down Expand Up @@ -350,14 +351,24 @@ void LayerView::contextMenuEvent(QContextMenuEvent *event)

void LayerView::keyPressEvent(QKeyEvent *event)
{
Layer *layer = mMapDocument ? mMapDocument->currentLayer() : nullptr;

switch (event->key()) {
case Qt::Key_Delete:
case Qt::Key_Backspace:
if (mMapDocument) {
const LayerModel *layerModel = mMapDocument->layerModel();
const QModelIndex index = mProxyModel->mapToSource(currentIndex());
if (auto layer = layerModel->toLayer(index))
mMapDocument->removeLayer(layer);
if (layer) {
mMapDocument->removeLayer(layer);
return;
}
break;
case Qt::Key_Space:
if (layer) {
QUndoCommand *command = nullptr;
if (event->modifiers() & Qt::ControlModifier)
command = new SetLayerLocked(mMapDocument, layer, !layer->isLocked());
else
command = new SetLayerVisible(mMapDocument, layer, !layer->isVisible());
mMapDocument->undoStack()->push(command);
return;
}
break;
Expand Down

0 comments on commit 0de0f20

Please sign in to comment.