m_net(new QNetworkConfigurationManager(this)),
m_skills(new SkillTree(this)),
m_model(new EveModel),
- m_timer(new QTimer(this))
+ m_timer(new QTimer(this)),
+ m_updateTimer(new QTimer(this))
{
setAlignment(Qt::AlignCenter);
setAttribute(Qt::WA_TranslucentBackground);
}
m_timer->setSingleShot(true);
connect(m_timer,SIGNAL(timeout()),this,SLOT(loadTraining()));
+ m_updateTimer->setSingleShot(true);
+ connect(m_updateTimer,SIGNAL(timeout()),this,SLOT(update()));
}
Widget::~Widget()
{
QPainter p(this);
QColor bgColor(0, 0, 0, 128);
- if (m_training) {
- // Queue empty -> red background
- if (!m_training->training) {
- bgColor.setRed(128);
- bgColor.setAlpha(160);
- } else if (m_training->currentTime.secsTo(m_training->lastTraining().endTime) < 60*60*24) {
- // Queue not full -> yellow background
- bgColor.setGreen(109);
- bgColor.setRed(163);
- }
- }
p.setBrush(bgColor);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect(), 25, 25);
- p.setPen(Qt::white);
+
QFont dFont(p.font());
dFont.setPixelSize(15);
p.setFont(dFont);
p.drawPixmap(iconLoc,*(character->characterIcon));
}
QRect nameLoc(0,10,150,20);
+ p.setPen(Qt::white);
p.drawText(nameLoc,Qt::AlignCenter,character->name);
if (m_training && m_training->training) {
- QRect skillTitle(0,110,150,50);
+ int timeLeft = m_training->currentTime.secsTo(m_training->lastTraining().endTime);
+ qDebug() << "Time left:" << timeLeft;
+ if (timeLeft < 60*60*24) {
+ // Queue not full -> yellow text
+
+ QColor penColor(254,241,53);
+ p.setPen(penColor);
+ }
+
+ QRect skillTitle(0,100,150,50);
p.drawText(skillTitle,Qt::AlignCenter|Qt::TextWordWrap,
QString("%1 %2").arg(m_skills->skillName(m_training->firstTraining().typeId))
.arg(m_training->firstTraining().level));
- QRect skillLoc(0,155,150,20);
+ QRect skillLoc(0,145,150,20);
p.drawText(skillLoc,Qt::AlignCenter,m_training->firstTraining().endTime.toString(Qt::SystemLocaleShortDate));
} else {
if (m_training != NULL && m_training->training) {
QDateTime limit = (m_training->cachedUntil > m_training->lastTraining().endTime) ?
m_training->cachedUntil : m_training->lastTraining().endTime;
+
qDebug() << "Next refresh:" << limit.toString(Qt::SystemLocaleShortDate);
int interval = 1000 * (m_training->currentTime.secsTo(limit) + 15);
//qDebug() << "Timer interval" << interval;
if (m_timer->isActive()) {
m_timer->stop();
}
+
m_timer->setInterval( interval );
m_timer->start();
+ if (m_updateTimer->isActive())
+ m_updateTimer->stop();
+
+ QDateTime nextUpdate = m_training->lastTraining().endTime;
+
+ nextUpdate.addSecs(-1*60*60*24);
+ if (nextUpdate > m_training->currentTime) {
+ m_updateTimer->setInterval(1000 * (m_training->currentTime.secsTo(nextUpdate) + 15));
+ m_updateTimer->start();
+ }
}
update();
}