void Preview::run(sc::PreviewReplyProxy const& reply) {
    // Support three different column layouts
    sc::ColumnLayout layout1col(1), layout2col(2), layout3col(3);

    // We define 3 different layouts, that will be used depending on the
    // device. The shell (view) will decide which layout fits best.
    // If, for instance, we are executing in a tablet probably the view will use
    // 2 or more columns.
    // Column layout definitions are optional.
    // However, we recommend that scopes define layouts for the best visual appearance.

    // Single column layout
    layout1col.add_column( { "image", "header", "summary", "tracks" });

    // Two column layout
    layout2col.add_column( { "image" });
    layout2col.add_column( { "header", "summary", "tracks"});

    // Three cokumn layout
    layout3col.add_column( { "image" });
    layout3col.add_column( { "header", "summary", "tracks"});
    layout3col.add_column( { });

    // Register the layouts we just created
    reply->register_layout( { layout1col, layout2col, layout3col });

    // Define the header section
    sc::PreviewWidget header("header", "header");
    // It has title and a subtitle properties
    header.add_attribute_mapping("title", "title");
    header.add_attribute_mapping("subtitle", "subtitle");

    // Define the image section
    sc::PreviewWidget image("image", "image");
    // It has a single source property, mapped to the result's art property
    image.add_attribute_mapping("source", "art");

    // Define the summary section
    sc::PreviewWidget description("summary", "text");
    // It has a text property, mapped to the result's description property
    description.add_attribute_mapping("text", "description");

    Result result = PreviewQueryBase::result();
    PreviewWidget listen("tracks", "audio");
    {
        VariantBuilder builder;
        builder.add_tuple({
            {"title", Variant("This is the song title")},
            {"source", Variant(result["musicSource"].get_string().c_str())}
        });
        listen.add_attribute_value("tracks", builder.end());
    }

    if ( result["musicSource"].get_string().length() != 0 ) {
        qDebug() << "it is not null";
        // Push each of the sections
        reply->push( { image, header, description, listen });

    } else {
        // Push each of the sections
        reply->push( { image, header, description });
    }
}
void Preview::run(sc::PreviewReplyProxy const& reply) {
    // Support three different column layouts
    sc::ColumnLayout layout1col(1), layout2col(2), layout3col(3);

    // We define 3 different layouts, that will be used depending on the
    // device. The shell (view) will decide which layout fits best.
    // If, for instance, we are executing in a tablet probably the view will use
    // 2 or more columns.
    // Column layout definitions are optional.
    // However, we recommend that scopes define layouts for the best visual appearance.

    // Single column layout
    layout1col.add_column( { "image", "header", "summary", "tracks",
                             "videos", "gallery_header", "gallerys", "reviews", "exp",
                              "review_input", "rating_input" });

    // Two column layout
    layout2col.add_column( { "image" });
    layout2col.add_column( { "header", "summary", "tracks",
                              "videos", "gallery_header", "gallerys", "reviews","exp",
                              "review_input", "rating_input" });

    // Three cokumn layout
    layout3col.add_column( { "image" });
    layout3col.add_column( { "header", "summary", "tracks",
                             "videos", "gallery_header", "gallerys", "reviews", "exp",
                             "review_input", "rating_input" });

    layout3col.add_column( {} );

    // Register the layouts we just created
    reply->register_layout( { layout1col, layout2col, layout3col });

    // Define the header section
    sc::PreviewWidget header("header", "header");
    // It has title and a subtitle properties
    header.add_attribute_mapping("title", "title");
    header.add_attribute_mapping("subtitle", "subtitle");

    // Define the image section
    sc::PreviewWidget image("image", "image");
    // It has a single source property, mapped to the result's art property
    image.add_attribute_mapping("source", "art");

    // Define the summary section
    sc::PreviewWidget description("summary", "text");
    // It has a text property, mapped to the result's description property
    description.add_attribute_mapping("text", "description");

    Result result = PreviewQueryBase::result();
    PreviewWidget listen("tracks", "audio");
    {
        VariantBuilder builder;
        builder.add_tuple({
            {"title", Variant("This is the song title")},
            {"source", Variant(result["musicSource"].get_string().c_str())}
        });
        listen.add_attribute_value("tracks", builder.end());
    }

    PreviewWidget video("videos", "video");
    video.add_attribute_value("source", Variant(result["videoSource"].get_string().c_str()));
    video.add_attribute_value("screenshot", Variant(result["screenshot"].get_string().c_str()));

    sc::PreviewWidget header_gal("gallery_header", "header");
    header_gal.add_attribute_value("title", Variant("Gallery files are:"));

    PreviewWidget gallery("gallerys", "gallery");
//    gallery.add_attribute_value("sources", Variant(result["array"]));
    gallery.add_attribute_mapping("sources", "array");

    PreviewWidgetList widgets({ image, header, description });

    if ( result["musicSource"].get_string().length() != 0 ) {
        widgets.emplace_back(listen);
    }

    if( result["videoSource"].get_string().length() != 0 ) {
        widgets.emplace_back(video);
    }

    if( result["array"].get_array().size() != 0 ) {
        widgets.emplace_back(header_gal);
        widgets.emplace_back(gallery);
    }

    // The following shows the review
    PreviewWidget review("reviews", "reviews");
    VariantBuilder builder;
    builder.add_tuple({
                          {"author", Variant("John Doe")},
                          {"review", Variant("very good")},
                          {"rating", Variant(3.5)}
                      });
    builder.add_tuple({
                          {"author", Variant("Mr. Smith")},
                          {"review", Variant("very poor")},
                          {"rating", Variant(5)}
                      });
    review.add_attribute_value("reviews", builder.end());
    widgets.emplace_back(review);

    // The following shows the expandable
    PreviewWidget expandable("exp", "expandable");
    expandable.add_attribute_value("title", Variant("This is an expandable widget"));
    expandable.add_attribute_value("collapsed-widgets", Variant(1));
    PreviewWidget w1("w1", "text");
    w1.add_attribute_value("title", Variant("Subwidget 1"));
    w1.add_attribute_value("text", Variant("A text"));
    PreviewWidget w2("w2", "text");
    w2.add_attribute_value("title", Variant("Subwidget 2"));
    w2.add_attribute_value("text", Variant("A text"));
    expandable.add_widget(w1);
    expandable.add_widget(w2);
    widgets.emplace_back(expandable);

    // The following shows a review rating-input
    PreviewWidget w_review("review_input", "rating-input");
    w_review.add_attribute_value("submit-label", Variant("Send"));
    w_review.add_attribute_value("visible", Variant("review"));
    w_review.add_attribute_value("required", Variant("review"));
    std::string reply_label = "Reply";
    std::string max_chars_label = "140 characters max";
    w_review.add_attribute_value("review-label", Variant(reply_label + ": " + max_chars_label));
    widgets.emplace_back(w_review);

    // The follwing shows a rating rating-input
    PreviewWidget w_rating("rating_input", "rating-input");
    w_rating.add_attribute_value("visible", Variant("rating"));
    w_rating.add_attribute_value("required", Variant("rating"));
    w_rating.add_attribute_value("rating-label", Variant("Please rate this"));
    widgets.emplace_back(w_rating);

    reply->push( widgets );
}
Beispiel #3
0
void Preview::run(sc::PreviewReplyProxy const& reply) {
    // Support three different column layouts
    sc::ColumnLayout layout1col(1), layout2col(2), layout3col(3);

    // We define 3 different layouts, that will be used depending on the
    // device. The shell (view) will decide which layout fits best.
    // If, for instance, we are executing in a tablet probably the view will use
    // 2 or more columns.
    // Column layout definitions are optional.
    // However, we recommend that scopes define layouts for the best visual appearance.

    // Single column layout
    layout1col.add_column( { "image", "header", "reviewId", "actions" });

    // Two column layout
    layout2col.add_column( { "image" });
    layout2col.add_column( { "header", "reviewId", "actions" });

    // Three cokumn layout
    layout3col.add_column( { "image" });
    layout3col.add_column( { "header", "reviewId", "actions" });
    layout3col.add_column( { });

    // Register the layouts we just created
    reply->register_layout( { layout1col, layout2col, layout3col });

    // Define the header section
    sc::PreviewWidget w_header("header", "header");
    // It has title and a subtitle properties
    w_header.add_attribute_mapping("title", "title");
    w_header.add_attribute_mapping("subtitle", "subtitle");

    // Define the image section
    sc::PreviewWidget w_image("image", "image");
    // It has a single source property, mapped to the result's art property
    w_image.add_attribute_mapping("source", "art");

    Result result = PreviewQueryBase::result();
    QString urlString(result["uri"].get_string().c_str());

    // Create an Open button and provide the URI to open for this preview result
    sc::PreviewWidget w_actions("actions", "actions");
    sc::VariantBuilder builder;
    builder.add_tuple({
            {"id", Variant("open")},
            {"label", Variant("Open")},
            {"uri", sc::Variant(urlString.toStdString())} // uri set, this action will be handled by the Dash
        });
    w_actions.add_attribute_value("actions", builder.end());

     PreviewWidgetList widgets({ w_header });

    //used for blogging
    PreviewWidget w_review("reviewId", "rating-input");
    w_review.add_attribute_value("submit-label", Variant("Publish"));
    w_review.add_attribute_value("visible", Variant("review"));
    w_review.add_attribute_value("required", Variant("review"));
    std::string reply_label = "Reply";
    std::string max_chars_label = "140 characters max";
    if (result.contains("newblog"))
        w_review.add_attribute_value("review-label", Variant(max_chars_label));
    if (result.contains("replyblog"))
        w_review.add_attribute_value("review-label", Variant(reply_label + ": " + max_chars_label));
    if (result.contains("getusertext"))
        widgets.emplace_back(w_review);

    if (!result.contains("noart"))
    {
        widgets.emplace_back(w_image);
        widgets.emplace_back(w_actions);
    }

    // Push each of the sections
    reply->push( widgets );
}
void Preview::run(unity::scopes::PreviewReplyProxy const& reply)
{
    // Client can display Previews differently depending on the context
    // By creates two layouts (one with one column, one with two) and then
    // adding widgets to them differently, Unity can pick the layout the
    // scope developer thinks is best for the mode
    ColumnLayout layout1col(1), layout2col(2);

    // add columns and widgets (by id) to layouts.
    // The single column layout gets one column and all widets
    layout1col.add_column({"headerId", "artId", "infoId", "telId", "actionsId"});
    // The two column layout gets two columns.
    // The first column gets the art and header widgets (by id)
    layout2col.add_column({"artId", "headerId"});
    // The second column gets the info and actions widgets
    layout2col.add_column({"infoId", "telId", "actionsId"});

    // Push the layouts into the PreviewReplyProxy intance, thus making them
    // available for use in Preview diplay
    reply->register_layout({layout1col, layout2col});

    //Create some widgets
    // header type first. note 'headerId' used in layouts
    // second field ('header) is a standard preview widget type
    PreviewWidget w_header("headerId", "header");
    // This maps the title field of the header widget (first param)  to the
    // title field in the result to be displayed in this preview, thus providing
    // the result-specific data to the preview for display
    w_header.add_attribute_mapping("title", "title");

    // Standard subtitle field here gets our 'artist' key value
    // w_header.add_attribute_mapping("subtitle", "artist");

    PreviewWidget w_art("artId", "image");
    w_art.add_attribute_mapping("source", "art");

    PreviewWidget w_info("infoId", "text");
    w_info.add_attribute_mapping("text", "address");

    PreviewWidget w_tel("telId", "text");
    w_tel.add_attribute_mapping("text", "telephone");

    Result result = PreviewQueryBase::result();
    QString urlString(result["uri"].get_string().c_str());
    // qDebug() << "[Details] GET " << urlString;
   // QUrl url = QUrl(urlString);

    // Create an Open button and provide the URI to open for this preview result
    PreviewWidget w_actions("actionsId", "actions");
    VariantBuilder builder;
    builder.add_tuple({
            {"id", Variant("open")},
            {"label", Variant("Open")},
            {"uri", Variant(urlString.toStdString())} // uri set, this action will be handled by the Dash
        });
    w_actions.add_attribute_value("actions", builder.end());

    // Bundle out widgets as required into a PreviewWidgetList
    PreviewWidgetList widgets({w_header, w_art, w_info, w_tel, w_actions});
    // And push them to the PreviewReplyProxy as needed for use in the preview
    reply->push(widgets);
}
Beispiel #5
0
///
/// \brief Preview::run
/// \param reply
///
void Preview::run(sc::PreviewReplyProxy const& reply) {
    sc::ColumnLayout layout1col(1), layout2col(2), layout3col(3);
    //ONE
    layout1col.add_column( { "header_widget", "summary_widget", "rating", "actions", "comment", "warning", "refrence", "drive", "power"} );
    //TWO
    layout2col.add_column( { "header_widget", "summary_widget", "rating", "actions", "icon_actions" } );
    layout2col.add_column( { "image_widget", "comment", "warining", "refrence", "drive", "power" } );
    //THREE
    layout3col.add_column( { "header_widget", "rating", "actions" });
    layout3col.add_column( { "summary_widget", "actions", "icon_actions" } );
    layout3col.add_column( { "image_widget", "comment", "warining", "refrence", "drive", "power" } );
    ///
    reply->register_layout( { layout1col, layout2col, layout3col } );

    //IMAGE
    sc::PreviewWidget image("image_widget", "image");
    image.add_attribute_mapping("source", "art");

    //HEADER
    sc::PreviewWidget header("header_widget", "header");
    header.add_attribute_mapping("title", "title");
    header.add_attribute_mapping("subtitle", "subtitle");
    header.add_attribute_mapping("attributes", "attributes");

    //SUMMARY
    sc::PreviewWidget summary("summary_widget", "text");
    summary.add_attribute_mapping("text", "summary");
    ///
    sc::Result result = PreviewQueryBase::result();

    //ICON-ACTIONS
    sc::PreviewWidget actions("actions", "icon-actions");
    sc::VariantBuilder builder;
     builder.add_tuple({
        {"id", sc::Variant("open")},
        {"label", sc::Variant(_("Open Terminal"))},
        {"icon", sc::Variant("http://www.commandlinefu.com/images/favicon.ico")},
        {"temporaryIcon", sc::Variant("/usr/share/icons/suru/actions/scalable/tick.svg")},
        {"uri", result["term"]} });
     builder.add_tuple({
        {"id", sc::Variant("open")},
        {"label", sc::Variant(_("Get Terminal"))},
        {"icon", sc::Variant("//usr/share/icons/suru/apps/sources/ubuntu-store.svg")},
        {"temporaryIcon", sc::Variant("/usr/share/icons/suru/actions/scalable/tick.svg")},
        {"uri", result["clp"]} });
     actions.add_attribute_value("actions", builder.end());
     // Define the actions section
/*     sc::PreviewWidget icon_actions("actions", "actions");
     //sc::VariantBuilder builder;
     builder.add_tuple({
         {"id", sc::Variant("open")},
         {"label", sc::Variant("Open")},
         {"icon", sc::Variant("/usr/share/icons/suru/devices/scalable/phone-smartphone-symbolic.svg")},
         {"uri", result["uri"]}
                                  });
      builder.add_tuple({
         {"id", sc::Variant("open")},
         {"label", sc::Variant("Open Terminal")},
         {"uri", result["term"]}
                                  });
      builder.add_tuple({
         {"id", sc::Variant("open")},
         {"label", sc::Variant("Get Terminal")},
         {"uri", result["clp"]}
                                  });
     icon_actions.add_attribute_value("actions", builder.end()); */
     ///
     /// \brief rating
     ///
     sc::PreviewWidget rating("rating", "rating-edit");
     rating.add_attribute_value("visible", sc::Variant("review"));
     rating.add_attribute_value("required", sc::Variant("review"));
     rating.add_attribute_value("review-label", sc::Variant(_("Adapt and Copy/Paste Command:")));
     rating.add_attribute_value("submit-label", sc::Variant(_("Open")));
     rating.add_attribute_value("review", result["mmm"]);
     ///
     /// \brief comment
     ///
     sc::PreviewWidget comment("comment", "comment");
     comment.add_attribute_value("submit-label", sc::Variant("Comment it!"));
     comment.add_attribute_value("author", sc::Variant(_("WARNING:")));
     comment.add_attribute_value("source", sc::Variant("/usr/share/icons/suru/actions/scalable/security-alert.svg"));
     comment.add_attribute_value("comment", sc::Variant(_("The Terminal is a magical and powerful thing, on the phone it runs unconfined. Any  move can and will spell certain doom, delete your files, launch missiles, destroy your phone, or worse. YOU HAVE BEEN WARNED!")));
     ///
     /// \brief warning
     ///
     sc::PreviewWidget warning("warning", "comment");
     warning.add_attribute_value("submit-label", sc::Variant("Comment it!"));
     warning.add_attribute_value("author", sc::Variant(_("WARNING:")));
     warning.add_attribute_value("source", sc::Variant("/usr/share/icons/suru/devices/scalable/phone-smartphone-symbolic.svg"));
     warning.add_attribute_value("comment", sc::Variant(_("If using this scope on phone/tablet be aware that: <br> - The system image is read only for a reason, enabling read/write will compromise the system in a way that will ultimately brick or cause you to reflash the phone. <br> - If you choose to enable read/write be warned that you will not get system image updates <br> - Do not use apt/apt-get or any such utilites, they will break your phone.")));
     ///
     /// \brief refrence
     ///
     sc::PreviewWidget refrence("refrence", "comment");
     refrence.add_attribute_value("submit-label", sc::Variant("Comment it!"));
     refrence.add_attribute_value("author", sc::Variant(_("WARNING:")));
     refrence.add_attribute_value("source", sc::Variant("/usr/share/icons/suru/actions/scalable/edit-paste.svg"));
     refrence.add_attribute_value("comment", sc::Variant(_("Use for documentation purposes only, copy/pasting and running commands is a terrible idea and is not supported nor recommended")));
     ///
     /// \brief drive
     ///
     sc::PreviewWidget drive("drive", "comment");
     drive.add_attribute_value("submit-label", sc::Variant("Comment it!"));
     drive.add_attribute_value("author", sc::Variant(_("WARNING:")));
     drive.add_attribute_value("source", sc::Variant("/usr/share/icons/suru/devices/scalable/audio-carkit-symbolic.svg"));
     drive.add_attribute_value("comment", sc::Variant(_("Do not use while driving.")));
     ///
     /// \brief power
     ///
     sc::PreviewWidget power("power", "comment");
     power.add_attribute_value("submit-label", sc::Variant("Comment it!"));
     power.add_attribute_value("author", sc::Variant(_("Powered By:")));
     power.add_attribute_value("source", sc::Variant("/usr/share/icons/suru/status/scalable/system-devices-panel-information.svg"));
     power.add_attribute_value("comment", sc::Variant("www.commandlinefu.com"));


        //rating.add_attribute_value("rating-icon-empty", unity::scopes::Variant("file:///tmp/star-empty.svg"));
        //rating.add_attribute_value("rating-icon-full", unity::scopes::Variant("file:///tmp/star-full.svg"));

    // Push each of the sections
    reply->push( { image, header, summary, actions, rating, comment, warning, refrence, drive, power} );
}