예제 #1
0
파일: tabwidget.cpp 프로젝트: 8jack/arora
WebView *TabWidget::webView(int index) const
{
    QWidget *widget = this->widget(index);
    if (WebViewWithSearch *webViewWithSearch = qobject_cast<WebViewWithSearch*>(widget)) {
        return webViewWithSearch->m_webView;
    } else if (widget) {
        // optimization to delay creating the first webview
        if (count() == 1) {
            TabWidget *that = const_cast<TabWidget*>(this);
            that->setUpdatesEnabled(false);
            LocationBar *currentLocationBar = qobject_cast<LocationBar*>(m_locationBars->widget(0));
            bool giveBackFocus = currentLocationBar->hasFocus();
            m_locationBars->removeWidget(currentLocationBar);
            m_locationBars->addWidget(new QWidget());
            that->newTab();
            that->closeTab(0);
            QWidget *newEmptyLineEdit = m_locationBars->widget(0);
            m_locationBars->removeWidget(newEmptyLineEdit);
            newEmptyLineEdit->deleteLater();
            m_locationBars->addWidget(currentLocationBar);
            currentLocationBar->setWebView(currentWebView());
            if (giveBackFocus)
                currentLocationBar->setFocus();
            that->setUpdatesEnabled(true);
            that->m_swappedDelayedWidget = true;
            return currentWebView();
        }
    }
    return 0;
}
예제 #2
0
WBWebView *WBTabWidget::webView(int index) const
{
    QWidget *widget = this->widget(index);
    if (WBWebView *webView = qobject_cast<WBWebView*>(widget)) {
        return webView;
    } else {
        // optimization to delay creating the first webview
        if (count() == 1) {
            WBTabWidget *that = const_cast<WBTabWidget*>(this);
            that->setUpdatesEnabled(false);
            that->newTab();
            that->closeTab(0);
            that->setUpdatesEnabled(true);
            return currentWebView();
        }
    }
    return 0;
}