You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by za...@apache.org on 2015/07/23 13:18:04 UTC

[02/10] cordova-ubuntu git commit: support Orientation preference from config.xml

support Orientation preference from config.xml


Project: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/commit/8db47ce6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/tree/8db47ce6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/diff/8db47ce6

Branch: refs/heads/master
Commit: 8db47ce687ae9f8bc60992c6fc0fd0344b4678f7
Parents: 1fd49d7
Author: Maxim Ermilov <ma...@canonical.com>
Authored: Thu Jan 15 22:11:30 2015 +0300
Committer: Maxim Ermilov <ma...@canonical.com>
Committed: Thu Jul 23 11:03:04 2015 +0300

----------------------------------------------------------------------
 CordovaUbuntu/CordovaViewInternal.qml |  2 +-
 qml/CordovaView.qml.in                | 10 ++++++++++
 src/cordova_config.cpp                | 12 ++++++++++++
 src/cordova_config.hpp                | 10 ++++++++++
 4 files changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/8db47ce6/CordovaUbuntu/CordovaViewInternal.qml
----------------------------------------------------------------------
diff --git a/CordovaUbuntu/CordovaViewInternal.qml b/CordovaUbuntu/CordovaViewInternal.qml
index 4c7009a..f9ba11c 100644
--- a/CordovaUbuntu/CordovaViewInternal.qml
+++ b/CordovaUbuntu/CordovaViewInternal.qml
@@ -22,7 +22,7 @@ import "cordova_wrapper.js" as CordovaWrapper
 import Ubuntu.Components 0.1
 import Ubuntu.Components.Popups 0.1
 
-Item {
+OrientationHelper {
     id: root
 
     anchors.fill: parent

http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/8db47ce6/qml/CordovaView.qml.in
----------------------------------------------------------------------
diff --git a/qml/CordovaView.qml.in b/qml/CordovaView.qml.in
index 79f2c0c..a9b14fe 100644
--- a/qml/CordovaView.qml.in
+++ b/qml/CordovaView.qml.in
@@ -45,6 +45,16 @@ Item {
             cordova.parent = loader.item
 
             loader.item.completed.connect(function() {
+                if (cordova.config().orientation() == 0) {
+                    loader.item.automaticOrientation = true
+                } else {
+                    loader.item.automaticOrientation = true
+                    if (cordova.config().orientation() == 1)
+                        loader.item.orientationAngle = 90
+                    else
+                        loader.item.orientationAngle = 0
+                }
+
                 loader.item.visible = true
                 loader.visible = true
                 splashscreen.visible = false

http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/8db47ce6/src/cordova_config.cpp
----------------------------------------------------------------------
diff --git a/src/cordova_config.cpp b/src/cordova_config.cpp
index b736783..da66e7b 100644
--- a/src/cordova_config.cpp
+++ b/src/cordova_config.cpp
@@ -39,6 +39,7 @@ Config::Config(const QString &xmlConfig) {
 
     _fullscreen = false;
     _disallowOverscroll = false;
+    _orientation = DEFAULT_ORIENTATION;
     nodes = config.documentElement().elementsByTagName("preference");
     for (int i = 0; i < nodes.size(); ++i) {
         QDomNode node = nodes.at(i);
@@ -50,6 +51,12 @@ Config::Config(const QString &xmlConfig) {
             _fullscreen = value == "true";
         if (name == "DisallowOverscroll")
             _disallowOverscroll = value == "true";
+        if (name == "Orientation") {
+            if (value == "landscape")
+                _orientation = LANDSCAPE;
+            if (value == "portrait")
+                _orientation = PORTRAIT;
+        }
     }
 
     _content = "index.html";
@@ -64,6 +71,11 @@ Config::Config(const QString &xmlConfig) {
 
     _appId = config.documentElement().attribute("id");
     _appVersion = config.documentElement().attribute("version");
+
+}
+
+int Config::orientation() const {
+    return _orientation;
 }
 
 const WhiteList& Config::whitelist() const {

http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/8db47ce6/src/cordova_config.hpp
----------------------------------------------------------------------
diff --git a/src/cordova_config.hpp b/src/cordova_config.hpp
index 619f277..8625d79 100644
--- a/src/cordova_config.hpp
+++ b/src/cordova_config.hpp
@@ -24,6 +24,12 @@ namespace CordovaInternal {
     class Config: public QObject {
         Q_OBJECT
     public:
+        enum Orientation {
+            DEFAULT_ORIENTATION = 0,
+            LANDSCAPE = 1,
+            PORTRAIT = 2
+        };
+
         explicit Config(const QString &xmlConfig);
 
         const WhiteList& whitelist() const;
@@ -34,12 +40,16 @@ namespace CordovaInternal {
 
         bool disallowOverscroll() const;
         Q_INVOKABLE bool fullscreen() const;
+
+        Q_INVOKABLE int orientation() const;
     private:
         WhiteList _whitelist;
         QString _content;
         QString _appId, _appVersion;
         bool _fullscreen, _disallowOverscroll;
 
+        Orientation _orientation;
+
         Q_DISABLE_COPY(Config);
     };
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org