ginebra2/ContentViews/GWebContentView.cpp
changeset 15 73c48011b8c7
parent 10 232fbd5a2dcb
equal deleted inserted replaced
13:491a1d15372f 15:73c48011b8c7
    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 */
    21 
    21 
    22 #include "GWebContentView.h"
    22 #include "GWebContentView.h"
    23 #include "GWebContentViewWidget.h"
    23 #include "GWebContentViewWidget.h"
    52 
    52 
    53   // ----------------------------------------------------------
    53   // ----------------------------------------------------------
    54 
    54 
    55   const qreal KZoomInStep = 1.05;
    55   const qreal KZoomInStep = 1.05;
    56   const qreal KZoomOutStep = 0.95238;
    56   const qreal KZoomOutStep = 0.95238;
    57 
    57   const qreal KInitialZoomFactorValue = 0.653061;
    58   GWebContentView::GWebContentView(ChromeWidget *chrome, QObject * parent, const QString &objectName)
    58   GWebContentView::GWebContentView(ChromeWidget *chrome, QObject * parent, const QString &objectName)
    59     : ControllableViewBase(parent),
    59     : ControllableViewBase(parent),
    60       m_networkMgr(0),
    60       m_networkMgr(0),
    61       m_chrome(chrome),
    61       m_chrome(chrome),
    62       m_timeLine(0),
    62       m_timeLine(0),
    65       m_forwardEnabled(false),
    65       m_forwardEnabled(false),
    66       m_sharedPage(0),
    66       m_sharedPage(0),
    67       m_currentSuperPage(m_superPages.begin()),
    67       m_currentSuperPage(m_superPages.begin()),
    68       m_currentPageIsSuperPage(false),
    68       m_currentPageIsSuperPage(false),
    69       m_timer(NULL),
    69       m_timer(NULL),
    70       m_enabled(true)
    70       m_enabled(true),
       
    71       m_savedZoomValueInView(KInitialZoomFactorValue) 
    71   {
    72   {
    72       setObjectName(objectName);
    73       setObjectName(objectName);
    73       WRT::WrtBrowserContainer* page = BrowserPageFactory::openBrowserPage();
    74       WRT::WrtBrowserContainer* page = BrowserPageFactory::openBrowserPage();
    74 
    75 
    75       setActions();
    76       setActions();
   174 }
   175 }
   175 
   176 
   176 void GWebContentView::zoomN()
   177 void GWebContentView::zoomN()
   177 {
   178 {
   178     if ((m_value * webWidget()->zoomFactor()) <  webWidget()->minimumScale()){
   179     if ((m_value * webWidget()->zoomFactor()) <  webWidget()->minimumScale()){
   179         if (m_timer && m_timer->isActive())
   180        // if (m_timer && m_timer->isActive())
   180             bitmapZoomStop();
   181             bitmapZoomStop();
   181     }else {
   182     }else {
   182         if (m_timer->isSingleShot()) {
   183         if (m_timer->isSingleShot()) {
   183             m_timer->setSingleShot(false);
   184             m_timer->setSingleShot(false);
   184             m_timer->start(1);
   185             m_timer->start(1);
   211         }else {
   212         }else {
   212             delete m_timer;
   213             delete m_timer;
   213             m_timer = NULL;
   214             m_timer = NULL;
   214             webWidget()->setZoomFactor(m_value * webWidget()->zoomFactor());
   215             webWidget()->setZoomFactor(m_value * webWidget()->zoomFactor());
   215         }
   216         }
       
   217         setSavedZoomValueInView(m_value * webWidget()->zoomFactor());
   216     }
   218     }
   217 }
   219 }
   218 
   220 
   219 void GWebContentView::zoomOut(qreal deltaPercent)
   221 void GWebContentView::zoomOut(qreal deltaPercent)
   220 {
   222 {
   239         }else {
   241         }else {
   240             delete m_timer;
   242             delete m_timer;
   241             m_timer = NULL;
   243             m_timer = NULL;
   242             webWidget()->setZoomFactor(m_value * webWidget()->zoomFactor());
   244             webWidget()->setZoomFactor(m_value * webWidget()->zoomFactor());
   243         }
   245         }
       
   246         setSavedZoomValueInView(m_value * webWidget()->zoomFactor());
   244     }
   247     }
   245 }
   248 }
   246 
   249 
   247 #endif
   250 #endif
   248 
   251 
   578   }
   581   }
   579 
   582 
   580   void GWebContentView::loadUrlToCurrentPage(const QString & url)
   583   void GWebContentView::loadUrlToCurrentPage(const QString & url)
   581   {
   584   {
   582       WRT::WrtBrowserContainer * activePage = WebPageController::getSingleton()->currentPage();
   585       WRT::WrtBrowserContainer * activePage = WebPageController::getSingleton()->currentPage();
   583 
   586       QString bookmark_url = url;
       
   587       if(!bookmark_url.contains(KBOOKMARKURLFILESLASH)){
       
   588          if(bookmark_url.contains(KBOOKMARKURLFILE))
       
   589             bookmark_url.replace(QString(KBOOKMARKURLFILE), QString(KBOOKMARKURLFILESLASH));
       
   590       }
       
   591       //--DeCoding URL for DoubleQuote and BackSlash--
       
   592       if (bookmark_url.contains(KENCODEDBACKSLASH, Qt::CaseInsensitive))
       
   593           bookmark_url.replace(QString(KENCODEDBACKSLASH), QString("\\"));
       
   594       if (bookmark_url.contains(KENCODEDDOUBLEQUOTE, Qt::CaseInsensitive))
       
   595           bookmark_url.replace(QString(KENCODEDDOUBLEQUOTE), QString("\""));
       
   596       
   584       if (activePage) {
   597       if (activePage) {
   585         activePage->mainFrame()->load(url);
   598           activePage->mainFrame()->load(bookmark_url);
   586       }
   599       }
   587   }
   600   }
   588 
   601 
   589   QWebPage *GWebContentView::currentPage() {
   602   QWebPage *GWebContentView::currentPage() {
   590       WRT::WrtBrowserContainer * activePage = WebPageController::getSingleton()->currentPage();
   603       WRT::WrtBrowserContainer * activePage = WebPageController::getSingleton()->currentPage();
   812     m_touchNavigation->setWantSlideViewCalls(true);
   825     m_touchNavigation->setWantSlideViewCalls(true);
   813 #else
   826 #else
   814     m_widget->showPage(false);
   827     m_widget->showPage(false);
   815 #endif
   828 #endif
   816     }
   829     }
       
   830 	WRT::WrtBrowserContainer * currPage = WebPageController::getSingleton()->currentPage();
       
   831 			if(currPage){
       
   832 			  webWidget()->initializeViewportParams();
       
   833 			  webWidget()->setZoomFactor(currPage->pageZoomMetaData().zoomValue);
       
   834 			}
   817   }
   835   }
   818 
   836 
   819   QObjectList GWebContentView::getSuperPages() {
   837   QObjectList GWebContentView::getSuperPages() {
   820     QObjectList *result = new QObjectList;
   838     QObjectList *result = new QObjectList;
   821     foreach(GVA::GSuperWebPage *page, m_superPages) {
   839     foreach(GVA::GSuperWebPage *page, m_superPages) {
   859     else if (m_forwardEnabled && !currentPage()->history()->canGoForward()){
   877     else if (m_forwardEnabled && !currentPage()->history()->canGoForward()){
   860       m_forwardEnabled = false;
   878       m_forwardEnabled = false;
   861       emit forwardEnabled(false);
   879       emit forwardEnabled(false);
   862     }
   880     }
   863 
   881 
   864     // Set focus to the Web View so that text boxes have the focus (BR-994)
   882     // Set focus to the Web View so that text boxes have the focus (BR-994) if user is not editing the
   865     m_widget->setFocus();
   883     // url field
       
   884     if (!WebPageController::getSingleton()->editMode())
       
   885         m_widget->setFocus();
   866 
   886 
   867 #if defined(__gva_no_chrome__) || defined(NO_RESIZE_ON_LOAD)
   887 #if defined(__gva_no_chrome__) || defined(NO_RESIZE_ON_LOAD)
   868     m_widget->onLoadFinished();
   888     m_widget->onLoadFinished();
   869 #endif
   889 #endif
   870   }
   890   }
  1013 
  1033 
  1014       m_enabled = value;
  1034       m_enabled = value;
  1015       widget()->setEnabled(value);
  1035       widget()->setEnabled(value);
  1016       widget()->update();
  1036       widget()->update();
  1017   }
  1037   }
       
  1038   void GWebContentView::setSavedZoomValueInView(qreal zoomValue){
       
  1039 	  m_savedZoomValueInView = zoomValue;
       
  1040   }
       
  1041   
       
  1042   qreal GWebContentView::getSavedZoomValueInView() const{
       
  1043       return m_savedZoomValueInView;
       
  1044   }
  1018 } // end of namespace GVA
  1045 } // end of namespace GVA
  1019 
  1046 
  1020 
  1047