diff -r b0dd75e285d2 -r 0f2326c2a325 ginebra2/ActionButtonSnippet.cpp --- a/ginebra2/ActionButtonSnippet.cpp Fri May 14 15:40:36 2010 +0300 +++ b/ginebra2/ActionButtonSnippet.cpp Wed Jun 23 17:59:43 2010 +0300 @@ -1,38 +1,55 @@ /* * 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 "ActionButtonSnippet.h" #include "controllableviewimpl.h" namespace GVA { - ActionButtonSnippet::ActionButtonSnippet( const QString & elementId, ChromeWidget * chrome, QGraphicsWidget * widget, const QWebElement & element ) + ActionButtonSnippet::ActionButtonSnippet( const QString & elementId, ChromeWidget * chrome, QGraphicsWidget * widget, const QWebElement & element ) : ChromeSnippet( elementId, chrome, widget, element ) { - connect(static_cast(m_widget), SIGNAL(activated()), this, SIGNAL(activated())); - connect(static_cast(m_widget), SIGNAL(contextMenuEvent()), this, SIGNAL(contextMenuEvent())); + + } + + QAction * ActionButtonSnippet::getDefaultAction() + { + return (static_cast(m_widget)->defaultAction()); } - + + void ActionButtonSnippet::setDefaultAction( QAction * action, QEvent::Type triggerOn ) + { + static_cast(m_widget)->setAction(action,triggerOn); + } + + QIcon ActionButtonSnippet::icon( ) + { + return static_cast(m_widget)->icon(); + } + void ActionButtonSnippet::setIcon( const QString & icon ) { static_cast(m_widget)->addIcon(icon); } - + void ActionButtonSnippet::setDisabledIcon( const QString & icon ) { static_cast(m_widget)->addIcon(icon, QIcon::Disabled); @@ -54,19 +71,20 @@ void ActionButtonSnippet::connectAction( const QString & action, const QString & view, const QString & inputEvent ) { ControllableViewBase *viewBase = m_chrome->getView( view ); - if(viewBase){ + + if (viewBase){ QAction * viewAction = viewBase->getAction(action); - if(viewAction) - static_cast(m_widget)->setAction(viewAction, - (inputEvent == "Down") ? QEvent::GraphicsSceneMousePress : QEvent::GraphicsSceneMouseRelease); + if (viewAction) + static_cast(m_widget)->setAction(viewAction, + (inputEvent == "Down") ? QEvent::GraphicsSceneMousePress : QEvent::GraphicsSceneMouseRelease); return; } - } + } - //NB: setEnabled and setLatched only affect button behavior when no action - //is currently set. These methods are intended to be used when the button - //is controlled by javascript. When an action has been set, button behavior and - //rendering is instead controlled by the action. + bool ActionButtonSnippet::isChecked( ) + { + return (static_cast(m_widget)->isChecked()); + } void ActionButtonSnippet::setEnabled( bool enabled ) { @@ -78,10 +96,23 @@ static_cast(m_widget)->setChecked(latched); } + void ActionButtonSnippet::setActive( bool enabled ) + { + static_cast(m_widget)->setActive(enabled); + } + void ActionButtonSnippet::setInputEvent( const QString & inputEvent ) { static_cast(m_widget)->setInputEvent((inputEvent=="Down") ? QEvent::GraphicsSceneMousePress : QEvent::GraphicsSceneMouseRelease); } + void ActionButtonSnippet::updateButtonState(bool state) { + if (state ) { + static_cast(m_widget)->onShown(); + } + else { + static_cast(m_widget)->onHidden(); + } + } }