首页 > 系统服务 > 详细

如何固定你的Ubuntu应用的方向

时间:2015-08-28 17:40:45      阅读:250      评论:0      收藏:0      [点我收藏+]

在这篇文章中,我们将介绍如何固定一个Ubuntu应用的方向。固定应用的方向对有些游戏应用来说,非常有用。这样可以让游戏专注于一个方向的布局,比如开车的游戏!


在Ubuntu应用中,我们可以通过如下的flag:


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

    // Note! applicationName needs to match the "name" field of the click manifest
    applicationName: "usermetrics.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)
   ...
}

这里有一个automaticOrientation标志位。由于一些原因,目前还是不能正常工作,虽然我们可以设置它为false。


目前我发现一个更加简单的办法,就是直接修改项目的.desktop文件:


[Desktop Entry]
Name=fixedorientationapp
Exec=qmlscene $@ Main.qml
Icon=fixedorientationapp.png
Terminal=false
Type=Application
X-Ubuntu-Touch=true
X-Ubuntu-Supported-Orientations=landscape


我们在上面添加了X-Ubuntu-Supported-Orientations=landscape。这样我们的应用就只有在landscape模式下。


当我们把项目的.desktop文件修改为:


[Desktop Entry]
Name=fixedorientationapp
Exec=qmlscene $@ Main.qml
Icon=fixedorientationapp.png
Terminal=false
Type=Application
X-Ubuntu-Touch=true
X-Ubuntu-Supported-Orientations=portrait

当我们运行我们的应用时,我们的应用只有在portrait模式下运行。不可以更改。

技术分享


整个应用的代码: git clone https://gitcafe.com/ubuntu/fixedorientationapp.git



版权声明:本文为博主原创文章,未经博主允许不得转载。

如何固定你的Ubuntu应用的方向

原文:http://blog.csdn.net/ubuntutouch/article/details/48053233

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!