Skip to content

Commit

Permalink
Tileset Editor: Focus name of new Terrain on add
Browse files Browse the repository at this point in the history
It's helpful since generally the terrain should be given a name.
  • Loading branch information
bjorn committed Mar 23, 2021
1 parent 3b989cf commit 05ade1d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/tiled/wangdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,33 @@ void WangDock::setDocument(Document *document)
void WangDock::editWangSetName(WangSet *wangSet)
{
const QModelIndex index = wangSetIndex(wangSet);
QItemSelectionModel *selectionModel = mWangSetView->selectionModel();

QItemSelectionModel *selectionModel = mWangSetView->selectionModel();
selectionModel->setCurrentIndex(index,
QItemSelectionModel::ClearAndSelect |
QItemSelectionModel::Rows);

mWangSetView->edit(index);
}

void WangDock::editWangColorName(int colorIndex)
{
const QModelIndex index = mWangColorModel->colorIndex(colorIndex);
if (!index.isValid())
return;

const QModelIndex viewIndex = static_cast<QAbstractProxyModel*>(mWangColorView->model())->mapFromSource(index);
if (!viewIndex.isValid())
return;

QItemSelectionModel *selectionModel = mWangColorView->selectionModel();
selectionModel->setCurrentIndex(viewIndex,
QItemSelectionModel::ClearAndSelect |
QItemSelectionModel::Rows);

mWangColorView->edit(viewIndex);
}

void WangDock::changeEvent(QEvent *event)
{
QDockWidget::changeEvent(event);
Expand Down Expand Up @@ -461,6 +479,7 @@ void WangDock::addColor()
tilesetDocument->undoStack()->push(new ChangeWangSetColorCount(tilesetDocument,
mCurrentWangSet,
mCurrentWangSet->colorCount() + 1));
editWangColorName(mCurrentWangSet->colorCount());
}
}

Expand Down
1 change: 1 addition & 0 deletions src/tiled/wangdock.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class WangDock : public QDockWidget
WangId currentWangId() const { return mCurrentWangId; }

void editWangSetName(WangSet *wangSet);
void editWangColorName(int colorIndex);

void setColorView();
void hideTemplateColorView();
Expand Down

0 comments on commit 05ade1d

Please sign in to comment.