1 /* This file is part of KsirK.
2    Copyright (C) 2001-2008 Gael de Chalendar <kleag@free.fr>
3 
4    KsirK is free software; you can redistribute it and/or
5    modify it under the terms of the GNU General Public
6    License as published by the Free Software Foundation, either version 2
7    of the License, or (at your option) any later version.
8 
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17    02110-1301, USA
18 */
19 
20 /*  begin                : Sat May 17 2008  */
21 
22 #include "arrowsprite.h"
23 
24 #include "ksirk_debug.h"
25 
26 #include <QBrush>
27 
28 namespace Ksirk
29 {
30 
31 namespace Sprites
32 {
33 
ArrowSprite(Qt::ArrowType type,QGraphicsItem * parent)34 ArrowSprite::ArrowSprite(Qt::ArrowType type, QGraphicsItem * parent) :
35     QGraphicsPolygonItem(parent)
36 {
37   QPolygonF polygon;
38   switch (type)
39   {
40   case Qt::UpArrow:
41     polygon << QPointF(0,0) << QPointF(80,0) << QPointF(40,-20) << QPointF(0,0);
42   break;
43   case Qt::DownArrow:
44     polygon << QPointF(0,0) << QPointF(80,0) << QPointF(40,20) << QPointF(0,0);
45   break;
46   case Qt::LeftArrow:
47     polygon << QPointF(0,0) << QPointF(0,80) << QPointF(-20,40) << QPointF(0,0);
48   break;
49   case Qt::RightArrow:
50     polygon << QPointF(0,0) << QPointF(0,80) << QPointF(20,40) << QPointF(0,0);
51   break;
52   default: ;
53   }
54   setBrush(Qt::black);
55   setActive(false);
56   setPolygon(polygon);
57 }
58 
~ArrowSprite()59 ArrowSprite::~ArrowSprite()
60 {
61 }
62 
setActive(bool value)63 void ArrowSprite::setActive(bool value)
64 {
65   int alpha = (value?128:64);
66 //   qCDebug(KSIRK_LOG) << value << alpha;
67   QBrush b = brush();
68   QColor color = b.color();
69   color.setAlpha(alpha);
70 //   qCDebug(KSIRK_LOG) << color.alpha();
71   b.setColor(color);
72   setBrush(b);
73 }
74 
75 } // closing namespace Sprites
76 } // closing namespace Ksirk
77