userguide/src/BrowserWrapper.cpp
changeset 24 bce8d4d2cc72
parent 13 1eb8015a8491
child 31 c91c3c86f666
equal deleted inserted replaced
15:c0dfc135a46c 24:bce8d4d2cc72
    34 void BrowserWrapper::init()
    34 void BrowserWrapper::init()
    35 {
    35 {
    36 	mWebView = new QGraphicsWebView();
    36 	mWebView = new QGraphicsWebView();
    37     mWebView->setZoomFactor(1.5);
    37     mWebView->setZoomFactor(1.5);
    38     mWebView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
    38     mWebView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
       
    39 	mWebView->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
       
    40 	mWebView->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
       
    41     mWebView->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
       
    42     mWebView->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
    39     connect(mWebView, SIGNAL(linkClicked(const QUrl&)), this, SIGNAL(linkClicked(const QUrl&)));
    43     connect(mWebView, SIGNAL(linkClicked(const QUrl&)), this, SIGNAL(linkClicked(const QUrl&)));
    40     
    44     
    41     QGraphicsLinearLayout* vLayout = new QGraphicsLinearLayout(this);
    45     QGraphicsLinearLayout* vLayout = new QGraphicsLinearLayout(this);
    42     vLayout->setOrientation(Qt::Vertical);
    46     vLayout->setOrientation(Qt::Vertical);
    43     vLayout->addItem(mWebView);
    47     vLayout->addItem(mWebView);
    44     vLayout->setContentsMargins(0,0,0,0);
    48     vLayout->setContentsMargins(0,0,0,0);
    45     setLayout(vLayout);
    49     setLayout(vLayout);
    46 }
    50 }
    47 
    51 
    48 void BrowserWrapper::setHtml(const QString& html, const QUrl& baseUrl)
    52 void BrowserWrapper::setHtml(const QString& html, const QUrl& url)
    49 {
    53 {
    50     mWebView->setHtml(html, baseUrl);
    54     mWebView->setHtml(html, url);
    51 
    55 
    52     if(!mHistory.count() || mHistory.top()!=baseUrl)
    56     if(!mHistory.count() || mHistory.top()!=url)
    53     {
    57     {
    54         mHistory.append(baseUrl);
    58         mHistory.append(url);
    55     }
    59     }
    56 }
    60 }
    57 
    61 
    58 void BrowserWrapper::clearHistory()
    62 void BrowserWrapper::clearHistory()
    59 {
    63 {