src/hbcore/image/hbframedrawer.cpp
changeset 6 c3690ec91ef8
parent 5 627c4a0fd0e7
child 28 b7da29130b0e
child 34 ed14f46c0e55
equal deleted inserted replaced
5:627c4a0fd0e7 6:c3690ec91ef8
    28 #include "hbmaskableiconimpl_p.h"
    28 #include "hbmaskableiconimpl_p.h"
    29 
    29 
    30 #include <hbinstance.h>
    30 #include <hbinstance.h>
    31 #include <hbiconimpl_p.h>
    31 #include <hbiconimpl_p.h>
    32 #include <hbiconloader_p.h>
    32 #include <hbiconloader_p.h>
    33 
    33 #include <hbthemeutils_p.h>
    34 
    34 
    35 #include <QPainter>
    35 #include <QPainter>
    36 #include <QIcon>
    36 #include <QIcon>
    37 #include <QPixmap>
    37 #include <QPixmap>
    38 #include <QDebug>
    38 #include <QDebug>
   199     borderWidths[0] = 0.0;
   199     borderWidths[0] = 0.0;
   200     borderWidths[1] = 0.0;
   200     borderWidths[1] = 0.0;
   201     borderWidths[2] = 0.0;
   201     borderWidths[2] = 0.0;
   202     borderWidths[3] = 0.0;
   202     borderWidths[3] = 0.0;
   203 
   203 
   204     // Remove possible file extension
   204     if (HbThemeUtils::isLogicalName(frameGraphicsName)) {
   205     int index = this->frameGraphicsName.lastIndexOf(QChar('.'));
   205         // Remove possible file extension
   206     if (index > 0) {
   206         int index = this->frameGraphicsName.lastIndexOf(QChar('.'));
   207         this->frameGraphicsName.resize(index);
   207         if (index>0) {
   208     }
   208             this->frameGraphicsName.resize(index);
       
   209         }
       
   210     }
       
   211 
   209     //Register the HbFrameDrawerPrivate Instance to HbIconLoader
   212     //Register the HbFrameDrawerPrivate Instance to HbIconLoader
   210     HbIconLoader::global()->storeFrameDrawerInfo(this);
   213     HbIconLoader::global()->storeFrameDrawerInfo(this);
   211 }
   214 }
   212 
   215 
   213 /*!
   216 /*!
   380         if (iconImpl) {
   383         if (iconImpl) {
   381             icon = new HbMaskableIconImpl(iconImpl);
   384             icon = new HbMaskableIconImpl(iconImpl);
   382         }
   385         }
   383 
   386 
   384     } else {
   387     } else {
   385         QStringList multiPieceFileNames;
   388         QStringList multiPieceFileNames = resolveMultiPieceFileNames();
   386         QStringList list = fileNameSuffixList();
   389         
   387         int nameListCount = list.count();
   390         for (int i = 0; i < frameParts; i++) {
   388         for (int i = 0; i < nameListCount; i++) {
       
   389             multiPieceFileNames.append(frameGraphicsName + list[i]);
       
   390             if (data.pixmapSizes[i].isEmpty()) {
   391             if (data.pixmapSizes[i].isEmpty()) {
   391                 data.pixmapSizes[i] = QSize(0, 0);
   392                 data.pixmapSizes[i] = QSize(0, 0);
   392             }
   393             }
   393         }
   394         }
   394 
   395 
   410                 fallbackMaskableIconList.append(new HbMaskableIconImpl(listOfIcons[i]));
   411                 fallbackMaskableIconList.append(new HbMaskableIconImpl(listOfIcons[i]));
   411             }
   412             }
   412         }
   413         }
   413 
   414 
   414     }
   415     }
       
   416 }
       
   417 
       
   418 QStringList HbFrameDrawerPrivate::resolveMultiPieceFileNames()
       
   419 {
       
   420     QStringList multiPieceFileNames;
       
   421 
       
   422     bool logicalName = HbThemeUtils::isLogicalName(frameGraphicsName);
       
   423 
       
   424     int suffixIndex = frameGraphicsName.length();
       
   425     if (!logicalName) {
       
   426         // If it is an absolute icon path, the suffix is inserted before the file extension
       
   427         int index = frameGraphicsName.lastIndexOf(QChar('.'));
       
   428         if (index > 0) {
       
   429             suffixIndex = index;
       
   430         }
       
   431     }
       
   432 
       
   433     QStringList list = fileNameSuffixList();
       
   434     int count = list.count();
       
   435     for (int i = 0; i < count; i++) {
       
   436         QString nameWithSuffix = frameGraphicsName;
       
   437         nameWithSuffix.insert(suffixIndex, list.at(i));
       
   438         multiPieceFileNames.append(nameWithSuffix);
       
   439     }
       
   440 
       
   441     return multiPieceFileNames;
   415 }
   442 }
   416 
   443 
   417 /*!
   444 /*!
   418 \internal
   445 \internal
   419 */
   446 */
   473                                                        QRect(position, multiPartSizeData.pixmapSizes[i]),
   500                                                        QRect(position, multiPartSizeData.pixmapSizes[i]),
   474                                                        Qt::AlignHCenter, clipPath);
   501                                                        Qt::AlignHCenter, clipPath);
   475                 }
   502                 }
   476             }
   503             }
   477         }
   504         }
   478         if (fallbackMaskableIconList[0]->iconImpl()
   505         if ( fallbackMaskableIconList.count() && fallbackMaskableIconList[0]->iconImpl()
   479                 && fallbackMaskableIconList[0]->iconImpl()->isCreatedOnServer()) {
   506              && fallbackMaskableIconList[0]->iconImpl()->isCreatedOnServer() ) {
   480             if (fallbackMaskableIconList[0]->iconImpl()->iconData().type != INVALID_FORMAT) {
   507             if ( fallbackMaskableIconList[0]->iconImpl()->iconData().type != INVALID_FORMAT ) {
   481                 // store the icon type
   508                 // store the icon type
   482                 iconType = fallbackMaskableIconList[0]->iconImpl()->iconData().type;
   509                 iconType = fallbackMaskableIconList[0]->iconImpl()->iconData().type;
   483             }
   510             }
   484         }
   511         }
   485     }
   512     }
   858 \internal
   885 \internal
   859 */
   886 */
   860 QSizeF HbFrameDrawerPrivate::defaultSize(const QString &framePartSuffix)
   887 QSizeF HbFrameDrawerPrivate::defaultSize(const QString &framePartSuffix)
   861 {
   888 {
   862     HbIconLoader *loader = HbIconLoader::global();
   889     HbIconLoader *loader = HbIconLoader::global();
   863     return loader->defaultSize(frameGraphicsName + framePartSuffix).toSize();
   890     
       
   891     QString nameWithSuffix = frameGraphicsName;
       
   892     if (HbThemeUtils::isLogicalName(frameGraphicsName)) {
       
   893         // Logical icon name, append suffix in the end
       
   894         nameWithSuffix.append(framePartSuffix);
       
   895     } else {
       
   896         // Absolute icon path, insert suffix before file extension
       
   897         int index = this->frameGraphicsName.lastIndexOf(QChar('.'));
       
   898         if (index > 0) {
       
   899             nameWithSuffix.insert(index, framePartSuffix);
       
   900         }
       
   901     }
       
   902 
       
   903     return loader->defaultSize(nameWithSuffix).toSize();
   864 }
   904 }
   865 
   905 
   866 bool HbFrameDrawerPrivate::isMirrored()
   906 bool HbFrameDrawerPrivate::isMirrored()
   867 {
   907 {
   868     // If mirroring mode is default, check automatic mirroring from loader.
   908     // If mirroring mode is default, check automatic mirroring from loader.
  1145 }
  1185 }
  1146 
  1186 
  1147 /*!
  1187 /*!
  1148 * Sets the frame graphics name. See the class description for the file name convention for different frame parts.
  1188 * Sets the frame graphics name. See the class description for the file name convention for different frame parts.
  1149 * \sa HbFrameDrawer::frameGraphicsName()
  1189 * \sa HbFrameDrawer::frameGraphicsName()
       
  1190 * \note Logical frame names that define a themable frame should not include filename extension, whereas absolute filenames
       
  1191 * must include full path and filename extension.
  1150 */
  1192 */
  1151 void HbFrameDrawer::setFrameGraphicsName(const QString &frameGraphicsName)
  1193 void HbFrameDrawer::setFrameGraphicsName(const QString &frameGraphicsName)
  1152 {
  1194 {
  1153     // Remove possible file extension
       
  1154     QString nameWithoutExt = frameGraphicsName;
  1195     QString nameWithoutExt = frameGraphicsName;
  1155     int index = nameWithoutExt.lastIndexOf(QChar('.'));
  1196 
  1156     if (index > 0) {
  1197     if (HbThemeUtils::isLogicalName(frameGraphicsName)) {
  1157         nameWithoutExt.resize(index);
  1198         // Remove possible file extension
       
  1199         int index = nameWithoutExt.lastIndexOf(QChar('.'));
       
  1200         if (index>0) {
       
  1201             nameWithoutExt.resize(index);
       
  1202         }
  1158     }
  1203     }
  1159 
  1204 
  1160     if (d->frameGraphicsName != nameWithoutExt) {
  1205     if (d->frameGraphicsName != nameWithoutExt) {
  1161         d->frameGraphicsName = nameWithoutExt;
  1206         d->frameGraphicsName = nameWithoutExt;
  1162         // Frame graphics changed, clear frame icon
  1207         // Frame graphics changed, clear frame icon