summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel d'Andrada <daniel.dandrada@canonical.com>2014-12-09 09:35:32 -0200
committerDaniel d'Andrada <daniel.dandrada@canonical.com>2014-12-09 09:35:32 -0200
commit0f316fb03ee05764f7c4032b426b70ad5abe8290 (patch)
treebf8022274f1a66471b24ee8cb6889e13f9ba6b82 /src
parent48af2827d3a1cdfa537d340a14a349c57a9d18f5 (diff)
Make MirsufaceItem::orientationAngle use an enum
Diffstat (limited to 'src')
-rw-r--r--src/modules/Unity/Application/mirsurfaceitem.cpp14
-rw-r--r--src/modules/Unity/Application/mirsurfaceitem.h20
2 files changed, 22 insertions, 12 deletions
diff --git a/src/modules/Unity/Application/mirsurfaceitem.cpp b/src/modules/Unity/Application/mirsurfaceitem.cpp
index 1156ba5..c4cef9c 100644
--- a/src/modules/Unity/Application/mirsurfaceitem.cpp
+++ b/src/modules/Unity/Application/mirsurfaceitem.cpp
@@ -252,7 +252,7 @@ MirSurfaceItem::MirSurfaceItem(std::shared_ptr<mir::scene::Surface> surface,
, m_session(session)
, m_firstFrameDrawn(false)
, m_live(true)
- , m_orientationAngle(0)
+ , m_orientationAngle(Angle0)
, m_textureProvider(nullptr)
, m_lastTouchEvent(nullptr)
{
@@ -359,12 +359,12 @@ MirSurfaceItem::State MirSurfaceItem::state() const
return static_cast<MirSurfaceItem::State>(m_surface->state());
}
-int MirSurfaceItem::orientationAngle() const
+MirSurfaceItem::OrientationAngle MirSurfaceItem::orientationAngle() const
{
return m_orientationAngle;
}
-void MirSurfaceItem::setOrientationAngle(int angle)
+void MirSurfaceItem::setOrientationAngle(MirSurfaceItem::OrientationAngle angle)
{
qCDebug(QTMIR_SURFACES, "MirSurfaceItem::setOrientationAngle(%d)", angle);
@@ -374,16 +374,16 @@ void MirSurfaceItem::setOrientationAngle(int angle)
MirOrientation mirOrientation;
switch (angle) {
- case 0:
+ case Angle0:
mirOrientation = mir_orientation_normal;
break;
- case 90:
+ case Angle90:
mirOrientation = mir_orientation_right;
break;
- case 180:
+ case Angle180:
mirOrientation = mir_orientation_inverted;
break;
- case 270:
+ case Angle270:
mirOrientation = mir_orientation_left;
break;
default:
diff --git a/src/modules/Unity/Application/mirsurfaceitem.h b/src/modules/Unity/Application/mirsurfaceitem.h
index 989338d..03a271c 100644
--- a/src/modules/Unity/Application/mirsurfaceitem.h
+++ b/src/modules/Unity/Application/mirsurfaceitem.h
@@ -69,6 +69,7 @@ class MirSurfaceItem : public QQuickItem
Q_OBJECT
Q_ENUMS(Type)
Q_ENUMS(State)
+ Q_ENUMS(OrientationAngle)
Q_PROPERTY(Type type READ type NOTIFY typeChanged)
Q_PROPERTY(State state READ state NOTIFY stateChanged)
@@ -77,7 +78,7 @@ class MirSurfaceItem : public QQuickItem
// How many degrees, clockwise, the UI in the surface has to rotate to match with the
// shell UI orientation
- Q_PROPERTY(int orientationAngle READ orientationAngle WRITE setOrientationAngle
+ Q_PROPERTY(OrientationAngle orientationAngle READ orientationAngle WRITE setOrientationAngle
NOTIFY orientationAngleChanged DESIGNABLE false)
public:
@@ -106,6 +107,13 @@ public:
Fullscreen = mir_surface_state_fullscreen,
};
+ enum OrientationAngle {
+ Angle0 = 0,
+ Angle90 = 90,
+ Angle180 = 180,
+ Angle270 = 270
+ };
+
//getters
Type type() const;
State state() const;
@@ -124,8 +132,8 @@ public:
bool isFirstFrameDrawn() const { return m_firstFrameDrawn; }
- int orientationAngle() const;
- void setOrientationAngle(int angle);
+ OrientationAngle orientationAngle() const;
+ void setOrientationAngle(OrientationAngle angle);
void setSession(SessionInterface *app);
@@ -139,7 +147,7 @@ Q_SIGNALS:
void typeChanged();
void stateChanged();
void nameChanged();
- void orientationAngleChanged(int angle);
+ void orientationAngleChanged(OrientationAngle angle);
void liveChanged(bool live);
void firstFrameDrawn(MirSurfaceItem *item);
@@ -199,7 +207,9 @@ private:
QPointer<SessionInterface> m_session;
bool m_firstFrameDrawn;
bool m_live;
- int m_orientationAngle; //FIXME - have to save the state as Mir has no getter for it (bug:1357429)
+
+ //FIXME - have to save the state as Mir has no getter for it (bug:1357429)
+ OrientationAngle m_orientationAngle;
QMirSurfaceTextureProvider *m_textureProvider;