54 { |
54 { |
55 |
55 |
56 m_type = TOOLBAR_WEB_VIEW; |
56 m_type = TOOLBAR_WEB_VIEW; |
57 m_subChromeInactiveTimer = new QTimer(this); |
57 m_subChromeInactiveTimer = new QTimer(this); |
58 connect(m_subChromeInactiveTimer, SIGNAL(timeout()), this, SLOT(onInactivityTimer())); |
58 connect(m_subChromeInactiveTimer, SIGNAL(timeout()), this, SLOT(onInactivityTimer())); |
59 |
59 #ifdef Q_WS_MAEMO_5 |
|
60 connect(m_chrome, SIGNAL(windowStateChanged(Qt::WindowStates)), this, SLOT(onWindowStateChanged(Qt::WindowStates))); |
|
61 #endif |
60 } |
62 } |
61 |
63 |
62 ContentToolbarSnippet::~ContentToolbarSnippet() |
64 ContentToolbarSnippet::~ContentToolbarSnippet() |
63 { |
65 { |
64 delete m_subChromeInactiveTimer; |
66 delete m_subChromeInactiveTimer; |
66 |
68 |
67 ContentToolbarSnippet * ContentToolbarSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element) |
69 ContentToolbarSnippet * ContentToolbarSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element) |
68 { |
70 { |
69 ContentToolbarSnippet * that = new ContentToolbarSnippet( elementId, chrome, element ); |
71 ContentToolbarSnippet * that = new ContentToolbarSnippet( elementId, chrome, element ); |
70 that->setChromeWidget( new ContentToolbarChromeItem( that ) ); |
72 that->setChromeWidget( new ContentToolbarChromeItem( that ) ); |
|
73 #ifdef BROWSER_LAYOUT_TENONE |
|
74 ToolbarChromeItem * w = static_cast<ToolbarChromeItem*>(that->widget()); |
|
75 w->addCornerBackground(); |
|
76 #endif |
71 return that; |
77 return that; |
72 } |
78 } |
73 |
79 |
74 void ContentToolbarSnippet::updateSize(QSize size) { |
80 void ContentToolbarSnippet::updateSize(QSize size) { |
75 //qDebug() << "ContentToolbarSnippet::updateSize" << size.width() ; |
81 //qDebug() << "ContentToolbarSnippet::updateSize" << size.width() ; |
76 setWidth(size.width()); |
82 setWidth(size.width()); |
77 ToolbarSnippet::updateSize(size); |
83 ToolbarSnippet::updateSize(size); |
78 |
84 |
79 } |
85 } |
80 |
86 |
|
87 void ContentToolbarSnippet::setChromeWidget(QGraphicsWidget * newWidget){ |
|
88 if(widget()) { |
|
89 // Disconnect from existing widget. |
|
90 disconnect(widget(), SIGNAL(inactivityTimer()), this, SLOT(onWidgetInactivityTimer())); |
|
91 } |
|
92 // Connect to new widget. |
|
93 connect(newWidget, SIGNAL(inactivityTimer()), this, SLOT(onWidgetInactivityTimer())); |
|
94 |
|
95 ToolbarSnippet::setChromeWidget(newWidget); |
|
96 } |
|
97 |
81 void ContentToolbarSnippet::updateOwnerArea() { |
98 void ContentToolbarSnippet::updateOwnerArea() { |
82 |
99 |
83 |
100 |
84 //qDebug() << "ContentToolbarSnippet::updateOwnerArea" << m_chrome->width() ; |
101 //qDebug() << "ContentToolbarSnippet::updateOwnerArea" << m_chrome->width() ; |
85 setWidth(m_chrome->layout()->size().width()); |
102 setWidth(m_chrome->layout()->size().width()); |
86 ToolbarSnippet::updateOwnerArea(); |
103 ToolbarSnippet::updateOwnerArea(); |
87 |
104 |
88 //qDebug() << "------------Relayout "<< elementId() << hidesContent(); |
105 //qDebug() << "------------Relayout "<< elementId() << hidesContent(); |
89 // If hidesContent is true, it means that the snippet is tied to the chrome's layout. Hence, we |
106 // If hidesContent is true, it means that the snippet is tied to the chrome's layout. Hence, we |
90 // should invalidate and activate the layout here so that the layout and recalculate all |
107 // should invalidate and activate the layout here so that the layout and recalculate all |
91 // edges (we don't want to wait for the asynchronous layout request to be handled as |
108 // edges (we don't want to wait for the asynchronous layout request to be handled as |
92 // that would cause the this snippet to be painted in incorrect position before the layoutRequest |
109 // that would cause the this snippet to be painted in incorrect position before the layoutRequest |
93 // is handled |
110 // is handled |
94 if (hidesContent() ) { |
111 if (hidesContent() ) { |
95 chrome()->layout()->layout()->invalidate(); |
112 chrome()->layout()->layout()->invalidate(); |
96 chrome()->layout()->layout()->activate(); |
113 chrome()->layout()->layout()->activate(); |
97 } |
114 } |
98 } |
115 } |
99 |
116 |
100 void ContentToolbarSnippet::setWidth(int width ){ |
117 void ContentToolbarSnippet::setWidth(int width ){ |
101 |
118 |
102 QGraphicsLinearLayout* l = layout(); |
119 QGraphicsLinearLayout* l = layout(); |
119 void ContentToolbarSnippet::addActionInfo(QString id) { |
136 void ContentToolbarSnippet::addActionInfo(QString id) { |
120 |
137 |
121 ToolbarActions_t* t = new ToolbarActions_t(); |
138 ToolbarActions_t* t = new ToolbarActions_t(); |
122 if (id == "BackButtonSnippet" ) { |
139 if (id == "BackButtonSnippet" ) { |
123 t->actionId = CONTENT_VIEW_ACTION_BACK; |
140 t->actionId = CONTENT_VIEW_ACTION_BACK; |
124 t->actionName = CONTENT_TOTOLBAR_BACK; |
141 t->actionName = CONTENT_TOOLBAR_BACK; |
125 t->normalImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back.png"; |
142 t->normalImg = ":/toolbar/icon_back.png"; |
126 t->disabledImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back_disabled.png"; |
143 t->disabledImg = ":/toolbar/icon_back_disabled.png"; |
127 t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_back_pressed.png"; |
144 t->activeImg = ":/toolbar/icon_back_pressed.png"; |
128 } |
145 } |
129 else if (id == "ZoomButtonSnippet" ) { |
146 else if (id == "ZoomButtonSnippet" ) { |
130 t->actionId = CONTENT_VIEW_ACTION_ZOOM; |
147 t->actionId = CONTENT_VIEW_ACTION_ZOOM; |
131 t->actionName = CONTENT_TOTOLBAR_ZOOM; |
148 t->actionName = CONTENT_TOOLBAR_ZOOM; |
132 t->normalImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_zoom.png"; |
149 t->normalImg = ":/toolbar/icon_zoom.png"; |
133 t->disabledImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_zoom_disabled.png"; |
150 t->disabledImg = ":/toolbar/icon_zoom_disabled.png"; |
134 t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_zoom_pressed.png"; |
151 t->activeImg = ":/toolbar/icon_zoom_pressed.png"; |
|
152 } |
|
153 else if (id == "ZoomInButtonSnippet" ) { |
|
154 t->actionId = CONTENT_VIEW_ACTION_ZOOM_IN; |
|
155 t->actionName = CONTENT_TOOLBAR_ZOOM_IN; |
|
156 t->normalImg = ":/toolbar/icon_zoom+.png"; |
|
157 t->disabledImg = ":/toolbar/icon_zoom+_disabled.png"; |
|
158 t->activeImg = ":/toolbaricon_zoom+_pressed.png"; |
|
159 } |
|
160 else if (id == "ZoomOutButtonSnippet" ) { |
|
161 t->actionId = CONTENT_VIEW_ACTION_ZOOM_OUT; |
|
162 t->actionName = CONTENT_TOOLBAR_ZOOM_OUT; |
|
163 t->normalImg = ":/toolbar/icon_zoom-.png"; |
|
164 t->disabledImg = ":/toolbar/icon_zoom-_disabled.png"; |
|
165 t->activeImg = ":/toolbar/icon_zoom-_pressed.png"; |
135 } |
166 } |
136 else if (id == "MenuButtonSnippet" ) { |
167 else if (id == "MenuButtonSnippet" ) { |
137 t->actionId = CONTENT_VIEW_ACTION_MENU; |
168 t->actionId = CONTENT_VIEW_ACTION_MENU; |
138 t->actionName = CONTENT_TOTOLBAR_MENU; |
169 t->actionName = CONTENT_TOOLBAR_MENU; |
139 t->normalImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_menu.png"; |
170 t->normalImg = ":/toolbar/icon_menu.png"; |
140 t->disabledImg = ""; |
171 t->disabledImg = ""; |
141 t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_menu_pressed.png"; |
172 t->activeImg = ":/toolbar/icon_menu_pressed.png"; |
142 } |
173 } |
143 else if (id == "MostVisitedButtonSnippet" ) { |
174 else if (id == "MostVisitedButtonSnippet" ) { |
144 t->actionId = CONTENT_VIEW_ACTION_MOSTVISITED; |
175 t->actionId = CONTENT_VIEW_ACTION_MOSTVISITED; |
145 t->actionName = CONTENT_TOTOLBAR_MOSTVISITED; |
176 t->actionName = CONTENT_TOOLBAR_MOSTVISITED; |
146 t->normalImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_mostvisited.png"; |
177 t->normalImg = ":/toolbar/icon_mostvisited.png"; |
147 t->disabledImg = ""; |
178 t->disabledImg = ""; |
148 t->activeImg = ":/chrome/bedrockchrome/toolbar.snippet/icons/icon_mostvisited_pressed.png"; |
179 t->activeImg = ":/toolbar/icon_mostvisited_pressed.png"; |
149 } |
180 } |
150 else if (id == "ToggleTBButtonSnippet" ) { |
181 else if (id == "ToggleTBButtonSnippet" ) { |
151 t->actionId = CONTENT_VIEW_ACTION_TOGGLETB; |
182 t->actionId = CONTENT_VIEW_ACTION_TOGGLETB; |
152 t->actionName = CONTENT_TOTOLBAR_TOGGLETB; |
183 t->actionName = CONTENT_TOOLBAR_TOGGLETB; |
153 t->normalImg = TOOLBAR_FULL_TB_TOGGLE_ICON; |
184 t->normalImg = TOOLBAR_FULL_TB_TOGGLE_ICON; |
154 t->disabledImg = ""; |
185 t->disabledImg = ""; |
155 t->activeImg = TOOLBAR_FULL_TB_SELECTED_TOGGLE_ICON; |
186 t->activeImg = TOOLBAR_FULL_TB_SELECTED_TOGGLE_ICON; |
156 } |
187 } |
157 t->id = id; |
188 t->id = id; |
268 ActionButtonSnippet * button = static_cast<ActionButtonSnippet*> (s); |
299 ActionButtonSnippet * button = static_cast<ActionButtonSnippet*> (s); |
269 |
300 |
270 // Set selected on press to false here so that we can control when to |
301 // Set selected on press to false here so that we can control when to |
271 // change action button icon state |
302 // change action button icon state |
272 button->setActiveOnPress(false); |
303 button->setActiveOnPress(false); |
|
304 if (button->getDefaultAction()) |
273 button->getDefaultAction()->setCheckable(true); |
305 button->getDefaultAction()->setCheckable(true); |
274 |
306 |
275 ChromeItem * item = static_cast<ChromeItem*>(s->widget()); |
307 ChromeItem * item = static_cast<ChromeItem*>(s->widget()); |
276 connect(item, SIGNAL(mouseEvent( QEvent::Type )), this, SLOT(onMouseEvent(QEvent::Type))); |
308 connect(item, SIGNAL(mouseEvent( QEvent::Type )), this, SLOT(onMouseEvent(QEvent::Type))); |
277 |
309 |
281 QAction * action = button->getDefaultAction(); |
313 QAction * action = button->getDefaultAction(); |
282 ToolbarActions_t * t = m_actionInfo.at(index); |
314 ToolbarActions_t * t = m_actionInfo.at(index); |
283 |
315 |
284 switch (t->actionId) { |
316 switch (t->actionId) { |
285 |
317 |
|
318 case CONTENT_VIEW_ACTION_MENU: |
|
319 addMenuButton(action, button); |
|
320 break; |
286 case CONTENT_VIEW_ACTION_ZOOM: |
321 case CONTENT_VIEW_ACTION_ZOOM: |
287 addZoomButton(action, button); |
322 addZoomButton(action, button); |
288 break; |
323 break; |
289 case CONTENT_VIEW_ACTION_MENU: |
324 case CONTENT_VIEW_ACTION_ZOOM_IN: |
290 addMenuButton(action, button); |
325 case CONTENT_VIEW_ACTION_ZOOM_OUT: |
|
326 button->setActiveOnPress(true); |
|
327 #if defined(Q_WS_MAEMO_5) && defined(BEDROCK_TILED_BACKING_STORE) |
|
328 button->setTriggerOnUp(false); |
|
329 #endif |
291 break; |
330 break; |
292 case CONTENT_VIEW_ACTION_MOSTVISITED: |
331 case CONTENT_VIEW_ACTION_MOSTVISITED: |
293 addMostVisitedButton(action, button); |
332 addMostVisitedButton(action, button); |
294 break; |
333 break; |
295 case CONTENT_VIEW_ACTION_TOGGLETB: |
334 case CONTENT_VIEW_ACTION_TOGGLETB: |
590 } |
650 } |
591 |
651 |
592 |
652 |
593 void ContentToolbarSnippet::handleToolbarStateChange(ContentToolbarState state){ |
653 void ContentToolbarSnippet::handleToolbarStateChange(ContentToolbarState state){ |
594 |
654 |
595 |
|
596 ActionButtonSnippet * button = getActionButtonSnippet(CONTENT_VIEW_ACTION_TOGGLETB); |
655 ActionButtonSnippet * button = getActionButtonSnippet(CONTENT_VIEW_ACTION_TOGGLETB); |
597 |
656 |
598 // set the appopriate icons based on the state |
657 // set the appopriate icons based on the state |
599 |
658 |
600 if (state != CONTENT_TOOLBAR_STATE_INVALID ) { |
659 if (state != CONTENT_TOOLBAR_STATE_INVALID ) { |
601 if (state == CONTENT_TOOLBAR_STATE_PARTIAL ) { |
660 if (state == CONTENT_TOOLBAR_STATE_PARTIAL ) { |
602 button->setIcon(TOOLBAR_PARTIAL_TB_TOGGLE_ICON); |
661 button->setIcon(TOOLBAR_PARTIAL_TB_TOGGLE_ICON); |
603 button->setActiveIcon(TOOLBAR_PARTIAL_TB_SELECTED_TOGGLE_ICON); |
662 button->setActiveIcon(TOOLBAR_PARTIAL_TB_SELECTED_TOGGLE_ICON); |
604 } |
663 } |
605 else if (state == CONTENT_TOOLBAR_STATE_FULL ) { |
664 else if (state == CONTENT_TOOLBAR_STATE_FULL ) { |
606 button->setIcon(TOOLBAR_FULL_TB_TOGGLE_ICON); |
665 button->setIcon(TOOLBAR_FULL_TB_TOGGLE_ICON); |
607 button->setActiveIcon(TOOLBAR_FULL_TB_SELECTED_TOGGLE_ICON); |
666 button->setActiveIcon(TOOLBAR_FULL_TB_SELECTED_TOGGLE_ICON); |
608 |
|
609 } |
667 } |
610 // Also reset the button state if the change in state was triggered by toggle-button selection |
668 // Also reset the button state if the change in state was triggered by toggle-button selection |
611 button->updateButtonState(false); |
669 button->updateButtonState(false); |
612 |
|
613 } |
670 } |
614 } |
671 } |
615 |
672 |
616 ChromeSnippet* ContentToolbarSnippet::getLinkedButton(ChromeSnippet * snippet ) { |
673 ChromeSnippet* ContentToolbarSnippet::getLinkedButton(ChromeSnippet * snippet ) { |
617 |
674 |