void PowerDevilRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match)
{
    Q_UNUSED(context)

    QDBusInterface iface("org.kde.Solid.PowerManagement",
                         "/org/kde/Solid/PowerManagement",
                         "org.kde.Solid.PowerManagement");
    if (match.id().startsWith("PowerDevil_ProfileChange")) {
        iface.asyncCall("loadProfile", match.data().toString());
    } else if (match.id() == "PowerDevil_BrightnessChange") {
        iface.asyncCall("setBrightness", match.data().toInt());
    } else if (match.id() == "PowerDevil_DimTotal") {
        iface.asyncCall("setBrightness", 0);
    } else if (match.id() == "PowerDevil_DimHalf") {
        iface.asyncCall("setBrightness", -2);
    } else if (match.id() == "PowerDevil_TurnOffScreen") {
        // FIXME: Maybe this should be even removed
        // iface.asyncCall("turnOffScreen");
    } else if (match.id().startsWith("PowerDevil_Suspend")) {
        switch ((Solid::PowerManagement::SleepState)match.data().toInt()) {
            case Solid::PowerManagement::SuspendState:
            case Solid::PowerManagement::StandbyState:
                iface.asyncCall("suspendToRam");
                break;
            case Solid::PowerManagement::HibernateState:
                iface.asyncCall("suspendToDisk");
                break;
        }
    }
}
Beispiel #2
0
void RecentDocuments::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match)
{
    Q_UNUSED(context)
    QString url = match.data().toString();
    qDebug() << "Opening Recent Document" << url;
    new KRun(url, 0);
}
void BookmarksRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &action)
{
    Q_UNUSED(context);
    const QString term = action.data().toString();
    QUrl url = QUrl(term);

    //support urls like "kde.org" by transforming them to http://kde.org
    if (url.scheme().isEmpty()) {
        const int idx = term.indexOf('/');

        url.clear();
        url.setHost(term.left(idx));
        if (idx != -1) {
            //allow queries
            const int queryStart = term.indexOf('?', idx);
            int pathLength = -1;
            if ((queryStart > -1) && (idx < queryStart)) {
                pathLength = queryStart - idx;
                url.setQuery(term.mid(queryStart));
            }

            url.setPath(term.mid(idx, pathLength));
        }
        url.setScheme(QStringLiteral("http"));
    }

    KToolInvocation::invokeBrowser(url.url());
}
void AudioPlayerControlRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match)
{
    Q_UNUSED(context)
    QDBusInterface tracklist(QString::fromLatin1( "org.mpris.%1").arg(m_player),
                             QLatin1String( "/TrackList" ), QLatin1String( "org.freedesktop.MediaPlayer" ));

    QVariantList data = match.data().value<QVariantList>();

    /* Only Amarok part*/
    QString url = data[2].toString();
    int pos = posInPlaylist(url);
    kDebug() << "pos" << pos;
    QAction *a = match.selectedAction();
    if (data[3].toString().compare(NONE)) {
        if (!a)
        {
            a = action(data[3].toString());
        }
        if (a == action(QUEUE)) {
            KUrl::List list;
            list << KUrl(url);
            KRun::run(QLatin1String( "amarok --queue %u" ), list, 0);
        } else if (a == action(APPEND)) {
            if (!(pos > -1)) {
                tracklist.call(QDBus::NoBlock, QLatin1String( "AddTrack" ), url , false);
            }
        } else {
            //Action play was selected
            if (pos > -1) {
                tracklist.call(QDBus::NoBlock, QLatin1String( "PlayTrack" ), pos);
            } else {
                tracklist.call(QDBus::NoBlock, QLatin1String( "AddTrack" ), url, true);
            }
        }
    }/* Only Amarok part over */ else {
        if ((data[4].toString().compare(QLatin1String( "start" )) == 0)) {
            //The players's interface isn't available but it should be started
            if (!startPlayer()) {
                return;
            }
        }

        QDBusMessage msg = QDBusMessage::createMethodCall(QString::fromLatin1( "org.mpris.%1").arg(m_player),data[0].toString(),
                           data[1].toString(), data[2].toString());
        kDebug() << msg;
        QVariantList args;
        for (int i = 5;data.length() > i;++i) {
            args << data[i];
        }
        msg.setArguments(args);
        QDBusConnection::sessionBus().call(msg, QDBus::NoBlock);
    }
}
void RecentDocuments::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match)
{
    Q_UNUSED(context)

    const QString url = match.data().toString();

    if (match.selectedAction() && match.selectedAction()->data().toString() == QLatin1String("openParentDir")) {
        KIO::highlightInFileManager({QUrl(url)});
        return;
    }

    new KRun(QUrl(url), 0);
}
QList<QAction *> RecentDocuments::actionsForMatch(const Plasma::QueryMatch &match)
{
    Q_UNUSED(match)

    const QString openParentDirId = QStringLiteral("openParentDir");

    if (!action(openParentDirId)) {
        (addAction(openParentDirId, QIcon::fromTheme(QStringLiteral("document-open-folder")), i18n("Open Containing Folder")))->setData(openParentDirId);
    }

    QList<QAction *> actions;

    if (QUrl(match.data().toString()).isLocalFile()) {
        actions << action(openParentDirId);
    }

    return actions;
}
Beispiel #7
0
void KopeteRunner::run(const Plasma::RunnerContext& context, const Plasma::QueryMatch& match)
{
    Q_UNUSED(context)

    // HACK: Strip off the "kopete_" prefix
    const QString id = match.data().toString();
    QString method;
    QVariantList args;
    if (id == "connect")
        method = "connectAll";
    else if (id == "disconnect")
        method = "disconnectAll";
    else if (id == "status")
    {
        method = "setOnlineStatus";
        QStringList status = match.text().split(": ");
        status.takeFirst();
        QStringList message = match.subtext().split(": ");
        message.takeFirst();
        args << status.join(": ") << message.join(": ");
    }
    else if (id == "message")
    {
        method = "setStatusMessage";
        QStringList message = match.text().split(": ");
        message.takeFirst();
        args << message.join(": ");
    }
    else if (!QUuid(id).isNull())
    {
        method = "openChat";
        args << id;
    }
    else
        qDebug("Unknown ID: %s", id.toUtf8().constData());
    if (!method.isNull())
    {
        QDBusMessage message = generateMethodCall(method);
        message.setArguments(args);
        QDBusConnection::sessionBus().send(message);
    }
}
void WebshortcutRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match)
{
    QString location;

    //qDebug() << "filter before run?" << m_filterBeforeRun;
    if (m_filterBeforeRun) {
        m_filterBeforeRun = false;
        //qDebug() << "look up webshortcut:" << context.query();
        KUriFilterData filterData (context.query());
        if (KUriFilter::self()->filterSearchUri(filterData, KUriFilter::WebShortcutFilter))
            location = filterData.uri().url();
    } else {
        location = match.data().toString();
    }

    //qDebug() << location;
    if (!location.isEmpty()) {
        KToolInvocation::invokeBrowser(location);
    }
}
void WebshortcutRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match)
{
    QUrl location;

    //qDebug() << "filter before run?" << m_filterBeforeRun;
    if (m_filterBeforeRun) {
        m_filterBeforeRun = false;
        //qDebug() << "look up webshortcut:" << context.query();
        KUriFilterData filterData (context.query());
        if (KUriFilter::self()->filterSearchUri(filterData, KUriFilter::WebShortcutFilter))
            location = filterData.uri();
    } else {
        location = match.data().toUrl();
    }

    //qDebug() << location;
    if (!location.isEmpty()) {
        QDesktopServices::openUrl(location);
    }
}
Beispiel #10
0
void PlasmaRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match)
{
    Q_UNUSED(context)

    const QVariantList data = match.data().toList();

    // pass in C locale, should be always understood
    const QString latLon =
        QString::number(data.at(1).toReal()) + QLatin1Char(' ') + QString::number(data.at(0).toReal());

    const QString distance = data.at(2).toString();

    const QStringList parameters = QStringList()
        << QStringLiteral( "--latlon" )
        << latLon
        << QStringLiteral( "--distance" )
        << distance
        << QStringLiteral( "--map" )
        << QStringLiteral( "earth/openstreetmap/openstreetmap.dgml" );
    QProcess::startDetached( QStringLiteral("marble"), parameters );
}
QList<QAction*> AudioPlayerControlRunner::actionsForMatch(const Plasma::QueryMatch &match)
{
    QList<QAction*> ret;
    QVariantList data = match.data().value<QVariantList>();

    if (data.length() > 3 && data[3].toString().compare(NONE)) {
        if (!action(PLAY)) {
            addAction(PLAY, KIcon(QLatin1String( "media-playback-start" )), i18n("Play"));
            addAction(QUEUE, KIcon(QLatin1String( "media-track-queue-amarok" )), i18n("Queue"));
            addAction(APPEND, KIcon(QLatin1String( "media-track-add-amarok" )), i18n("Append to playlist"));
        }

        const QStringList actions = data[3].toString().split(QLatin1Char( ',' ));

        for (int i = 0; i < actions.length(); ++i) {
            ret << action(actions[i]);
        }
    }

    return ret;
}
void PidginRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match){
    Q_UNUSED(context);
    qDebug() << match.text() << match.data().toString();
    pidgin_d.startChat(match.data().toString());
}