Example #1
0
void DArrowRectangle::horizontalMove(int x, int y)
{
    QRect dRect = QApplication::desktop()->geometry();
    qreal delta = shadowBlurRadius() - shadowDistance();

    int lRelativeX = x - dRect.x() - (width() - delta) / 2;
    int rRelativeX = x - dRect.x() + (width() - delta) / 2 - dRect.width();
    int absoluteX = 0;

    if (lRelativeX < 0)//out of screen in left side
    {
        //arrowX use relative coordinates
        setArrowX(width() / 2 - delta + lRelativeX);
        absoluteX = dRect.x() - delta;
    }
    else if(rRelativeX > 0)//out of screen in right side
    {
        setArrowX(width() / 2 - delta * 2 + rRelativeX);
        absoluteX = dRect.x() + dRect.width() - width() + delta;
    }
    else
        absoluteX = x - width() / 2;

    switch (m_arrowDirection)
    {
    case ArrowTop:
        QWidget::move(absoluteX, y);
        break;
    case ArrowBottom:
        QWidget::move(absoluteX, y - height());
        break;
    default:
        break;
    }
}
Example #2
0
void DArrowRectangle::verticalMove(int x, int y)
{
    QRect dRect = QApplication::desktop()->geometry();
    qreal delta = shadowBlurRadius() - shadowDistance();

    int lRelativeY = y - dRect.y() - (height() - delta) / 2;
    int rRelativeY = y - dRect.y() + (height() - delta) / 2 - dRect.height();
    int absoluteY = 0;

    if (lRelativeY < 0)//out of screen in top side
    {
        //arrowY use relative coordinates
        setArrowY(height() / 2 - delta + lRelativeY);
        absoluteY = dRect.y() - delta;
    }
    else if(rRelativeY > 0)//out of screen in bottom side
    {
        setArrowY(height() / 2 - delta * 2 + rRelativeY);
        absoluteY = dRect.y() + dRect.height() - height() + delta;
    }
    else
        absoluteY = y - height() / 2;

    switch (m_arrowDirection)
    {
    case ArrowLeft:
        QWidget::move(x, absoluteY);
        break;
    case ArrowBottom:
        QWidget::move(x - width(), absoluteY);
        break;
    default:
        break;
    }
}
Example #3
0
void DArrowRectangle::setContent(QWidget *content)
{
    if (!content)
        return;

    m_content = content;
    m_content->setParent(this);
    m_content->show();

    qreal delta = shadowBlurRadius() + shadowDistance() + margin();

    resizeWithContent();

    switch(m_arrowDirection)
    {
    case ArrowLeft:
        m_content->move(m_arrowHeight + delta, delta);
        break;
    case ArrowRight:
        m_content->move(delta, delta);
        break;
    case ArrowTop:
        m_content->move(delta, delta + m_arrowHeight);
        break;
    case ArrowBottom:
        m_content->move(delta, delta);
        break;
    }

    update();
}
Example #4
0
QPainterPath DArrowRectangle::getBottomCornerPath()
{
    qreal delta = shadowBlurRadius() + shadowDistance();

    QRect rect = this->rect().marginsRemoved(QMargins(delta, delta, delta, delta));

    QPoint cornerPoint(rect.x() + (m_arrowX > 0 ? m_arrowX : rect.width() / 2), rect.y()  + rect.height());
    QPoint topLeft(rect.x(), rect.y());
    QPoint topRight(rect.x() + rect.width(), rect.y());
    QPoint bottomRight(rect.x() + rect.width(), rect.y() + rect.height() - m_arrowHeight);
    QPoint bottomLeft(rect.x(), rect.y() + rect.height() - m_arrowHeight);
    int radius = this->m_radius > (rect.height() / 2 - m_arrowHeight) ? rect.height() / 2 -m_arrowHeight : this->m_radius;

    QPainterPath border;
    border.moveTo(topLeft.x() + radius, topLeft.y());
    border.lineTo(topRight.x() - radius, topRight.y());
    border.arcTo(topRight.x() - 2 * radius, topRight.y(), 2 * radius, 2 * radius, 90, -90);
    border.lineTo(bottomRight.x(), bottomRight.y() - radius);
    border.arcTo(bottomRight.x() - 2 * radius, bottomRight.y() - 2 * radius, 2 * radius, 2 * radius, 0, -90);
    border.lineTo(cornerPoint.x() + m_arrowWidth / 2, cornerPoint.y() - m_arrowHeight);
    border.lineTo(cornerPoint);
    border.lineTo(cornerPoint.x() - m_arrowWidth / 2, cornerPoint.y() - m_arrowHeight);
    border.lineTo(bottomLeft.x() + radius, bottomLeft.y());
    border.arcTo(bottomLeft.x(), bottomLeft.y() - 2 * radius, 2 * radius, 2 * radius, -90, -90);
    border.lineTo(topLeft.x(), topLeft.y() + radius);
    border.arcTo(topLeft.x(), topLeft.y(), 2 * radius, 2 * radius, 180, -90);

    return border;
}
DWIDGET_USE_NAMESPACE

DArrowRectangle::DArrowRectangle(ArrowDirection direction, QWidget * parent) :
    QWidget(parent),m_arrowDirection(direction)
{
    DGraphicsGlowEffect *glowEffect = new DGraphicsGlowEffect(this);
    glowEffect->setBlurRadius(shadowBlurRadius());
    glowEffect->setDistance(shadowDistance());
    glowEffect->setXOffset(shadowXOffset());
    glowEffect->setYOffset(shadowYOffset());
    setGraphicsEffect(glowEffect);
}
Example #6
0
DUI_USE_NAMESPACE

DArrowRectangle::DArrowRectangle(ArrowDirection direction, QWidget * parent) :
    QWidget(parent),m_arrowDirection(direction)
{
    D_THEME_INIT_WIDGET(DArrowRectangle);

    setWindowFlags(Qt::SplashScreen);
    setAttribute(Qt::WA_TranslucentBackground);

    DGraphicsGlowEffect *glowEffect = new DGraphicsGlowEffect(this);
    glowEffect->setBlurRadius(shadowBlurRadius());
    glowEffect->setDistance(shadowDistance());
    glowEffect->setXOffset(shadowXOffset());
    glowEffect->setYOffset(shadowYOffset());
    setGraphicsEffect(glowEffect);
}
Example #7
0
QSize DArrowRectangle::getFixedSize()
{
    if (m_content)
    {        
        qreal delta = shadowBlurRadius() + shadowDistance() + margin();

        switch(m_arrowDirection)
        {
        case ArrowLeft:
        case ArrowRight:
            return QSize(m_content->width() + delta * 2 + m_arrowHeight, m_content->height() + delta * 2);
        case ArrowTop:
        case ArrowBottom:
            return QSize(m_content->width() + delta * 2, m_content->height() + delta * 2 + m_arrowHeight);
        }
    }

    return QSize(0, 0);
}
void DArrowRectangle::resizeWithContent()
{
    setFixedSize(getFixedSize());

    repaint();

    //Shadow Transparent For MouseEvents
    qreal delta = shadowBlurRadius() + shadowDistance();
    Q_UNUSED(delta);
//    XRectangle m_contentXRect;
//    m_contentXRect.x = 0;
//    m_contentXRect.y = 0;
//    m_contentXRect.width = width() - delta * 2;
//    m_contentXRect.height = height() - delta * 2;
//    XShapeCombineRectangles(QX11Info::display(), winId(), ShapeInput,
//                            delta + shadowXOffset(),
//                            delta + shadowYOffset(),
//                            &m_contentXRect, 1, ShapeSet, YXBanded);
}
Example #9
0
void DArrowRectangle::resizeWithContent()
{
    setFixedSize(getFixedSize());

    update();

#ifdef Q_OS_UNIX
    //Shadow Transparent For MouseEvents
    qreal delta = shadowBlurRadius() + shadowDistance();

    XRectangle m_contentXRect;
    m_contentXRect.x = 0;
    m_contentXRect.y = 0;
    m_contentXRect.width = width() - delta * 2;
    m_contentXRect.height = height() - delta * 2;
    XShapeCombineRectangles(QX11Info::display(), winId(), ShapeInput,
                            delta + shadowXOffset(),
                            delta + shadowYOffset(),
                            &m_contentXRect, 1, ShapeSet, YXBanded);
#endif
}