示例#1
0
void InternalToolBox::immutabilityChanged(Plasma::ImmutabilityType immutability)
{
    const bool unlocked = immutability == (Plasma::Mutable);

    if (containment() &&
        (containment()->type() == Plasma::Containment::PanelContainment ||
         containment()->type() == Plasma::Containment::CustomPanelContainment)) {
        setVisible(unlocked);
    } else {
        setIsMovable(unlocked);
    }
}
示例#2
0
void Panel::setLocation(const QString &locationString)
{
    Plasma::Containment *c = containment();
    if (!c) {
        return;
    }

    const QString lower = locationString.toLower();
    Plasma::Types::Location loc = Plasma::Types::Floating;
    Plasma::Types::FormFactor ff = Plasma::Types::Planar;
    if (lower == "desktop") {
        loc = Plasma::Types::Desktop;
    } else if (lower == "fullscreen") {
        loc = Plasma::Types::FullScreen;
    } else if (lower == "top") {
        loc = Plasma::Types::TopEdge;
        ff = Plasma::Types::Horizontal;
    } else if (lower == "bottom") {
        loc = Plasma::Types::BottomEdge;
        ff = Plasma::Types::Horizontal;
    } else if (lower == "left") {
        loc = Plasma::Types::LeftEdge;
        ff = Plasma::Types::Vertical;
    } else if (lower == "right") {
        loc = Plasma::Types::RightEdge;
        ff = Plasma::Types::Vertical;
    }

    c->setLocation(loc);
    c->setFormFactor(ff);
}
示例#3
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";
}
示例#4
0
PanelView *Panel::panel() const
{
    Plasma::Containment *c = containment();
    if (!c || !m_corona) {
        return 0;
    }

    return m_corona->panelView(c);
}
示例#5
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();
}
示例#6
0
KConfigGroup Panel::panelConfig() const
{
    int screenNum = qMax(screen(), 0); //if we don't have a screen (-1) we'll be put on screen 0

    if (QGuiApplication::screens().size() < screenNum) {
        return KConfigGroup();
    }
    QScreen *s = QGuiApplication::screens().at(screenNum);
    return PanelView::panelConfig(m_corona, containment(), s);
}
示例#7
0
void NetToolBox::init()
{
    m_containment = containment();
    Q_ASSERT(m_containment);

    m_icon = KIcon("plasma");
    m_closeIcon = KIcon("dialog-close");
    m_iconSize = QSize(KIconLoader::SizeSmall, KIconLoader::SizeSmall);
    m_animHighlightFrame = 0;
    m_hovering = false;
    m_showing = false;
    m_location = Plasma::BottomEdge;
    m_newToolsPosition = 0;

    setZValue(9000);
    resize(KIconLoader::SizeMedium, KIconLoader::SizeMedium);
    setAcceptHoverEvents(true);

    m_toolContainer = new ToolContainer(this);
    m_toolContainer->hide();
    m_toolContainer->setFlag(QGraphicsWidget::ItemStacksBehindParent);
    m_toolContainerLayout = new QGraphicsLinearLayout(m_toolContainer);
    m_toolContainerLayout->addStretch();

    m_background = new Plasma::Svg(this);
    m_background->setImagePath("widgets/toolbox");
    m_background->setContainsMultipleImages(true);
    setLocation(Plasma::BottomEdge);

    m_containment->installEventFilter(this);
    connect(m_containment, SIGNAL(geometryChanged()), this, SLOT(containmentGeometryChanged()));
    containmentGeometryChanged();

    slideAnim = Plasma::Animator::create(Plasma::Animator::SlideAnimation, this);
    slideAnim->setProperty("movementDirection", Plasma::Animation::MoveAny);
    connect(slideAnim, SIGNAL(stateChanged(QAbstractAnimation::State,
                        QAbstractAnimation::State)),
                this, SLOT(onMovement(QAbstractAnimation::State,QAbstractAnimation::State)));
    connect(slideAnim, SIGNAL(finished()), this, SLOT(movementFinished()));

    anim = new QPropertyAnimation(this, "highlight", this);
    anim->setDuration(250);
    anim->setStartValue(0);
    anim->setEndValue(1);
}
示例#8
0
void
Context::Applet::collapse( bool on )
{
    qreal finalHeight = ( on ) ? m_heightCollapseOn : m_heightCollapseOff;
    const qreal maxHeight = containment()->size().height();
    if( (finalHeight > maxHeight) || (finalHeight < 0) )
        finalHeight = maxHeight;

    prepareGeometryChange();
    // warning: view() currently can return pointer to ToolbarView, not the ContextView
    ContextView *v = ContextView::self(); // may return null
    // Plasma::Applet::view() might return 0, if the widget is not yet constructed, etc.
    // \sa https://bugs.kde.org/show_bug.cgi?id=258741. If view is not available
    // yet, regardless of the animation setting the preferred size is set
    // straight away.
    if( !v || !AmarokConfig::animateAppletCollapse() )
    {
        setPreferredHeight( finalHeight );
        emit sizeHintChanged( Qt::PreferredSize );
        updateGeometry();
        return;
    }

    if( finalHeight == size().height() )
        return;

    // debug() << pluginName() << (on ? "collapsing to" : "uncollapsing to") << finalHeight;
    QPropertyAnimation *pan = m_animation.data();
    if( !pan )
        pan = new QPropertyAnimation( this, "preferredSize" );
    if( pan->state() == QAbstractAnimation::Running )
        pan->stop();
    pan->setDuration( 600 );
    pan->setEasingCurve( QEasingCurve::InQuad );
    pan->setStartValue( size() );
    pan->setEndValue( QSizeF(size().width(), finalHeight) );
    connect( pan, SIGNAL(finished()), SLOT(collapseAnimationFinished()) );
    m_animation = pan;
    pan->setDirection( QAbstractAnimation::Forward );

    v->addCollapseAnimation( pan );
}
示例#9
0
void XbmcremoteApplet::init()
{
    Plasma::Containment * c = containment();

    /* When applet is not in panel the tooltip always appears when hovering
       any point of the popup's area, which is annoying. */
    if (c && (c->containmentType() == Plasma::Containment::PanelContainment ||
              c->containmentType() == Plasma::Containment::CustomPanelContainment)) {
        Plasma::ToolTipManager::self()->registerWidget(this);
        m_panelContainment = true;
    } else {
        m_panelContainment = false;
    }

    //kDebug();

    m_popup = new DeclarativePopup(this);
    // TODO: config
//    connect(d->m_popup, SIGNAL(configNeedsSaving()), this, SIGNAL(configNeedsSaving()));

    // TODO: context options
//    QAction* action = new QAction(i18nc("CheckBox to enable or disable networking completely", "Enable networking"), this);
//    action->setToolTip(i18nc("@info:tooltip tooltip for the 'Enable networking' checkbox", "Enable or disable the networking system"));
//    action->setCheckable(true);
//    action->setChecked(NetworkManager::isNetworkingEnabled());
//    connect(action, SIGNAL(triggered(bool)), d->m_popup, SLOT(networkingEnabledToggled(bool)));
//    connect(NetworkManager::notifier(), SIGNAL(networkingEnabledChanged(bool)),
//            action, SLOT(setChecked(bool)));

//    d->actions.append(action);

    setGraphicsWidget(m_popup);

    connect(Xbmc::instance(), SIGNAL(connectedChanged(bool)), SLOT(connectedChanged(bool)));
    connect(Xbmc::instance(), SIGNAL(activePlayerChanged()), SLOT(activePlayerChanged()));
}
示例#10
0
void PanelView::updateStruts()
{
    QDesktopWidget *desktop = QApplication::desktop();
    const QRect myScreen = desktop->screenGeometry(containment()->screen());
    QRect workspace = myScreen;
    int numScreens = desktop->numScreens();
    for(int screen = 0; screen < numScreens; ++screen)
    {
        workspace |= desktop->screenGeometry(screen);
    }

    int leftOffset = myScreen.left() -  workspace.left();
    int rightOffset = workspace.right() - myScreen.right();
    int bottomOffset = workspace.bottom() - myScreen.bottom();
    int topOffset = myScreen.top() - workspace.top();

    NETExtendedStrut strut;
    switch (location())
    {
        case Plasma::TopEdge:
            strut.top_width = height() + topOffset;
            strut.top_start = x();
            strut.top_end = x() + width() - 1;
            break;

        case Plasma::BottomEdge:
            strut.bottom_width = height() + bottomOffset;
            strut.bottom_start = x();
            strut.bottom_end = x() + width() - 1;
            break;

        case Plasma::RightEdge:
            strut.right_width = width() + rightOffset;
            strut.right_start = y();
            strut.right_end = y() + height() - 1;
            break;

        case Plasma::LeftEdge:
            strut.left_width = width() + leftOffset;
            strut.left_start = y();
            strut.left_end = y() + height() - 1;
            break;

        default:
            //kokodoko?
            break;
    }
    KWindowSystem::setExtendedStrut(winId(),
                                    strut.left_width,
                                    strut.left_start,
                                    strut.left_end,
                                    strut.right_width,
                                    strut.right_start,
                                    strut.right_end,
                                    strut.top_width,
                                    strut.top_start,
                                    strut.top_end,
                                    strut.bottom_width,
                                    strut.bottom_start,
                                    strut.bottom_end
                                   );
}