[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [gluon/creator-qmlintro-shreya] creator: Adding top and bottom states for text alignment with corres
From:       Shreya Pandit <shreya () shreyapandit ! com>
Date:       2012-06-17 14:00:09
Message-ID: 20120617140009.32E5CA60A9 () git ! kde ! org
[Download RAW message or body]

Git commit d89085976a22cec86e622ba305fb3edf5a7b3258 by Shreya Pandit.
Committed on 17/06/2012 at 15:59.
Pushed by pandit into branch 'creator-qmlintro-shreya'.

Adding top and bottom states for text alignment with corresponding docker

M  +21   -3    creator/introslideshow.cpp
M  +6    -1    creator/introslideshow.h
M  +52   -6    creator/ui/introduction.qml

http://commits.kde.org/gluon/d89085976a22cec86e622ba305fb3edf5a7b3258

diff --git a/creator/introslideshow.cpp b/creator/introslideshow.cpp
index 89f225f..c663cfe 100644
--- a/creator/introslideshow.cpp
+++ b/creator/introslideshow.cpp
@@ -67,6 +67,16 @@ void IntroSlideShow::setDockername(QString name)
 
 }
 
+qreal IntroSlideShow::getdockY()
+{
+    return dockY;
+}
+
+qreal IntroSlideShow::getdockHeight()
+{
+    return dockHeight;
+}
+
 qreal IntroSlideShow::getdockX()
 {
     return dockX;
@@ -87,20 +97,28 @@ qreal IntroSlideShow::getrefWidth()
      return refWidth;
 }
 
+qreal IntroSlideShow::getrefHeight()
+{
+     return refHeight;
+}
+
 void IntroSlideShow::updateDocker()
 {
-    count++;
     QRect rectangle;
     rectangle= kapp->activeWindow()->findChild<QWidget*>(docker)->frameGeometry();
     setWidth(rectangle.width());
-    refWidth=kapp->activeWindow()->width()/2 ;
+    refWidth=kapp->activeWindow()->width() ;
+    refHeight= kapp->activeWindow()->height()/2 ;
     dockX= rectangle.x();
+    dockY= rectangle.y();
     dockWidth= rectangle.width();
+    dockHeight= rectangle.height();
     setHeight(rectangle.height());
     setX(rectangle.x());
     setY(rectangle.y());
     qDebug()<<rectangle.x()+rectangle.width();
-    qDebug()<<kapp->activeWindow()->width()/2 ;
+    qDebug()<<"Limit 1"<<kapp->activeWindow()->width()/4 ;
+    qDebug()<<"Limit 2"<<kapp->activeWindow()->width()*0.75;
 }
 
 void IntroSlideShow::setX (int x)
diff --git a/creator/introslideshow.h b/creator/introslideshow.h
index 4c763c8..0296057 100644
--- a/creator/introslideshow.h
+++ b/creator/introslideshow.h
@@ -47,6 +47,9 @@ class IntroSlideShow: public QObject
             Q_INVOKABLE qreal getdockX();
             Q_INVOKABLE qreal getdockWidth();
             Q_INVOKABLE qreal getrefWidth();
+            Q_INVOKABLE qreal getdockY();
+            Q_INVOKABLE qreal getdockHeight();
+            Q_INVOKABLE qreal getrefHeight();
             void setWidth(qreal width);
             void setHeight(qreal height);
             void setDockername(QString name);
@@ -57,11 +60,13 @@ class IntroSlideShow: public QObject
             int y() const;
 
         private:
-            int count;
             QString docker;
             qreal refWidth;
             qreal dockX;
             qreal dockWidth;
+            qreal dockY;
+            qreal dockHeight;
+            qreal refHeight;
             int m_width;
             int m_height;
             int m_x;
diff --git a/creator/ui/introduction.qml b/creator/ui/introduction.qml
index 235f856..4037f63 100644
--- a/creator/ui/introduction.qml
+++ b/creator/ui/introduction.qml
@@ -101,7 +101,7 @@ Item {
             id : text;
             font.pointSize: 12;
             font.bold : true;
-            text: "test";
+            text: "In addition to the more traditional Grid, Row, and Column, QML \
also provides a way to layout items using the concept of anchors. Each item can be \
thought of as having a set of 7 invisible : left, horizontalCenter, right, top, \
verticalCenter, baseline, and bottom.";  opacity: 0;
             style: Text.Raised;
             color: "white";
@@ -110,12 +110,48 @@ Item {
             states: [
 
                 State {
+                    name: "top"
+                    AnchorChanges {
+                                target: text
+                                anchors.top: viewport.bottom;
+                                anchors.horizontalCenter: viewport.horizontalCenter;
+                    }
+                    StateChangeScript {
+                             name: "myScript1"
+                             script: {console.log("In top");}
+
+                    }
+
+                },
+
+                State {
+                    name: "bottom"
+                    AnchorChanges {
+                                target: text
+                                anchors.bottom: viewport.top;
+                                anchors.horizontalCenter: viewport.horizontalCenter
+
+                    }
+                    StateChangeScript {
+                             name: "myScript1"
+                             script: {console.log("In bottom");}
+
+                    }
+
+                },
+
+                State {
                     name: "right"
                     AnchorChanges {
                                 target: text
                                 anchors.left: viewport.right;
 
                     }
+                    StateChangeScript {
+                             name: "myScript1"
+                             script: {console.log("In right");}
+
+                    }
                 },
 
                 State {
@@ -125,6 +161,11 @@ Item {
                                 anchors.right: viewport.left;
 
                     }
+                    StateChangeScript {
+                             name: "myScript1"
+                             script: {console.log("In left");}
+
+                    }
 
                 }
             ]
@@ -132,19 +173,24 @@ Item {
 
             function orient() {
 
-                if ((animator.getdockX() +animator.getdockWidth()) < \
(animator.getrefWidth())){ +                if ((animator.getdockX() \
+animator.getdockWidth()) < (0.25*animator.getrefWidth())){  text.state = "right";
                     console.log("dockname is");
                     console.log(animator.dockername);
                 }
 
+                else if((animator.getdockX() +animator.getdockWidth()) > \
(0.75*(animator.getrefWidth()))) { +
+                        text.state = "left";
+                        console.log("dockname is");
+                        console.log(animator.dockername);
+                    }
+
                 else{
 
-                    text.state = "left";
-                    console.log("dockname is");
-                    console.log(animator.dockername);
+                    if((animator.getdockY()+animator.getdockHeight()) < \
animator.getrefHeight()) {text.state = "top";} +                    else{text.state = \
"bottom";}  }
-
                 show();
 
             }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic