Пример #1
0
int MetabarFunctions::getHeight(DOM::HTMLElement &element)
{
    int height = 0;
    DOM::NodeList children = element.childNodes();
    for(uint i = 0; i < children.length(); i++) {
        DOM::HTMLElement node = static_cast<DOM::HTMLElement>(children.item(i));
        DOM::CSSStyleDeclaration style = node.style();

        DOM::DOMString css_height = style.getPropertyValue("height");
        if(!css_height.isNull()) {
            height += css_height.string().left(css_height.string().length() - 2).toInt();
        }
        else {
            int h = 0;
            if(!node.isNull()) {
                h = node.getRect().height();
            }

            DOM::DOMString display = style.getPropertyValue("display");
            if(display == "none") {
                h = 0;
            }
            else if(h == 0) {
                h = 20;
            }

            height += h;
        }
    }

    return height;
}
Пример #2
0
void MetabarFunctions::toggle(DOM::DOMString item)
{
    DOM::HTMLDocument doc = m_html->htmlDocument();
    DOM::HTMLElement node = static_cast<DOM::HTMLElement>(doc.getElementById(item));

    if(!node.isNull()) {
        DOM::NodeList children = node.childNodes();
        DOM::CSSStyleDeclaration style = node.style();
        DOM::DOMString expanded = node.getAttribute("expanded");

        bool isExpanded = expanded == "true";

        int height = 0;
        if(!isExpanded) {
            height = getHeight(node);
        }

        DOM::DOMString att = isExpanded ? "false" : "true";
        node.setAttribute("expanded", att);

        KConfig config("metabarrc");
        config.setGroup("General");

        if(config.readBoolEntry("AnimateResize", false)) {
            resizeMap[item.string()] = height;

            if(!timer->isActive()) {
                timer->start(RESIZE_SPEED);
            }
        }
        else {
            style.setProperty("height", QString("%1px").arg(height), CSS_PRIORITY);
        }
    }
}
Пример #3
0
void MetabarFunctions::hide(DOM::DOMString item)
{
    DOM::HTMLDocument doc = m_html->htmlDocument();
    DOM::HTMLElement node = static_cast<DOM::HTMLElement>(doc.getElementById(item));
    if(!node.isNull()) {
        DOM::HTMLElement parent = static_cast<DOM::HTMLElement>(node.parentNode());

        DOM::CSSStyleDeclaration style = parent.style();
        style.setProperty("display", "none", CSS_PRIORITY);
    }
}