[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [gluon/creator-qmlintro-shreya] creator: Trying to track Mainwindow object
From: Shreya Pandit <shreya () shreyapandit ! com>
Date: 2012-06-03 12:16:34
Message-ID: 20120603121634.0ED5CA60C6 () git ! kde ! org
[Download RAW message or body]
Git commit 81b34a0a70e4ab8f251b2a75f948e90369c8bee9 by Shreya Pandit.
Committed on 03/06/2012 at 14:15.
Pushed by pandit into branch 'creator-qmlintro-shreya'.
Trying to track Mainwindow object
M +34 -12 creator/introduction.cpp
M +37 -19 creator/introduction.h
M +3 -7 creator/main.cpp
M +19 -3 creator/mainwindow.cpp
M +4 -3 creator/mainwindow.h
M +32 -20 creator/ui/introduction.qml
http://commits.kde.org/gluon/81b34a0a70e4ab8f251b2a75f948e90369c8bee9
diff --git a/creator/introduction.cpp b/creator/introduction.cpp
index 73c3bda..f01162f 100644
--- a/creator/introduction.cpp
+++ b/creator/introduction.cpp
@@ -19,37 +19,59 @@
#include "introduction.h"
#include <QRect>
+#include <QDebug>
+#include <KDE/KApplication>
class QRect;
+class QDebug;
+class KApplication;
IntroSlideShow::IntroSlideShow()
{
- qmlRegisterType<IntroSlideShow>("Intro",1,0,"IntroSlideshow");
-
+ qDebug() << "INSIDE CONSTRUCTOR";
+ timer = new QTimer();
+ timer->setSingleShot(true);
+ timer->singleShot(3000, this, SLOT(on_timeout()));
}
+IntroSlideShow::~IntroSlideShow()
+{
+ delete timer;
+}
void IntroSlideShow::startIntro()
{
+ qDebug() << "INSIDE START INTRO";
- setdockername("");
- view->setSource( QUrl::fromLocalFile( KGlobal::dirs()->locate( "appdata", \
"introduction.qml" ) )); +/* view = new QDeclarativeView( QUrl::fromLocalFile( \
KGlobal::dirs()->locate( "appdata", "introduction.qml" ) ), this_windowcopy ); \
view->setStyleSheet("background: transparent"); view->setResizeMode( \
QDeclarativeView::SizeRootObjectToView );
- view->setGeometry( windowcopy->rect());
- view->show();
+ view->setGeometry(this_windowcopy->rect());
+ view->show();*/
}
+void IntroSlideShow::on_timeout()
+{
+ qDebug() << "INSIDE TIMEOUT";
+ this_windowcopy= kapp->activeWindow();
+ qDebug() <<"OUR WINDOWCOPY IS" << this_windowcopy;
+ qmlRegisterType<IntroSlideShow>("Intro",1,0,"IntroSlideShow");
+
+}
+
+
+
void IntroSlideShow::updateDocker()
{
- QRect rectangle;
- rectangle= windowcopy->findChild<QWidget*>( docker )->frameGeometry();
- setWidth(rectangle.width());
- setHeight(rectangle.height());
- setXpos(rectangle.x());
- setYpos(rectangle.y());
+ qDebug() << "Inside updateDocker";
+ QWidget *rectangle;
+ /*setWidth(rectangle->width());
+ setHeight(rectangle->height());
+ setXpos(rectangle->x());
+ setYpos(rectangle->y());
+*/
}
diff --git a/creator/introduction.h b/creator/introduction.h
index a926252..4036a8c 100644
--- a/creator/introduction.h
+++ b/creator/introduction.h
@@ -26,11 +26,19 @@
#include <QtDeclarative/QDeclarativeItem>
#include <QtDeclarative/QDeclarativeView>
#include <QString>
+#include <QDebug>
+#include <QWidget>
+#include <QTimer>
+#include <QWidget>
+class QTimer;
class QDeclarativeContext;
class QDeclarativeItem;
class QDeclarativeView;
class QString;
+class QDebug;
+class QWidget;
+
class IntroSlideShow: public QDeclarativeItem
{
@@ -42,28 +50,44 @@ class IntroSlideShow: public QDeclarativeItem
Q_PROPERTY(int xpos READ xpos WRITE setXpos NOTIFY xposChanged)
Q_PROPERTY(int ypos READ ypos WRITE setYpos NOTIFY yposChanged)
- public:
+public slots:
+ void on_timeout();
+
+
+public:
IntroSlideShow();
+ ~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;}
+ qreal width() const { return implicitWidth(); }
+ qreal height() const { return implicitHeight(); }
+ int xpos() const { return x(); }
+ int ypos() const { return y(); }
+
+ void setWidth(qreal width){qDebug() << "Inside setwidth"; \
setImplicitWidth(width); emit widthChanged();}
- void setdockername(QString name){
+ void setHeight(qreal height){ setImplicitHeight(height); emit \
heightChanged();} +
+ void setXpos(qreal xpos){ setX(xpos);emit xposChanged();}
+
+ void setYpos(qreal ypos){ setY(ypos);emit yposChanged();}
+
+ Q_INVOKABLE void setdockername(QString name){
docker=name;
- if(docker!="") { updateDocker(); }
+ qDebug() << "Inside set dockername" ;
+ if(QString::compare(docker,"", Qt::CaseInsensitive)) {
+ qDebug() << "INSIDE IF" ;
+ qDebug() << docker;
+ updateDocker();
+ }
+ emit dockernameChanged();
}
- void startIntro();
+ Q_INVOKABLE void startIntro();
void updateDocker();
- GluonCreator::MainWindow *windowcopy;
+ QWidget *this_windowcopy;
+ QTimer *timer;
QDeclarativeView* view;
QDeclarativeContext *context;
QString docker;
@@ -76,12 +100,6 @@ class IntroSlideShow: public QDeclarativeItem
void xposChanged();
void yposChanged();
- private:
-
- int m_width;
- int m_height;
- int m_xpos;
- int m_ypos;
};
diff --git a/creator/main.cpp b/creator/main.cpp
index 4f42179..ff975d6 100644
--- a/creator/main.cpp
+++ b/creator/main.cpp
@@ -32,6 +32,8 @@
#include <core/gluon_global.h>
#include "aboutdata.h"
#include "introduction.h"
+#include <QDebug>
+
int main( int argc, char** argv )
{
@@ -54,12 +56,6 @@ int main( int argc, char** argv )
GluonCreator::MainWindow* window = new GluonCreator::MainWindow( args->count() > \
0 ? args->arg( 0 ) : QString() ); window->show();
splash.finish( window );
-
- //Instantiate QML Bindings for SlideShow
- IntroSlideShow *introObj = new IntroSlideShow();
- introObj->windowcopy=window ;
- introObj->view = new QDeclarativeView(window);
- introObj->context = introObj->view->rootContext();
- introObj->startIntro();
+ kapp->setActiveWindow(window);
app.exec();
}
diff --git a/creator/mainwindow.cpp b/creator/mainwindow.cpp
index 83e4a7f..b01634f 100644
--- a/creator/mainwindow.cpp
+++ b/creator/mainwindow.cpp
@@ -23,7 +23,8 @@
#include <QtCore/QVariantList>
#include <QtCore/QFileInfo>
#include <QtCore/QTimer>
-
+#include <QDebug>
+#include <QWidget>
#include <KDE/KFileDialog>
#include <KDE/KStandardAction>
#include <KDE/KActionCollection>
@@ -35,6 +36,8 @@
#include <KDE/KRecentFilesAction>
#include <KDE/KParts/PartManager>
#include <KDE/KMenuBar>
+#include <KDE/KApplication>
+#include <KDE/KAboutData>
#include <engine/game.h>
#include <engine/gameproject.h>
@@ -52,8 +55,12 @@
#include "gluoncreatorsettings.h"
#include "dialogs/projectselectiondialog.h"
#include "dialogs/configdialog.h"
+#include <QTimer>
+
+class QTimer;
using namespace GluonCreator;
+class QDebug;
class MainWindow::Private
{
@@ -70,7 +77,6 @@ MainWindow::MainWindow( const QString& fileName, QWidget* parent, \
Qt::WindowFlag : KParts::MainWindow( parent, flags ), d( new Private )
{
d->modified = false;
-
GluonCore::GluonObjectFactory::instance()->loadPlugins();
DockManager::instance()->setMainWindow( this );
@@ -94,6 +100,10 @@ MainWindow::MainWindow( const QString& fileName, QWidget* parent, \
Qt::WindowFlag setupActions();
setupGUI();
stateChanged( "initial" );
+ obj= new IntroSlideShow();
+ QTimer *time = new QTimer();
+ time->setSingleShot(true);
+ time->singleShot(5000, this, SLOT(timeout()));
d->projectDialog = new ProjectSelectionDialog( this );
d->projectDialog->setModal( true );
@@ -133,11 +143,17 @@ void MainWindow::closeEvent( QCloseEvent* event )
QWidget::closeEvent( event );
}
+
void MainWindow::openProject( const KUrl& url )
{
openProject( url.path() );
}
+void MainWindow::timeout()
+{
+ obj->startIntro();
+}
+
void MainWindow::openProject( const QString& fileName )
{
if( !fileName.isEmpty() && QFile::exists( fileName ) )
@@ -404,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/mainwindow.h b/creator/mainwindow.h
index f9335ff..24b0260 100644
--- a/creator/mainwindow.h
+++ b/creator/mainwindow.h
@@ -21,7 +21,8 @@
#define GLUONCREATOR_MAINWINDOW_H
#include <KDE/KParts/MainWindow>
-
+#include "introduction.h"
+class IntroSlideShow ;
class KUrl;
class KRecentFilesAction;
namespace GluonCreator
@@ -46,7 +47,7 @@ namespace GluonCreator
void saveProject( const QString& fileName );
void saveProjectAs();
void showPreferences();
-
+ void timeout();
void playGame();
void pauseGame();
void stopGame();
@@ -64,7 +65,7 @@ namespace GluonCreator
private:
void setupActions();
-
+ IntroSlideShow *obj;
class Private;
Private* const d;
};
diff --git a/creator/ui/introduction.qml b/creator/ui/introduction.qml
index a9178d5..a23fd89 100644
--- a/creator/ui/introduction.qml
+++ b/creator/ui/introduction.qml
@@ -71,31 +71,36 @@ Item {
Item {
id: viewport;
- width: parent.m_width / 2;
- height: parent.m_height / 2;
- x: parent.m_width / 4;
- y: parent.m_height / 4;
+ width: parent.width / 2;
+ height: parent.height / 2;
+ x: parent.width / 4;
+ y: parent.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;
- }
+ IntroSlideShow {
+ id :animator;
+ Component.onCompleted:{
+ console.log("I am inside instance");
+ }
+ }
MouseArea {
anchors.fill: parent;
-
onClicked: {
+
switch(animator.dockername){
case(""):
+ console.log("going to component")
viewport.state = 'component';
break;
case("ComponentsDock"):
+ console.log("going to project")
viewport.state = 'project';
break;
@@ -120,40 +125,47 @@ Item {
}
+
+ onDockernameChanged: {
+ animator.setdockername(animator.dockername);
+ }
+
+ }
+
}
- }
+
states: [
State {
name: "component"
- PropertyChanges { target:animator; dockername : "ComponentsDock"}
- PropertyChanges { target: viewport; x: animator.m_xpos; y: \
animator.m_ypos; width:animator.m_width; height:animator.m_height} + \
PropertyChanges { target:animator; dockername: "ComponentsDock"} + \
PropertyChanges { target: viewport; x: animator.x; y: animator.y; \
width:animator.implicitWidth; height:animator.implicitHeight} },
State {
name: "project"
PropertyChanges { target:animator; dockername : "ProjectDock"}
- PropertyChanges { target: viewport; x: animator.m_xpos; y: \
animator.m_ypos; width:animator.m_width; height:animator.m_height } + \
PropertyChanges { target: viewport; x: animator.x; y: animator.y; \
width:animator.implicitWidth; height:animator.implicitHeight } },
State {
name: "message"
PropertyChanges { target:animator; dockername : "MessageDock"}
- PropertyChanges { target: viewport; x: animator.m_xpos; y: \
animator.m_ypos; width:animator.m_width; height:animator.m_height } + \
PropertyChanges { target: viewport; x: animator.x; y: animator.y; \
width:animator.implicitWidth; height:animator.implicitHeight } },
State {
name: "scene"
PropertyChanges { target:animator; dockername : "SceneDock"}
- PropertyChanges { target: viewport; x: animator.m_xpos; y: \
animator.m_ypos; width:animator.m_width; height:animator.m_height } + \
PropertyChanges { target: viewport; x: animator.x; y: animator.y; \
width:animator.implicitWidth; height:animator.implicitHeight } },
State {
name: "property"
PropertyChanges { target:animator; dockername : "PropertiesDock"}
- PropertyChanges { target: viewport; x: animator.m_xpos; y: \
animator.m_ypos; width:animator.m_width; height:animator.m_height } + \
PropertyChanges { target: viewport; x: animator.x; y: animator.y; \
width:animator.implicitWidth; height:animator.implicitHeight } }
]
@@ -161,27 +173,27 @@ Item {
Transition {
from: "*"; to: "component"
- NumberAnimation { properties: "x,y,m_width,m_height"; duration: 1000 \
} + NumberAnimation { properties: "x,y,width,height"; duration: 1000 }
},
Transition {
from: "*"; to: "project"
- NumberAnimation { properties: "x,y,m_width,m_height"; duration: 1000 \
} + NumberAnimation { properties: "x,y,width,height"; duration: 1000 }
},
Transition {
from: "*"; to: "message"
- NumberAnimation { properties: "x,y,m_width,m_height"; duration: 1000 \
} + NumberAnimation { properties: "x,y,width,height"; duration: 1000 }
},
Transition {
from: "*"; to: "scene"
- NumberAnimation { properties: "x,y,m_width,m_height"; duration: 1000 \
} + NumberAnimation { properties: "x,y,width,height"; duration: 1000 }
},
Transition {
from: "*"; to: "property"
- NumberAnimation { properties: "x,y,m_width,m_height"; duration: 1000 \
} + 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