3
|
1 |
|
|
2 |
/*
|
|
3 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
* All rights reserved.
|
|
5 |
*
|
|
6 |
* This program is free software: you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU Lesser General Public License as published by
|
|
8 |
* the Free Software Foundation, version 2.1 of the License.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU Lesser General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU Lesser General Public License
|
|
16 |
* along with this program. If not,
|
|
17 |
* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
|
|
18 |
*
|
|
19 |
* Description:
|
|
20 |
* This is the base class for all chrome items and extends QGraphicsWidget.
|
|
21 |
*
|
|
22 |
*/
|
|
23 |
#include "ChromeItem.h"
|
|
24 |
#include "ChromeEffect.h"
|
|
25 |
#include <QtGui>
|
16
|
26 |
#include "qstmgestureevent.h"
|
|
27 |
|
3
|
28 |
|
|
29 |
namespace GVA {
|
16
|
30 |
using namespace qstmGesture;
|
3
|
31 |
|
16
|
32 |
ChromeItem::ChromeItem(ChromeSnippet * snippet, QGraphicsItem* parent)
|
|
33 |
: QGraphicsWidget(parent),
|
3
|
34 |
m_snippet(snippet)
|
16
|
35 |
{
|
|
36 |
grabGesture(QStm_Gesture::assignedType());
|
|
37 |
setObjectName("ChromeItem");
|
|
38 |
installEventFilter(this);
|
|
39 |
}
|
3
|
40 |
|
|
41 |
ChromeItem::~ChromeItem() {
|
|
42 |
|
|
43 |
}
|
|
44 |
|
|
45 |
void ChromeItem::setSnippet(ChromeSnippet * s) {
|
|
46 |
m_snippet = s;
|
|
47 |
}
|
|
48 |
|
|
49 |
void ChromeItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
|
|
50 |
{
|
|
51 |
QGraphicsWidget::paint(painter, option, widget);
|
|
52 |
if(m_snippet && !m_snippet->enabled()) {
|
|
53 |
painter->save();
|
|
54 |
painter->setOpacity(ChromeEffect::disabledOpacity);
|
|
55 |
painter->fillRect(option->exposedRect, ChromeEffect::disabledColor);
|
|
56 |
painter->restore();
|
|
57 |
}
|
|
58 |
}
|
16
|
59 |
|
|
60 |
|
|
61 |
bool ChromeItem::handleGesture(QEvent* event)
|
|
62 |
{
|
|
63 |
//return QStm_GestureEventFilter::instance()->event(event);
|
|
64 |
return false;
|
|
65 |
}
|
3
|
66 |
|
16
|
67 |
bool ChromeItem::eventFilter(QObject* receiver, QEvent* event)
|
|
68 |
{
|
|
69 |
//if (receiver == this) {
|
|
70 |
// return QStm_GestureEventFilter::instance()->eventFilter(receiver, event);
|
|
71 |
//}
|
|
72 |
return false;
|
|
73 |
}
|
|
74 |
|
|
75 |
bool ChromeItem::event(QEvent* event)
|
|
76 |
{
|
|
77 |
bool ret = false;
|
|
78 |
if (event->type() == QEvent::Gesture) {
|
|
79 |
ret = handleGesture(event);
|
|
80 |
}
|
|
81 |
if (!ret) {
|
|
82 |
ret = QGraphicsWidget::event(event);
|
|
83 |
}
|
|
84 |
return ret;
|
|
85 |
}
|
|
86 |
|
3
|
87 |
} // end of namespace GVA
|