src/hbcore/image/hbiconsource.cpp
changeset 5 627c4a0fd0e7
parent 3 11d3954df52a
child 6 c3690ec91ef8
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    50 // to avoid IconLoader dependency in ThemeIndexer, which needs this source file.
    50 // to avoid IconLoader dependency in ThemeIndexer, which needs this source file.
    51 QString iconTypeFromFilename(const QString &iconPath)
    51 QString iconTypeFromFilename(const QString &iconPath)
    52 {
    52 {
    53     QString loweredIconPath = iconPath.toLower();
    53     QString loweredIconPath = iconPath.toLower();
    54 
    54 
    55     if (loweredIconPath.endsWith(".svgz") ) {
    55     if (loweredIconPath.endsWith(QLatin1String(".svgz"))) {
    56         return "SVG";
    56         return QLatin1String("SVG");
    57     }
    57     }
    58     if (loweredIconPath.endsWith(".qpic") ) {
    58     if (loweredIconPath.endsWith(QLatin1String(".qpic"))) {
    59         return "PIC";
    59         return QLatin1String("PIC");
    60     }
    60     }
    61 
    61 
    62     if (loweredIconPath.endsWith(".svg")
    62     if (loweredIconPath.endsWith(QLatin1String(".svg"))
    63         || loweredIconPath.endsWith(".png")
    63         || loweredIconPath.endsWith(QLatin1String(".png"))
    64         || loweredIconPath.endsWith(".mng")
    64         || loweredIconPath.endsWith(QLatin1String(".mng"))
    65         || loweredIconPath.endsWith(".gif")
    65         || loweredIconPath.endsWith(QLatin1String(".gif"))
    66         || loweredIconPath.endsWith(".xpm")
    66         || loweredIconPath.endsWith(QLatin1String(".xpm"))
    67         || loweredIconPath.endsWith(".jpg")
    67         || loweredIconPath.endsWith(QLatin1String(".jpg"))
    68         || loweredIconPath.endsWith(".nvg")) {
    68         || loweredIconPath.endsWith(QLatin1String(".nvg"))) {
    69         return iconPath.right(3).toUpper();
    69         return iconPath.right(3).toUpper();
    70     }
    70     }
    71 
    71 
    72     if (loweredIconPath.endsWith(".xml")
    72     if (loweredIconPath.endsWith(QLatin1String(".xml"))
    73         || loweredIconPath.endsWith(".axml")
    73         || loweredIconPath.endsWith(QLatin1String(".axml"))
    74         || loweredIconPath.endsWith(".fxml"))
    74         || loweredIconPath.endsWith(QLatin1String(".fxml")))
    75     {
    75     {
    76         return "BLOB";
    76         return "BLOB";
    77     }
    77     }
    78 
    78 
    79     return iconPath.section('.', -1);
    79     return iconPath.section('.', -1);
    91         ret = QSize(0, 0);
    91         ret = QSize(0, 0);
    92         } 
    92         } 
    93      
    93      
    94     const quint8* lBuf = (quint8*) buffer.data();
    94     const quint8* lBuf = (quint8*) buffer.data();
    95     if((buffer.length() > NVG_VIEWBOX_WIDTH_OFS) && (buffer.length() > NVG_VIEWBOX_HEIGHT_OFS)) {	
    95     if((buffer.length() > NVG_VIEWBOX_WIDTH_OFS) && (buffer.length() > NVG_VIEWBOX_HEIGHT_OFS)) {	
       
    96         // Do not change to qreal, no matter what krazy says.
    96 	    float lViewboxWidth = * (float*)(lBuf + NVG_VIEWBOX_WIDTH_OFS);
    97 	    float lViewboxWidth = * (float*)(lBuf + NVG_VIEWBOX_WIDTH_OFS);
    97 	    float lViewboxHeight = * (float*)(lBuf + NVG_VIEWBOX_HEIGHT_OFS);
    98 	    float lViewboxHeight = * (float*)(lBuf + NVG_VIEWBOX_HEIGHT_OFS);
    98 
    99 
    99 	    if (lViewboxWidth > 0 && lViewboxHeight > 0) {
   100 	    if (lViewboxWidth > 0 && lViewboxHeight > 0) {
   100 	        ret = QSize((int)lViewboxWidth, (int)lViewboxHeight);
   101 	        ret = QSize((int)lViewboxWidth, (int)lViewboxHeight);