1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 //USER |
|
19 #include "lcvideowidget.h" |
|
20 |
|
21 //SYSTEM |
|
22 #include <QPainter> |
|
23 |
|
24 const qreal lcVideoWidgetCornerRounding = 10.0; |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 LcVideoWidget::LcVideoWidget(QGraphicsItem *parent, bool showVideo) : |
|
31 HbTransparentWindow(parent), |
|
32 mShowVideo(showVideo) |
|
33 { |
|
34 setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true); |
|
35 } |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 LcVideoWidget::~LcVideoWidget() |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 void LcVideoWidget::paint( |
|
50 QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
51 { |
|
52 Q_UNUSED(widget) |
|
53 QPointF initialPosition(0,0); |
|
54 |
|
55 //Workaround: widgets positioning takes time, do not paint if they are not |
|
56 //positioned correctly. |
|
57 |
|
58 if ( this->pos() != initialPosition ) { |
|
59 |
|
60 painter->save(); |
|
61 if ( mShowVideo ){ |
|
62 |
|
63 QPainter::CompositionMode origCompositionMode = painter->compositionMode(); |
|
64 painter->setCompositionMode(QPainter::CompositionMode_Source); |
|
65 #if ( defined __WINSCW__ ) || ( defined __WINS__ ) |
|
66 if( mLocalPlayer ){ |
|
67 painter->setBrush(QColor(Qt::darkGreen)); |
|
68 }else{ |
|
69 painter->setBrush(QColor(Qt::darkRed)); |
|
70 } |
|
71 #else |
|
72 painter->setBrush(QColor(0,0,0,0)); |
|
73 #endif |
|
74 painter->drawRoundedRect( option->exposedRect, |
|
75 lcVideoWidgetCornerRounding, lcVideoWidgetCornerRounding); |
|
76 |
|
77 painter->setCompositionMode(origCompositionMode); // restore |
|
78 } else { |
|
79 painter->setBrush(QColor(0,0,0,255)); |
|
80 painter->drawRoundedRect( option->exposedRect, |
|
81 lcVideoWidgetCornerRounding, lcVideoWidgetCornerRounding); |
|
82 } |
|
83 painter->restore(); |
|
84 } |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void LcVideoWidget::setShowVideo(bool showVideo) |
|
92 { |
|
93 mShowVideo = showVideo; |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 bool LcVideoWidget::isShowingVideo() |
|
101 { |
|
102 return mShowVideo; |
|
103 } |
|
104 |
|
105 // End of file |
|