homescreenapp/stateplugins/hshomescreenstateplugin/src/hswallpaperselectionstate.cpp
changeset 90 3ac3aaebaee5
parent 62 341166945d65
child 98 e6f74eb7f69f
equal deleted inserted replaced
86:e4f038c420f7 90:3ac3aaebaee5
    21 #include "hspage.h"
    21 #include "hspage.h"
    22 #include "hswallpaper.h"
    22 #include "hswallpaper.h"
    23 #include "hsconfiguration.h"
    23 #include "hsconfiguration.h"
    24 
    24 
    25 #ifdef Q_OS_SYMBIAN
    25 #ifdef Q_OS_SYMBIAN
    26 #include "hsimagefetcherclient.h"
    26 #include "hsimagehandlingclient.h"
    27 #else
    27 #else
    28 #include "xqaiwgetimageclient.h"
    28 #include "xqaiwgetimageclient.h"
    29 #endif
    29 #endif
    30 
    30 
    31 // Helper macros for connecting state entry and exit actions.
    31 // Helper macros for connecting state entry and exit actions.
    43 /*!
    43 /*!
    44 
    44 
    45 */
    45 */
    46 HsWallpaperSelectionState::HsWallpaperSelectionState(QState *parent)
    46 HsWallpaperSelectionState::HsWallpaperSelectionState(QState *parent)
    47   : QState(parent),    
    47   : QState(parent),    
    48     mImageFetcher(0),
    48     mImageHandler(0),
    49     mWallpaper(0),    
    49     mWallpaper(0),    
    50     mWaitDialog(0)
    50     mWaitDialog(0)
    51 {
    51 {
    52     setupStates();
    52     setupStates();
    53 }
    53 }
    67 {
    67 {
    68     // States
    68     // States
    69     
    69     
    70     QState *state_processing = new QState(this);
    70     QState *state_processing = new QState(this);
    71     QState *state_selectingImage = new QState(state_processing);
    71     QState *state_selectingImage = new QState(state_processing);
       
    72     QState *state_editingImage = new QState(state_processing);
    72     QState *state_assigningImage = new QState(state_processing);
    73     QState *state_assigningImage = new QState(state_processing);
    73     QState *state_errorMessage = new QState(this);
    74     QState *state_errorMessage = new QState(this);
    74     
    75     
    75     setInitialState(state_processing);
    76     setInitialState(state_processing);
    76     state_processing->setInitialState(state_selectingImage);
    77     state_processing->setInitialState(state_selectingImage);
    77     
    78     
    78     // Transitions
    79     // Transitions
    79 
    80 #if defined (Q_OS_SYMBIAN) && !defined (__WINSCW__)
       
    81     state_selectingImage->addTransition(
       
    82         this, SIGNAL(event_assignImage()), state_editingImage);
       
    83 #else
    80     state_selectingImage->addTransition(
    84     state_selectingImage->addTransition(
    81         this, SIGNAL(event_assignImage()), state_assigningImage);
    85         this, SIGNAL(event_assignImage()), state_assigningImage);
       
    86 #endif // Q_OS_SYMBIAN
    82     
    87     
    83     state_processing->addTransition(
    88     state_processing->addTransition(
    84         this, SIGNAL(event_error()), state_errorMessage);
    89         this, SIGNAL(event_error()), state_errorMessage);
    85 
    90 
    86     // Actions
    91     // Actions
    87 
    92 
    88     ENTRY_ACTION(state_selectingImage, action_selectingImage_start)
    93     ENTRY_ACTION(state_selectingImage, action_selectingImage_start)
    89     EXIT_ACTION(state_selectingImage, action_selectingImage_cleanup)
    94     EXIT_ACTION(state_selectingImage, action_imageHandler_cleanup)
       
    95 
       
    96     ENTRY_ACTION(state_editingImage, action_editingImage_start)
       
    97     EXIT_ACTION(state_editingImage, action_imageHandler_cleanup)
    90 
    98 
    91     ENTRY_ACTION(state_assigningImage, action_assigningImage_showWaitDialog)
    99     ENTRY_ACTION(state_assigningImage, action_assigningImage_showWaitDialog)
    92     ENTRY_ACTION(state_assigningImage, action_assigningImage_start)
   100     ENTRY_ACTION(state_assigningImage, action_assigningImage_start)
    93     EXIT_ACTION(state_assigningImage, action_assigningImage_cleanup)
   101     EXIT_ACTION(state_assigningImage, action_assigningImage_cleanup)
    94     EXIT_ACTION(state_assigningImage, action_assigningImage_hideWaitDialog)
   102     EXIT_ACTION(state_assigningImage, action_assigningImage_hideWaitDialog)
   100 
   108 
   101 */
   109 */
   102 void HsWallpaperSelectionState::action_selectingImage_start()
   110 void HsWallpaperSelectionState::action_selectingImage_start()
   103 {
   111 {
   104 #ifdef Q_OS_SYMBIAN
   112 #ifdef Q_OS_SYMBIAN
   105     mImageFetcher = new HsImageFetcherClient;
   113     mImageHandler = new HsImageHandlingClient;
   106 #else    
   114 #else    
   107     mImageFetcher = new XQAIWGetImageClient;
   115     mImageHandler = new XQAIWGetImageClient;
   108 #endif
   116 #endif
   109 
   117 
   110     connect(mImageFetcher, SIGNAL(fetchCompleted(const QString&)),
   118     connect(mImageHandler, SIGNAL(fetchCompleted(const QString&)),
   111             this, SLOT(onFetchCompleted(const QString&)));
   119             this, SLOT(onFetchCompleted(const QString&)));
   112     connect(mImageFetcher, SIGNAL(fetchFailed(int, const QString&)),
   120     connect(mImageHandler, SIGNAL(fetchFailed(int, const QString&)),
   113             this, SLOT(onFetchFailed(int, const QString&)));
   121             this, SLOT(onFetchFailed(int, const QString&)));
   114 
   122 
   115     mImageFetcher->fetch();
   123     mImageHandler->fetch();
   116 }
   124 }
   117  
   125  
   118 /*!
   126 /*!
   119 
   127 
   120 */
   128 */
   121 void HsWallpaperSelectionState::action_selectingImage_cleanup()
   129 void HsWallpaperSelectionState::action_imageHandler_cleanup()
   122 {
   130 {
   123     mImageFetcher->disconnect(this);
   131     mImageHandler->disconnect(this);
   124     mImageFetcher->deleteLater();
   132     mImageHandler->deleteLater();
   125     mImageFetcher = 0;
   133     mImageHandler = 0;
   126 }
   134 }
   127 
   135 
   128 /*!
   136 /*!
   129 
   137 
   130 */
   138 */
   178 {
   186 {
   179     // TODO: Waiting for UX decision.
   187     // TODO: Waiting for UX decision.
   180     emit event_waitInput();
   188     emit event_waitInput();
   181 }
   189 }
   182 
   190 
       
   191 #ifdef COVERAGE_MEASUREMENT
       
   192 #pragma CTC SKIP
       
   193 #endif //COVERAGE_MEASUREMENT
       
   194 /*!
       
   195 
       
   196 */
       
   197 void HsWallpaperSelectionState::action_editingImage_start()
       
   198 {
       
   199 #ifdef Q_OS_SYMBIAN    
       
   200     mImageHandler = new HsImageHandlingClient; 
       
   201 
       
   202     connect(mImageHandler, SIGNAL(editorCompleted()),
       
   203             this, SLOT(onEditorCompleted()));
       
   204     connect(mImageHandler, SIGNAL(editorFailed(int, const QString&)),
       
   205             this, SLOT(onFetchFailed(int, const QString&)));
       
   206 
       
   207     mImageHandler->edit(mImagePath);
       
   208 #endif //Q_OS_SYMBIAN
       
   209 }
       
   210 #ifdef COVERAGE_MEASUREMENT
       
   211 #pragma CTC ENDSKIP
       
   212 #endif //COVERAGE_MEASUREMENT
       
   213 
   183 /*!
   214 /*!
   184 
   215 
   185 */
   216 */
   186 void HsWallpaperSelectionState::onFetchCompleted(const QString &imagePath)
   217 void HsWallpaperSelectionState::onFetchCompleted(const QString &imagePath)
   187 {
   218 {
   212 */
   243 */
   213 void HsWallpaperSelectionState::onImageSetFailed()
   244 void HsWallpaperSelectionState::onImageSetFailed()
   214 {
   245 {
   215     emit event_error();
   246     emit event_error();
   216 }
   247 }
       
   248 
       
   249 #ifdef COVERAGE_MEASUREMENT
       
   250 #pragma CTC SKIP
       
   251 #endif //COVERAGE_MEASUREMENT
       
   252 /*!
       
   253 
       
   254 */
       
   255 void HsWallpaperSelectionState::onEditorCompleted()
       
   256 {    
       
   257     emit event_waitInput();
       
   258 }
       
   259 #ifdef COVERAGE_MEASUREMENT
       
   260 #pragma CTC ENDSKIP
       
   261 #endif //COVERAGE_MEASUREMENT