[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [gluon/creator-qmlintro-shreya] creator: Code cleanup, use QObject and introduce properties.
From: Shantanu Tushar <shaan7in () gmail ! com>
Date: 2012-06-14 19:13:28
Message-ID: 20120614191328.598E4A60A9 () git ! kde ! org
[Download RAW message or body]
Git commit 7909552277d199e94c265c70ac9f534190515def by Shantanu Tushar.
Committed on 14/06/2012 at 21:12.
Pushed by shantanu into branch 'creator-qmlintro-shreya'.
Code cleanup, use QObject and introduce properties.
Transitions doesnt let the state PropertyChanges apply immediately,
disable for now.
M +1 -1 creator/CMakeLists.txt
M +0 -76 creator/introduction.h
R +39 -43 creator/introslideshow.cpp [from: creator/introduction.cpp - 074% similarity]
C +23 -20 creator/introslideshow.h [from: creator/introduction.h - 067% similarity]
M +2 -1 creator/mainwindow.h
M +10 -10 creator/ui/introduction.qml
http://commits.kde.org/gluon/7909552277d199e94c265c70ac9f534190515def
diff --git a/creator/CMakeLists.txt b/creator/CMakeLists.txt
index 5fdf7e4..41d63bc 100644
--- a/creator/CMakeLists.txt
+++ b/creator/CMakeLists.txt
@@ -35,7 +35,7 @@ add_subdirectory(nodeeditor)
set(gluoncreator_SRCS
main.cpp
mainwindow.cpp
- introduction.cpp
+ introslideshow.cpp
dialogs/configdialog.cpp
dialogs/newprojectdialogpage.cpp
diff --git a/creator/introduction.h b/creator/introduction.h
index 59ccccd..e69de29 100644
--- a/creator/introduction.h
+++ b/creator/introduction.h
@@ -1,76 +0,0 @@
-/******************************************************************************
- * 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
-
-#include "mainwindow.h"
-#include <QtDeclarative/QDeclarativeItem>
-#include <QString>
-#include <QtGlobal>
-
-class QDeclarativeItem;
-class QString;
-
-
-class IntroSlideShow: public QDeclarativeItem
-{
- Q_OBJECT
- Q_PROPERTY(QString dockername READ dockername WRITE setdockername NOTIFY dockernameChanged)
- Q_PROPERTY(int width READ width WRITE setWidth )
- Q_PROPERTY(int height READ height WRITE setHeight )
- Q_PROPERTY(int xpos READ xpos WRITE setXpos )
- Q_PROPERTY(int ypos READ ypos WRITE setYpos )
-
- public:
- IntroSlideShow();
- ~IntroSlideShow();
- QString dockername();
- 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);
- void setYpos(qreal ypos);
- void setdockername(QString name);
- void updateDocker();
- int count;
- QString docker;
- qreal refWidth;
- qreal dockX;
- qreal dockWidth;
-
- signals:
-
- void dockernameChanged();
- void widthChanged();
- void heightChanged();
- void xposChanged();
- void yposChanged();
- void alignmentChanged();
-
-
-};
-
-#endif // IntroSlideShow_H
diff --git a/creator/introduction.cpp b/creator/introslideshow.cpp
similarity index 74%
rename from creator/introduction.cpp
rename to creator/introslideshow.cpp
index fb8a1c3..ff1b6f8 100644
--- a/creator/introduction.cpp
+++ b/creator/introslideshow.cpp
@@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "introduction.h"
+#include "introslideshow.h"
#include <QRect>
#include <KDE/KApplication>
#include <QDebug>
@@ -36,40 +36,34 @@ IntroSlideShow::~IntroSlideShow()
delete this;
}
-void IntroSlideShow::setWidth(qreal width)
+int IntroSlideShow::height() const
{
- setImplicitWidth(width);
- emit widthChanged();
+ return m_height;
}
-
-void IntroSlideShow::setHeight(qreal height)
+int IntroSlideShow::width() const
{
- setImplicitHeight(height);
- emit heightChanged();
+ return m_width;
}
-void IntroSlideShow::setXpos(qreal xpos)
+void IntroSlideShow::setWidth(qreal width)
{
- setX(xpos);
- emit xposChanged();
+ m_width = width;
+ emit widthChanged();
}
-void IntroSlideShow::setYpos(qreal ypos)
+void IntroSlideShow::setHeight(qreal height)
{
- setY(ypos);
- emit yposChanged();
+ m_height = height;
+ emit heightChanged();
}
-
-void IntroSlideShow::setdockername(QString name)
+void IntroSlideShow::setDockername(QString name)
{
docker=name;
-// if(QString::compare(docker,"", Qt::CaseInsensitive)) {
+// if(QString::compare(docker,"", Qt::CaseInsensitive)) {
updateDocker();
-
-
-emit dockernameChanged();
+ emit dockernameChanged();
}
qreal IntroSlideShow::getdockX()
@@ -82,7 +76,7 @@ qreal IntroSlideShow::getdockWidth()
return dockWidth;
}
-QString IntroSlideShow::dockername()
+QString IntroSlideShow::dockername() const
{
return docker;
}
@@ -92,26 +86,6 @@ qreal IntroSlideShow::getrefWidth()
return refWidth;
}
-qreal IntroSlideShow::width() const
-{
- return implicitWidth();
-}
-
-qreal IntroSlideShow::height() const
-{
- return implicitHeight();
-}
-
-int IntroSlideShow::ypos() const
-{
- return y();
-}
-
-int IntroSlideShow::xpos() const
-{
- return x();
-}
-
void IntroSlideShow::updateDocker()
{
count++;
@@ -119,15 +93,37 @@ void IntroSlideShow::updateDocker()
qDebug()<<"in update docker for" << count <<"th time";
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());
+ setX(rectangle.x());
+ setY(rectangle.y());
qDebug()<<rectangle.x()+rectangle.width();
qDebug()<<kapp->activeWindow()->width()/2 ;
}
+void IntroSlideShow::setX (int x)
+{
+ m_x = x;
+ emit xChanged();
+}
+
+void IntroSlideShow::setY (int y)
+{
+ m_y = y;
+ emit yChanged();
+}
+
+int IntroSlideShow::x() const
+{
+ return m_x;
+}
+
+int IntroSlideShow::y() const
+{
+ return m_y;
+}
diff --git a/creator/introduction.h b/creator/introslideshow.h
similarity index 67%
copy from creator/introduction.h
copy to creator/introslideshow.h
index 59ccccd..4c763c8 100644
--- a/creator/introduction.h
+++ b/creator/introslideshow.h
@@ -28,49 +28,52 @@
class QDeclarativeItem;
class QString;
-
-class IntroSlideShow: public QDeclarativeItem
+class IntroSlideShow: public QObject
{
Q_OBJECT
- Q_PROPERTY(QString dockername READ dockername WRITE setdockername NOTIFY dockernameChanged)
- Q_PROPERTY(int width READ width WRITE setWidth )
- Q_PROPERTY(int height READ height WRITE setHeight )
- Q_PROPERTY(int xpos READ xpos WRITE setXpos )
- Q_PROPERTY(int ypos READ ypos WRITE setYpos )
+ 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 x READ x WRITE setX NOTIFY xChanged)
+ Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged)
public:
IntroSlideShow();
~IntroSlideShow();
- QString dockername();
- qreal width() const;
- qreal height() const;
+ QString dockername() const;
+ int width() const;
+ int height() const;
+ //TODO: change to properties instead of INVOKABLEs
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);
- void setYpos(qreal ypos);
- void setdockername(QString name);
+ void setDockername(QString name);
void updateDocker();
+ int x() const;
+ void setX(int x);
+ void setY(int y);
+ int y() const;
+
+ private:
int count;
QString docker;
qreal refWidth;
qreal dockX;
qreal dockWidth;
+ int m_width;
+ int m_height;
+ int m_x;
+ int m_y;
signals:
-
void dockernameChanged();
void widthChanged();
void heightChanged();
- void xposChanged();
- void yposChanged();
void alignmentChanged();
-
-
+ void xChanged();
+ void yChanged();
};
#endif // IntroSlideShow_H
diff --git a/creator/mainwindow.h b/creator/mainwindow.h
index 923cdc9..e109551 100644
--- a/creator/mainwindow.h
+++ b/creator/mainwindow.h
@@ -21,11 +21,12 @@
#ifndef GLUONCREATOR_MAINWINDOW_H
#define GLUONCREATOR_MAINWINDOW_H
+#include "introslideshow.h"
+
#include <KDE/KParts/MainWindow>
#include <QtDeclarative/QDeclarativeView>
#include <KDE/KStandardDirs>
#include <QtDeclarative/QDeclarativeItem>
-#include <introduction.h>
class KStandardDirs;
class QDeclarativeView;
diff --git a/creator/ui/introduction.qml b/creator/ui/introduction.qml
index 2b71416..55bc559 100644
--- a/creator/ui/introduction.qml
+++ b/creator/ui/introduction.qml
@@ -79,8 +79,8 @@ Item {
}
id: viewport;
- width: animator.implicitWidth;
- height: animator.implicitHeight;
+ width: animator.width;
+ height: animator.height;
x: animator.x;
y: animator.y;
@@ -255,14 +255,14 @@ Item {
}
]
- transitions: [
-
- Transition {
- from: "*"; to: "*"
- NumberAnimation { properties: "x,y,width,height"; duration: 500 }
- ScriptAction { scriptName: "myScript" }
- }
- ]
+// transitions: [
+//
+// Transition {
+// from: "*"; to: "*"
+// NumberAnimation { properties: "x,y,width,height"; duration: 500 }
+// ScriptAction { scriptName: "myScript" }
+// }
+// ]
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic