标签:
我们在QML应用中有时需要调用系统设置(system settings)来完成我们的一些设置。比如,我们在使用GPS来定位时,可能GPS并没有打开,如果在我们的应用中直接打开系统中的GPS设置页面,这样我们就可以直接打开系统的GPS而不用单独设计一个页面。我们可以通过使用URL dispatcher的方法来打开另外一个应用。在先前的我们的文章中,我们已经讲述了很多关于URL dispatcher方面的东西:
[
{
"protocol": "settings"
}
]
Qt.openUrlExternally("settings:///system/about");import QtQuick 2.0
import Ubuntu.Components 1.1
/*!
\brief MainView with a Label and Button elements.
*/
MainView {
// objectName for functional testing purposes (autopilot-qt5)
objectName: "mainView"
// Note! applicationName needs to match the "name" field of the click manifest
applicationName: "urldispatcher.liu-xiao-guo"
/*
This property enables the application to change orientation
when the device is rotated. The default is false.
*/
//automaticOrientation: true
// Removes the old toolbar and enables new features of the new header.
useDeprecatedToolbar: false
width: units.gu(60)
height: units.gu(85)
property var plugins: ["about", "phone", "battery", "bluetooth", "brightness",
"cellular", "language", "background", "flight-mode",
"notifications", "orientation-lock", "reset", "security-privacy",
"sound", "system-update", "time-date", "wifi"]
Page {
title: i18n.tr("urldispatcher")
Flickable {
clip: true
width: parent.width
height: parent.height
contentHeight: content.childrenRect.height
Column {
id: content
anchors.centerIn: parent
spacing: units.gu(1)
Repeater {
model: plugins
delegate: Button {
text: modelData
onClicked: {
Qt.openUrlExternally("settings:///system/" + modelData);
}
}
}
}
}
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/ubuntutouch/article/details/47723685