Implemented event filter in PanelWidget to enforce the receiving of mouse events (for the panel resize handle)
This commit is contained in:
@@ -82,10 +82,31 @@ namespace Bloom::Widgets
|
||||
this->setVisible(visible);
|
||||
}
|
||||
|
||||
bool PanelWidget::eventFilter(QObject* object, QEvent* event) {
|
||||
const auto eventType = event->type();
|
||||
|
||||
if (event->isSinglePointEvent()) {
|
||||
auto* pointerEvent = dynamic_cast<QSinglePointEvent*>(event);
|
||||
|
||||
if (
|
||||
this->initialResizePoint.has_value()
|
||||
|| this->isPositionWithinHandleArea(pointerEvent->position().toPoint())
|
||||
) {
|
||||
this->event(event);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PanelWidget::event(QEvent* event) {
|
||||
if (event->type() == QEvent::Type::HoverMove) {
|
||||
auto* hoverEvent = dynamic_cast<QHoverEvent*>(event);
|
||||
if (this->initialResizePoint.has_value() || this->isPositionWithinHandleArea(hoverEvent->position().toPoint())) {
|
||||
if (
|
||||
this->initialResizePoint.has_value()
|
||||
|| this->isPositionWithinHandleArea(hoverEvent->position().toPoint())
|
||||
) {
|
||||
this->setCursor(this->resizeCursor);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -78,6 +78,7 @@ namespace Bloom::Widgets
|
||||
std::optional<QPoint> initialResizePoint = std::nullopt;
|
||||
int initialResizeSize = 0;
|
||||
|
||||
bool eventFilter(QObject *object, QEvent *event) override;
|
||||
bool event(QEvent* event) override;
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace Bloom::Widgets
|
||||
auto* containerLayout = this->container->findChild<QVBoxLayout*>();
|
||||
|
||||
this->snapshotListView = new ListView({}, this);
|
||||
this->snapshotListView->viewport()->installEventFilter(parent);
|
||||
this->snapshotListView->setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded);
|
||||
|
||||
this->snapshotListScene = this->snapshotListView->listScene();
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Bloom::Widgets
|
||||
this->rightPanel = new PanelWidget(PanelWidgetType::RIGHT, this->settings.rightPanelState, this);
|
||||
this->rightPanel->setObjectName("right-panel");
|
||||
this->rightPanel->setMinimumResize(200);
|
||||
this->rightPanel->setHandleSize(5);
|
||||
this->rightPanel->setHandleSize(6);
|
||||
this->subContainerLayout->insertWidget(2, this->rightPanel);
|
||||
|
||||
this->snapshotManager = new SnapshotManager(
|
||||
|
||||
Reference in New Issue
Block a user