[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [gluon/creator-qmlintro-shreya] creator: Establishing Communication and updating through Q_PROPERTY
From: Shreya Pandit <shreya () shreyapandit ! com>
Date: 2012-05-28 13:49:00
Message-ID: 20120528134900.A666DA60A9 () git ! kde ! org
[Download RAW message or body]
Git commit 9a2ebba902dbe0f31a959d6e5aab53fa69da37cb by Shreya Pandit.
Committed on 28/05/2012 at 15:48.
Pushed by pandit into branch 'creator-qmlintro-shreya'.
Establishing Communication and updating through Q_PROPERTY framework
M +16 -20 creator/introduction.cpp
M +41 -4 creator/introduction.h
M +0 -1 creator/main.cpp
M +20 -26 creator/ui/introduction.qml
http://commits.kde.org/gluon/9a2ebba902dbe0f31a959d6e5aab53fa69da37cb
diff --git a/creator/introduction.cpp b/creator/introduction.cpp
index 704afa1..73c3bda 100644
--- a/creator/introduction.cpp
+++ b/creator/introduction.cpp
@@ -22,9 +22,9 @@
class QRect;
-IntroSlideShow::IntroSlideShow(QObject *parent):
- QObject(parent)
+IntroSlideShow::IntroSlideShow()
{
+ qmlRegisterType<IntroSlideShow>("Intro",1,0,"IntroSlideshow");
}
@@ -32,28 +32,24 @@ IntroSlideShow::IntroSlideShow(QObject *parent):
void IntroSlideShow::startIntro()
{
- view->setSource( QUrl::fromLocalFile( KGlobal::dirs()->locate( "appdata", \
"introduction.qml" ) ));
- view->setStyleSheet("background: transparent");
- view->setResizeMode( QDeclarativeView::SizeRootObjectToView );
- view->setGeometry( windowcopy->rect());
- view->show();
+ setdockername("");
+ 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()
{
+ QRect rectangle;
+ rectangle= windowcopy->findChild<QWidget*>( docker )->frameGeometry();
+ setWidth(rectangle.width());
+ setHeight(rectangle.height());
+ setXpos(rectangle.x());
+ setYpos(rectangle.y());
- docker =dockername;
- QGraphicsObject *object = view->rootObject();
- QObject *geometry = object->findChild<QObject*>("geometry");
- if(geometry)
- {
- QRect rectangle;
- 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());
- }
}
+
diff --git a/creator/introduction.h b/creator/introduction.h
index 4f7c442..a926252 100644
--- a/creator/introduction.h
+++ b/creator/introduction.h
@@ -23,29 +23,66 @@
#include "mainwindow.h"
#include <KDE/KStandardDirs>
#include <QtDeclarative/QDeclarativeContext>
+#include <QtDeclarative/QDeclarativeItem>
#include <QtDeclarative/QDeclarativeView>
-#include <QGraphicsObject>
#include <QString>
+
class QDeclarativeContext;
+class QDeclarativeItem;
class QDeclarativeView;
class QString;
-class IntroSlideShow: public QObject
+class IntroSlideShow: public QDeclarativeItem
{
Q_OBJECT
+ Q_PROPERTY(QString dockername READ dockername WRITE setdockername NOTIFY \
dockernameChanged) + Q_PROPERTY(int width READ width WRITE setWidth NOTIFY \
widthChanged) + 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)
public:
- IntroSlideShow(QObject *parent = 0);
+ IntroSlideShow();
+ QString dockername() const {return docker;}
+ int width() const { return m_width; }
+ int height() const { return m_height; }
+ int xpos() const { return m_xpos; }
+ int ypos() const { return m_ypos; }
+ void setWidth(int width){ m_width=width;}
+ void setHeight(int height){ m_height=height;}
+ void setXpos(int xpos){ m_xpos=xpos;}
+ void setYpos(int ypos){ m_ypos=ypos;}
+
+ void setdockername(QString name){
- Q_INVOKABLE void updateDocker(QString dockername);
+ docker=name;
+ if(docker!="") { updateDocker(); }
+ }
void startIntro();
+ void updateDocker();
GluonCreator::MainWindow *windowcopy;
QDeclarativeView* view;
QDeclarativeContext *context;
QString docker;
+
+ signals:
+
+ void dockernameChanged();
+ void widthChanged();
+ void heightChanged();
+ void xposChanged();
+ void yposChanged();
+
+ private:
+
+ int m_width;
+ int m_height;
+ int m_xpos;
+ int m_ypos;
+
};
#endif // IntroSlideShow_H
diff --git a/creator/main.cpp b/creator/main.cpp
index f5c9e47..4f42179 100644
--- a/creator/main.cpp
+++ b/creator/main.cpp
@@ -60,7 +60,6 @@ int main( int argc, char** argv )
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 6f30a3e..a9178d5 100644
--- a/creator/ui/introduction.qml
+++ b/creator/ui/introduction.qml
@@ -18,7 +18,7 @@
*/
import QtQuick 1.0
-
+import Intro 1.0
Item {
Rectangle {
@@ -68,29 +68,23 @@ Item {
color: "black";
}
- Item {
- id :animator;
- property string dockername:"";
- x:0;
- y :0;
- width :0;
- height :0;
- onDockernameChanged :intro.updateDocker(dockername);
- objectName: "geometry";
- }
Item {
id: viewport;
- width: parent.width / 2;
- height: parent.height / 2;
- x: parent.width / 4;
- y: parent.height / 4;
+ width: parent.m_width / 2;
+ height: parent.m_height / 2;
+ x: parent.m_width / 4;
+ y: parent.m_height / 4;
Behavior on width { NumberAnimation { duration: 500; } }
Behavior on height { NumberAnimation { duration: 500; } }
Behavior on x { NumberAnimation { duration: 500; } }
Behavior on y { NumberAnimation { duration: 500; } }
+ IntroSlideshow {
+ id :animator;
+ }
+
MouseArea {
anchors.fill: parent;
@@ -135,31 +129,31 @@ Item {
State {
name: "component"
PropertyChanges { target:animator; dockername : "ComponentsDock"}
- PropertyChanges { target: viewport; x: animator.x; y: animator.y; \
width:animator.width; height:animator.height } + PropertyChanges { \
target: viewport; x: animator.m_xpos; y: animator.m_ypos; width:animator.m_width; \
height:animator.m_height} },
State {
name: "project"
PropertyChanges { target:animator; dockername : "ProjectDock"}
- PropertyChanges { target: viewport; x: animator.x; y: animator.y; \
width:animator.width; height:animator.height } + PropertyChanges { \
target: viewport; x: animator.m_xpos; y: animator.m_ypos; width:animator.m_width; \
height:animator.m_height } },
State {
name: "message"
PropertyChanges { target:animator; dockername : "MessageDock"}
- PropertyChanges { target: viewport; x: animator.x; y: animator.y; \
width:animator.width; height:animator.height } + PropertyChanges { \
target: viewport; x: animator.m_xpos; y: animator.m_ypos; width:animator.m_width; \
height:animator.m_height } },
State {
name: "scene"
PropertyChanges { target:animator; dockername : "SceneDock"}
- PropertyChanges { target: viewport; x: animator.x; y: animator.y; \
width:animator.width; height:animator.height } + PropertyChanges { \
target: viewport; x: animator.m_xpos; y: animator.m_ypos; width:animator.m_width; \
height:animator.m_height } },
State {
name: "property"
PropertyChanges { target:animator; dockername : "PropertiesDock"}
- PropertyChanges { target: viewport; x: animator.x; y: animator.y; \
width:animator.width; height:animator.height } + PropertyChanges { \
target: viewport; x: animator.m_xpos; y: animator.m_ypos; width:animator.m_width; \
height:animator.m_height } }
]
@@ -167,32 +161,32 @@ Item {
Transition {
from: "*"; to: "component"
- NumberAnimation { properties: "x,y,width,height"; duration: 1000 }
+ NumberAnimation { properties: "x,y,m_width,m_height"; duration: 1000 \
} },
Transition {
from: "*"; to: "project"
- NumberAnimation { properties: "x,y,width,height"; duration: 1000 }
+ NumberAnimation { properties: "x,y,m_width,m_height"; duration: 1000 \
} },
Transition {
from: "*"; to: "message"
- NumberAnimation { properties: "x,y,width,height"; duration: 1000 }
+ NumberAnimation { properties: "x,y,m_width,m_height"; duration: 1000 \
} },
Transition {
from: "*"; to: "scene"
- NumberAnimation { properties: "x,y,width,height"; duration: 1000 }
+ NumberAnimation { properties: "x,y,m_width,m_height"; duration: 1000 \
} },
Transition {
from: "*"; to: "property"
- NumberAnimation { properties: "x,y,width,height"; duration: 1000 }
+ NumberAnimation { properties: "x,y,m_width,m_height"; duration: 1000 \
} }
]
- }
+}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic