summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlli Werwolff <qt-info@nokia.com>2010-12-08 13:37:14 +0100
committerOlli Werwolff <qt-info@nokia.com>2010-12-09 09:55:35 +0100
commitf82260b66040553385c78a1b130e5d0300d8f7ac (patch)
treee1385676373dc8476f9893db5d33c63265ab34d1
parent71d2898b244835fac6b4cd5af22bf987b0341e39 (diff)
Differentiate between "portrait" and "landscape" models in AccelerometerControl
Reviewed-by: ckamm
-rw-r--r--models/maemoFremantle/N900_back.pngbin0 -> 1157713 bytes
-rw-r--r--models/maemoFremantle/N900_left.pngbin0 -> 193023 bytes
-rw-r--r--models/maemoFremantle/N900_top.pngbin0 -> 324504 bytes
-rw-r--r--src/other/deviceitem.cpp1
-rw-r--r--src/other/deviceitem.h1
-rw-r--r--src/ui/accelerometercontrol.cpp62
-rw-r--r--src/ui/accelerometercontrol.h17
-rw-r--r--src/ui/mainwindow.cpp1
-rw-r--r--src/ui/sensorsui.cpp4
-rw-r--r--src/ui/sensorsui.h1
10 files changed, 78 insertions, 9 deletions
diff --git a/models/maemoFremantle/N900_back.png b/models/maemoFremantle/N900_back.png
new file mode 100644
index 0000000..dc74ee1
--- /dev/null
+++ b/models/maemoFremantle/N900_back.png
Binary files differ
diff --git a/models/maemoFremantle/N900_left.png b/models/maemoFremantle/N900_left.png
new file mode 100644
index 0000000..3f6379b
--- /dev/null
+++ b/models/maemoFremantle/N900_left.png
Binary files differ
diff --git a/models/maemoFremantle/N900_top.png b/models/maemoFremantle/N900_top.png
new file mode 100644
index 0000000..11365d9
--- /dev/null
+++ b/models/maemoFremantle/N900_top.png
Binary files differ
diff --git a/src/other/deviceitem.cpp b/src/other/deviceitem.cpp
index 8e146aa..6282a66 100644
--- a/src/other/deviceitem.cpp
+++ b/src/other/deviceitem.cpp
@@ -290,6 +290,7 @@ void DeviceItem::updateScreenOrientation()
mDeviceData.availableGeometry = mAvailableGeometry;
emit deviceChanged(newResolution, mDeviceData);
+ emit deviceChanged(mDeviceData.mockup->width() < mDeviceData.mockup->height());
}
void DeviceItem::initiateRotate()
diff --git a/src/other/deviceitem.h b/src/other/deviceitem.h
index 0537050..0f44d00 100644
--- a/src/other/deviceitem.h
+++ b/src/other/deviceitem.h
@@ -290,6 +290,7 @@ signals:
void viewSizeRequired(const QSize &size);
void deviceChanged(const QSize &resolution, const DeviceData &device);
+ void deviceChanged(bool mainOrientationPortrait);
void offsetChanged(const QPoint &newOffset);
void buttonPressed(Qt::Key key, QString text);
diff --git a/src/ui/accelerometercontrol.cpp b/src/ui/accelerometercontrol.cpp
index e469cfc..3dd2295 100644
--- a/src/ui/accelerometercontrol.cpp
+++ b/src/ui/accelerometercontrol.cpp
@@ -71,15 +71,29 @@ void AccelerometerControl::initializeGL()
QDir n8ModelDir(QCoreApplication::applicationDirPath());
n8ModelDir.cd("models/symbian3");
QImage frontImg(n8ModelDir.absoluteFilePath("N8_3D_front.png"));
- mFrontTexture = bindTexture(frontImg);
QImage backImg(n8ModelDir.absoluteFilePath("N8_3D_back.png"));
- mBackTexture = bindTexture(backImg);
QImage rightImg(n8ModelDir.absoluteFilePath("N8_3D_right.png"));
- mRightTexture = bindTexture(rightImg);
QImage topImg(n8ModelDir.absoluteFilePath("N8_3D_top.png"));
- mTopTexture = bindTexture(topImg);
QImage bottomImg(n8ModelDir.absoluteFilePath("N8_3D_bottom.png"));
- mBottomTexture = bindTexture(bottomImg);
+ mFrontPortraitTexture = bindTexture(frontImg);
+ mBackPortraitTexture = bindTexture(backImg);
+ mLeftPortraitTexture = bindTexture(rightImg);
+ mRightPortraitTexture = bindTexture(rightImg);
+ mTopPortraitTexture = bindTexture(topImg);
+ mBottomPortraitTexture = bindTexture(bottomImg);
+ QDir n900ModelDir(QCoreApplication::applicationDirPath());
+ n900ModelDir.cd("models/maemoFremantle");
+ frontImg = QImage(n900ModelDir.absoluteFilePath("N900.png"));
+ backImg = QImage(n900ModelDir.absoluteFilePath("N900_back.png"));
+ rightImg = QImage(n900ModelDir.absoluteFilePath("N900_left.png"));
+ topImg = QImage(n900ModelDir.absoluteFilePath("N900_top.png"));
+ bottomImg = QImage(n900ModelDir.absoluteFilePath("N900_top.png"));
+ mFrontLandscapeTexture = bindTexture(frontImg);
+ mBackLandscapeTexture = bindTexture(backImg);
+ mLeftLandscapeTexture = bindTexture(rightImg);
+ mRightLandscapeTexture = bindTexture(rightImg);
+ mTopLandscapeTexture = bindTexture(topImg);
+ mBottomLandscapeTexture = bindTexture(topImg);
}
void AccelerometerControl::resizeGL(int w, int h)
@@ -101,9 +115,18 @@ void AccelerometerControl::resizeGL(int w, int h)
void AccelerometerControl::drawMobile()
{
// actually, half
- qreal height = 0.8;
- qreal width = height / 1.92; // values for the N8, based on the textures
- qreal depth = height / 7.16;
+ qreal height;
+ qreal width;
+ qreal depth;
+ if (!mDefaultPortrait) {
+ height = 0.4;
+ width = height * 1.84; // values for the N900, based on the textures
+ depth = width / 5.21;
+ } else {
+ height = 0.8;
+ width = height / 1.92; // values for the N8, based on the textures
+ depth = height / 7.16;
+ }
// backside
glBindTexture(GL_TEXTURE_2D, mBackTexture);
@@ -148,7 +171,7 @@ void AccelerometerControl::drawMobile()
glEnd();
// left side
- glBindTexture(GL_TEXTURE_2D, mRightTexture);
+ glBindTexture(GL_TEXTURE_2D, mLeftTexture);
glBegin(GL_QUADS);
glColor3f(1, 1, 1);
glTexCoord2f(0, 0);
@@ -249,3 +272,24 @@ void AccelerometerControl::mousePressEvent(QMouseEvent *event)
{
mOldMousePosition = event->pos();
}
+
+void AccelerometerControl::setDeviceOrientation(bool portrait)
+{
+ mDefaultPortrait = portrait;
+ if (portrait) {
+ mFrontTexture = mFrontPortraitTexture;
+ mBackTexture = mBackPortraitTexture;
+ mLeftTexture = mLeftPortraitTexture;
+ mRightTexture = mRightPortraitTexture;
+ mTopTexture = mTopPortraitTexture;
+ mBottomTexture = mBottomPortraitTexture;
+ } else {
+ mFrontTexture = mFrontLandscapeTexture;
+ mBackTexture = mBackLandscapeTexture;
+ mLeftTexture = mLeftLandscapeTexture;
+ mRightTexture = mRightLandscapeTexture;
+ mTopTexture = mTopLandscapeTexture;
+ mBottomTexture = mBottomLandscapeTexture;
+ }
+ updateGL();
+}
diff --git a/src/ui/accelerometercontrol.h b/src/ui/accelerometercontrol.h
index e55c3ea..199aab0 100644
--- a/src/ui/accelerometercontrol.h
+++ b/src/ui/accelerometercontrol.h
@@ -40,6 +40,8 @@ class AccelerometerControl : public QGLWidget
public:
explicit AccelerometerControl(QWidget *parent = 0);
+ void setDeviceOrientation(bool portrait);
+
signals:
void valueChanged(const QVector3D &value);
@@ -61,12 +63,27 @@ private:
QPoint mOldMousePosition;
QQuaternion mRotation;
QVector3D mUpValue;
+ bool mDefaultPortrait;
GLuint mFrontTexture;
GLuint mBackTexture;
+ GLuint mLeftTexture;
GLuint mRightTexture;
GLuint mTopTexture;
GLuint mBottomTexture;
+
+ GLuint mFrontPortraitTexture;
+ GLuint mBackPortraitTexture;
+ GLuint mLeftPortraitTexture;
+ GLuint mRightPortraitTexture;
+ GLuint mTopPortraitTexture;
+ GLuint mBottomPortraitTexture;
+ GLuint mFrontLandscapeTexture;
+ GLuint mBackLandscapeTexture;
+ GLuint mLeftLandscapeTexture;
+ GLuint mRightLandscapeTexture;
+ GLuint mTopLandscapeTexture;
+ GLuint mBottomLandscapeTexture;
};
#endif // ACCELEROMETERCONTROL_H
diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp
index 8b4c638..f0ef043 100644
--- a/src/ui/mainwindow.cpp
+++ b/src/ui/mainwindow.cpp
@@ -217,6 +217,7 @@ MainWindow::MainWindow(QWidget *parent)
SensorsUi *sensorsUi = new SensorsUi(this);
mobility->mSensorsUi = sensorsUi;
config->addSimulateSubPage(sensorsUi);
+ connect(deviceItem, SIGNAL(deviceChanged(bool)), sensorsUi, SLOT(updateDeviceDefaultOrientation(bool)));
OrganizerUi *organizerUi = new OrganizerUi(mobility->mOrganizer, this);
config->addSimulateSubPage(organizerUi);
diff --git a/src/ui/sensorsui.cpp b/src/ui/sensorsui.cpp
index cbc1f47..4b669d9 100644
--- a/src/ui/sensorsui.cpp
+++ b/src/ui/sensorsui.cpp
@@ -624,3 +624,7 @@ QDateTime SensorsScriptInterface::timestamp() const
{
return ui->mTimeEdit->dateTime();
}
+void SensorsUi::updateDeviceDefaultOrientation(bool isPortrait)
+{
+ mAccelerometerControl->setDeviceOrientation(isPortrait);
+}
diff --git a/src/ui/sensorsui.h b/src/ui/sensorsui.h
index d8a9b6f..b13924b 100644
--- a/src/ui/sensorsui.h
+++ b/src/ui/sensorsui.h
@@ -192,6 +192,7 @@ public:
public slots:
void setSensorsData(const SensorsUi::SensorsData &data);
void setDisplayedSensorsData(const SensorsUi::SensorsData &data);
+ void updateDeviceDefaultOrientation(bool isPortrait);
signals:
void sensorsDataChanged(const SensorsUi::SensorsData &data) const;