qml-app-development有任何标准图标吗?
我正在开发一个qml-app,我想在按钮上放置图标。 我想使用ubuntu标准图标来获取真正的ubuntu外观我的应用程序。 我怎样才能做到这一点?
官方的Ubuntu Touch图标主题称为Ubuntu Mobile,可以在ubuntu-mobile-icons
包中安装。 以下是提供的图标示例:
要使用代码中的图标,只需使用图标的路径即可。 例如,要在工具栏按钮中设置图标,请执行以下操作:
ToolbarButton { text: i18n.tr("Refresh") iconSource: Qt.resolvedUrl("/usr/share/icons/ubuntu-mobile/actions/scalable/reload.svg") }
为了避免不得不一遍又一遍地重复根路径,我通常使用一个名为getIcon
的小函数,它返回一个图标的实际路径:
function getIcon(name) { return Qt.resolvedUrl("/usr/share/icons/ubuntu-mobile/actions/scalable/" + name + ".svg") }
之前的例子是:
ToolbarButton { text: i18n.tr("Refresh") iconSource: getIcon("reload") }
我刚刚开始涉足QML,但看起来Ubuntu SDK提供了一种从主题Icon元素访问图标的方法。 这是一个Hello Worldish示例:
import QtQuick 2.0 import Ubuntu.Components 0.1 MainView { id: root objectName: "mainView" width: units.gu(50) height: units.gu(75) property real margins: units.gu(2) property real buttonWidth: units.gu(9) Page { title: i18n.tr("Icons!") Column { anchors { fill: parent margins: root.margins } spacing: units.gu(1) Icon { name: "call-start" width: 48 height: 48 } Icon { name: "call-stop" width: 48 height: 48 } Icon { name: "find" width: 48 height: 48 } } } }
这给你:
AFAICT,这实际上似乎不支持Freedesktop Icon主题规范提供的全套图标,但…..
Ubuntu手机的默认主题是Suru,图标位于/usr/share/icons/suru
任何图标都可以按名称使用。 甚至Suru图标外的图标设置。
如果文件是/usr/share/icons/suru/actions/scalable/like.svg
代码可以是:
Action { id: likeAction iconName: "like" // the files name without file ending text: "I like this" }
这为您提供了一个带有心形图标的动作按钮。