示例#1
0
void PopupWebPage::checkBehaviour()
{
    if (m_createNewWindow) {
        PopupWebView* view = new PopupWebView;
        view->setWebPage(this);

        PopupWindow* popup = new PopupWindow(view);
        popup->setWindowGeometry(m_geometry);
        popup->setMenuBarVisibility(m_menuBarVisible);
        popup->setStatusBarVisibility(m_statusBarVisible);
        popup->setToolBarVisibility(m_toolBarVisible);
        popup->show();

        p_QupZilla->addDeleteOnCloseWidget(popup);

        disconnect(this, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(slotGeometryChangeRequested(QRect)));
        disconnect(this, SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SLOT(slotMenuBarVisibilityChangeRequested(bool)));
        disconnect(this, SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SLOT(slotToolBarVisibilityChangeRequested(bool)));
        disconnect(this, SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SLOT(slotStatusBarVisibilityChangeRequested(bool)));

        disconnect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
        disconnect(this, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int)));
        disconnect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool)));
    }
    else {
int BrowserMainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: loadPage((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 1: slotHome(); break;
        case 2: save(); break;
        case 3: slotLoadProgress((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 4: slotUpdateStatusbar((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 5: slotUpdateWindowTitle((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 6: slotUpdateWindowTitle(); break;
        case 7: loadUrl((*reinterpret_cast< const QUrl(*)>(_a[1]))); break;
        case 8: slotPreferences(); break;
        case 9: slotFileNew(); break;
        case 10: slotFileOpen(); break;
        case 11: slotFilePrintPreview(); break;
        case 12: slotFilePrint(); break;
        case 13: slotPrivateBrowsing(); break;
        case 14: slotFileSaveAs(); break;
        case 15: slotEditFind(); break;
        case 16: slotEditFindNext(); break;
        case 17: slotEditFindPrevious(); break;
        case 18: slotShowBookmarksDialog(); break;
        case 19: slotAddBookmark(); break;
        case 20: slotViewZoomIn(); break;
        case 21: slotViewZoomOut(); break;
        case 22: slotViewResetZoom(); break;
        case 23: slotViewZoomTextOnly((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 24: slotViewToolbar(); break;
        case 25: slotViewBookmarksBar(); break;
        case 26: slotViewStatusbar(); break;
        case 27: slotViewPageSource(); break;
        case 28: slotViewFullScreen((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 29: slotWebSearch(); break;
        case 30: slotToggleInspector((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 31: slotAboutApplication(); break;
        case 32: slotDownloadManager(); break;
        case 33: slotSelectLineEdit(); break;
        case 34: slotAboutToShowBackMenu(); break;
        case 35: slotAboutToShowForwardMenu(); break;
        case 36: slotAboutToShowWindowMenu(); break;
        case 37: slotOpenActionUrl((*reinterpret_cast< QAction*(*)>(_a[1]))); break;
        case 38: slotShowWindow(); break;
        case 39: slotSwapFocus(); break;
        case 40: printRequested((*reinterpret_cast< QWebFrame*(*)>(_a[1]))); break;
        case 41: geometryChangeRequested((*reinterpret_cast< const QRect(*)>(_a[1]))); break;
        case 42: updateToolbarActionText((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 43: updateBookmarksToolbarActionText((*reinterpret_cast< bool(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 44;
    }
    return _id;
}
示例#3
0
PopupWindow::PopupWindow(PopupWebView* view, bool showStatusBar)
    : QWidget()
    , m_view(view)
    , m_page(view->webPage())
{
    m_layout = new QVBoxLayout(this);
    m_layout->setContentsMargins(0, 0, 0, 0);
    m_layout->setSpacing(0);

    m_locationBar = new PopupLocationBar(this);
    m_locationBar->setView(m_view);

    m_statusBar = new QStatusBar(this);
    m_statusBar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
    m_statusBar->setVisible(showStatusBar);

    m_progressBar = new ProgressBar(m_statusBar);
    m_statusBar->addPermanentWidget(m_progressBar);
    m_progressBar->hide();

    m_statusBarMessage = new PopupStatusBarMessage(this);

    m_layout->addWidget(m_locationBar);
    m_layout->addWidget(m_view);
    m_layout->addWidget(m_statusBar);
    setLayout(m_layout);

    connect(m_view, SIGNAL(showNotification(QWidget*)), this, SLOT(showNotification(QWidget*)));
    connect(m_view, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged()));
    connect(m_view, SIGNAL(urlChanged(QUrl)), m_locationBar, SLOT(showUrl(QUrl)));
    connect(m_view, SIGNAL(iconChanged()), m_locationBar, SLOT(showIcon()));
    connect(m_view, SIGNAL(statusBarMessage(QString)), this, SLOT(showStatusBarMessage(QString)));
    connect(m_view, SIGNAL(loadStarted()), this, SLOT(loadStarted()));
    connect(m_view, SIGNAL(loadProgress(int)), this, SLOT(loadProgress(int)));
    connect(m_view, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished()));

    connect(m_page, SIGNAL(linkHovered(QString, QString, QString)), this, SLOT(showStatusBarMessage(QString)));
    connect(m_page, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(setWindowGeometry(QRect)));
    connect(m_page, SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SLOT(setStatusBarVisibility(bool)));
    connect(m_page, SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SLOT(setMenuBarVisibility(bool)));
    connect(m_page, SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SLOT(setToolBarVisibility(bool)));

    m_view->setFocus();
    titleChanged();

    QUrl urlToShow = m_view->url();
    if (urlToShow.isEmpty()) {
        urlToShow = m_view->page()->mainFrame()->requestedUrl();
    }

    m_locationBar->showUrl(urlToShow);

    // Ensuring correct sizes for widgets in layout are calculated even
    // before calling QWidget::show()
    m_layout->invalidate();
    m_layout->activate();
}
示例#4
0
PopupWindow::PopupWindow(PopupWebView* view)
    : QWidget()
    , m_view(view)
    , m_page(view->webPage())
{
    m_layout = new QVBoxLayout(this);
    m_layout->setContentsMargins(0, 0, 0, 0);
    m_layout->setSpacing(0);

    m_locationBar = new PopupLocationBar(this);
    m_locationBar->setView(m_view);

    m_statusBar = new QStatusBar(this);
    m_statusBar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);

    m_layout->addWidget(m_locationBar);
    m_layout->addWidget(m_view);
    m_layout->addWidget(m_statusBar);
    setLayout(m_layout);

    connect(m_view, SIGNAL(showNotification(QWidget*)), this, SLOT(showNotification(QWidget*)));
    connect(m_view, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged()));
    connect(m_view, SIGNAL(urlChanged(QUrl)), m_locationBar, SLOT(showUrl(QUrl)));
    connect(m_view, SIGNAL(iconChanged()), m_locationBar, SLOT(showIcon()));
    connect(m_view, SIGNAL(statusBarMessage(QString)), m_statusBar, SLOT(showMessage(QString)));

    connect(m_page, SIGNAL(linkHovered(QString, QString, QString)), m_statusBar, SLOT(showMessage(QString)));
    connect(m_page, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(setWindowGeometry(QRect)));
    connect(m_page, SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SLOT(setStatusBarVisibility(bool)));
    connect(m_page, SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SLOT(setMenuBarVisibility(bool)));
    connect(m_page, SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SLOT(setToolBarVisibility(bool)));
    connect(m_page, SIGNAL(windowCloseRequested()), this, SLOT(close()));

    m_view->setFocus();
    titleChanged();

    QUrl urlToShow = m_view->url();
    if (urlToShow.isEmpty()) {
        urlToShow = m_view->page()->mainFrame()->requestedUrl();
    }

    m_locationBar->showUrl(urlToShow);
}
示例#5
0
void PageRunner::finished(bool ok) {
    // bind nativeio
    if (!ok) {
        qApp->exit(1);
    }
    if (!scriptMode) {
        mainFrame()->evaluateJavaScript(getRuntimeBindings());
    }

    // connect signals
    connect(this, SIGNAL(contentsChanged()), this, SLOT(noteChange()));
    connect(this, SIGNAL(downloadRequested(QNetworkRequest)),
            this, SLOT(noteChange()));
    connect(this, SIGNAL(repaintRequested(QRect)),
            this, SLOT(noteChange()));
    connect(mainFrame(), SIGNAL(pageChanged()), this, SLOT(noteChange()));
    connect(this, SIGNAL(geometryChangeRequested(QRect)),
            this, SLOT(noteChange()));
    QTimer::singleShot(150, this, SLOT(reallyFinished()));
    changed = false;
    time.start();
}
示例#6
0
PopupWebPage::PopupWebPage(QWebPage::WebWindowType type, QupZilla* mainClass)
    : WebPage(mainClass)
    , p_QupZilla(mainClass)
    , m_type(type)
    , m_createNewWindow(false)
    , m_menuBarVisible(false)
    , m_statusBarVisible(false)
    , m_toolBarVisible(false)
    , m_isLoading(false)
    , m_progress(0)
{
    connect(this, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(slotGeometryChangeRequested(QRect)));
    connect(this, SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SLOT(slotMenuBarVisibilityChangeRequested(bool)));
    connect(this, SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SLOT(slotToolBarVisibilityChangeRequested(bool)));
    connect(this, SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SLOT(slotStatusBarVisibilityChangeRequested(bool)));

    connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
    connect(this, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int)));
    connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool)));

    QTimer::singleShot(0, this, SLOT(checkBehaviour()));
}
示例#7
0
void PopupWebPage::checkBehaviour()
{
    // If menubar/statusbar/toolbar visibility is explicitly set in window.open call,
    // at least one of those variables will be false.
    // If so, we should open new window.
    // But not when all visibilities are false, it occurs with target=_blank links

    if (!m_createNewWindow && (!m_menuBarVisible || !m_statusBarVisible || !m_toolBarVisible)
            && !(!m_menuBarVisible && !m_statusBarVisible && !m_toolBarVisible)) {
        m_createNewWindow = true;
    }

    if (m_createNewWindow) {
        PopupWebView* view = new PopupWebView;
        view->setWebPage(this);

        PopupWindow* popup = new PopupWindow(view);
        popup->setWindowGeometry(m_geometry);
        popup->setMenuBarVisibility(m_menuBarVisible);
        popup->setStatusBarVisibility(m_statusBarVisible);
        popup->setToolBarVisibility(m_toolBarVisible);
        popup->show();

        if (m_isLoading) {
            view->fakeLoadingProgress(m_progress);
        }

        p_QupZilla->addDeleteOnCloseWidget(popup);

        disconnect(this, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(slotGeometryChangeRequested(QRect)));
        disconnect(this, SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SLOT(slotMenuBarVisibilityChangeRequested(bool)));
        disconnect(this, SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SLOT(slotToolBarVisibilityChangeRequested(bool)));
        disconnect(this, SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SLOT(slotStatusBarVisibilityChangeRequested(bool)));

        disconnect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
        disconnect(this, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int)));
        disconnect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool)));
    }
    else {
示例#8
0
文件: tabwidget.cpp 项目: KertyXP/qt
    // webview
    WebView *webView = new WebView;
    urlLineEdit->setWebView(webView);
    connect(webView, SIGNAL(loadStarted()),
            this, SLOT(webViewLoadStarted()));
    connect(webView, SIGNAL(loadFinished(bool)),
            this, SLOT(webViewIconChanged()));
    connect(webView, SIGNAL(iconChanged()),
            this, SLOT(webViewIconChanged()));
    connect(webView, SIGNAL(titleChanged(QString)),
            this, SLOT(webViewTitleChanged(QString)));
    connect(webView, SIGNAL(urlChanged(QUrl)),
            this, SLOT(webViewUrlChanged(QUrl)));
    connect(webView->page(), SIGNAL(windowCloseRequested()),
            this, SLOT(windowCloseRequested()));
    connect(webView->page(), SIGNAL(geometryChangeRequested(QRect)),
            this, SIGNAL(geometryChangeRequested(QRect)));
    connect(webView->page(), SIGNAL(printRequested(QWebFrame*)),
            this, SIGNAL(printRequested(QWebFrame*)));
    connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)),
            this, SIGNAL(menuBarVisibilityChangeRequested(bool)));
    connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)),
            this, SIGNAL(statusBarVisibilityChangeRequested(bool)));
    connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)),
            this, SIGNAL(toolBarVisibilityChangeRequested(bool)));
    addTab(webView, tr("(Untitled)"));
    if (makeCurrent)
        setCurrentWidget(webView);

    // webview actions
    for (int i = 0; i < m_actions.count(); ++i) {
示例#9
0
PopupWindow::PopupWindow(PopupWebView* view)
    : QWidget()
    , m_view(view)
    , m_page(qobject_cast<PopupWebPage*>(view->page()))
    , m_search(0)
{
    m_layout = new QVBoxLayout(this);
    m_layout->setContentsMargins(0, 0, 0, 0);
    m_layout->setSpacing(0);

    m_locationBar = new PopupLocationBar(this);
    m_locationBar->setView(m_view);

    m_statusBar = new QStatusBar(this);
    m_statusBar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);

    m_progressBar = new ProgressBar(m_statusBar);
    m_statusBar->addPermanentWidget(m_progressBar);
    m_progressBar->hide();

    m_view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    m_statusBarMessage = new PopupStatusBarMessage(this);

    m_menuBar = new QMenuBar(this);

    QMenu* menuFile = new QMenu(tr("File"));
    menuFile->addAction(QIcon::fromTheme("document-save"), tr("&Save Page As..."), m_view, SLOT(savePageAs()))->setShortcut(QKeySequence("Ctrl+S"));
    menuFile->addAction(tr("Save Page Screen"), this, SLOT(savePageScreen()));
    menuFile->addAction(QIcon::fromTheme("mail-message-new"), tr("Send Link..."), m_view, SLOT(sendPageByMail()));
    menuFile->addAction(QIcon::fromTheme("document-print"), tr("&Print..."), m_view, SLOT(printPage()))->setShortcut(QKeySequence("Ctrl+P"));
    menuFile->addSeparator();
    menuFile->addAction(QIcon::fromTheme("window-close"), tr("Close"), this, SLOT(close()))->setShortcut(QKeySequence("Ctrl+W"));
    m_menuBar->addMenu(menuFile);

    m_menuEdit = new QMenu(tr("Edit"));
    m_menuEdit->addAction(QIcon::fromTheme("edit-undo"), tr("&Undo"), this, SLOT(editUndo()))->setShortcut(QKeySequence("Ctrl+Z"));
    m_menuEdit->addAction(QIcon::fromTheme("edit-redo"), tr("&Redo"), this, SLOT(editRedo()))->setShortcut(QKeySequence("Ctrl+Shift+Z"));
    m_menuEdit->addSeparator();
    m_menuEdit->addAction(QIcon::fromTheme("edit-cut"), tr("&Cut"), this, SLOT(editCut()))->setShortcut(QKeySequence("Ctrl+X"));
    m_menuEdit->addAction(QIcon::fromTheme("edit-copy"), tr("C&opy"), this, SLOT(editCopy()))->setShortcut(QKeySequence("Ctrl+C"));
    m_menuEdit->addAction(QIcon::fromTheme("edit-paste"), tr("&Paste"), this, SLOT(editPaste()))->setShortcut(QKeySequence("Ctrl+V"));
    m_menuEdit->addSeparator();
    m_menuEdit->addAction(QIcon::fromTheme("edit-select-all"), tr("Select All"), m_view, SLOT(selectAll()))->setShortcut(QKeySequence("Ctrl+A"));
    m_menuEdit->addAction(QIcon::fromTheme("edit-find"), tr("Find"), this, SLOT(searchOnPage()))->setShortcut(QKeySequence("Ctrl+F"));
    connect(m_menuEdit, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEditMenu()));
    m_menuBar->addMenu(m_menuEdit);

    m_menuView = new QMenu(tr("View"));
    m_actionStop = m_menuView->addAction(qIconProvider->standardIcon(QStyle::SP_BrowserStop), tr("&Stop"), m_view, SLOT(stop()));
    m_actionStop->setShortcut(QKeySequence("Esc"));
    m_actionReload = m_menuView->addAction(qIconProvider->standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), m_view, SLOT(reload()));
    m_actionReload->setShortcut(QKeySequence("F5"));
    m_menuView->addSeparator();
    m_menuView->addAction(QIcon::fromTheme("zoom-in"), tr("Zoom &In"), m_view, SLOT(zoomIn()))->setShortcut(QKeySequence("Ctrl++"));
    m_menuView->addAction(QIcon::fromTheme("zoom-out"), tr("Zoom &Out"), m_view, SLOT(zoomOut()))->setShortcut(QKeySequence("Ctrl+-"));
    m_menuView->addAction(QIcon::fromTheme("zoom-original"), tr("Reset"), m_view, SLOT(zoomReset()))->setShortcut(QKeySequence("Ctrl+0"));
    m_menuView->addSeparator();
    m_menuView->addAction(QIcon::fromTheme("text-html"), tr("&Page Source"), m_view, SLOT(showSource()))->setShortcut(QKeySequence("Ctrl+U"));
    m_menuBar->addMenu(m_menuView);

    // Make shortcuts available even with hidden menubar
    QList<QAction*> actions = m_menuBar->actions();
    foreach(QAction * action, actions) {
        if (action->menu()) {
            actions += action->menu()->actions();
        }
        addAction(action);
    }

    m_layout->insertWidget(0, m_menuBar);
    m_layout->addWidget(m_locationBar);
    m_layout->addWidget(m_view);
    m_layout->addWidget(m_statusBar);
    setLayout(m_layout);

    connect(m_view, SIGNAL(showNotification(QWidget*)), this, SLOT(showNotification(QWidget*)));
    connect(m_view, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged()));
    connect(m_view, SIGNAL(urlChanged(QUrl)), m_locationBar, SLOT(showUrl(QUrl)));
    connect(m_view, SIGNAL(iconChanged()), m_locationBar, SLOT(showIcon()));
    connect(m_view, SIGNAL(statusBarMessage(QString)), this, SLOT(showStatusBarMessage(QString)));
    connect(m_view, SIGNAL(loadStarted()), this, SLOT(loadStarted()));
    connect(m_view, SIGNAL(loadProgress(int)), this, SLOT(loadProgress(int)));
    connect(m_view, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished()));

    connect(m_page, SIGNAL(linkHovered(QString, QString, QString)), this, SLOT(showStatusBarMessage(QString)));
    connect(m_page, SIGNAL(geometryChangeRequested(QRect)), this, SLOT(setWindowGeometry(QRect)));
    connect(m_page, SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SLOT(setStatusBarVisibility(bool)));
    connect(m_page, SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SLOT(setMenuBarVisibility(bool)));
    connect(m_page, SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SLOT(setToolBarVisibility(bool)));

    m_view->setFocus();
    titleChanged();

    QUrl urlToShow = m_view->url();
    if (urlToShow.isEmpty()) {
        urlToShow = m_view->page()->mainFrame()->requestedUrl();
    }

    m_locationBar->showUrl(urlToShow);

    // Ensuring correct sizes for widgets in layout are calculated even
    // before calling QWidget::show()
    m_layout->invalidate();
    m_layout->activate();
}