File indexing completed on 2024-04-21 03:40:43

0001 /*
0002     SPDX-FileCopyrightText: 2005-2006 Albert Astals Cid <aacid@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "counter.h"
0008 
0009 #include <QColor>
0010 #include <QPainter>
0011 
0012 #include "number.h"
0013 
0014 void counter::paint(QPainter &p, bool drawScore, int score, bool drawTimer, const QColor &c1, const QColor &c2, const QColor &c3, QSvgRenderer *renderer)
0015 {
0016     p.save();
0017     p.translate(45, 15);
0018     p.setPen(QPen(Qt::black, 3));
0019     p.setBrush(QColor(40, 40, 40));
0020     if (drawTimer)
0021     {
0022         p.fillRect(-44, -13, 98, 48, p.brush());
0023         p.drawRoundedRect(-45, -15, 100, 50, 15, 15, Qt::RelativeSize);
0024     }
0025     else
0026     {
0027         p.fillRect(-44, -13, 70, 48, p.brush());
0028         p.drawRoundedRect(-45, -15, 73, 50, 15, 15, Qt::RelativeSize);
0029     }
0030     
0031     if (drawTimer)
0032     {
0033         p.fillRect(35, -6, 11, 9, c1);
0034         p.fillRect(35, 6, 11, 9, c2);
0035         p.fillRect(35, 18, 11, 9, c3);
0036     }
0037     
0038     if (drawScore)
0039     {
0040         p.translate(-5, -5);
0041         number n(score);
0042         n.paint(p, 2, renderer);
0043     }
0044     
0045     p.restore();
0046 }
0047 
0048 int counter::width(bool drawTimer)
0049 {
0050     if (drawTimer) return 100;
0051     else return 73;
0052 }
0053 
0054 int counter::height()
0055 {
0056     return 50;
0057 }