--- a/ginebra2/ActionButtonSnippet.cpp Fri May 14 15:40:36 2010 +0300
+++ b/ginebra2/ActionButtonSnippet.cpp Tue Jun 29 00:46:29 2010 -0400
@@ -1,49 +1,69 @@
/*
* 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<ActionButton*>(m_widget), SIGNAL(activated()), this, SIGNAL(activated()));
- connect(static_cast<ActionButton*>(m_widget), SIGNAL(contextMenuEvent()), this, SIGNAL(contextMenuEvent()));
+
+ }
+
+ ActionButtonSnippet * ActionButtonSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element)
+ {
+ ActionButtonSnippet* that = new ActionButtonSnippet(elementId, chrome, 0, element);
+ that->setChromeWidget( new ActionButton( that ) );
+ return that;
}
-
+
+ QAction * ActionButtonSnippet::getDefaultAction()
+ {
+ return (static_cast<ActionButton*>(m_widget)->defaultAction());
+ }
+
+ //void ActionButtonSnippet::setDefaultAction( QAction * action, QEvent::Type triggerOn )
+ void ActionButtonSnippet::setDefaultAction( QAction * action, bool triggerOnDown, bool triggerOnUp)
+ {
+ static_cast<ActionButton*>(m_widget)->setAction(action,triggerOnDown, triggerOnUp);
+ }
+
+ QIcon ActionButtonSnippet::icon( )
+ {
+ return static_cast<ActionButton*>(m_widget)->icon();
+ }
+
void ActionButtonSnippet::setIcon( const QString & icon )
{
static_cast<ActionButton*>(m_widget)->addIcon(icon);
}
-
+
void ActionButtonSnippet::setDisabledIcon( const QString & icon )
{
static_cast<ActionButton*>(m_widget)->addIcon(icon, QIcon::Disabled);
}
- void ActionButtonSnippet::setSelectedIcon( const QString & icon )
- {
- static_cast<ActionButton*>(m_widget)->addIcon(icon, QIcon::Selected);
- }
-
void ActionButtonSnippet::setActiveIcon( const QString & icon )
{
static_cast<ActionButton*>(m_widget)->addIcon(icon, QIcon::Active);
@@ -51,37 +71,45 @@
// Scriptable method to directly connect an action button to a view action
- void ActionButtonSnippet::connectAction( const QString & action, const QString & view, const QString & inputEvent )
+ void ActionButtonSnippet::connectAction( const QString & action, const QString & view, bool onDown, bool onUp)
{
ControllableViewBase *viewBase = m_chrome->getView( view );
- if(viewBase){
+
+ if (viewBase){
QAction * viewAction = viewBase->getAction(action);
- if(viewAction)
- static_cast<ActionButton*>(m_widget)->setAction(viewAction,
- (inputEvent == "Down") ? QEvent::GraphicsSceneMousePress : QEvent::GraphicsSceneMouseRelease);
+ if (viewAction)
+ static_cast<ActionButton*>(m_widget)->setAction(viewAction, onDown, onUp);
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<ActionButton*>(m_widget)->isChecked());
+ }
void ActionButtonSnippet::setEnabled( bool enabled )
{
static_cast<ActionButton*>(m_widget)->setEnabled(enabled);
}
- void ActionButtonSnippet::setLatched( bool latched )
+ void ActionButtonSnippet::setActive( bool enabled )
{
- static_cast<ActionButton*>(m_widget)->setChecked(latched);
+ static_cast<ActionButton*>(m_widget)->setActive(enabled);
+ }
+
+ void ActionButtonSnippet::setActiveOnPress( bool active )
+ {
+ static_cast<ActionButton*>(m_widget)->setActiveOnPress(active);
}
- void ActionButtonSnippet::setInputEvent( const QString & inputEvent )
- {
- static_cast<ActionButton*>(m_widget)->setInputEvent((inputEvent=="Down") ? QEvent::GraphicsSceneMousePress : QEvent::GraphicsSceneMouseRelease);
+ void ActionButtonSnippet::updateButtonState(bool state) {
+ if (state ) {
+ static_cast<ActionButton*>(m_widget)->onShown();
+ }
+ else {
+ static_cast<ActionButton*>(m_widget)->onHidden();
+ }
}
-
}