Logo Search packages:      
Sourcecode: ultracopier version File versions  Download package

QIcon Main_window::dynaIcon ( int  percent = -1,
QString  text = "" 
) [private]

Create progessive icon.

Do QIcon with top and bottom image mixed and percent writed on it. The icon it be search in the style path. Do by mongaulois, remake by alpha_one_x86.

Parameters:
percentindique how many percent need be showed, sould be between 0 and 100
textThe showed text if needed (optionnal)
Returns:
QIcon of the final image
Note:
Can be used as it: dynaIcon(75,"...")

Definition at line 644 of file Mwindow.cpp.

References getOldProgression, pixmapBottom, and pixmapTop.

Referenced by updateTheCopyStat().

{
      #if (DEBUG_ULTRACOPIER>0)
      if(pixmapTop->isNull() || pixmapBottom->isNull())
            DEBUGCONSOLE(10,"Main_window::dynaIcon","Error loading the icons");
      #endif
      if(percent==-1)
            percent=getOldProgression;
      if(percent<0)
            percent=0;
      if(percent>100)
            percent=100;
      //pixmap avec un fond transparent
      #ifdef Q_OS_WIN32
      QPixmap resultImage(16,16);
      #else
      QPixmap resultImage(22,22);
      #endif
      resultImage.fill(Qt::transparent);
      {
            QPainter painter(&resultImage);
            
            //preprocessing the calcul
            float percent_1 = (100.-percent)/100.;
            float percent_2 =  percent/100.;
            
            //top image
            QRect target(0, 0, resultImage.width(), (int)(percent_1*resultImage.height()));
            QRect source(0, 0, pixmapTop->width(), (int)(percent_1*pixmapTop->height()));
            painter.drawPixmap(target, *pixmapTop, source);
            
            //bottom image
            QRect target2(0, (int)(percent_1*resultImage.height()), resultImage.width(), (int)(percent_2*resultImage.height()));
            QRect source2(0, (int)(percent_1*pixmapBottom->height()), pixmapBottom->width(), (int)(percent_2*pixmapBottom->height()));
            painter.drawPixmap(target2, *pixmapBottom, source2);
            
            if(text.isEmpty())
            {
                  if(percent!=100)
                        text=QString::number(percent);
                  else
                        text=" :)";
            }
            
            painter.setPen(QPen(Qt::black));
            #ifdef Q_OS_WIN32
            painter.drawText(2,14,text);
            #else
            painter.drawText(5,16,text);
            #endif
            painter.setPen(QPen(Qt::white));
            #ifdef Q_OS_WIN32
            painter.drawText(1,13,text);
            #else
            painter.drawText(4,15,text);
            #endif
      }
      return QIcon(resultImage);
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index