如何得到Ubuntu UI Toolkit的版本

161 阅读1分钟

我们知道在利用Ubuntu Toolkit的时候,我们总希望能够得到我们手机的Toolkit的版本.这样我们可以知道那些API是可以用的,那些是不可以在我们的手机版本中运用的.在我们的API网址中,有许多的API有如下的描述:

\

\

它表明该API所能够支持的Ubuntu.Components的版本.那么我们怎么能够发现我们的手机的Ubuntu.Components的版本呢?

\

方法一:

\

在手机中我们通过命令行的方法来寻找,比如:

\

\

\

通过上面的命令,我们可以看到在手机中有如下的文件目录存在:

\

/usr/lib/arm-linux-gnueabihf/qt5/qml/Ubuntu/Components/1.3

\

表明"1.3"版本是在我们的手机中被支持的.

\

方法二

\

通过Ubuntu API的方法得到:

\

Main.qml

\

import QtQuick 2.4
import Ubuntu.Components 1.3

MainView {
    // objectName for functional testing purposes (autopilot-qt5)
    objectName: "mainView"

    // Note! applicationName needs to match the "name" field of the click manifest
    applicationName: "ubuntutoolkitversion.liu-xiao-guo"

    width: units.gu(60)
    height: units.gu(85)

    Page {
        title: i18n.tr("ubuntutoolkitversion")

        Column {
            anchors.centerIn: parent
            Label { text: "Toolkit ver: " + Ubuntu.toolkitVersion  }
            Label { text: "Major: " + Ubuntu.toolkitVersionMajor  }
            Label { text: "Minor: " + Ubuntu.toolkitVersionMinor  }
            Label { text: "Toolkit ver: " + Ubuntu.version(Ubuntu.toolkitVersionMajor,
                                         Ubuntu.toolkitVersionMinor)  }
        }
    }
}

\

就像API的描述一样,这个API是从Ubuntu.Components 1.2版本中开始支持的.运行该应用:

\

\

\

我们从上面的输出可以看出来,手机中的Ubuntu Toolkit的版本是1.3.

整个项目的源码在: github.com/liu-xiao-gu…

\

\