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

List:       kde-commits
Subject:    [gluon/creator-qmlintro-shreya] creator: Setting fade-in and fade-out of text
From:       Shreya Pandit <shreya () shreyapandit ! com>
Date:       2012-06-11 12:47:39
Message-ID: 20120611124739.802B1A60BB () git ! kde ! org
[Download RAW message or body]

Git commit cfe2ddd98d34b9971c6b9f9db3312b95e857cd35 by Shreya Pandit.
Committed on 11/06/2012 at 14:47.
Pushed by pandit into branch 'creator-qmlintro-shreya'.

Setting fade-in and fade-out of text

M  +39   -13   creator/introduction.cpp
M  +12   -8    creator/introduction.h
M  +1    -1    creator/mainwindow.cpp
M  +81   -38   creator/ui/introduction.qml

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

diff --git a/creator/introduction.cpp b/creator/introduction.cpp
index b16d525..ff60658 100644
--- a/creator/introduction.cpp
+++ b/creator/introduction.cpp
@@ -71,13 +71,44 @@ void IntroSlideShow::setdockername(QString name)
     emit dockernameChanged();
 }
 
-void IntroSlideShow::setAlignment(QString align)
+qreal IntroSlideShow::getdockX()
 {
-    if(!QString::compare(align,"left", Qt::CaseInsensitive)) {m_alignment= "left";}
-    else {m_alignment = "right";}
-    qDebug() << m_alignment;
+    return dockX;
+}
+
+qreal IntroSlideShow::getdockWidth()
+{
+    return dockWidth;
+}
+
+QString IntroSlideShow::dockername() const
+{
+    return docker;
+}
+
+qreal IntroSlideShow::getrefWidth()
+{
+     return refWidth;
+}
+
+qreal IntroSlideShow::width() const
+{
+     return implicitWidth();
+}
+
+qreal IntroSlideShow::height() const
+{
+     return implicitHeight();
+}
 
-    emit alignmentChanged();
+int IntroSlideShow::ypos() const
+{
+     return y();
+}
+
+int IntroSlideShow::xpos() const
+{
+     return x();
 }
 
 void IntroSlideShow::updateDocker()
@@ -85,17 +116,12 @@ void IntroSlideShow::updateDocker()
     QRect rectangle;
     rectangle= kapp->activeWindow()->findChild<QWidget*>(docker)->frameGeometry();
     setWidth(rectangle.width());
+    refWidth=kapp->activeWindow()->width()/2 ;
+    dockX= rectangle.x();
+    dockWidth= rectangle.width();
     setHeight(rectangle.height());
     setXpos(rectangle.x());
     setYpos(rectangle.y());
-    if ((rectangle.x()+ rectangle.width()) < (kapp->activeWindow()->width()/2))
-    {setAlignment("left");
-
-    }
-     else
-    {setAlignment("right");
-
-    }
 
 }
 
diff --git a/creator/introduction.h b/creator/introduction.h
index b222260..395589c 100644
--- a/creator/introduction.h
+++ b/creator/introduction.h
@@ -23,6 +23,7 @@
 #include "mainwindow.h"
 #include <QtDeclarative/QDeclarativeItem>
 #include <QString>
+#include <QtGlobal>
 
 class QDeclarativeItem;
 class QString;
@@ -36,17 +37,18 @@ class IntroSlideShow: public QDeclarativeItem
         Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
         Q_PROPERTY(int xpos READ xpos WRITE setXpos NOTIFY xposChanged)
         Q_PROPERTY(int ypos READ ypos WRITE setYpos NOTIFY yposChanged)
-        Q_PROPERTY(QString alignment READ alignment WRITE setAlignment NOTIFY \
alignmentChanged)  
         public:
             IntroSlideShow();
             ~IntroSlideShow();
-            QString dockername() const {return docker;}
-            qreal width() const { return implicitWidth(); }
-            qreal height() const { return implicitHeight(); }
-            int xpos() const { return x(); }
-            int ypos() const { return y(); }
-            Q_INVOKABLE QString alignment() { return m_alignment; }
+            QString dockername() const;
+            qreal width() const;
+            qreal height() const;
+            Q_INVOKABLE qreal getdockX();
+            Q_INVOKABLE qreal getdockWidth();
+            Q_INVOKABLE qreal getrefWidth();
+            int xpos() const;
+            int ypos() const;
             void setWidth(qreal width);
             void setHeight(qreal height);
             void setXpos(qreal xpos);
@@ -55,7 +57,9 @@ class IntroSlideShow: public QDeclarativeItem
             Q_INVOKABLE void setdockername(QString name);
             void updateDocker();
             QString docker;
-            QString m_alignment;
+            qreal refWidth;
+            qreal dockX;
+            qreal dockWidth;
 
         signals:
 
diff --git a/creator/mainwindow.cpp b/creator/mainwindow.cpp
index 454bb3c..1f465fe 100644
--- a/creator/mainwindow.cpp
+++ b/creator/mainwindow.cpp
@@ -420,7 +420,7 @@ void MainWindow::addAsset()
 void GluonCreator::MainWindow::showNewProjectDialog()
 {
     d->projectDialog->setPage( ProjectSelectionDialog::NewProjectPage );
-    d->projectDialog->show();
+//    d->projectDialog->show();
 }
 
 void MainWindow::showOpenProjectDialog()
diff --git a/creator/ui/introduction.qml b/creator/ui/introduction.qml
index 79104c9..f3b3e71 100644
--- a/creator/ui/introduction.qml
+++ b/creator/ui/introduction.qml
@@ -19,9 +19,10 @@
 
 import QtQuick 1.0
 import Intro 1.0
+
 Item {
 
-   Rectangle {
+    Rectangle {
         id: topOverlay;
 
         anchors.top: parent.top;
@@ -81,73 +82,115 @@ Item {
         Behavior on x { NumberAnimation { duration: 500; } }
         Behavior on y { NumberAnimation { duration: 500; } }
 
-            IntroSlideShow {
+        IntroSlideShow {
                 id :animator;
     }
 
+
+
         Text {
             id : text;
-            font.pointSize: 18;
+            font.pointSize: 12;
+            font.bold : true;
             text: "test";
+            opacity: 0;
             style: Text.Raised;
-            styleColor: "white";
+            color: "white";
+            property bool showText: true ;
+
+            states: [
+
+            State {
+                    name: "right"
+                    AnchorChanges {
+                                target: text
+                                anchors.left: viewport.right;
+
+                            }
+              },
+
+            State {
+                    name: "left"
+                    AnchorChanges {
+                                target: text
+                                anchors.right: viewport.left;
+
+                            }
+
+                }
+]
+
+
             function orient() {
-                console.log("IN ORIENT") ;
-                if (animator.alignment == "left")
-                {anchors.left= viewport.right;
-                 anchors.right= viewport.left;
+
+                if ((animator.getdockX() +animator.getdockWidth()) < \
(animator.getrefWidth())){ +                    text.state = "right";
                 }
-                 else
-                { anchors.right= viewport.left;
+                 else{
+                    text.state = "left";
                 }
+                show();
 
             }
+
+            function show(){opacity=1; showText = false ;}
+
+            Behavior on opacity {
+                NumberAnimation { properties:"opacity"; duration: 100 }
+         }
     }
 
         MouseArea {
-            anchors.fill: parent;
-            onClicked: {
 
-                switch(animator.dockername){
+            Timer {
+                id: showTimer
+                interval: 500
+                onTriggered:  {
+                     switch(animator.dockername){
 
-                case(""):
-                    viewport.state = 'component';
-                    break;
+                                   case(""):
+                                       viewport.state = 'component';
+                                       break;
 
-                case("ComponentsDock"):
-                    viewport.state = 'project';
-                    break;
+                                   case("ComponentsDock"):
+                                       viewport.state = 'project';
+                                       break;
 
-                case("ProjectDock"):
-                    viewport.state = 'message';
-                    break;
+                                   case("ProjectDock"):
+                                       viewport.state = 'message';
+                                       break;
 
-                case("MessageDock"):
-                    viewport.state = 'scene';
-                    break;
+                                   case("MessageDock"):
+                                       viewport.state = 'scene';
+                                       break;
 
-                case("SceneDock"):
-                    viewport.state = 'property';
-                    break;
+                                   case("SceneDock"):
+                                       viewport.state = 'property';
+                                       break;
 
-                case("PropertiesDock"):
-                    viewport.state = 'component';
-                    break;
+                                   case("PropertiesDock"):
+                                       viewport.state = 'component';
+                                       break;
 
-                default:
-                    break;
+                                   default:
+                                       break;
 
                 }
 
+            }
 
-               onDockernameChanged: {
-                        animator.setdockername(animator.dockername);
-               }
+        }
 
-                }
+            anchors.fill: parent;
+            onClicked: {
+                if(!text.showText){ text.opacity = 0 ;}
+                showTimer.start();
+                onDockernameChanged: { animator.setdockername(animator.dockername);}
 
             }
 
+        }
+
 
 
         states: [
@@ -155,7 +198,7 @@ Item {
         State {
                 name: "component"
                 PropertyChanges { target:animator; dockername: "ComponentsDock"}
-                PropertyChanges { target: viewport; x: animator.x; y: animator.y; \
width:animator.implicitWidth; height:animator.implicitHeight; toolTip: "Yeh hai \
component"} +                PropertyChanges { target: viewport; x: animator.x; y: \
animator.y; width:animator.implicitWidth; height:animator.implicitHeight; }  \
StateChangeScript {  name: "myScript"
                          script: { text.orient();}


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

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