[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [gluon/creator-qmlintro-shreya] creator: Change logic for aligning text. Find position with enough s
From: Shreya Pandit <shreya () shreyapandit ! com>
Date: 2012-06-21 9:28:08
Message-ID: 20120621092808.0C4FCA60A9 () git ! kde ! org
[Download RAW message or body]
Git commit c40878ff9aa83045af78d8c067397b7c89be2c39 by Shreya Pandit.
Committed on 21/06/2012 at 11:27.
Pushed by pandit into branch 'creator-qmlintro-shreya'.
Change logic for aligning text. Find position with enough space to accomodate \
textBox.
M +46 -16 creator/introslideshow.cpp
M +17 -8 creator/introslideshow.h
M +47 -9 creator/ui/introduction.qml
http://commits.kde.org/gluon/c40878ff9aa83045af78d8c067397b7c89be2c39
diff --git a/creator/introslideshow.cpp b/creator/introslideshow.cpp
index 57932db..8f09306 100644
--- a/creator/introslideshow.cpp
+++ b/creator/introslideshow.cpp
@@ -20,13 +20,18 @@
#include "introslideshow.h"
#include <QRect>
#include <KDE/KApplication>
+#include <QTimer>
+class QTimer;
class QRect;
class KApplication;
IntroSlideShow::IntroSlideShow()
{
-
+ QTimer *timer = new QTimer(this);
+ connect(timer, SIGNAL(timeout()), this, SLOT(getWindow()));
+ timer->setSingleShot(true);
+ timer->start(1000);
}
IntroSlideShow::~IntroSlideShow()
@@ -34,6 +39,16 @@ IntroSlideShow::~IntroSlideShow()
delete this;
}
+
+void IntroSlideShow::getWindow()
+{
+ mainWidth = kapp->activeWindow()->width();
+ mainHeight= kapp->activeWindow()->height();
+ mainX = kapp->activeWindow()->x();
+ mainY = kapp->activeWindow()->y();
+ qDebug()<< mainWidth << mainHeight << mainX << mainY ;
+}
+
int IntroSlideShow::height() const
{
return m_height;
@@ -62,42 +77,57 @@ void IntroSlideShow::setDockername(QString name)
updateDocker();
emit dockernameChanged();
+}
+qreal IntroSlideShow::bLeftDock()
+{
+ return (dockY+dockHeight);
}
-qreal IntroSlideShow::getdockY()
+qreal IntroSlideShow::bLeftMain()
{
- return dockY;
+ return (mainY+mainHeight);
}
-qreal IntroSlideShow::getdockHeight()
+qreal IntroSlideShow::tRightDock()
+{
+ return (dockX+dockWidth);
+}
+qreal IntroSlideShow::tRightMain()
+{
+ return (mainX+mainWidth);
+}
+qreal IntroSlideShow::dWidth()
+{
+ return dockWidth;
+}
+qreal IntroSlideShow::dHeight()
{
return dockHeight;
}
-qreal IntroSlideShow::getdockX()
+qreal IntroSlideShow::dX()
{
return dockX;
}
-qreal IntroSlideShow::getdockWidth()
+qreal IntroSlideShow::dY()
{
- return dockWidth;
+ return dockY;
}
-QString IntroSlideShow::dockername() const
+qreal IntroSlideShow::mX()
{
- return docker;
+ return mainX;
}
-
-qreal IntroSlideShow::getrefWidth()
+qreal IntroSlideShow::mY()
{
- return refWidth;
+ return mainY;
}
-qreal IntroSlideShow::getrefHeight()
+QString IntroSlideShow::dockername() const
{
- return refHeight;
+ return docker;
}
void IntroSlideShow::updateDocker()
@@ -105,8 +135,8 @@ void IntroSlideShow::updateDocker()
QRect rectangle;
rectangle= kapp->activeWindow()->findChild<QWidget*>(docker)->frameGeometry();
setWidth(rectangle.width());
- refWidth=kapp->activeWindow()->width() ;
- refHeight= kapp->activeWindow()->height()/2 ;
+ // refWidth=kapp->activeWindow()->width() ;
+ // refHeight= kapp->activeWindow()->height()/2 ;
dockX= rectangle.x();
dockY= rectangle.y();
dockWidth= rectangle.width();
diff --git a/creator/introslideshow.h b/creator/introslideshow.h
index 0296057..f93bfd5 100644
--- a/creator/introslideshow.h
+++ b/creator/introslideshow.h
@@ -44,12 +44,16 @@ class IntroSlideShow: public QObject
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();
- Q_INVOKABLE qreal getdockY();
- Q_INVOKABLE qreal getdockHeight();
- Q_INVOKABLE qreal getrefHeight();
+ Q_INVOKABLE qreal bLeftMain();
+ Q_INVOKABLE qreal bLeftDock();
+ Q_INVOKABLE qreal tRightDock();
+ Q_INVOKABLE qreal tRightMain();
+ Q_INVOKABLE qreal dWidth();
+ Q_INVOKABLE qreal dHeight();
+ Q_INVOKABLE qreal dX();
+ Q_INVOKABLE qreal dY();
+ Q_INVOKABLE qreal mX();
+ Q_INVOKABLE qreal mY();
void setWidth(qreal width);
void setHeight(qreal height);
void setDockername(QString name);
@@ -61,17 +65,22 @@ class IntroSlideShow: public QObject
private:
QString docker;
- qreal refWidth;
+ qreal mainWidth;
+ qreal mainX;
+ qreal mainY;
+ qreal mainHeight;
qreal dockX;
qreal dockWidth;
qreal dockY;
qreal dockHeight;
- qreal refHeight;
int m_width;
int m_height;
int m_x;
int m_y;
+ public slots:
+ void getWindow();
+
signals:
void dockernameChanged();
void widthChanged();
diff --git a/creator/ui/introduction.qml b/creator/ui/introduction.qml
index b1d4694..6e279ca 100644
--- a/creator/ui/introduction.qml
+++ b/creator/ui/introduction.qml
@@ -102,11 +102,11 @@ Item {
Rectangle{
id: textBox;
- color: "Transparent";
+ color: "Blue ";
property int i: 0;
property bool showText: true ;
width: topmost.width / 4;
- height: topmost.height / 4;
+ height: topmost.height /6;
x: topmost.width / 5;
y: topmost.height / 5;
states: [
@@ -118,6 +118,11 @@ Item {
anchors.top: viewport.bottom;
anchors.horizontalCenter: viewport.horizontalCenter;
}
+ StateChangeScript {
+ name: "myScript1"
+ script: { console.log("In top");}
+
+ }
},
@@ -129,6 +134,12 @@ Item {
anchors.horizontalCenter: viewport.horizontalCenter
}
+ StateChangeScript {
+ name: "myScript1"
+ script: { console.log("In bottom");}
+
+ }
+
},
State {
@@ -136,8 +147,16 @@ Item {
AnchorChanges {
target: textBox;
anchors.left: viewport.right;
+ anchors.verticalCenter: viewport.verticalCenter;
+
+
+ }
+ StateChangeScript {
+ name: "myScript1"
+ script: { console.log("In right");}
}
+
},
State {
@@ -145,6 +164,12 @@ Item {
AnchorChanges {
target: textBox;
anchors.right: viewport.left;
+ anchors.verticalCenter: viewport.verticalCenter;
+
+ }
+ StateChangeScript {
+ name: "myScript1"
+ script: { console.log("In left");}
}
@@ -171,20 +196,33 @@ Item {
}
function orient() {
- if ((animator.getdockX() +animator.getdockWidth()) < \
(0.25*animator.getrefWidth())){
- textBox.state = "right";
+ if (((animator.tRightMain() - animator.tRightDock()) > \
textBox.width)&&(animator.dHeight()-textBox.height > 0)) + {
+ textBox.state = 'right';
+ console.log ("In If for right");
}
- else if((animator.getdockX() +animator.getdockWidth()) > \
(0.75*(animator.getrefWidth()))) { + else \
if(((animator.dX()-animator.mX()) > \
textBox.width)&&(animator.dHeight()-textBox.height > 0)) + {
- textBox.state = "left";
+ console.log ("In If for left");
+ textBox.state = 'left';
}
- else{
+ else if (((animator.dY()-animator.mY()) > \
textBox.height)&&(animator.dWidth()- textBox.width >0)) + {
+ textBox.state = 'bottom';
+ console.log ("In If for bottom");
- if((animator.getdockY()+animator.getdockHeight()) < \
animator.getrefHeight()) {textBox.state = "top";}
- else{textBox.state = "bottom";}
}
+
+ else
+ {
+ textBox.state = "top";
+ console.log ("In If for top");
+
+ }
+
show();
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic