[nostalgia/core/studio] Fix the TileSheetEditor color key overflow
This commit is contained in:
parent
45a27800b6
commit
d7b82a6eed
@ -926,15 +926,14 @@ void TileSheetEditor::saveItem() {
|
|||||||
bool TileSheetEditor::eventFilter(QObject *o, QEvent *e) {
|
bool TileSheetEditor::eventFilter(QObject *o, QEvent *e) {
|
||||||
if (e->type() == QEvent::KeyPress) {
|
if (e->type() == QEvent::KeyPress) {
|
||||||
const auto k = static_cast<QKeyEvent*>(e)->key();
|
const auto k = static_cast<QKeyEvent*>(e)->key();
|
||||||
if (k >= Qt::Key_1 && k <= Qt::Key_9) {
|
const auto max = m_colorPicker.colorTable->rowCount() - 1;
|
||||||
m_colorPicker.colorTable->setCurrentCell(k - Qt::Key_1, 0);
|
if (k >= Qt::Key_0 && k <= Qt::Key_9) {
|
||||||
return true;
|
const auto val = k - Qt::Key_1 + (k == Qt::Key_0 ? 10 : 0);
|
||||||
} else if (k == Qt::Key_0) {
|
m_colorPicker.colorTable->setCurrentCell(std::min(max, val), 0);
|
||||||
m_colorPicker.colorTable->setCurrentCell(k - Qt::Key_1 + 10, 0);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QObject::eventFilter(o, e);
|
return QWidget::eventFilter(o, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *TileSheetEditor::setupColorPicker(QWidget *parent) {
|
QWidget *TileSheetEditor::setupColorPicker(QWidget *parent) {
|
||||||
|
@ -284,7 +284,7 @@ class TileSheetEditor: public studio::Editor {
|
|||||||
protected:
|
protected:
|
||||||
void saveItem() override;
|
void saveItem() override;
|
||||||
|
|
||||||
bool eventFilter(QObject *obj, QEvent *event);
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *setupColorPicker(QWidget *widget);
|
QWidget *setupColorPicker(QWidget *widget);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user