ginebra2/ToolbarSnippet.cpp
changeset 6 1c3b8676e58c
parent 5 0f2326c2a325
equal deleted inserted replaced
5:0f2326c2a325 6:1c3b8676e58c
    27 #include <QDebug>
    27 #include <QDebug>
    28 
    28 
    29 
    29 
    30 namespace GVA {
    30 namespace GVA {
    31 
    31 
    32   ToolbarSnippet::ToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QRectF& ownerArea, const QWebElement & element, QGraphicsWidget * widget)
    32   ToolbarSnippet::ToolbarSnippet(const QString& elementId, ChromeWidget * chrome, const QWebElement & element)
    33                        : WebChromeContainerSnippet(elementId, chrome, ownerArea, element, widget)
    33                        : WebChromeContainerSnippet(elementId, chrome, element)
    34   {
    34   {
    35 
    35 
    36       connect(m_chrome,  SIGNAL(chromeComplete()), this, SLOT(onChromeComplete()));
    36       connect(m_chrome,  SIGNAL(chromeComplete()), this, SLOT(onChromeComplete()));
    37 
    37 
    38   }
    38   }
    51       WebChromeContainerSnippet::updateSize(sz);
    51       WebChromeContainerSnippet::updateSize(sz);
    52   }
    52   }
    53 
    53 
    54   void ToolbarSnippet::updateOwnerArea() {
    54   void ToolbarSnippet::updateOwnerArea() {
    55 
    55 
    56       setLayoutWidth(m_chrome->width());
    56     setLayoutWidth(m_chrome->layout()->size().width());
    57       WebChromeContainerSnippet::updateOwnerArea();
    57     WebChromeContainerSnippet::updateOwnerArea();
    58 
    58 
    59   }
    59   }
    60 
    60 
    61   void ToolbarSnippet::onChromeComplete() {
    61   void ToolbarSnippet::onChromeComplete() {
    62 
    62 
    67   }
    67   }
    68 
    68 
    69   void ToolbarSnippet::setAction(ChromeSnippet * s) {
    69   void ToolbarSnippet::setAction(ChromeSnippet * s) {
    70 
    70 
    71       //qDebug() << "setAction: " << s->elementId() << m_actionInfo.size();
    71       //qDebug() << "setAction: " << s->elementId() << m_actionInfo.size();
    72       ChromeItem * item = static_cast<ChromeItem*>(s->widget());
       
    73      
    72      
    74       bool res = connect(item, SIGNAL(mouseEvent( QEvent::Type )), this, SLOT(onMouseEvent(QEvent::Type)));
       
    75 
       
    76       ActionButtonSnippet * button  = static_cast<ActionButtonSnippet*> (s);
    73       ActionButtonSnippet * button  = static_cast<ActionButtonSnippet*> (s);
    77       int index = getIndex(s);
    74       int index = getIndex(s);
    78 
    75 
    79       if (index != -1) {
    76       if (index != -1) {
    80           ToolbarActions_t * t = m_actionInfo.at(index);
    77           ToolbarActions_t * t = m_actionInfo.at(index);
    81           button->connectAction(t->actionName, m_type);
    78           button->connectAction(t->actionName, m_type);
    82 
    79 
    83           // Set the button icons if it has not been set for any state (we can do this through Javascript)
    80           // Set the button icons if it has not been set for any state (we can do this through Javascript)
    84           //qDebug() << "setAction " << s->elementId() << button->icon().isNull();
    81           //qDebug() << "setAction " << s->elementId() << button->icon().isNull();
    85           if (button->icon().isNull() ) {
    82           if (button->icon().isNull() ) {
    86               button->setIcon(t->activeImg);
    83               button->setIcon(t->normalImg);
    87               button->setDisabledIcon(t->disabledImg);
    84               button->setDisabledIcon(t->disabledImg);
    88               button->setSelectedIcon(t->selectedImg);
    85               button->setActiveIcon(t->activeImg);
    89           }
    86           }
    90 
    87 
    91       }
    88       }
    92   }
    89   }
    93 
    90