Esempio n. 1
0
    void setContent(const ToolTipContent &data)
    {
        QString html;
        QString mainText = data.mainText();
        if (!mainText.isEmpty()) {
            if (mainText.size() < 50) {
                // don't let short texts wrap on us!
                mainText = mainText.replace(" ", "&nbsp;");
            }
            html.append("<div align=\"center\"><b>" + mainText + "</b></div>");
        }
        html.append(data.subText());

        m_anchor.clear();
        m_document->clear();
        data.registerResources(m_document);
        if (!html.isEmpty()) {
            m_document->setHtml("<p>" + html + "</p>");
        } else {
            m_document->clear();
        }
        m_document->adjustSize();

        update();
    }
Esempio n. 2
0
    void setContent(const ToolTipContent &data)
    {
        QString html;
        if (!data.mainText().isEmpty()) {
            html.append("<div><b>" + data.mainText() + "</b></div>");
        }
        html.append(data.subText());

        m_anchor.clear();
        m_document->clear();
        data.registerResources(m_document);
        if (!html.isEmpty()) {
            m_document->setHtml("<p>" + html + "</p>");
        }
        m_document->adjustSize();

        m_haloRects.clear();
        QTextLayout *layout = m_document->begin().layout();
        //layout->setPosition(QPointF(textRect.x(), textBoundingRect->y()));
        QTextLine line;
        for (int i = 0; i < layout->lineCount(); ++i) {
            line = layout->lineAt(i);

            // Add halo rect only when a non empty line is found
            if (line.naturalTextWidth()) {
                m_haloRects.append(line.naturalTextRect().translated(layout->position().toPoint()).toRect().translated(m_margin, m_margin));
            }
        }

        update();
    }
Esempio n. 3
0
void Launcher::updateToolTipContent()
{
    ToolTipContent toolTipContent;
    toolTipContent.setMainText(m_data.name());
    toolTipContent.setSubText(m_data.description());
    toolTipContent.setImage(icon());

    ToolTipManager::self()->setContent(this, toolTipContent);
}
Esempio n. 4
0
void ToolTip::setContent(QObject *tipper, const ToolTipContent &data)
{
    //reset our size
    d->text->setContent(data);
    if (data.image().isNull()) {
        d->imageLabel->hide();
    } else {
        d->imageLabel->show();
        d->imageLabel->setPixmap(data.image());
    }

    if (data.highlightWindows() && !data.windowsToPreview().isEmpty()) {
        WindowEffects::highlightWindows(winId(), QList<WId>() << winId() << data.windowsToPreview());
    }

    d->preview->setWindowIds(data.windowsToPreview());
    d->preview->setHighlightWindows(data.highlightWindows());

    d->autohide = data.autohide();
    d->source = tipper;

    if (isVisible()) {
        d->preview->setInfo();
        //kDebug() << "about to check size";
        checkSize();
    }
}