Ejemplo n.º 1
0
void UIPopupStack::prepareContent()
{
    /* Create main-layout: */
    m_pMainLayout = new QVBoxLayout(this);
    {
        /* Configure main-layout: */
        m_pMainLayout->setContentsMargins(0, 0, 0, 0);
        /* Create scroll-area: */
        m_pScrollArea = new QScrollArea;
        {
            /* Configure scroll-area: */
            m_pScrollArea->setCursor(Qt::ArrowCursor);
            m_pScrollArea->setWidgetResizable(true);
            m_pScrollArea->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
            m_pScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
            //m_pScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
            QPalette pal = m_pScrollArea->palette();
            pal.setColor(QPalette::Window, QColor(Qt::transparent));
            m_pScrollArea->setPalette(pal);
            /* Create scroll-viewport: */
            m_pScrollViewport = new UIPopupStackViewport;
            {
                /* Configure scroll-viewport: */
                m_pScrollViewport->setCursor(Qt::ArrowCursor);
                /* Connect scroll-viewport: */
                connect(this, SIGNAL(sigProposeStackViewportWidth(int)),
                        m_pScrollViewport, SLOT(sltHandleProposalForWidth(int)));
                connect(m_pScrollViewport, SIGNAL(sigSizeHintChanged()),
                        this, SLOT(sltAdjustGeometry()));
                connect(m_pScrollViewport, SIGNAL(sigPopupPaneDone(QString, int)),
                        this, SIGNAL(sigPopupPaneDone(QString, int)));
                connect(m_pScrollViewport, SIGNAL(sigPopupPaneRemoved(QString)),
                        this, SLOT(sltPopupPaneRemoved(QString)));
                connect(m_pScrollViewport, SIGNAL(sigPopupPanesRemoved()),
                        this, SLOT(sltPopupPanesRemoved()));
            }
            /* Assign scroll-viewport to scroll-area: */
            m_pScrollArea->setWidget(m_pScrollViewport);
        }
        /* Add scroll-area to layout: */
        m_pMainLayout->addWidget(m_pScrollArea);
    }
}
Ejemplo n.º 2
0
void UIPopupStackViewport::sltPopupPaneDone(int iResultCode)
{
    /* Make sure the sender is the popup-pane: */
    UIPopupPane *pPopupPane = qobject_cast<UIPopupPane*>(sender());
    if (!pPopupPane)
    {
        AssertMsgFailed(("Should be called by popup-pane only!"));
        return;
    }

    /* Make sure the popup-pane still exists: */
    const QString strPopupPaneID(m_panes.key(pPopupPane, QString()));
    if (strPopupPaneID.isNull())
    {
        AssertMsgFailed(("Popup-pane already destroyed!"));
        return;
    }

    /* Notify listeners about popup-pane removal: */
    emit sigPopupPaneDone(strPopupPaneID, iResultCode);

    /* Delete popup-pane asyncronously.
     * To avoid issues with events which already posted: */
    m_panes.remove(strPopupPaneID);
    pPopupPane->deleteLater();

    /* Notify listeners about popup-pane removed: */
    emit sigPopupPaneRemoved(strPopupPaneID);

    /* Adjust geometry: */
    sltAdjustGeometry();

    /* Make sure this stack still contains popup-panes: */
    if (!m_panes.isEmpty())
        return;

    /* Notify listeners about popup-stack: */
    emit sigPopupPanesRemoved();
}