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 StatusIndicatorMenuWindow::resetMenuWidget() { if (menuWidget) delete menuWidget; menuWidget = new StatusIndicatorMenu(); connect(menuWidget, SIGNAL(showRequested()), this, SLOT(makeVisible())); connect(menuWidget, SIGNAL(hideRequested()), menuWidget, SLOT(disappear())); connect(menuWidget, SIGNAL(disappeared()), this, SLOT(hideWindow())); // Initialize the status indicator menu after the first USB banner has been shown QTimer::singleShot(7000, this, SLOT(initializeMenuWidget())); }
void Ut_StatusIndicatorMenuWindow::testInitialization() { QVERIFY(statusIndicatorMenuWindow->menuWidget); QVERIFY(disconnect(statusIndicatorMenuWindow, SIGNAL(displayExited()), statusIndicatorMenuWindow, SLOT(displayInActive()))); QVERIFY(disconnect(statusIndicatorMenuWindow, SIGNAL(displayEntered()), statusIndicatorMenuWindow, SLOT(displayActive()))); QVERIFY(disconnect(statusIndicatorMenuWindow->menuWidget, SIGNAL(showRequested()), statusIndicatorMenuWindow, SLOT(makeVisible()))); QVERIFY(disconnect(statusIndicatorMenuWindow->menuWidget, SIGNAL(hideRequested()), statusIndicatorMenuWindow->menuWidget, SLOT(disappear()))); QVERIFY(disconnect(statusIndicatorMenuWindow->menuWidget, SIGNAL(disappeared()), statusIndicatorMenuWindow, SLOT(hideWindow()))); QVERIFY(gSceneWindowStateMap.contains(statusIndicatorMenuWindow->menuWidget)); QCOMPARE(gSceneWindowStateMap[statusIndicatorMenuWindow->menuWidget], MSceneWindow::Disappeared); }
StatusIndicatorMenuDropDownView::StatusIndicatorMenuDropDownView(StatusIndicatorMenu *controller) : MSceneWindowView(controller), controller(controller), settingsPluginsExtensionArea(NULL), statusIndicatorExtensionArea(NULL), pannableViewport(NULL), closeButtonOverlay(NULL), backgroundWidget(new MStylableWidget) { // Create close button overlay closeButtonOverlay = createCloseButtonOverlay(); // Create the pannable area background widget backgroundWidget->setStyleName("StatusIndicatorMenuWindowBackground"); connect(controller, SIGNAL(hideRequested()), this, SLOT(resetViewport())); connect(controller, SIGNAL(displayEntered()), SLOT(ensureIsViewable())); // Schedule the view to be initialized QTimer::singleShot(VIEW_INITIALIZATION_DELAY, this, SLOT(ensureIsViewable())); }
MOverlay *StatusIndicatorMenuDropDownView::createCloseButtonOverlay() { // Create a close button MButton *closeButton = new MButton; closeButton->setViewType("icon"); closeButton->setObjectName("StatusIndicatorMenuCloseButton"); closeButton->setIconID("icon-m-framework-close"); connect(closeButton, SIGNAL(clicked()), controller, SIGNAL(hideRequested())); // Add two overlay widgets that will not allow mouse events to pass through them next to the close button QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); layout->addItem(new EventEaterWidget); layout->addItem(closeButton); layout->addItem(new EventEaterWidget); // Create the overlay itself MOverlay *closeButtonOverlay = new MOverlay; closeButtonOverlay->setLayout(layout); closeButtonOverlay->setObjectName("CloseButtonOverlay"); return closeButtonOverlay; }
void ExternalPlugin::hide(const std::string& key) { LOG(Trace, "hide, key = " << key); emit hideRequested(key); }