m_pPainter
= new QPainter(m_pQiblaImage
);
m_pPainter
->setCompositionMode
(QPainter::CompositionMode_SourceOver);
m_pPainter->translate(144.5,144.5);
m_pPainter->save();
//Compass background
fileName.append("compass.png");
m_pPainter->rotate(360 - angleToNorth);
m_pPainter->drawImage(-144.5,-144.5,source);
// m_pPainter->restore();
//m_pPainter->save();
fileName.clear();
fileName.append(IMAGES_PATH);
fileName.append("Qibla-needle.png");
source.load(fileName);
m_pPainter->rotate(NormalizeTo360(m_qibla-90/*+ (360-angleToNorth)*/));
m_pPainter->drawImage(-114.5,-20.5,source);
// m_pPainter->restore();
//m_pPainter->save();
if(QTime::currentTime() < m_prayerTimes
[4] && QTime::currentTime() > m_prayerTimes
[1] && m_gpsMode
!= 2/*ON*/) {
//qDebug()<<"current time is "<< QTime::currentTime();
//qDebug()<<"prayer Time = "<<m_prayerTimes[5];
fileName.clear();
fileName.append(IMAGES_PATH);
fileName.append("sun-needle.png");
source.load(fileName);
m_pPainter->rotate(360 - NormalizeTo360(getSunQiblaDir(m_CityInfo.longitude, m_CityInfo.latitude) * DPR)/*+(360 - angleToNorth)*/);
m_pPainter->drawImage(-114.5,-20.5,source);
m_pPainter->restore();
m_pPainter->save();
}
else
{
m_pPainter->restore();
m_pPainter->save();
}
fileName.clear();
fileName.append(IMAGES_PATH);
fileName.append("Compass-needle.png");
source.load(fileName);
m_pPainter->rotate(360 - angleToNorth);
m_pPainter->drawImage(-17.5,-106.5,source);
m_pPainter->restore();
m_pPainter->save();
fileName.clear();
fileName.append(IMAGES_PATH);
fileName.append("compass-center.png");
source.load(fileName);
m_pPainter->drawImage(-10.5,-10.5,source);
m_pPainter->restore();
m_pPainter->save();
fileName.clear();
fileName.append(IMAGES_PATH);
fileName.append("compass-glass.png");
source.load(fileName);
m_pPainter->drawImage(-144.5, -144.5,source);
m_pPainter->end();
ui
->compass
->setPixmap
(QPixmap::fromImage(*m_pQiblaImage
));
delete m_pQiblaImage;
m_pQiblaImage=NULL;
delete m_pPainter;
m_pPainter =NULL;
update(47, 33, 289, 289);
m_pQiblaImage = new QImage(QSize(289,289),QImage::Format_ARGB32_Premultiplied);
m_pPainter = new QPainter(m_pQiblaImage);
m_pPainter->setCompositionMode(QPainter::CompositionMode_SourceOver);
m_pPainter->translate(144.5,144.5);
m_pPainter->save();
//Compass background
QString fileName(IMAGES_PATH);
fileName.append("compass.png");
QImage source(fileName);
m_pPainter->rotate(360 - angleToNorth);
m_pPainter->drawImage(-144.5,-144.5,source);
// m_pPainter->restore();
//m_pPainter->save();
fileName.clear();
fileName.append(IMAGES_PATH);
fileName.append("Qibla-needle.png");
source.load(fileName);
m_pPainter->rotate(NormalizeTo360(m_qibla-90/*+ (360-angleToNorth)*/));
m_pPainter->drawImage(-114.5,-20.5,source);
// m_pPainter->restore();
//m_pPainter->save();
if(QTime::currentTime() < m_prayerTimes[4] && QTime::currentTime() > m_prayerTimes[1] && m_gpsMode != 2/*ON*/)
{
//qDebug()<<"current time is "<< QTime::currentTime();
//qDebug()<<"prayer Time = "<<m_prayerTimes[5];
fileName.clear();
fileName.append(IMAGES_PATH);
fileName.append("sun-needle.png");
source.load(fileName);
m_pPainter->rotate(360 - NormalizeTo360(getSunQiblaDir(m_CityInfo.longitude, m_CityInfo.latitude) * DPR)/*+(360 - angleToNorth)*/);
m_pPainter->drawImage(-114.5,-20.5,source);
m_pPainter->restore();
m_pPainter->save();
}
else
{
m_pPainter->restore();
m_pPainter->save();
}
fileName.clear();
fileName.append(IMAGES_PATH);
fileName.append("Compass-needle.png");
source.load(fileName);
m_pPainter->rotate(360 - angleToNorth);
m_pPainter->drawImage(-17.5,-106.5,source);
m_pPainter->restore();
m_pPainter->save();
fileName.clear();
fileName.append(IMAGES_PATH);
fileName.append("compass-center.png");
source.load(fileName);
m_pPainter->drawImage(-10.5,-10.5,source);
m_pPainter->restore();
m_pPainter->save();
fileName.clear();
fileName.append(IMAGES_PATH);
fileName.append("compass-glass.png");
source.load(fileName);
m_pPainter->drawImage(-144.5, -144.5,source);
m_pPainter->end();
ui->compass->setPixmap(QPixmap::fromImage(*m_pQiblaImage));
delete m_pQiblaImage;
m_pQiblaImage=NULL;
delete m_pPainter;
m_pPainter =NULL;
update(47, 33, 289, 289);
To copy to clipboard, switch view to plain text mode
Bookmarks