diff -r b0dd75e285d2 -r 0954f5dd2cd0 ginebra2/ToolbarChromeItem.cpp --- a/ginebra2/ToolbarChromeItem.cpp Fri May 14 15:40:36 2010 +0300 +++ b/ginebra2/ToolbarChromeItem.cpp Tue Jun 29 00:46:29 2010 -0400 @@ -1,47 +1,45 @@ /* * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License as published by +* the Free Software Foundation, version 2.1 of the License. * -* Initial Contributors: -* Nokia Corporation - initial contribution. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. * -* Contributors: +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, +* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". * -* Description: +* Description: * */ - #include "ToolbarChromeItem.h" +#include "NativeChromeItem.h" #include "GWebContentView.h" #include "WebChromeContainerSnippet.h" +#include "ChromeEffect.h" #include -#define TOOLBAR_MARGIN 4 -#define TOOLBAR_BORDER_WIDTH 3 -#define TOOLBAR_BORDER_COLOR "#2A3447" +#define TOOLBAR_BG_OPACITY 0.75 #define TOOLBAR_GRADIENT_START "#2E3B57" #define TOOLBAR_GRADIENT_END "#44587D" -#define TOOLBAR_RIGHTCORNER_ITEM 2 #define TOOLBAR_LEFTCORNER_ITEM 0 namespace GVA { - ToolbarChromeItem::ToolbarChromeItem(QGraphicsItem* parent) - : QGraphicsWidget(parent), - m_snippet(NULL), + ToolbarChromeItem::ToolbarChromeItem(ChromeSnippet* snippet, QGraphicsItem* parent) + : ChromeItem(NULL, parent), m_partialbg(NULL), - m_opacity(0.75) + m_opacity(TOOLBAR_BG_OPACITY) { - - setProperties(); - - + setSnippet(snippet); } ToolbarChromeItem::~ToolbarChromeItem() @@ -65,58 +63,73 @@ Q_UNUSED(widget) painter->save(); - + painter->setRenderHint(QPainter::Antialiasing); - + painter->setPen(m_pen); painter->setOpacity(m_opacity); - + // qDebug() << __PRETTY_FUNCTION__ << boundingRect(); painter->fillPath(*m_partialbg, QBrush(m_grad)); painter->drawPath(*m_partialbg); - + // restore painter - painter->restore(); - - } - void ToolbarChromeItem::setSnippet(WebChromeContainerSnippet* snippet) { + painter->restore(); - //qDebug() << __func__ << snippet; - m_snippet = snippet; + if(!isEnabled()) { + // Disabled, apply whitewash. + ChromeEffect::paintDisabledRect(painter, opt->exposedRect); + } } void ToolbarChromeItem::setProperties() { - m_pen.setWidth(TOOLBAR_BORDER_WIDTH); - m_pen.setBrush(QBrush(TOOLBAR_BORDER_COLOR)); - + m_pen.setWidth(m_borderWidth); + m_pen.setBrush(QBrush(m_borderColor)); + m_grad.setColorAt(0, TOOLBAR_GRADIENT_START); m_grad.setColorAt(1, TOOLBAR_GRADIENT_END); - + } void ToolbarChromeItem::addPartialbg() { WebChromeContainerSnippet * s = static_cast(m_snippet); + if(!s->layout()->itemAt(TOOLBAR_LEFTCORNER_ITEM)) + return; QRectF rc = s->layout()->itemAt(TOOLBAR_LEFTCORNER_ITEM)->geometry(); if (m_partialbg) { delete m_partialbg; } m_partialbg = new QPainterPath(); - int width = rc.width()-TOOLBAR_MARGIN; - + qreal width = rc.width()-m_padding; + // Add left corner bg m_partialbg->addEllipse(1, 1, width, width); // Right Corner background - int x = boundingRect().width()- rc.width() + 1; + qreal x = boundingRect().width()- rc.width() + 1; QRectF r(x, 1, width, width); m_partialbg->addEllipse(r); } + void ToolbarChromeItem::setSnippet(ChromeSnippet* snippet) { + + ChromeItem::setSnippet(snippet); + QString cssVal = m_snippet->element().styleProperty("border-top-color", + QWebElement::ComputedStyle); + NativeChromeItem::CSSToQColor(cssVal, m_borderColor); + + cssVal = m_snippet->element().styleProperty("padding-top", QWebElement::ComputedStyle); + m_padding = cssVal.remove("px").toInt(); + + cssVal = m_snippet->element().styleProperty("border-top-width", QWebElement::ComputedStyle); + m_borderWidth = cssVal.remove("px").toInt(); + setProperties(); + } } // end of namespace GVA