ginebra2/ChromeItem.cpp
changeset 3 0954f5dd2cd0
child 16 3c88a81ff781
equal deleted inserted replaced
1:b0dd75e285d2 3:0954f5dd2cd0
       
     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>
       
    26 
       
    27 namespace GVA {
       
    28 
       
    29 ChromeItem::ChromeItem(ChromeSnippet * snippet, QGraphicsItem* parent)
       
    30 : QGraphicsWidget(parent),
       
    31   m_snippet(snippet)
       
    32 {
       
    33 }
       
    34 
       
    35 ChromeItem::~ChromeItem() {
       
    36 
       
    37 }
       
    38 
       
    39 void ChromeItem::setSnippet(ChromeSnippet * s) {
       
    40     m_snippet = s;
       
    41 }
       
    42 
       
    43 void ChromeItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
       
    44 {
       
    45     QGraphicsWidget::paint(painter, option, widget);
       
    46     if(m_snippet && !m_snippet->enabled()) {
       
    47         painter->save();
       
    48         painter->setOpacity(ChromeEffect::disabledOpacity);
       
    49         painter->fillRect(option->exposedRect, ChromeEffect::disabledColor);
       
    50         painter->restore();
       
    51     }
       
    52 }
       
    53 
       
    54 } // end of namespace GVA