标签:
在这篇文章中,我们将介绍如何使用gallery PreviewWidget在Scope Preview中显示多幅图片。更多关于PreviewWidget类型可以参阅API。
首先,我们来下载我们上一节课里讲到的scopetemplate例程:
git clone https://gitcafe.com/ubuntu/scopetemplates_video.git
为了能够显示多幅图片,我们对我们的程序做了如下的修改:
// add an array to show the gallary of it sc::VariantArray arr; for(const auto &datum : icons_) { arr.push_back(Variant(datum.toStdString())); } r["array"] = sc::Variant(arr);
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"])); 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); } reply->push( widgets );
PreviewWidget gallery("gallerys", "gallery"); gallery.add_attribute_value("sources", Variant(result["array"]));
PreviewWidget gallery("gallerys", "gallery"); gallery.add_attribute_mapping("sources", "array");
标签:
原文地址:http://blog.csdn.net/ubuntutouch/article/details/46606673