00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef WALLPAPEREDITORWIDGET_H
00020 #define WALLPAPEREDITORWIDGET_H
00021
00022 #include <QPointer>
00023 #include <MPhysics2DPanning>
00024 #include <meegocontrolexport.h>
00025 #include <dcpwidget.h>
00026
00027 #include "wallpaperbusinesslogic.h"
00028 #include "wallpaperitrans.h"
00029
00030 class MContainer;
00031 class MLinearLayoutPolicy;
00032 class QGraphicsSceneMouseEvent;
00033 class QGraphicsSceneWheelEvent;
00034 class MAction;
00035 class QSize;
00036 class QPixmap;
00037 class QImage;
00038 class QPointF;
00039 class QGestureEvent;
00040 class WallpaperInfoHeader;
00041
00042
00043 #define NO_EDITING
00044
00077 class MC_EXPORT WallpaperEditorWidget : public DcpWidget
00078 {
00079 Q_OBJECT
00080
00081 public:
00082 WallpaperEditorWidget (
00083 WallpaperBusinessLogic *wallpaperBusinessLogic,
00084 QGraphicsWidget *parent = 0);
00085 ~WallpaperEditorWidget ();
00086
00087 virtual bool pagePans () const;
00088 virtual bool back ();
00089 virtual void paint (
00090 QPainter *painter,
00091 const QStyleOptionGraphicsItem *option,
00092 QWidget *widget = 0);
00093
00094 void saveImage ();
00095 void dropImage ();
00096
00097 protected:
00098 virtual void polishEvent ();
00099 virtual void retranslateUi();
00100
00101 #ifndef NO_EDITING
00102 virtual void mousePressEvent (QGraphicsSceneMouseEvent *event);
00103 virtual void wheelEvent (QGraphicsSceneWheelEvent *event);
00104
00105 void panGestureEvent (
00106 QGestureEvent *event,
00107 QPanGesture *panGesture);
00108
00109 virtual void pinchGestureEvent (
00110 QGestureEvent *event,
00111 QPinchGesture *gesture);
00112
00113 virtual void pinchGestureStarted (
00114 QGestureEvent *event,
00115 QPinchGesture *gesture);
00116
00117 virtual void pinchGestureUpdate (
00118 QGestureEvent *event,
00119 QPinchGesture *gesture);
00120
00121 virtual void pinchGestureEnded (
00122 QGestureEvent *event,
00123 QPinchGesture *gesture);
00124 #endif
00125
00126 signals:
00127 void doneClicked ();
00128 void cancelClicked ();
00129
00130 private slots:
00131 void redrawImage ();
00132 void queueRedrawImage ();
00133 void orientationChanged (M::Orientation orientation);
00134 void slotDoneActivated ();
00135 void slotCancelActivated ();
00136 void createContent ();
00137 void createWidgets ();
00138 void panningPhysicsPositionChanged (const QPointF &position);
00139 void panningPhysicsPanningStopped ();
00140 void scalePhysicsPositionChanged(const QPointF &position);
00141
00142 private:
00143 QPointF toggleTitlebars (bool show);
00144 void setupPanningPhysics ();
00145
00146 int imageX () const;
00147 int imageY () const;
00148 int imageDX () const;
00149 int imageDY () const;
00150 void gestureWorkaround (QPointF *point);
00151 bool supportsLandscape () const;
00152 bool supportsPortrait () const;
00153
00154 private:
00155 QPointer<WallpaperBusinessLogic> m_WallpaperBusinessLogic;
00156
00157
00158
00159 WallpaperInfoHeader *m_InfoHeader;
00160 QImage m_bgLandscape;
00161 QImage m_bgPortrait;
00162 MAction *m_DoneAction;
00163 MAction *m_CancelAction;
00164 bool m_NoTitlebar;
00165 bool m_OrientationLocked;
00166 M::Orientation m_Orientation;
00167
00168 QPointF m_LastClick;
00169 QPointF m_UserOffset;
00170 QPointF m_ImageFixpoint;
00171
00172 WallpaperITrans m_Trans;
00173 WallpaperITrans m_LandscapeTrans;
00174 WallpaperITrans m_PortraitTrans;
00175
00176 qreal m_OriginalScaleFactor;
00177 bool m_PinchOngoing;
00178 bool m_PanOngoing;
00179 bool m_HasPendingRedraw;
00180 MPhysics2DPanning *m_Physics;
00181 MPhysics2DPanning *m_ScalePhysics;
00182
00183 #ifdef UNIT_TEST
00184 friend class Ut_WallpaperEditorWidget;
00185 #endif
00186 };
00187
00188 #endif