src/gui/styles/qs60style_s60.cpp
changeset 18 2f34d5167611
parent 3 41300fa6a67c
child 19 fcece45ef507
equal deleted inserted replaced
3:41300fa6a67c 18:2f34d5167611
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the QtGui module of the Qt Toolkit.
     7 ** This file is part of the QtGui module of the Qt Toolkit.
     8 **
     8 **
    48 #include "private/qpixmap_s60_p.h"
    48 #include "private/qpixmap_s60_p.h"
    49 #include "private/qcore_symbian_p.h"
    49 #include "private/qcore_symbian_p.h"
    50 #include "qapplication.h"
    50 #include "qapplication.h"
    51 
    51 
    52 #include <w32std.h>
    52 #include <w32std.h>
    53 #include <aknsconstants.h>
    53 #include <AknsConstants.h>
    54 #include <aknconsts.h>
    54 #include <aknconsts.h>
    55 #include <aknsitemid.h>
    55 #include <AknsItemID.h>
    56 #include <aknsutils.h>
    56 #include <AknsUtils.h>
    57 #include <aknsdrawutils.h>
    57 #include <AknsDrawUtils.h>
    58 #include <aknsskininstance.h>
    58 #include <AknsSkinInstance.h>
    59 #include <aknsbasicbackgroundcontrolcontext.h>
    59 #include <AknsBasicBackgroundControlContext.h>
    60 #include <avkon.mbg>
    60 #include <avkon.mbg>
    61 #include <AknFontAccess.h>
    61 #include <AknFontAccess.h>
    62 #include <AknLayoutFont.h>
    62 #include <AknLayoutFont.h>
    63 #include <aknutils.h>
    63 #include <AknUtils.h>
    64 #include <aknnavi.h>
    64 #include <aknnavi.h>
    65 #include <gulicon.h>
    65 #include <gulicon.h>
       
    66 #include <AknBitmapAnimation.h>
    66 
    67 
    67 #if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN)
    68 #if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN)
    68 
    69 
    69 QT_BEGIN_NAMESPACE
    70 QT_BEGIN_NAMESPACE
    70 
    71 
    71 enum TDrawType {
    72 enum TDrawType {
    72     EDrawIcon,
    73     EDrawIcon,
    73     EDrawGulIcon,
    74     EDrawGulIcon,
    74     EDrawBackground,
    75     EDrawBackground,
       
    76     EDrawAnimation,
    75     ENoDraw
    77     ENoDraw
    76 };
    78 };
    77 
    79 
    78 enum TSupportRelease {
    80 enum TSupportRelease {
    79     ES60_None     = 0x0000, //indicates that the commonstyle should draw the graphics
    81     ES60_None     = 0x0000, //indicates that the commonstyle should draw the graphics
    95     int supportInfo;
    97     int supportInfo;
    96     int newMajorSkinId;
    98     int newMajorSkinId;
    97     int newMinorSkinId;
    99     int newMinorSkinId;
    98 } partMapEntry;
   100 } partMapEntry;
    99 
   101 
       
   102 AnimationData::AnimationData(const QS60StyleEnums::SkinParts part, int frames, int interval) : m_id(part),
       
   103     m_frames(frames), m_interval(interval), m_mode(QS60StyleEnums::AM_Looping)
       
   104 {
       
   105 }
       
   106 
       
   107 AnimationDataV2::AnimationDataV2(const AnimationData &data) : AnimationData(data.m_id, data.m_frames, data.m_interval),
       
   108     m_animation(0), m_currentFrame(0), m_resourceBased(false), m_timerId(0)
       
   109 {
       
   110 }
       
   111 AnimationDataV2::~AnimationDataV2()
       
   112 {
       
   113     delete m_animation;
       
   114 }
       
   115 
       
   116 QS60StyleAnimation::QS60StyleAnimation(const QS60StyleEnums::SkinParts part, int frames, int interval)
       
   117 {
       
   118     QT_TRAP_THROWING(m_defaultData = new (ELeave) AnimationData(part, frames, interval));
       
   119     QT_TRAP_THROWING(m_currentData = new (ELeave) AnimationDataV2(*m_defaultData));
       
   120 }
       
   121 
       
   122 QS60StyleAnimation::~QS60StyleAnimation()
       
   123 {
       
   124     delete m_currentData;
       
   125     delete m_defaultData;
       
   126 }
       
   127 
       
   128 void QS60StyleAnimation::setAnimationObject(CAknBitmapAnimation* animation)
       
   129 {
       
   130     Q_ASSERT(animation);
       
   131     if (m_currentData->m_animation)
       
   132         delete m_currentData->m_animation;
       
   133     m_currentData->m_animation = animation;
       
   134 }
       
   135 
       
   136 void QS60StyleAnimation::resetToDefaults()
       
   137 {
       
   138     delete m_currentData;
       
   139     m_currentData = 0;
       
   140     QT_TRAP_THROWING(m_currentData = new (ELeave) AnimationDataV2(*m_defaultData));
       
   141 }
       
   142 
   100 class QS60StyleModeSpecifics
   143 class QS60StyleModeSpecifics
   101 {
   144 {
   102 public:
   145 public:
   103     static QPixmap skinnedGraphics(QS60StyleEnums::SkinParts stylepart,
   146     static QPixmap skinnedGraphics(QS60StyleEnums::SkinParts stylepart,
   104         const QSize &size, QS60StylePrivate::SkinElementFlags flags);
   147         const QSize &size, QS60StylePrivate::SkinElementFlags flags);
   111     static bool disabledFrameGraphic(QS60StylePrivate::SkinFrameElements &frame);
   154     static bool disabledFrameGraphic(QS60StylePrivate::SkinFrameElements &frame);
   112     static QPixmap generateMissingThemeGraphic(QS60StyleEnums::SkinParts &part, const QSize &size, QS60StylePrivate::SkinElementFlags flags);
   155     static QPixmap generateMissingThemeGraphic(QS60StyleEnums::SkinParts &part, const QSize &size, QS60StylePrivate::SkinElementFlags flags);
   113     static QSize naviPaneSize();
   156     static QSize naviPaneSize();
   114     static TAknsItemID partSpecificThemeId(int part);
   157     static TAknsItemID partSpecificThemeId(int part);
   115 
   158 
       
   159     static QVariant themeDefinition(QS60StyleEnums::ThemeDefinitions definition, QS60StyleEnums::SkinParts part);
       
   160 
   116 private:
   161 private:
   117     static QPixmap createSkinnedGraphicsLX(QS60StyleEnums::SkinParts part,
   162     static QPixmap createSkinnedGraphicsLX(QS60StyleEnums::SkinParts part,
   118         const QSize &size, QS60StylePrivate::SkinElementFlags flags);
   163         const QSize &size, QS60StylePrivate::SkinElementFlags flags);
   119     static QPixmap createSkinnedGraphicsLX(QS60StylePrivate::SkinFrameElements frameElement, const QSize &size, QS60StylePrivate::SkinElementFlags flags);
   164     static QPixmap createSkinnedGraphicsLX(QS60StylePrivate::SkinFrameElements frameElement, const QSize &size, QS60StylePrivate::SkinElementFlags flags);
   120     static QPixmap colorSkinnedGraphicsLX(const QS60StyleEnums::SkinParts &stylepart,
   165     static QPixmap colorSkinnedGraphicsLX(const QS60StyleEnums::SkinParts &stylepart,
   126     // Array to match the skin ID, fallback graphics and Qt widget graphics.
   171     // Array to match the skin ID, fallback graphics and Qt widget graphics.
   127     static const partMapEntry m_partMap[];
   172     static const partMapEntry m_partMap[];
   128 };
   173 };
   129 
   174 
   130 const partMapEntry QS60StyleModeSpecifics::m_partMap[] = {
   175 const partMapEntry QS60StyleModeSpecifics::m_partMap[] = {
   131     /* SP_QgnGrafBarWait */                {KAknsIIDQgnGrafBarWaitAnim,            EDrawIcon,   ES60_All,    -1,-1},
   176     /* SP_QgnGrafBarWaitAnim */            {KAknsIIDQgnGrafBarWaitAnim,       EDrawAnimation,   ES60_All,    -1,-1},
   132     /* SP_QgnGrafBarFrameCenter */         {KAknsIIDQgnGrafBarFrameCenter,         EDrawIcon,   ES60_All,    -1,-1},
   177     /* SP_QgnGrafBarFrameCenter */         {KAknsIIDQgnGrafBarFrameCenter,         EDrawIcon,   ES60_All,    -1,-1},
   133     /* SP_QgnGrafBarFrameSideL */          {KAknsIIDQgnGrafBarFrameSideL,          EDrawIcon,   ES60_All,    -1,-1},
   178     /* SP_QgnGrafBarFrameSideL */          {KAknsIIDQgnGrafBarFrameSideL,          EDrawIcon,   ES60_All,    -1,-1},
   134     /* SP_QgnGrafBarFrameSideR */          {KAknsIIDQgnGrafBarFrameSideR,          EDrawIcon,   ES60_All,    -1,-1},
   179     /* SP_QgnGrafBarFrameSideR */          {KAknsIIDQgnGrafBarFrameSideR,          EDrawIcon,   ES60_All,    -1,-1},
   135     /* SP_QgnGrafBarProgress */            {KAknsIIDQgnGrafBarProgress,            EDrawIcon,   ES60_All,    -1,-1},
   180     /* SP_QgnGrafBarProgress */            {KAknsIIDQgnGrafBarProgress,            EDrawIcon,   ES60_All,    -1,-1},
       
   181     // No drop area for 3.x non-touch devices
       
   182     /* SP_QgnGrafOrgBgGrid */              {KAknsIIDNone,                          EDrawIcon,   ES60_3_X,    EAknsMajorGeneric ,0x1eba}, //KAknsIIDQgnGrafOrgBgGrid   
   136     /* SP_QgnGrafScrollArrowDown */        {KAknsIIDQgnGrafScrollArrowDown,     EDrawGulIcon,   ES60_All,    -1,-1},
   183     /* SP_QgnGrafScrollArrowDown */        {KAknsIIDQgnGrafScrollArrowDown,     EDrawGulIcon,   ES60_All,    -1,-1},
   137     /* SP_QgnGrafScrollArrowLeft */        {KAknsIIDQgnGrafScrollArrowLeft,     EDrawGulIcon,   ES60_All,    -1,-1},
   184     /* SP_QgnGrafScrollArrowLeft */        {KAknsIIDQgnGrafScrollArrowLeft,     EDrawGulIcon,   ES60_All,    -1,-1},
   138     /* SP_QgnGrafScrollArrowRight */       {KAknsIIDQgnGrafScrollArrowRight,    EDrawGulIcon,   ES60_All,    -1,-1},
   185     /* SP_QgnGrafScrollArrowRight */       {KAknsIIDQgnGrafScrollArrowRight,    EDrawGulIcon,   ES60_All,    -1,-1},
   139     /* SP_QgnGrafScrollArrowUp */          {KAknsIIDQgnGrafScrollArrowUp,       EDrawGulIcon,   ES60_All,    -1,-1},
   186     /* SP_QgnGrafScrollArrowUp */          {KAknsIIDQgnGrafScrollArrowUp,       EDrawGulIcon,   ES60_All,    -1,-1},
   140     /* SP_QgnGrafTabActiveL */             {KAknsIIDQgnGrafTabActiveL,             EDrawIcon,   ES60_All,    -1,-1},
   187     /* SP_QgnGrafTabActiveL */             {KAknsIIDQgnGrafTabActiveL,             EDrawIcon,   ES60_All,    -1,-1},
   369 }
   416 }
   370 
   417 
   371 void QS60StyleModeSpecifics::fallbackInfo(const QS60StyleEnums::SkinParts &stylePart, TInt &fallbackIndex)
   418 void QS60StyleModeSpecifics::fallbackInfo(const QS60StyleEnums::SkinParts &stylePart, TInt &fallbackIndex)
   372 {
   419 {
   373     switch(stylePart) {
   420     switch(stylePart) {
   374         case QS60StyleEnums::SP_QgnGrafBarWait:
   421         case QS60StyleEnums::SP_QgnGrafBarWaitAnim:
   375             fallbackIndex = EMbmAvkonQgn_graf_bar_wait_1;
   422             fallbackIndex = EMbmAvkonQgn_graf_bar_wait_1;
   376             break;
   423             break;
   377         case QS60StyleEnums::SP_QgnGrafBarFrameCenter:
   424         case QS60StyleEnums::SP_QgnGrafBarFrameCenter:
   378             fallbackIndex = EMbmAvkonQgn_graf_bar_frame_center;
   425             fallbackIndex = EMbmAvkonQgn_graf_bar_frame_center;
   379             break;
   426             break;
   602 bool QS60StylePrivate::hasSliderGrooveGraphic()
   649 bool QS60StylePrivate::hasSliderGrooveGraphic()
   603 {
   650 {
   604     return QSysInfo::s60Version() != QSysInfo::SV_S60_3_1;
   651     return QSysInfo::s60Version() != QSysInfo::SV_S60_3_1;
   605 }
   652 }
   606 
   653 
       
   654 bool QS60StylePrivate::isSingleClickUi()
       
   655 {
       
   656     return (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0);
       
   657 }
       
   658 
   607 QPoint qt_s60_fill_background_offset(const QWidget *targetWidget)
   659 QPoint qt_s60_fill_background_offset(const QWidget *targetWidget)
   608 {
   660 {
   609     CCoeControl *control = targetWidget->effectiveWinId();
   661     CCoeControl *control = targetWidget->effectiveWinId();
   610     TPoint pos(0,0);
   662     TPoint pos(0,0);
   611     if (control) {
   663     if (control) {
   707 
   759 
   708             CleanupStack::PopAndDestroy(4, background); //background, dev, gc, bgContext
   760             CleanupStack::PopAndDestroy(4, background); //background, dev, gc, bgContext
   709     //        QS60WindowSurface::lockBitmapHeap();
   761     //        QS60WindowSurface::lockBitmapHeap();
   710             break;
   762             break;
   711         }
   763         }
       
   764         case EDrawAnimation: {
       
   765             CFbsBitmap* animationFrame;
       
   766             CFbsBitmap* frameMask;
       
   767             CAknBitmapAnimation* aknAnimation = 0;
       
   768             TBool constructedFromTheme = ETrue;
       
   769 
       
   770             QS60StyleAnimation* animation = QS60StylePrivate::animationDefinition(part); //ownership is not passed
       
   771             if (animation) {
       
   772                 if (!animation->animationObject() && !animation->isResourceBased()) {// no pre-made item exists, create new animation
       
   773                     CAknBitmapAnimation* newAnimation = CAknBitmapAnimation::NewL();
       
   774                     CleanupStack::PushL(newAnimation);
       
   775                     if (newAnimation)
       
   776                         constructedFromTheme = newAnimation->ConstructFromSkinL(skinId);
       
   777                     if (constructedFromTheme && newAnimation->BitmapAnimData()->FrameArray().Count() > 0) {
       
   778                         animation->setResourceBased(false);
       
   779                         animation->setAnimationObject(newAnimation); //animation takes ownership
       
   780                     }
       
   781                     CleanupStack::Pop(newAnimation);
       
   782                 }
       
   783                 //fill-in stored information
       
   784                 aknAnimation = animation->animationObject();
       
   785                 constructedFromTheme = !animation->isResourceBased();
       
   786             }
       
   787 
       
   788             const int currentFrame = QS60StylePrivate::currentAnimationFrame(part);
       
   789             if (constructedFromTheme && aknAnimation && aknAnimation->BitmapAnimData()->FrameArray().Count() > 0) {
       
   790                 //Animation was created succesfully and contains frames, just fetch current frame
       
   791                 if(currentFrame >= aknAnimation->BitmapAnimData()->FrameArray().Count())
       
   792                     User::Leave(KErrOverflow);
       
   793                 const CBitmapFrameData* frameData = aknAnimation->BitmapAnimData()->FrameArray().At(currentFrame);
       
   794                 if (frameData) {
       
   795                     animationFrame = frameData->Bitmap();
       
   796                     frameMask = frameData->Mask();
       
   797                 }
       
   798             } else {
       
   799                 //Theme does not contain animation theming, create frames from resource file
       
   800                 TInt fallbackGraphicID = -1;
       
   801                 fallbackInfo(part, fallbackGraphicID);
       
   802                 fallbackGraphicID = fallbackGraphicID + (currentFrame * 2); //skip masks
       
   803                 TInt fallbackGraphicsMaskID =
       
   804                     (fallbackGraphicID == KErrNotFound) ? KErrNotFound : fallbackGraphicID + 1; //masks are auto-generated as next in mif files
       
   805                 if (fallbackGraphicsMaskID != KErrNotFound)
       
   806                     fallbackGraphicsMaskID = fallbackGraphicsMaskID + (currentFrame * 2); //skip actual graphics
       
   807 
       
   808                 //Then draw animation frame
       
   809                 AknsUtils::CreateIconL(
       
   810                     skinInstance,
       
   811                     KAknsIIDDefault, //animation is not themed, lets force fallback graphics
       
   812                     animationFrame,
       
   813                     frameMask,
       
   814                     AknIconUtils::AvkonIconFileName(),
       
   815                     fallbackGraphicID ,
       
   816                     fallbackGraphicsMaskID);
       
   817             }
       
   818             result = fromFbsBitmap(animationFrame, frameMask, flags, targetSize);
       
   819             if (!constructedFromTheme) {
       
   820                 delete animationFrame;
       
   821                 animationFrame = 0;
       
   822                 delete frameMask;
       
   823                 frameMask = 0;
       
   824             }
       
   825             break;
       
   826         }
   712     }
   827     }
   713     if (!result)
   828     if (!result)
   714         result = QPixmap();
   829         result = QPixmap();
   715 
   830 
   716     return result;
   831     return result;
   729         rotatedBy90or270 ? TSize(size.height(), size.width()) : qt_QSize2TSize(size);
   844         rotatedBy90or270 ? TSize(size.height(), size.width()) : qt_QSize2TSize(size);
   730 
   845 
   731     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
   846     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
   732     QPixmap result;
   847     QPixmap result;
   733 
   848 
   734 //        QS60WindowSurface::unlockBitmapHeap();
       
   735     static const TDisplayMode displayMode = S60->supportsPremultipliedAlpha ? Q_SYMBIAN_ECOLOR16MAP : EColor16MA;
   849     static const TDisplayMode displayMode = S60->supportsPremultipliedAlpha ? Q_SYMBIAN_ECOLOR16MAP : EColor16MA;
   736     static const TInt drawParam = S60->supportsPremultipliedAlpha ? KAknsDrawParamDefault : KAknsDrawParamNoClearUnderImage|KAknsDrawParamRGBOnly;
   850     static const TInt drawParam = S60->supportsPremultipliedAlpha ? KAknsDrawParamDefault : KAknsDrawParamNoClearUnderImage|KAknsDrawParamRGBOnly;
   737 
   851 
   738     CFbsBitmap *frame = new (ELeave) CFbsBitmap(); //offscreen
   852     CFbsBitmap *frame = new (ELeave) CFbsBitmap(); //offscreen
   739     CleanupStack::PushL(frame);
   853     CleanupStack::PushL(frame);
   907         newSkinId.Set(m_partMap[(int)part].skinID);
  1021         newSkinId.Set(m_partMap[(int)part].skinID);
   908     return newSkinId;
  1022     return newSkinId;
   909 }
  1023 }
   910 
  1024 
   911 QFont QS60StylePrivate::s60Font_specific(
  1025 QFont QS60StylePrivate::s60Font_specific(
   912     QS60StyleEnums::FontCategories fontCategory, int pointSize)
  1026     QS60StyleEnums::FontCategories fontCategory,
   913 {
  1027     int pointSize, bool resolveFontSize)
       
  1028 {
       
  1029     Q_UNUSED(resolveFontSize);
       
  1030 
   914     TAknFontCategory aknFontCategory = EAknFontCategoryUndefined;
  1031     TAknFontCategory aknFontCategory = EAknFontCategoryUndefined;
   915     switch (fontCategory) {
  1032     switch (fontCategory) {
   916         case QS60StyleEnums::FC_Primary:
  1033         case QS60StyleEnums::FC_Primary:
   917             aknFontCategory = EAknFontCategoryPrimary;
  1034             aknFontCategory = EAknFontCategoryPrimary;
   918             break;
  1035             break;
   980     }
  1097     }
   981 
  1098 
   982     m_pmPointer = data[activeLayoutIndex];
  1099     m_pmPointer = data[activeLayoutIndex];
   983 }
  1100 }
   984 
  1101 
       
  1102 Q_GLOBAL_STATIC(QList<QS60StyleAnimation *>, m_animations)
       
  1103 
   985 QS60StylePrivate::QS60StylePrivate()
  1104 QS60StylePrivate::QS60StylePrivate()
   986 {
  1105 {
       
  1106     //Animation defaults need to be created when style is instantiated
       
  1107     QS60StyleAnimation* progressBarAnimation = new QS60StyleAnimation(QS60StyleEnums::SP_QgnGrafBarWaitAnim, 7, 100);
       
  1108     m_animations()->append(progressBarAnimation);
   987     // No need to set active layout, if dynamic metrics API is available
  1109     // No need to set active layout, if dynamic metrics API is available
   988     setActiveLayout();
  1110     setActiveLayout();
   989 }
  1111 }
   990 
  1112 
   991 QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list,
  1113 QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list,
  1131     return result;
  1253     return result;
  1132 }
  1254 }
  1133 
  1255 
  1134 QPixmap QS60StylePrivate::backgroundTexture()
  1256 QPixmap QS60StylePrivate::backgroundTexture()
  1135 {
  1257 {
       
  1258     bool createNewBackground = false;
  1136     if (!m_background) {
  1259     if (!m_background) {
       
  1260         createNewBackground = true;
       
  1261     } else {
       
  1262         //if background brush does not match screensize, re-create it
       
  1263         if (m_background->width() != S60->screenWidthInPixels ||
       
  1264             m_background->height() != S60->screenHeightInPixels) {
       
  1265             delete m_background;
       
  1266             createNewBackground = true;
       
  1267         }
       
  1268     }
       
  1269 
       
  1270     if (createNewBackground) {
  1137         QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen,
  1271         QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen,
  1138                 QSize(S60->screenWidthInPixels, S60->screenHeightInPixels), 0, SkinElementFlags());
  1272             QSize(S60->screenWidthInPixels, S60->screenHeightInPixels), 0, SkinElementFlags());
  1139         m_background = new QPixmap(background);
  1273         m_background = new QPixmap(background);
  1140     }
  1274     }
  1141     return *m_background;
  1275     return *m_background;
  1142 }
  1276 }
  1143 
  1277 
  1144 QSize QS60StylePrivate::screenSize()
  1278 QSize QS60StylePrivate::screenSize()
  1145 {
  1279 {
  1146     const TSize screenSize = QS60Data::screenDevice()->SizeInPixels();
  1280     return QSize(S60->screenWidthInPixels, S60->screenHeightInPixels);
  1147     return QSize(screenSize.iWidth, screenSize.iHeight);
       
  1148 }
  1281 }
  1149 
  1282 
  1150 QS60Style::QS60Style()
  1283 QS60Style::QS60Style()
  1151     : QCommonStyle(*new QS60StylePrivate)
  1284     : QCommonStyle(*new QS60StylePrivate)
  1152 {
  1285 {
  1171         QEvent e(QEvent::StyleChange);
  1304         QEvent e(QEvent::StyleChange);
  1172         QApplication::sendEvent(topLevelWidget, &e);
  1305         QApplication::sendEvent(topLevelWidget, &e);
  1173         setThemePalette(topLevelWidget);
  1306         setThemePalette(topLevelWidget);
  1174         topLevelWidget->ensurePolished();
  1307         topLevelWidget->ensurePolished();
  1175     }
  1308     }
       
  1309 #ifndef QT_NO_PROGRESSBAR
       
  1310     //re-start animation timer
       
  1311     stopAnimation(QS60StyleEnums::SP_QgnGrafBarWaitAnim); //todo: once we have more animations, we could say "stop all running ones"
       
  1312     startAnimation(QS60StyleEnums::SP_QgnGrafBarWaitAnim); //and "re-start all previously running ones"
       
  1313 #endif
  1176 }
  1314 }
  1177 
  1315 
  1178 QSize QS60StylePrivate::naviPaneSize()
  1316 QSize QS60StylePrivate::naviPaneSize()
  1179 {
  1317 {
  1180     return QS60StyleModeSpecifics::naviPaneSize();
  1318     return QS60StyleModeSpecifics::naviPaneSize();
  1190             return QSize(naviContainer->Size().iWidth, naviContainer->Size().iHeight);
  1328             return QSize(naviContainer->Size().iWidth, naviContainer->Size().iHeight);
  1191     }
  1329     }
  1192     return QSize(0,0);
  1330     return QSize(0,0);
  1193 }
  1331 }
  1194 
  1332 
       
  1333 int QS60StylePrivate::currentAnimationFrame(QS60StyleEnums::SkinParts part)
       
  1334 {
       
  1335     QS60StyleAnimation *animation = animationDefinition(part);
       
  1336     // todo: looping could be done in QS60Style::timerEvent
       
  1337     if (animation->frameCount() == animation->currentFrame())
       
  1338         animation->setCurrentFrame(0);
       
  1339     return animation->currentFrame();
       
  1340 }
       
  1341 
       
  1342 QS60StyleAnimation* QS60StylePrivate::animationDefinition(QS60StyleEnums::SkinParts part)
       
  1343 {
       
  1344     int i = 0;
       
  1345     const int animationsCount = m_animations()->isEmpty() ? 0 : m_animations()->count();
       
  1346     for(; i < animationsCount; i++) {
       
  1347         if (part == m_animations()->at(i)->animationId())
       
  1348             break;
       
  1349     }
       
  1350     return m_animations()->at(i);
       
  1351 }
       
  1352 
       
  1353 void QS60StylePrivate::startAnimation(QS60StyleEnums::SkinParts animationPart)
       
  1354 {
       
  1355     Q_Q(QS60Style);
       
  1356 
       
  1357     //Query animation data from theme and store values to local struct.
       
  1358     QVariant themeAnimationDataVariant = QS60StyleModeSpecifics::themeDefinition(
       
  1359         QS60StyleEnums::TD_AnimationData, animationPart);
       
  1360     QList<QVariant> themeAnimationData = themeAnimationDataVariant.toList();
       
  1361 
       
  1362     QS60StyleAnimation *animation = QS60StylePrivate::animationDefinition(animationPart);
       
  1363     if (animation) {
       
  1364         if (themeAnimationData.at(QS60StyleEnums::AD_Interval).toInt() != 0)
       
  1365             animation->setInterval(themeAnimationData.at(QS60StyleEnums::AD_Interval).toInt());
       
  1366 
       
  1367         if (themeAnimationData.at(QS60StyleEnums::AD_NumberOfFrames).toInt() != 0)
       
  1368             animation->setFrameCount(themeAnimationData.at(QS60StyleEnums::AD_NumberOfFrames).toInt());
       
  1369 
       
  1370         //todo: playmode is ignored for now, since it seems to return invalid data on some themes
       
  1371         //lets use the table values for play mode
       
  1372 
       
  1373         animation->setCurrentFrame(0); //always initialize
       
  1374         const int timerId = q->startTimer(animation->interval());
       
  1375         animation->setTimerId(timerId);
       
  1376     }
       
  1377 }
       
  1378 
       
  1379 void QS60StylePrivate::stopAnimation(QS60StyleEnums::SkinParts animationPart)
       
  1380 {
       
  1381     Q_Q(QS60Style);
       
  1382 
       
  1383     QS60StyleAnimation *animation = QS60StylePrivate::animationDefinition(animationPart);
       
  1384     if (animation) {
       
  1385         animation->setCurrentFrame(0);
       
  1386         if (animation->timerId() != 0) {
       
  1387             q->killTimer(animation->timerId());
       
  1388             animation->setTimerId(0);
       
  1389         }
       
  1390         animation->resetToDefaults();
       
  1391     }
       
  1392 }
       
  1393 
       
  1394 QVariant QS60StyleModeSpecifics::themeDefinition(
       
  1395     QS60StyleEnums::ThemeDefinitions definition, QS60StyleEnums::SkinParts part)
       
  1396 {
       
  1397     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
  1398 
       
  1399     Q_ASSERT(skinInstance);
       
  1400 
       
  1401     switch(definition) {
       
  1402     //Animation definitions
       
  1403     case QS60StyleEnums::TD_AnimationData:
       
  1404         {
       
  1405             CAknsBmpAnimItemData *animationData;
       
  1406             TAknsItemID animationSkinId = partSpecificThemeId(part);
       
  1407             QList<QVariant> list;
       
  1408 
       
  1409             TRAPD( error, QT_TRYCATCH_LEAVING(
       
  1410                     animationData = static_cast<CAknsBmpAnimItemData*>(skinInstance->CreateUncachedItemDataL(
       
  1411                             animationSkinId, EAknsITBmpAnim))));
       
  1412             if (error)
       
  1413                 return list;
       
  1414 
       
  1415             if (animationData) {
       
  1416                 list.append((int)animationData->FrameInterval());
       
  1417                 list.append((int)animationData->NumberOfImages());
       
  1418 
       
  1419                 QS60StyleEnums::AnimationMode playMode;
       
  1420                 switch(animationData->PlayMode()) {
       
  1421                     case CBitmapAnimClientData::EPlay:
       
  1422                         playMode = QS60StyleEnums::AM_PlayOnce;
       
  1423                         break;
       
  1424                     case CBitmapAnimClientData::ECycle:
       
  1425                         playMode = QS60StyleEnums::AM_Looping;
       
  1426                         break;
       
  1427                     case CBitmapAnimClientData::EBounce:
       
  1428                         playMode = QS60StyleEnums::AM_Bounce;
       
  1429                         break;
       
  1430                     default:
       
  1431                         break;
       
  1432                 }
       
  1433                 list.append(QVariant((int)playMode));
       
  1434                 delete animationData;
       
  1435             } else {
       
  1436                 list.append(0);
       
  1437                 list.append(0);
       
  1438             }
       
  1439             return list;
       
  1440         }
       
  1441         break;
       
  1442     default:
       
  1443         break;
       
  1444     }
       
  1445     return QVariant();
       
  1446 }
       
  1447 
  1195 #endif // Q_WS_S60
  1448 #endif // Q_WS_S60
  1196 
  1449 
  1197 QT_END_NAMESPACE
  1450 QT_END_NAMESPACE
  1198 
  1451 
  1199 #endif // QT_NO_STYLE_S60 || QT_PLUGIN
  1452 #endif // QT_NO_STYLE_S60 || QT_PLUGIN