We can use reviews Previewwidget to show our results. For the review, for example, if it is a 5-star rating, we can show 5 stars indicating the highest level of customer acceptance of a product.
To see our API's connection, we can see the following code:
{ previewwidget W1 ("Summary", "reviews"); W1.add_attribute_value ("Rating-icon-empty", Variant ("File:///tmp/star-empty.svg")); W1.add_attribute_value ("Rating-icon-full", Variant ("File:///tmp/star-full.svg")); Variantbuilder Builder; Builder.add_tuple ({ {"author", Variant ("John Doe")}, {"rating", Variant (3)} ); Builder.add_tuple ({ {"author", Variant ("Mr Smith")}, {"rating", Variant (5)} ); W1.add_attribute_value ("Reviews", Builder.end ()); ...}
Although the use of their own definition of the picture "Rating-icon-empty" and "Rating-icon-full", but I think it is generally not recommended to use although it can be customized. The reason is that we have to strictly follow the Ubuntu standard icon to design their own pictures, so as to make the display is correct!
In combination with the above code, we use the following code in our own code:
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);
Here we have added an item "review" to denote a textual evaluation of a product. Here we do not use any custom images, which by default are used by the system itself.
To run our scope, the following is displayed:
The source code for the entire project is: Git clone https://gitcafe.com/ubuntu/scopetemplates_review.git
Use reviews Previewwidget to display rating levels in Ubuntu scope