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