Esempio n. 1
0
QString Panel::location() const
{
    Plasma::Containment *c = containment();
    if (!c) {
        return "floating";
    }

    switch (c->location()) {
        case Plasma::Types::Floating:
            return "floating";
            break;
        case Plasma::Types::Desktop:
            return "desktop";
            break;
        case Plasma::Types::FullScreen:
            return "fullscreen";
            break;
        case Plasma::Types::TopEdge:
            return "top";
            break;
        case Plasma::Types::BottomEdge:
            return "bottom";
            break;
        case Plasma::Types::LeftEdge:
            return "left";
            break;
        case Plasma::Types::RightEdge:
            return "right";
            break;
    }

    return "floating";
}
Esempio n. 2
0
void PanelView::updateGeometry(int)
{
    Plasma::Containment *c = containment();
    if(!c)
        return;
    QRect screenGeometry = QApplication::desktop()->screenGeometry(c->screen());
    QPoint topLeft;
    QSize newSize;

    int length = mLength;
    Plasma::Location loc = c->location();
    if(length < 0)
    {
        if(loc == Plasma::TopEdge || loc == Plasma::BottomEdge)
            length = screenGeometry.width() - qAbs(mOffSet);
        else
            length = screenGeometry.height() - qAbs(mOffSet);
    }
    int depth = qMax(mDepth, 1);
    int offSet = qMax(mOffSet, 0);

    switch(loc)
    {
    case Plasma::TopEdge:
        topLeft = QPoint(screenGeometry.left() + offSet, screenGeometry.top());
        newSize = QSize(length, depth);
        break;

    case Plasma::BottomEdge:
        topLeft = QPoint(screenGeometry.left() + offSet, screenGeometry.bottom() - depth);
        newSize = QSize(length, depth);
        break;

    case Plasma::LeftEdge:
        topLeft = QPoint(screenGeometry.left(), screenGeometry.top() + offSet);
        newSize = QSize(depth, length);
        break;

    case Plasma::RightEdge:
        topLeft = QPoint(screenGeometry.right() - depth, screenGeometry.top() + offSet);
        newSize = QSize(depth, length);
        break;

    default:
        qDebug() << "Not a panel location";
        //Set a valid geometry anyway.
        topLeft = screenGeometry.topLeft();
        newSize = QSize(screenGeometry.width(), mDepth);
        break;
    }
    setGeometry(QRect(topLeft, newSize));
    c->setMaximumSize(newSize);
    c->setMinimumSize(newSize);
    c->resize(newSize);
    mStrutTimer->start();
}