Yellow text color if training queue has room for more skills, adjust text location
[evehomescreen] / src / widget.cpp
index 634c0d1..399f0fe 100644 (file)
@@ -55,21 +55,10 @@ void Widget::paintEvent(QPaintEvent *event)
 {
     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);
@@ -80,13 +69,23 @@ void Widget::paintEvent(QPaintEvent *event)
             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 {
 
@@ -158,6 +157,7 @@ void Widget::trainingLoaded()
     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;