diff --git a/qt/rack_widget.cpp b/qt/rack_widget.cpp index 26e0c44..56f335b 100644 --- a/qt/rack_widget.cpp +++ b/qt/rack_widget.cpp @@ -170,12 +170,24 @@ vector RackWidget::filterRack(const vector &iTiles) const // Drag & drop handling +bool RackWidget::canStartDragDrop() const +{ + if (m_game == NULL || m_game->isFinished()) + return false; + // Drag & drop is not allowed when a word is being played + return m_tiles.size() == m_filteredTiles.size(); +} + + void RackWidget::tilePressed(int row, int col, QMouseEvent *event) { ASSERT(row == 0, "Multi-line racks are not supported"); ASSERT(col >= 0 && (unsigned)col < m_tilesVect.size(), "Invalid tile index: " << col); + if (!canStartDragDrop()) + return; + LOG_DEBUG("Starting drag for tile " << col); TileWidget *tileWidget = m_tilesVect[col]; diff --git a/qt/rack_widget.h b/qt/rack_widget.h index 55882b8..3aadb9d 100644 --- a/qt/rack_widget.h +++ b/qt/rack_widget.h @@ -102,6 +102,8 @@ private: */ vector filterRack(const vector &iTiles) const; + bool canStartDragDrop() const; + /** * Return the 0-based index of the tile found at the given (relative) * position. If there is no such tile, return -1.