コード例 #1
0
ファイル: control-widget.cpp プロジェクト: altagir/x10-widget
void ControlWidget::DisconnectSource()
{
    Plasma::DataEngine* engine = m_parent->getDataEngine();
    if (engine && engine->isValid())
    {
        Logger::Log(DEBUG, "Disconnecting source %s", m_unit.address());
        engine->disconnectSource(m_unit.address(), this);
    }
}
コード例 #2
0
ファイル: clock.cpp プロジェクト: mgottschlag/kwin-tiling
void Clock::connectToEngine()
{
    resetLastTimeSeen();

    Plasma::DataEngine* timeEngine = dataEngine("time");
    timeEngine->disconnectSource(m_oldTimezone, this);
    m_oldTimezone = currentTimezone();

    if (m_showSecondHand) {
        timeEngine->connectSource(currentTimezone(), this, 500);
    } else {
        timeEngine->connectSource(currentTimezone(), this, 6000, Plasma::AlignToMinute);
    }
}
コード例 #3
0
ファイル: potd.cpp プロジェクト: fluxer/kde-extraapps
void PoTD::dataUpdated(const QString &source, const Plasma::DataEngine::Data &data)
{
    if (source == QLatin1String("Providers")) {
        m_providers = data;
        if (!m_provider.isEmpty() && !m_providers.contains(m_provider)) {
            Plasma::DataEngine *engine = dataEngine(QLatin1String("potd"));
            engine->disconnectSource(m_provider, this);
            m_provider = DEFAULT_PROVIDER;
            engine->connectSource(m_provider, this);
        }
    } else if (source == m_provider) {
        QImage image = data["Image"].value<QImage>();
        render(image, boundingRect().size().toSize(), MaxpectResize);
    } else {
        dataEngine(QLatin1String("potd"))->disconnectSource(source, this);
    }
}
コード例 #4
0
ファイル: potd.cpp プロジェクト: fluxer/kde-extraapps
void PoTD::paint(QPainter *painter, const QRectF& exposedRect)
{
    if (m_image.isNull()) {
        painter->fillRect(exposedRect, QBrush(Qt::black));
        const QString provider = m_providers.isEmpty() || m_provider.isEmpty() ? QString()
                                                                               : m_providers.value(m_provider).toString();
        const QString text = provider.isEmpty() ? i18n("Loading the picture of the day...")
                                                : i18n("Loading the picture of the day from %1...", provider);
        QRect textRect = painter->fontMetrics().boundingRect(text);
        textRect.moveCenter(boundingRect().center().toPoint());
        painter->setPen(Qt::white);
        painter->drawText(textRect.topLeft(), text);
    } else {
        if (m_image.size() != boundingRect().size().toSize()) {
            Plasma::DataEngine *engine = dataEngine(QLatin1String("potd"));
            // refresh the data which will trigger a re-render
            engine->disconnectSource(m_provider, this);
            engine->connectSource(m_provider, this);
        }
        painter->drawImage(exposedRect, m_image, exposedRect);
    }
}