Initial work for the SnapshotDiff window
This commit is contained in:
@@ -87,6 +87,22 @@ namespace Bloom::Widgets
|
||||
void ListScene::mousePressEvent(QGraphicsSceneMouseEvent* mouseEvent) {
|
||||
const auto button = mouseEvent->button();
|
||||
|
||||
const auto mousePosition = mouseEvent->buttonDownScenePos(button);
|
||||
|
||||
const auto items = this->items(mousePosition);
|
||||
if (items.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* clickedListItem = dynamic_cast<ListItem*>(items.first());
|
||||
if (clickedListItem == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (clickedListItem->selected && button == Qt::MouseButton::RightButton) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto selectedItemCount = this->selectedItems.size();
|
||||
if (selectedItemCount > 0) {
|
||||
const auto ctrlModifierEnabled = (mouseEvent->modifiers() & Qt::ControlModifier) != 0;
|
||||
@@ -109,18 +125,6 @@ namespace Bloom::Widgets
|
||||
}
|
||||
}
|
||||
|
||||
const auto mousePosition = mouseEvent->buttonDownScenePos(button);
|
||||
|
||||
const auto items = this->items(mousePosition);
|
||||
if (items.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* clickedListItem = dynamic_cast<ListItem*>(items.first());
|
||||
if (clickedListItem == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->selectionLimit > 0) {
|
||||
this->selectedItems.push_back(clickedListItem);
|
||||
clickedListItem->selected = true;
|
||||
@@ -148,6 +152,14 @@ namespace Bloom::Widgets
|
||||
return;
|
||||
}
|
||||
|
||||
if (!clickedListItem->selected) {
|
||||
/*
|
||||
* Sometimes, QT won't trigger a press event when the user double clicks. This usually happens when the
|
||||
* first click closes a context menu.
|
||||
*/
|
||||
this->mousePressEvent(mouseEvent);
|
||||
}
|
||||
|
||||
emit this->itemDoubleClicked(clickedListItem);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user