怎样在QML应用中调用系统设置中的页面来设置我们的系统

我们在QML应用中有时须要调用系统设置(system settings)来完毕我们的一些设置。比方,我们在使用GPS来定位时,可能GPS并没有打开,假设在我们的应用中直接打开系统中的GPS设置页面,这样我们就能够直接打开系统的GPS而不用单独设计一个页面。我们能够通过使用URL dispatcher的方法来打开另外一个应用。在先前的我们的文章中,我们已经讲述了非常多关于URL dispatcher方面的东西:

  1. 怎么在Ubuntu手机上发送短信及拨打电话
  2. 使用URL dispatcher的范例

关于系统设置(system-settings)的源代码,我们能够在 地址找到。


怎样查看系统的url dispatcher


通常情况下,我们可能非常想知道系统中究竟有那些的URL dispatcher。

我们能够通过例如以下的命名来查看我们的手机系统的URL dispatcher:


 


上面列举了我们手机系统中已经有的URL dispatcher。

比方我们能够查看system-settings的url dispatcher的protocol:



[
        {
                "protocol": "settings"
        }
]


这样我们在我们的QML应用中使用例如以下的方法来启动系统设置中的页面:

 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);
                        }
                    }
                }
            }

        }
    }
}

执行我们的应用:

  

posted on 2017-07-30 21:00 mthoutai 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/mthoutai/p/7260433.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值