Qt: fix issue with hog count being not visible on low resolutions/long team names and hard to read on very high resolutions
authorsheepluva
Mon, 30 Apr 2012 23:14:40 +0200
changeset 6968 23722ba0f89a
parent 6967 1224c6fb36c3
child 6969 3273a2b983ca
Qt: fix issue with hog count being not visible on low resolutions/long team names and hard to read on very high resolutions
QTfrontend/ui/widget/hedgehogerWidget.cpp
QTfrontend/ui/widget/hedgehogerWidget.h
--- a/QTfrontend/ui/widget/hedgehogerWidget.cpp	Mon Apr 30 23:35:40 2012 +0400
+++ b/QTfrontend/ui/widget/hedgehogerWidget.cpp	Mon Apr 30 23:14:40 2012 +0200
@@ -19,6 +19,8 @@
 
 #include "hedgehogerWidget.h"
 
+#include <QPainter>
+
 #include "frameTeam.h"
 
 CHedgehogerWidget::CHedgehogerWidget(const QImage& im, const QImage& img, QWidget * parent) :
@@ -32,6 +34,8 @@
       numItems = pOurFrameTeams->maxHedgehogsPerGame - pOurFrameTeams->overallHedgehogs;
     } else numItems = 4;
     pOurFrameTeams->overallHedgehogs += numItems;*/
+
+    this->setMinimumWidth(20);
 }
 
 void CHedgehogerWidget::incItems()
@@ -74,3 +78,17 @@
 {
     return numItems;
 }
+
+void CHedgehogerWidget::paintEvent(QPaintEvent* event)
+{
+    Q_UNUSED(event);
+
+    if (this->width() >= 11 * numItems + 28)
+        ItemNum::paintEvent(event);
+
+    QPainter painter(this);
+    const QFont font("MS Shell Dlg", 12);
+    painter.setFont(font);
+    painter.drawText(this->width() - 14, 24, QString::number(numItems));
+
+}
--- a/QTfrontend/ui/widget/hedgehogerWidget.h	Mon Apr 30 23:35:40 2012 +0400
+++ b/QTfrontend/ui/widget/hedgehogerWidget.h	Mon Apr 30 23:14:40 2012 +0200
@@ -42,6 +42,8 @@
         virtual void incItems();
         virtual void decItems();
 
+        virtual void paintEvent(QPaintEvent* event);
+
     private:
         CHedgehogerWidget();
         FrameTeams* pOurFrameTeams;