File indexing completed on 2025-03-16 03:51:21
0001 /* This file is part of KsirK. 0002 Copyright (C) 2001-2008 Gael de Chalendar <kleag@free.fr> 0003 0004 KsirK is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU General Public 0006 License as published by the Free Software Foundation, either version 2 0007 of the License, or (at your option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 General Public License for more details. 0013 0014 You should have received a copy of the GNU General Public License 0015 along with this program; if not, write to the Free Software 0016 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0017 02110-1301, USA 0018 */ 0019 0020 /* begin : Sat May 17 2008 */ 0021 0022 #include "arrowsprite.h" 0023 0024 #include "ksirk_debug.h" 0025 0026 #include <QBrush> 0027 0028 namespace Ksirk 0029 { 0030 0031 namespace Sprites 0032 { 0033 0034 ArrowSprite::ArrowSprite(Qt::ArrowType type, QGraphicsItem * parent) : 0035 QGraphicsPolygonItem(parent) 0036 { 0037 QPolygonF polygon; 0038 switch (type) 0039 { 0040 case Qt::UpArrow: 0041 polygon << QPointF(0,0) << QPointF(80,0) << QPointF(40,-20) << QPointF(0,0); 0042 break; 0043 case Qt::DownArrow: 0044 polygon << QPointF(0,0) << QPointF(80,0) << QPointF(40,20) << QPointF(0,0); 0045 break; 0046 case Qt::LeftArrow: 0047 polygon << QPointF(0,0) << QPointF(0,80) << QPointF(-20,40) << QPointF(0,0); 0048 break; 0049 case Qt::RightArrow: 0050 polygon << QPointF(0,0) << QPointF(0,80) << QPointF(20,40) << QPointF(0,0); 0051 break; 0052 default: ; 0053 } 0054 setBrush(Qt::black); 0055 setActive(false); 0056 setPolygon(polygon); 0057 } 0058 0059 ArrowSprite::~ArrowSprite() 0060 { 0061 } 0062 0063 void ArrowSprite::setActive(bool value) 0064 { 0065 int alpha = (value?128:64); 0066 // qCDebug(KSIRK_LOG) << value << alpha; 0067 QBrush b = brush(); 0068 QColor color = b.color(); 0069 color.setAlpha(alpha); 0070 // qCDebug(KSIRK_LOG) << color.alpha(); 0071 b.setColor(color); 0072 setBrush(b); 0073 } 0074 0075 } // closing namespace Sprites 0076 } // closing namespace Ksirk