3 * All rights reserved. |
3 * All rights reserved. |
4 * |
4 * |
5 * This program is free software: you can redistribute it and/or modify |
5 * This program is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU Lesser General Public License as published by |
6 * it under the terms of the GNU Lesser General Public License as published by |
7 * the Free Software Foundation, version 2.1 of the License. |
7 * the Free Software Foundation, version 2.1 of the License. |
8 * |
8 * |
9 * This program is distributed in the hope that it will be useful, |
9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU Lesser General Public License for more details. |
12 * GNU Lesser General Public License for more details. |
13 * |
13 * |
14 * You should have received a copy of the GNU Lesser General Public License |
14 * You should have received a copy of the GNU Lesser General Public License |
15 * along with this program. If not, |
15 * along with this program. If not, |
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
17 * |
17 * |
18 * Description: |
18 * Description: |
19 * |
19 * |
20 */ |
20 */ |
236 int centerIndex = d->m_flowInterface->centerIndex(); |
236 int centerIndex = d->m_flowInterface->centerIndex(); |
237 if(centerIndex >= 0 && centerIndex < d->m_pageList->count()) |
237 if(centerIndex >= 0 && centerIndex < d->m_pageList->count()) |
238 { |
238 { |
239 QString pagetitle(d->m_pageList->at(centerIndex)->mainFrame()->title()); |
239 QString pagetitle(d->m_pageList->at(centerIndex)->mainFrame()->title()); |
240 if(pagetitle.isEmpty()) |
240 if(pagetitle.isEmpty()) |
241 title += qtTrId("txt_browser_windows_blank"); |
241 title += qtTrId("txt_browser_windows_new_window"); |
242 else |
242 else |
243 title += pagetitle; |
243 title += pagetitle; |
244 } |
244 } |
245 } |
245 } |
246 return title; |
246 return title; |
373 // connect creation signals |
373 // connect creation signals |
374 connect(d->m_actionAddWindow, SIGNAL(triggered()), this, SLOT(addPage())); |
374 connect(d->m_actionAddWindow, SIGNAL(triggered()), this, SLOT(addPage())); |
375 connect(d->m_actionDelWindow, SIGNAL(triggered()), this, SLOT(delPage())); |
375 connect(d->m_actionDelWindow, SIGNAL(triggered()), this, SLOT(delPage())); |
376 } |
376 } |
377 |
377 |
378 void WindowView::setMode(Mode m) |
378 void WindowView::setMode(Mode m) |
379 { |
379 { |
380 d->m_mode = m; |
380 d->m_mode = m; |
381 } |
381 } |
382 |
382 |
383 void WindowView::setSize(QSize& size) |
383 void WindowView::setSize(QSize& size) |
435 title = qtTrId("txt_browser_windows_new_window"); |
435 title = qtTrId("txt_browser_windows_new_window"); |
436 |
436 |
437 QWebHistoryItem item = window->history()->currentItem(); |
437 QWebHistoryItem item = window->history()->currentItem(); |
438 WebPageData data = item.userData().value<WebPageData>(); |
438 WebPageData data = item.userData().value<WebPageData>(); |
439 QImage img = data.m_thumbnail; |
439 QImage img = data.m_thumbnail; |
440 |
440 |
441 QSize size = window->webWidget()->size().toSize(); |
441 QSize size = window->webWidget()->size().toSize(); |
442 QSize imgSize = img.size(); |
442 QSize imgSize = img.size(); |
443 float ratio = (float)size.width() / (float)size.height(); |
443 float ratio = (float)size.width() / (float)size.height(); |
444 float imgRatio = (float)imgSize.width() / (float)imgSize.height(); |
444 float imgRatio = (float)imgSize.width() / (float)imgSize.height(); |
445 if (imgRatio != ratio) { |
445 if (imgRatio != ratio) { |
446 size.scale(imgSize, Qt::KeepAspectRatio); |
446 size.scale(imgSize, Qt::KeepAspectRatio); |
447 img = img.copy(0, 0, size.width(), size.height()); |
447 img = img.copy(0, 0, size.width(), size.height()); |
448 } |
448 } |
449 |
449 |
450 d->m_flowInterface->addSlide(img, title); |
450 d->m_flowInterface->addSlide(img, title); |
451 } |
451 } |
452 setCenterIndex(d->m_pageManager->currentPage()); |
452 setCenterIndex(d->m_pageManager->currentPage()); |
453 } |
453 } |
454 |
454 |
581 |
581 |
582 void WindowView::addPage(WrtBrowserContainer* pg) |
582 void WindowView::addPage(WrtBrowserContainer* pg) |
583 { |
583 { |
584 Q_ASSERT(d->m_flowInterface); |
584 Q_ASSERT(d->m_flowInterface); |
585 |
585 |
586 //qDebug() << "WindowView::addPage: COUNT "<< d->m_newPages.count(); |
586 //qDebug() << "WindowView::addPage: COUNT "<< d->m_newPages.count(); |
587 if (d->m_flowInterface->slideAnimationOngoing() || (d->m_mode == WindowViewModeNormal && d->m_state == WindowViewAddPage)) |
587 if (d->m_flowInterface->slideAnimationOngoing() || (d->m_mode == WindowViewModeNormal && d->m_state == WindowViewAddPage)) |
588 return; |
588 return; |
589 |
589 |
590 d->m_state = WindowViewAddPage; |
590 d->m_state = WindowViewAddPage; |
591 |
591 |
596 if (pg && !pg->mainFrame()->requestedUrl().isEmpty() ) { |
596 if (pg && !pg->mainFrame()->requestedUrl().isEmpty() ) { |
597 if (!pg->mainFrame()->title().isEmpty()) |
597 if (!pg->mainFrame()->title().isEmpty()) |
598 title = pg->mainFrame()->title(); |
598 title = pg->mainFrame()->title(); |
599 else if (!pg->mainFrame()->url().isEmpty() ) |
599 else if (!pg->mainFrame()->url().isEmpty() ) |
600 title = d->m_pageManager->partialUrl(pg->mainFrame()->url()); |
600 title = d->m_pageManager->partialUrl(pg->mainFrame()->url()); |
601 else |
601 else |
602 title = d->m_pageManager->partialUrl(pg->mainFrame()->requestedUrl()); |
602 title = d->m_pageManager->partialUrl(pg->mainFrame()->requestedUrl()); |
603 |
603 |
604 //qDebug() << "WindowView::addPage - Title " << pg->mainFrame()->title() << "Url : "<< pg->mainFrame()->url().toString()<< "Requested Url : " << pg->mainFrame()->requestedUrl().toString() ; |
604 //qDebug() << "WindowView::addPage - Title " << pg->mainFrame()->title() << "Url : "<< pg->mainFrame()->url().toString()<< "Requested Url : " << pg->mainFrame()->requestedUrl().toString() ; |
605 } |
605 } |
606 |
606 |
607 int index = d->m_flowInterface->centerIndex(); |
607 int index = d->m_flowInterface->centerIndex(); |
608 d->m_flowInterface->insert(index + 1, img, title); |
608 d->m_flowInterface->insert(index + 1, img, title); |
613 void WindowView::addPageCplt(int index) |
613 void WindowView::addPageCplt(int index) |
614 { |
614 { |
615 /* Adding a new page is completed when the index reaches the newly added index*/ |
615 /* Adding a new page is completed when the index reaches the newly added index*/ |
616 Q_ASSERT(d->m_state == WindowViewAddPage); |
616 Q_ASSERT(d->m_state == WindowViewAddPage); |
617 |
617 |
618 |
618 |
619 //qDebug() << " WindowView::addPageCplt: index " << index << "add new page" << d->m_newPages.count(); |
619 //qDebug() << " WindowView::addPageCplt: index " << index << "add new page" << d->m_newPages.count(); |
620 /* If new pages were added, show them before transitioning back to content view */ |
620 /* If new pages were added, show them before transitioning back to content view */ |
621 if (d->m_newPages.count() ) { |
621 if (d->m_newPages.count() ) { |
622 |
622 |
623 //qDebug() << " WindowView::addPageCplt: index " << index << "add new page" << d->m_newPages.count(); |
623 //qDebug() << " WindowView::addPageCplt: index " << index << "add new page" << d->m_newPages.count(); |
624 QTimer::singleShot(WINDOWVIEW_TIME_TO_ADD_NEXTPAGE, this, SLOT(addNextPage())); |
624 QTimer::singleShot(WINDOWVIEW_TIME_TO_ADD_NEXTPAGE, this, SLOT(addNextPage())); |
625 |
625 |
626 } |
626 } |
627 else { |
627 else { |
628 connect(d->m_flowInterface, SIGNAL(endAnimationCplt()), this, SLOT(addPageCplt())); |
628 connect(d->m_flowInterface, SIGNAL(endAnimationCplt()), this, SLOT(addPageCplt())); |
661 emit centerIndexChanged(index); |
661 emit centerIndexChanged(index); |
662 |
662 |
663 disconnect(d->m_flowInterface, SIGNAL(endAnimationCplt()), this, SLOT(addPageCplt())); |
663 disconnect(d->m_flowInterface, SIGNAL(endAnimationCplt()), this, SLOT(addPageCplt())); |
664 d->m_state = WindowViewActive; |
664 d->m_state = WindowViewActive; |
665 updateActions(); |
665 updateActions(); |
666 |
666 |
667 if (d->m_mode == WindowViewModeTransition ) { |
667 if (d->m_mode == WindowViewModeTransition ) { |
668 emit newWindowTransitionComplete(); |
668 emit newWindowTransitionComplete(); |
669 } |
669 } |
670 |
670 |
671 emit addPageComplete(); |
671 emit addPageComplete(); |