void WebWidget::openUrl(const QUrl &url, OpenHints hints) { WebWidget *widget = clone(false, (hints & PrivateOpen)); widget->setRequestedUrl(url, false); emit requestedNewWindow(widget, hints); }
void WebWidget::openUrl(const QUrl &url, WindowsManager::OpenHints hints) { WebWidget *widget = clone(false, hints.testFlag(WindowsManager::PrivateOpen)); widget->setRequestedUrl(url, false); emit requestedNewWindow(widget, hints); }
void PopupsBarWidget::openUrl(QAction *action) { if (!action) { return; } if (action->data().isNull()) { for (int i = 0; i < m_popupsMenu->actions().count(); ++i) { const QUrl url(m_popupsMenu->actions().at(i)->data().toUrl()); if (!url.isEmpty()) { emit requestedNewWindow(url, WindowsManager::NewTabOpen); } } return; } emit requestedNewWindow(action->data().toUrl(), WindowsManager::NewTabOpen); }
void WindowsManager::open(const QUrl &url, OpenHints hints) { Window *window = m_mainWindow->getWorkspace()->getActiveWindow(); if (hints == NewTabOpen && !url.isEmpty() && window && Utils::isUrlEmpty(window->getUrl())) { hints = CurrentTabOpen; } if (hints == DefaultOpen && url.scheme() == QLatin1String("about") && !url.path().isEmpty() && url.path() != QLatin1String("blank") && url.path() != QLatin1String("start") && (!window || !Utils::isUrlEmpty(window->getUrl()))) { hints = NewTabOpen; } if (hints == DefaultOpen && url.scheme() != QLatin1String("javascript") && ((window && Utils::isUrlEmpty(window->getUrl())) || SettingsManager::getValue(QLatin1String("Browser/ReuseCurrentTab")).toBool())) { hints = CurrentTabOpen; } if (m_isPrivate) { hints |= PrivateOpen; } if (hints.testFlag(NewWindowOpen)) { emit requestedNewWindow(hints.testFlag(PrivateOpen), hints.testFlag(BackgroundOpen), url); } else if (hints.testFlag(CurrentTabOpen) && window && window->getType() == QLatin1String("web")) { if (window->isPrivate() == hints.testFlag(PrivateOpen)) { window->getContentsWidget()->setHistory(WindowHistoryInformation()); window->setUrl(url, false); } else { close(m_mainWindow->getTabBar()->currentIndex()); openTab(url, hints); } } else { openTab(url, hints); } }
QWebEnginePage* QtWebEnginePage::createWindow(QWebEnginePage::WebWindowType type) { if (type == QWebEnginePage::WebDialog) { QtWebEngineWebWidget *widget(NULL); if (!m_widget || m_widget->getLastUrlClickTime().isNull() || m_widget->getLastUrlClickTime().secsTo(QDateTime::currentDateTime()) > 1) { const QString popupsPolicy(SettingsManager::getValue(QLatin1String("Content/PopupsPolicy"), (m_widget ? m_widget->getRequestedUrl() : QUrl())).toString()); if (popupsPolicy == QLatin1String("blockAll")) { return NULL; } if (popupsPolicy == QLatin1String("ask")) { QtWebEnginePage *page(new QtWebEnginePage(false, NULL)); page->markAsPopup(); connect(page, SIGNAL(aboutToNavigate(QUrl, QWebEnginePage::NavigationType)), this, SLOT(removePopup(QUrl))); return page; } } if (m_widget) { widget = qobject_cast<QtWebEngineWebWidget*>(m_widget->clone(false)); } else { widget = new QtWebEngineWebWidget(false, NULL, NULL); } widget->pageLoadStarted(); emit requestedNewWindow(widget, WindowsManager::calculateOpenHints(WindowsManager::NewTabOpen)); return widget->getPage(); } return QWebEnginePage::createWindow(type); }
QWebPage* QtWebKitWebPage::createWindow(QWebPage::WebWindowType type) { if (type == QWebPage::WebBrowserWindow) { QtWebKitWebPage *page = new QtWebKitWebPage(NULL); QtWebKitWebWidget *widget = new QtWebKitWebWidget(settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled), (m_webWidget ? m_webWidget->getBackend() : NULL), NULL, page); if (m_webWidget) { widget->setDefaultTextEncoding(m_webWidget->getDefaultTextEncoding()); widget->setQuickSearchEngine(m_webWidget->getSearchEngine()); widget->setZoom(m_webWidget->getZoom()); } emit requestedNewWindow(widget); return page; } return QWebPage::createWindow(type); }
QWebPage* QtWebKitWebPage::createWindow(QWebPage::WebWindowType type) { if (type == QWebPage::WebBrowserWindow) { QtWebKitWebWidget *widget = NULL; if (m_webWidget) { widget = qobject_cast<QtWebKitWebWidget*>(m_webWidget->clone(false)); } else { widget = new QtWebKitWebWidget(settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled), NULL, NULL); } emit requestedNewWindow(widget, DefaultOpen); return widget->getPage(); } return QWebPage::createWindow(type); }
QWebEnginePage* QtWebEnginePage::createWindow(QWebEnginePage::WebWindowType type) { if (type == QtWebEnginePage::WebBrowserWindow || type == QWebEnginePage::WebBrowserTab) { QtWebEngineWebWidget *widget = NULL; if (m_widget) { widget = qobject_cast<QtWebEngineWebWidget*>(m_widget->clone(false)); widget->setRequestedUrl(m_widget->getRequestedUrl(), false, true); } else { widget = new QtWebEngineWebWidget(false, NULL, NULL); } emit requestedNewWindow(widget, WindowsManager::DefaultOpen); return widget->getPage(); } return QWebEnginePage::createWindow(type); }
void MainWindow::actionNewWindowPrivate() { emit requestedNewWindow(true); }
void WebContentsWidget::notifyRequestedNewWindow(WebWidget *widget, OpenHints hints) { emit requestedNewWindow(new WebContentsWidget(isPrivate(), widget, NULL), hints); }
void MainWindow::triggerAction(int identifier, const QVariantMap ¶meters) { switch (identifier) { case ActionsManager::NewWindowAction: emit requestedNewWindow(false, false, QUrl()); break; case ActionsManager::NewWindowPrivateAction: emit requestedNewWindow(true, false, QUrl()); break; case ActionsManager::OpenAction: { const QUrl url = QFileDialog::getOpenFileUrl(this, tr("Open File")); if (url.isValid()) { m_windowsManager->open(url); } } break; case ActionsManager::ClosePrivateTabsPanicAction: if (SessionsManager::isPrivate()) { Application::getInstance()->close(); } else { const QList<MainWindow*> windows = SessionsManager::getWindows(); for (int i = 0; i < windows.count(); ++i) { if (windows[i]->getWindowsManager()->isPrivate()) { windows[i]->close(); } else { windows[i]->getWindowsManager()->triggerAction(ActionsManager::ClosePrivateTabsAction); } } } break; case ActionsManager::MaximizeTabAction: case ActionsManager::MinimizeTabAction: case ActionsManager::RestoreTabAction: case ActionsManager::AlwaysOnTopTabAction: case ActionsManager::MaximizeAllAction: case ActionsManager::MinimizeAllAction: case ActionsManager::RestoreAllAction: case ActionsManager::CascadeAllAction: case ActionsManager::TileAllAction: m_workspace->triggerAction(identifier, parameters); break; case ActionsManager::CloseWindowAction: close(); break; case ActionsManager::SessionsAction: { SessionsManagerDialog dialog(this); dialog.exec(); } break; case ActionsManager::SaveSessionAction: { SaveSessionDialog dialog(this); dialog.exec(); } break; case ActionsManager::GoToPageAction: { OpenAddressDialog dialog(this); connect(&dialog, SIGNAL(requestedLoadUrl(QUrl,WindowsManager::OpenHints)), m_windowsManager, SLOT(open(QUrl,WindowsManager::OpenHints))); connect(&dialog, SIGNAL(requestedOpenBookmark(BookmarksItem*,WindowsManager::OpenHints)), m_windowsManager, SLOT(open(BookmarksItem*,WindowsManager::OpenHints))); connect(&dialog, SIGNAL(requestedSearch(QString,QString,WindowsManager::OpenHints)), m_windowsManager, SLOT(search(QString,QString,WindowsManager::OpenHints))); dialog.exec(); } break; case ActionsManager::GoToHomePageAction: { const QString homePage = SettingsManager::getValue(QLatin1String("Browser/HomePage")).toString(); if (!homePage.isEmpty()) { m_windowsManager->open(QUrl(homePage), WindowsManager::CurrentTabOpen); } } break; case ActionsManager::BookmarksAction: { const QUrl url(QLatin1String("about:bookmarks")); if (!SessionsManager::hasUrl(url, true)) { m_windowsManager->open(url); } } break; case ActionsManager::AddBookmarkAction: addBookmark(QUrl(), QString(), QString(), true); break; case ActionsManager::QuickBookmarkAccessAction: { OpenBookmarkDialog dialog(this); connect(&dialog, SIGNAL(requestedOpenBookmark(BookmarksItem*)), m_windowsManager, SLOT(open(BookmarksItem*))); dialog.exec(); } break; case ActionsManager::WorkOfflineAction: SettingsManager::setValue(QLatin1String("Network/WorkOffline"), parameters); break; case ActionsManager::FullScreenAction: if (isFullScreen()) { restoreWindowState(); } else { storeWindowState(); showFullScreen(); } break; case ActionsManager::ShowTabSwitcherAction: if (!m_tabSwitcher) { m_tabSwitcher = new TabSwitcherWidget(m_windowsManager, this); } m_tabSwitcher->raise(); m_tabSwitcher->resize(size()); m_tabSwitcher->show(TabSwitcherWidget::ActionReason); break; case ActionsManager::ShowMenuBarAction: { ToolBarDefinition definition = ToolBarsManager::getToolBarDefinition(ToolBarsManager::MenuBar); definition.visibility = (parameters.value(QLatin1String("isChecked")).toBool() ? AlwaysVisibleToolBar : AlwaysHiddenToolBar); ToolBarsManager::setToolBar(definition); } break; case ActionsManager::ShowTabBarAction: { ToolBarDefinition definition = ToolBarsManager::getToolBarDefinition(ToolBarsManager::TabBar); definition.visibility = (parameters.value(QLatin1String("isChecked")).toBool() ? AlwaysVisibleToolBar : AlwaysHiddenToolBar); ToolBarsManager::setToolBar(definition); } break; case ActionsManager::ShowSidebarAction: SettingsManager::setValue(QLatin1String("Sidebar/Visible"), parameters.value(QLatin1String("isChecked")).toBool()); break; case ActionsManager::OpenPanelAction: if (m_sidebar && m_sidebar->getCurrentPanel()) { m_windowsManager->open(m_sidebar->getCurrentPanel()->getUrl(), WindowsManager::NewTabOpen); } break; case ActionsManager::ClosePanelAction: SettingsManager::setValue(QLatin1String("Sidebar/CurrentPanel"), QString()); break; case ActionsManager::ShowErrorConsoleAction: m_ui->consoleDockWidget->setVisible(parameters.value(QLatin1String("isChecked")).toBool()); break; case ActionsManager::LockToolBarsAction: ToolBarsManager::setToolBarsLocked(parameters.value(QLatin1String("isChecked")).toBool()); break; case ActionsManager::ContentBlockingAction: { ContentBlockingDialog dialog(this); dialog.exec(); } break; case ActionsManager::HistoryAction: { const QUrl url(QLatin1String("about:history")); if (!SessionsManager::hasUrl(url, true)) { m_windowsManager->open(url); } } break; case ActionsManager::ClearHistoryAction: { ClearHistoryDialog dialog(SettingsManager::getValue(QLatin1String("History/ManualClearOptions")).toStringList(), false, this); dialog.exec(); } break; case ActionsManager::NotesAction: { const QUrl url(QLatin1String("about:notes")); if (!SessionsManager::hasUrl(url, true)) { m_windowsManager->open(url); } } break; case ActionsManager::TransfersAction: { const QUrl url(QLatin1String("about:transfers")); if (!SessionsManager::hasUrl(url, true)) { m_windowsManager->open(url); } } break; case ActionsManager::CookiesAction: { const QUrl url(QLatin1String("about:cookies")); if (!SessionsManager::hasUrl(url, true)) { m_windowsManager->open(url); } } break; case ActionsManager::PreferencesAction: { PreferencesDialog dialog(QLatin1String("general"), this); dialog.exec(); } break; case ActionsManager::SwitchApplicationLanguageAction: { LocaleDialog dialog(this); dialog.exec(); } break; case ActionsManager::CheckForUpdatesAction: { UpdateCheckerDialog *dialog = new UpdateCheckerDialog(this); dialog->show(); } break; case ActionsManager::DiagnosticReportAction: { ReportDialog *dialog = new ReportDialog(this); dialog->show(); } break; case ActionsManager::AboutApplicationAction: { WebBackend *backend = AddonsManager::getWebBackend(); QString about = tr("<b>Otter %1</b><br>Web browser controlled by the user, not vice-versa.").arg(Application::getInstance()->getFullVersion()); about.append(QLatin1String("<br><br>") + tr("Web backend: %1 %2.").arg(backend->getTitle()).arg(backend->getEngineVersion()) + QLatin1String("<br><br>")); if (QSslSocket::supportsSsl()) { about.append(tr("SSL library version: %1.").arg(QSslSocket::sslLibraryVersionString())); } else { about.append(tr("SSL library not available.")); } QMessageBox::about(this, QLatin1String("Otter"), about); } break; case ActionsManager::AboutQtAction: Application::getInstance()->aboutQt(); break; case ActionsManager::ExitAction: Application::getInstance()->close(); break; default: m_windowsManager->triggerAction(identifier, parameters); break; } }