MPannableViewport* StatusIndicatorMenuDropDownView::createPannableArea() { // Create pannable area contents statusIndicatorExtensionArea = createVerticalExtensionArea(); QGraphicsLinearLayout *contentLayout = new QGraphicsLinearLayout(Qt::Vertical); contentLayout->setContentsMargins(0, 0, 0, 0); contentLayout->setSpacing(0); contentLayout->addItem(statusIndicatorExtensionArea); MWidgetController *contentWidget = new MStylableWidget; contentWidget->setStyleName("StatusIndicatorMenuContentWidget"); contentWidget->setLayout(contentLayout); QGraphicsLinearLayout *pannableLayout = new QGraphicsLinearLayout(Qt::Vertical); pannableLayout->setContentsMargins(0, 0, 0, 0); pannableLayout->setSpacing(0); pannableLayout->addItem(contentWidget); QGraphicsWidget *closeButtonRow = createCloseButtonRow(); pannableLayout->addItem(closeButtonRow); pannableLayout->addStretch(); // Create a container widget for the pannable area PannedWidgetController *pannedWidget = new PannedWidgetController; pannedWidget->setLayout(pannableLayout); pannedWidget->setBottommostWidget(closeButtonRow); connect(pannedWidget, SIGNAL(positionOrSizeChanged()), this, SLOT(setPannabilityAndLayout())); connect(pannedWidget, SIGNAL(pressedOutSideContents()), controller, SIGNAL(hideRequested())); // Setup the pannable viewport MPannableViewport *pannableViewport = new MPannableViewport; pannableViewport->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); pannableViewport->setWidget(pannedWidget); return pannableViewport; }
void PannedWidgetController::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (bottommostWidget_) { // Test that the y position of the event is bigger than the bottom edge of the bottommost widget. // The calculations are done in this widget's coordinate space. if (event->pos().y() > bottommostWidget_->y() + bottommostWidget_->geometry().height()) { emit pressedOutSideContents(); } } }