当前位置: 首页>>代码示例>>C++>>正文


C++ RunnerContext::addMatches方法代码示例

本文整理汇总了C++中plasma::RunnerContext::addMatches方法的典型用法代码示例。如果您正苦于以下问题:C++ RunnerContext::addMatches方法的具体用法?C++ RunnerContext::addMatches怎么用?C++ RunnerContext::addMatches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plasma::RunnerContext的用法示例。


在下文中一共展示了RunnerContext::addMatches方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: match

void PidginRunner::match(Plasma::RunnerContext &context)
{
    qDebug() << Q_FUNC_INFO ;
    QString query = context.query();
    if ( !query.isEmpty() )
    {
        qDebug() << " Pidgin runner trigger word";
        QString contactName = query ;

        // so now let's filter all contacts from
        // pidgin
        QStringList contacts = pidgin_d.search(query);
        QList<Plasma::QueryMatch> matches;
        std::for_each(contacts.begin(), contacts.end(), [&contacts, &matches, this](const QString& c )
        {
            Plasma::QueryMatch match(this);
            QVariantMap map = pidgin_d.buddyId(c);
            match.setText(c);
            match.setSubtext(map["buddyStatus"].toString());
            match.setData(c);
            match.setId(c);
            match.setType(Plasma::QueryMatch::ExactMatch);
            QIcon icon(map["buddyIconPath"].toString());
            match.setIcon(icon);
            matches.append(match);

        });
        context.addMatches(matches);
    }
}
开发者ID:freexploit,项目名称:plasma-runner-pidgin,代码行数:30,代码来源:pidgin_runner.cpp

示例2: match


//.........这里部分代码省略.........
        QueryMatch match(this);

        match.setType(QueryMatch::ExactMatch);
        match.setIcon(KIcon("user-"));
        match.setText(i18n("Set all accounts as online"));
        match.setData("connect");

        matches.append(match);
    }
    else if (term == "disconnect")
    {
        QueryMatch match(this);

        match.setType(QueryMatch::ExactMatch);
        match.setIcon(KIcon("user-offline"));
        match.setText(i18n("Set all accounts as offline"));
        match.setData("disconnect");

        matches.append(match);
    }
    else if (term.startsWith(QLatin1String("status")))
    {
        QStringList query = context.query().split(' ');
        // Take the status text
        query.takeFirst();
        if (!query.isEmpty())
        {
            // Take the status to set
            const QString status = query.takeFirst();
            if (!status.isEmpty())
            {
                QueryMatch match(this);

                match.setType(QueryMatch::ExactMatch);
                match.setIcon(KIcon("user-away"));
                match.setText(i18nc("The \': \' is used as a separator", "Status: %1", status));
                // Rejoin the status message
                const QString message = query.join(" ");
                if (!message.isEmpty())
                    match.setSubtext(i18nc("The \': \' is used as a separator", "Message: %1", message));
                match.setData("status");

                matches.append(match);
            }
        }
    }
    else if (term.startsWith(QLatin1String("message")))
    {
        QStringList query = context.query().split(' ');
        // Take the status text
        query.takeFirst();
        if (!query.isEmpty())
        {
            // Rejoin the rest of the message
            const QString message = query.join(" ");
            if (!message.isEmpty())
            {
                QueryMatch match(this);

                match.setType(QueryMatch::ExactMatch);
                match.setIcon(KIcon("im-status-message-edit"));
                match.setText(i18nc("The \': \' is used as a separator", "Message: %1", message));
                match.setData(i18n("Set Status Message"));
                match.setData("status");

                matches.append(match);
            }
        }
    }
    QHashIterator<QString, QVariantMap> i(m_contactData);
    while (i.hasNext()) {
	i.next();
        // Keep a reference for easier use
        const ContactProperties& props = i.value();
        // Skip unreachable contacts
        if (!props["message_reachable"].toBool())
            continue;

        const QString name = props["display_name"].toString();
        const QString picture = props["picture"].toString();
        const QString status = props["status"].toString();
        const QString message = props["status_message"].toString();
        if (name.contains(term, Qt::CaseInsensitive))
        {
            QueryMatch match(this);

            match.setType((name.compare(context.query(), Qt::CaseInsensitive)) ? QueryMatch::PossibleMatch : QueryMatch::ExactMatch);
            match.setIcon(KIcon(KUrl(picture).isLocalFile() ? picture : "kopete"));
            match.setText(i18n("Send message to %1", name));
            const QString statusLine = i18n("Status: %1", status);
            const QString subtext = message.isEmpty() ? statusLine : i18n("%1\nMessage: %2", statusLine, message);
            match.setSubtext(subtext);
            match.setData(i.key());

            matches.append(match);
        }
    }

    context.addMatches(term, matches);
}
开发者ID:KDE,项目名称:kdeplasma-addons,代码行数:101,代码来源:kopeterunner.cpp

示例3: match

void AudioPlayerControlRunner::match(Plasma::RunnerContext &context)
{
    if (context.query().length() < 3) {
        return;
    }

    const QString term = context.query();

    QList<Plasma::QueryMatch> matches;

    if (m_useCommands) {
        /* DBus paths that are used in the command executes */
        /* The data variable looks like this:
         * "/PlayerQLatin1String( " " )org.freedesktop.MediaPlayerQLatin1String( " " )PlayQLatin1String( " " )actionsQLatin1String( " " )start" args...
         * <path>    <interface>                 <method> <actions> <start player>
         * <actions> is NONE if no action is needed
         */

        QVariantList playcontrol;
        playcontrol  << QLatin1String( "/Player" ) << QLatin1String( "org.freedesktop.MediaPlayer" );

        /* The commands */

        //Play
        if (context.isValid() && m_comPlay.startsWith(term, Qt::CaseInsensitive) &&
	    (!m_running || m_songsInPlaylist)) {
            QVariantList data = playcontrol;
            data << ((currentSong() == -1) ? QLatin1String( "Next" ) : QLatin1String( "Play" )) << NONE << QLatin1String( "start" );
            matches << createMatch(this, i18n("Start playing"), i18n("Audio player control"), QLatin1String( "play" ),
                                   KIcon( QLatin1String( "media-playback-start" )), data, 1.0);
        }

        if (!context.isValid() || !m_running) {
            //The interface of the player is not availalbe, so the rest of the commands
            //is not needed
            context.addMatches(matches);
            return;
        }

        if (context.isValid() && m_songsInPlaylist) {
            //The playlist isn't empty
            //Next song
            if (m_comNext.startsWith(term,Qt::CaseInsensitive)
                    && m_nextSongAvailable) {
                QVariantList data = playcontrol;
                data << QLatin1String( "Next" ) << NONE << QLatin1String( "nostart" );
                matches << createMatch(this, i18n("Play next song"), i18n("Audio player control"),
                                       QLatin1String( "next" ), KIcon( QLatin1String( "media-skip-forward" )), data, 1.0);
            }

            //Previous song
            if (context.isValid() && m_comPrev.startsWith(term,Qt::CaseInsensitive)
                    && m_prevSongAvailable) {
                QVariantList data = playcontrol;
                data << QLatin1String( "Prev" ) << NONE << QLatin1String( "nostart" );
                matches << createMatch(this, i18n("Play previous song"), i18n("Audio player control") ,
                                       QLatin1String( "previous" ), KIcon( QLatin1String( "media-skip-backward" )), data, 1.0);
            }
        }//--- if (m_songsInPlaylist)

        //Pause
        if (context.isValid() && m_comPause.startsWith(term,Qt::CaseInsensitive)) {
            QVariantList data = playcontrol;
            data << QLatin1String( "Pause" ) << NONE << QLatin1String( "nostart" );
            matches << createMatch(this, i18n("Pause playing"), i18n("Audio player control"),
                                   QLatin1String( "pause" ), KIcon( QLatin1String( "media-playback-pause" )), data, 1.0);
        }

        //Stop
        if (context.isValid() && m_comStop.startsWith(term,Qt::CaseInsensitive)) {
            QVariantList data = playcontrol;
            data << QLatin1String( "Stop" ) << NONE << QLatin1String( "nostart" );
            matches << createMatch(this, i18n("Stop playing"), i18n("Audio player control"),
                                   QLatin1String( "stop" ), KIcon( QLatin1String( "media-playback-stop" )), data, 1.0);
        }

        //Increase
        if (context.isValid() && m_comIncrease.startsWith(term,Qt::CaseInsensitive)) {
            QVariantList data = playcontrol;
            data << QLatin1String( "VolumeUp" ) << NONE << QLatin1String( "nostart" ) << m_increaseBy;
            matches << createMatch(this, i18n("Increase volume by %1" , m_increaseBy),
                                   QLatin1String( "volumeup" ), i18n("Audio player control"), KIcon(QLatin1String( "audio-volume-high" )), data, 1.0);
        } else if (context.isValid() && equals(term, QRegExp( m_comIncrease + QLatin1String( " \\d{1,2}0{0,1}" ) ) ) ) {
            int volumeChange = getNumber(term, ' ' );
            QVariantList data = playcontrol;
            data << QLatin1String( "VolumeUp" ) << NONE << QLatin1String( "nostart" ) << volumeChange;
            matches << createMatch(this, i18n("Increase volume by %1" , volumeChange),
                                   QLatin1String( "volumeup" ), i18n("Audio player control"), KIcon(QLatin1String( "audio-volume-high" )), data, 1.0);
        }

        //Decrease
        if (context.isValid() && m_comDecrease.startsWith(term,Qt::CaseInsensitive)) {
            QVariantList data = playcontrol;
            data << QLatin1String( "VolumeDown" ) << NONE << QLatin1String( "nostart" ) << m_decreaseBy;
            matches << createMatch(this, i18n("Reduce volume by %1", m_decreaseBy),
                                   QLatin1String( "volumedown" ), i18n("Audio player control"), KIcon(QLatin1String( "audio-volume-low" )), data, 1.0);
        } else if (context.isValid() && equals(term, QRegExp( m_comDecrease + QLatin1String( " \\d{1,2}0{0,1}" ) ) ) ) {
            int volumeChange = getNumber(term, ' ');
            QVariantList data = playcontrol;
            data << QLatin1String( "VolumeDown" ) << NONE << QLatin1String( "nostart" ) << volumeChange;
//.........这里部分代码省略.........
开发者ID:KDE,项目名称:kdeplasma-addons,代码行数:101,代码来源:audioplayercontrolrunner.cpp

示例4: match

void PowerDevilRunner::match(Plasma::RunnerContext &context)
{
    const QString term = context.query();
    if (term.length() < m_shortestCommand) {
        return;
    }

    QList<Plasma::QueryMatch> matches;

    QString parameter;

    if (parseQuery(term,
                   QList<QRegExp>() << QRegExp(i18nc("Note this is a KRunner keyword; %1 is a parameter", "power profile %1", "(.*)"), Qt::CaseInsensitive)
                                    << QRegExp(i18nc("Note this is a KRunner keyword", "power profile"), Qt::CaseInsensitive),
                   parameter)) {
        for (StringStringMap::const_iterator i = m_availableProfiles.constBegin(); i != m_availableProfiles.constEnd(); ++i) {
            if (!parameter.isEmpty()) {
                if (!i.value().startsWith(parameter, Qt::CaseInsensitive)) {
                    continue;
                }
            }
            Plasma::QueryMatch match(this);
            match.setType(Plasma::QueryMatch::ExactMatch);
            match.setIcon(KIcon(m_profileIcon[i.key()]));
            match.setText(i18n("Set Profile to '%1'", i.value()));
            match.setData(i.key());
            match.setRelevance(1);
            match.setId("ProfileChange "+ i.key());
            matches.append(match);
        }
    } else if (parseQuery(term,
                          QList<QRegExp>() << QRegExp(i18nc("Note this is a KRunner keyword; %1 is a parameter", "screen brightness %1", "(.*)"), Qt::CaseInsensitive)
                                           << QRegExp(i18nc("Note this is a KRunner keyword", "screen brightness"), Qt::CaseInsensitive)
                                           << QRegExp(i18nc("Note this is a KRunner keyword; %1 is a parameter", "dim screen %1", "(.*)"), Qt::CaseInsensitive)
                                           << QRegExp(i18nc("Note this is a KRunner keyword", "dim screen"), Qt::CaseInsensitive),
                          parameter)) {
        if (!parameter.isEmpty()) {
            bool test;
            int b = parameter.toInt(&test);
            if (test) {
                int brightness = qBound(0, b, 100);
                Plasma::QueryMatch match(this);
                match.setType(Plasma::QueryMatch::ExactMatch);
                match.setIcon(KIcon("preferences-system-power-management"));
                match.setText(i18n("Set Brightness to %1", brightness));
                match.setData(brightness);
                match.setRelevance(1);
                match.setId("BrightnessChange");
                matches.append(match);
            }
        } else {
            Plasma::QueryMatch match1(this);
            match1.setType(Plasma::QueryMatch::ExactMatch);
            match1.setIcon(KIcon("preferences-system-power-management"));
            match1.setText(i18n("Dim screen totally"));
            match1.setRelevance(1);
            match1.setId("DimTotal");
            matches.append(match1);

            Plasma::QueryMatch match2(this);
            match2.setType(Plasma::QueryMatch::ExactMatch);
            match2.setIcon(KIcon("preferences-system-power-management"));
            match2.setText(i18n("Dim screen by half"));
            match2.setRelevance(1);
            match2.setId("DimHalf");
            matches.append(match2);

            Plasma::QueryMatch match3(this);
            match3.setType(Plasma::QueryMatch::ExactMatch);
            match3.setIcon(KIcon("video-display"));
            match3.setText(i18n("Turn off screen"));
            match3.setRelevance(1);
            match3.setId("TurnOffScreen");
            matches.append(match3);
        }
    } else if (term.compare(i18nc("Note this is a KRunner keyword", "suspend"), Qt::CaseInsensitive) == 0) {
        QSet< Solid::PowerManagement::SleepState > states = Solid::PowerManagement::supportedSleepStates();

        if (states.contains(Solid::PowerManagement::SuspendState)) {
            addSuspendMatch(Solid::PowerManagement::SuspendState, matches);
        }

        if (states.contains(Solid::PowerManagement::HibernateState)) {
            addSuspendMatch(Solid::PowerManagement::HibernateState, matches);
        }
    } else if (term.compare(i18nc("Note this is a KRunner keyword", "sleep"), Qt::CaseInsensitive) == 0 ||
               term.compare(i18nc("Note this is a KRunner keyword", "to ram"), Qt::CaseInsensitive) == 0) {
        addSuspendMatch(Solid::PowerManagement::SuspendState, matches);
    } else if (term.compare(i18nc("Note this is a KRunner keyword", "hibernate"), Qt::CaseInsensitive) == 0 ||
               term.compare(i18nc("Note this is a KRunner keyword", "to disk"), Qt::CaseInsensitive) == 0) {
        addSuspendMatch(Solid::PowerManagement::HibernateState, matches);
    }

    if (!matches.isEmpty()) {
        context.addMatches(term, matches);
    }
}
开发者ID:mgottschlag,项目名称:kwin-tiling,代码行数:97,代码来源:PowerDevilRunner.cpp


注:本文中的plasma::RunnerContext::addMatches方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。