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

List:       kde-commits
Subject:    [gluon/creator-qmlintro-shreya] creator: Geometry is updated using custom QML Item, which interacts
From:       Shreya Pandit <shreya () shreyapandit ! com>
Date:       2012-05-03 19:25:14
Message-ID: 20120503192514.695F7A60A9 () git ! kde ! org
[Download RAW message or body]

Git commit 5989a35493235730c4c68ce253a15a2641e1cb45 by Shreya Pandit.
Committed on 03/05/2012 at 21:24.
Pushed by pandit into branch 'creator-qmlintro-shreya'.

Geometry is updated using custom QML Item, which interacts with introSlideshow class

M  +35   -15   creator/introduction.cpp
M  +34   -9    creator/introduction.h
M  +6    -3    creator/main.cpp
M  +105  -30   creator/ui/introduction.qml

http://commits.kde.org/gluon/5989a35493235730c4c68ce253a15a2641e1cb45

diff --git a/creator/introduction.cpp b/creator/introduction.cpp
index 212538b..704afa1 100644
--- a/creator/introduction.cpp
+++ b/creator/introduction.cpp
@@ -1,39 +1,59 @@
+/******************************************************************************
+ * This file is part of the Gluon Development Platform
+ * Copyright (c) 2012 Shreya Pandit <shreya@shreyapandit.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
 #include "introduction.h"
 #include <QRect>
+
 class QRect;
 
 IntroSlideShow::IntroSlideShow(QObject *parent):
-  QObject(parent){
+  QObject(parent)
+{
 
-    startIntro();
 }
 
 
-void IntroSlideShow::startIntro(){
-
-    view = new QDeclarativeView( window );
-    context = view->rootContext();
+void IntroSlideShow::startIntro()
+{
 
-    view->setSource( QUrl::fromLocalFile( KGlobal::dirs()->locate( "appdata", \
                "introduction.qml" ) ));
-    view->setStyleSheet("background: transparent");
-    view->setResizeMode( QDeclarativeView::SizeRootObjectToView );
-    view->setGeometry( window->rect());
-    view->show();
+     view->setSource( QUrl::fromLocalFile( KGlobal::dirs()->locate( "appdata", \
"introduction.qml" ) )); +     view->setStyleSheet("background: transparent");
+     view->setResizeMode( QDeclarativeView::SizeRootObjectToView );
+     view->setGeometry( windowcopy->rect());
+     view->show();
 
 }
 
-void IntroSlideShow::updateDocker(QString dockername){
+void IntroSlideShow::updateDocker(QString dockername)
+{
 
     docker =dockername;
     QGraphicsObject *object = view->rootObject();
     QObject *geometry = object->findChild<QObject*>("geometry");
-    if(geometry){
+    if(geometry)
+    {
         QRect rectangle;
-        rectangle= window->findChild<QWidget*>( docker )->frameGeometry();
+        rectangle= windowcopy->findChild<QWidget*>( docker )->frameGeometry();
         geometry->setProperty("width",rectangle.width());
         geometry->setProperty("x",rectangle.x());
         geometry->setProperty("y",rectangle.y());
-        geometry->setProperty("height",rectangle.height());*/
+        geometry->setProperty("height",rectangle.height());
     }
 
 }
diff --git a/creator/introduction.h b/creator/introduction.h
index a636db3..4f7c442 100644
--- a/creator/introduction.h
+++ b/creator/introduction.h
@@ -1,3 +1,22 @@
+/******************************************************************************
+ * This file is part of the Gluon Development Platform
+ * Copyright (c) 2012 Shreya Pandit <shreya@shreyapandit.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
 #ifndef INTRODUCTION_H
 #define INTRODUCTION_H
 
@@ -11,16 +30,22 @@ class QDeclarativeContext;
 class QDeclarativeView;
 class QString;
 
-class IntroSlideShow: public QObject {
+class IntroSlideShow: public QObject
+{
+
+    Q_OBJECT
+
+    public:
+        IntroSlideShow(QObject *parent = 0);
+
+        Q_INVOKABLE void updateDocker(QString dockername);
+
+        void startIntro();
 
-public:
-    IntroSlideShow(QObject *parent = 0);
-    Q_INVOKABLE void updateDocker(QString dockername);
-    void startIntro();
-    GluonCreator::MainWindow *window;
-    QDeclarativeView* view;
-    QDeclarativeContext *context;
-    QString docker;
+        GluonCreator::MainWindow *windowcopy;
+        QDeclarativeView* view;
+        QDeclarativeContext *context;
+        QString docker;
 };
 
 #endif // IntroSlideShow_H
diff --git a/creator/main.cpp b/creator/main.cpp
index 4fc6cc8..f5c9e47 100644
--- a/creator/main.cpp
+++ b/creator/main.cpp
@@ -56,8 +56,11 @@ int main( int argc, char** argv )
     splash.finish( window );
 
     //Instantiate QML Bindings for SlideShow
-    IntroSlideShow *intro = new IntroSlideShow();
-    intro->context->setContextProperty("intro", intro);
-
+    IntroSlideShow *introObj = new IntroSlideShow();
+    introObj->windowcopy=window ;
+    introObj->view = new QDeclarativeView(window);
+    introObj->context = introObj->view->rootContext();
+    introObj->context->setContextProperty("intro", introObj);
+    introObj->startIntro();
     app.exec();
 }
diff --git a/creator/ui/introduction.qml b/creator/ui/introduction.qml
index 5f893d4..6f30a3e 100644
--- a/creator/ui/introduction.qml
+++ b/creator/ui/introduction.qml
@@ -1,8 +1,27 @@
+/******************************************************************************
+ * This file is part of the Gluon Development Platform
+ * Copyright (c) 2012 Shreya Pandit <shreya@shreyapandit.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
 import QtQuick 1.0
 
 Item {
 
-    Rectangle {
+   Rectangle {
         id: topOverlay;
 
         anchors.top: parent.top;
@@ -10,9 +29,10 @@ Item {
         anchors.right: parent.right;
         anchors.bottom: viewport.top;
 
-        opacity: 0.1;
-        color: "blue";
+        opacity: 0.7;
+        color: "black";
     }
+
     Rectangle {
 
         id: leftOverlay;
@@ -20,8 +40,8 @@ Item {
         anchors.left: parent.left;
         anchors.right: viewport.left;
         anchors.bottom: bottomOverlay.top;
-        opacity: 0.1;
-        color: "blue";
+        opacity: 0.7;
+        color: "black";
      }
 
     Rectangle {
@@ -32,9 +52,10 @@ Item {
         anchors.right: parent.right;
         anchors.bottom: bottomOverlay.top;
 
-        opacity: 0.1;
-        color: "blue";
+        opacity: 0.7;
+        color: "black";
     }
+
     Rectangle {
         id: bottomOverlay;
 
@@ -43,24 +64,23 @@ Item {
         anchors.right: parent.right;
         anchors.bottom: parent.bottom;
 
-        opacity: 0.1;
-        color: "blue";
+        opacity: 0.7;
+        color: "black";
     }
 
     Item {
-        id :dummy;
+        id :animator;
         property string dockername:"";
         x:0;
         y :0;
         width :0;
         height :0;
-        onDockernameChanged : intro.updateDocker(dockername);
+        onDockernameChanged :intro.updateDocker(dockername);
         objectName: "geometry";
     }
 
     Item {
         id: viewport;
-        property int flag: 0
         width: parent.width / 2;
         height: parent.height / 2;
         x: parent.width / 4;
@@ -71,36 +91,75 @@ Item {
         Behavior on x { NumberAnimation { duration: 500; } }
         Behavior on y { NumberAnimation { duration: 500; } }
 
-    MouseArea {
-        anchors.fill: parent;
+        MouseArea {
+            anchors.fill: parent;
+
+            onClicked: {
+                switch(animator.dockername){
+
+                case(""):
+                    viewport.state = 'component';
+                    break;
+
+                case("ComponentsDock"):
+                    viewport.state = 'project';
+                    break;
+
+                case("ProjectDock"):
+                    viewport.state = 'message';
+                    break;
+
+                case("MessageDock"):
+                    viewport.state = 'scene';
+                    break;
 
-        onClicked: {
-            switch(flag){
-            case(0):
-                viewport.state = 'component';
-                break;
-            case(1):
-                viewport.state = 'project';
-                break;
-            default:
-                break;
+                case("SceneDock"):
+                    viewport.state = 'property';
+                    break;
+
+                case("PropertiesDock"):
+                    viewport.state = 'component';
+                    break;
+
+                default:
+                    break;
+
+                }
 
             }
-        }
 
     }
-    states: [
+
+        states: [
 
         State {
                 name: "component"
-                PropertyChanges { target:dummy; dockername : "ComponentsDock"}
-                PropertyChanges { target: viewport; flag:1; x: dummy.x; y: dummy.y; \
width:dummy.width; height:dummy.height } +                PropertyChanges { \
target:animator; dockername : "ComponentsDock"} +                PropertyChanges { \
target: viewport; x: animator.x; y: animator.y; width:animator.width; \
height:animator.height }  },
 
         State {
                 name: "project"
-                PropertyChanges { target:dummy; dockername : "ProjectsDock"}
-                PropertyChanges { target: viewport;flag:2 ; x: dummy.x; y: dummy.y; \
width:dummy.width; height:dummy.height } +                PropertyChanges { \
target:animator; dockername : "ProjectDock"} +                PropertyChanges { \
target: viewport; x: animator.x; y: animator.y; width:animator.width; \
height:animator.height } +            },
+
+        State {
+                name: "message"
+                PropertyChanges { target:animator; dockername : "MessageDock"}
+                PropertyChanges { target: viewport; x: animator.x; y: animator.y; \
width:animator.width; height:animator.height } +            },
+
+        State {
+                name: "scene"
+                PropertyChanges { target:animator; dockername : "SceneDock"}
+                PropertyChanges { target: viewport; x: animator.x; y: animator.y; \
width:animator.width; height:animator.height } +            },
+
+        State {
+                name: "property"
+                PropertyChanges { target:animator; dockername : "PropertiesDock"}
+                PropertyChanges { target: viewport; x: animator.x; y: animator.y; \
width:animator.width; height:animator.height }  }
     ]
 
@@ -114,7 +173,23 @@ Item {
             Transition {
                 from: "*"; to: "project"
                 NumberAnimation { properties: "x,y,width,height"; duration: 1000 }
+            },
+
+            Transition {
+                from: "*"; to: "message"
+                NumberAnimation { properties: "x,y,width,height"; duration: 1000 }
+            },
+
+            Transition {
+                from: "*"; to: "scene"
+                NumberAnimation { properties: "x,y,width,height"; duration: 1000 }
+            },
+
+            Transition {
+                from: "*"; to: "property"
+                NumberAnimation { properties: "x,y,width,height"; duration: 1000 }
             }
+
         ]
 
     }


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

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