QFont HelpWebView::viewerFont() const { //if (m_HelpEngine.usesBrowserFont()) // return m_HelpEngine.browserFont(); QWebSettings *webSettings = QWebSettings::globalSettings(); return QFont(webSettings->fontFamily(QWebSettings::StandardFont), webSettings->fontSize(QWebSettings::DefaultFontSize)); }
bool ZoomEventFilter::eventFilter (QObject *viewObj, QEvent *someEvent) { if (someEvent->type () != QEvent::Wheel) return false; QWheelEvent *e = static_cast<QWheelEvent*> (someEvent); if (!(e->modifiers () & Qt::ControlModifier)) return false; int degrees = e->delta () / 8; int steps = static_cast<qreal> (degrees) / 15; QWebView *view = qobject_cast<QWebView*> (viewObj); if (e->modifiers () & Qt::ShiftModifier) { auto multiplier = view->textSizeMultiplier (); multiplier += steps * 0.1; view->setTextSizeMultiplier (multiplier); } else { QWebSettings *settings = view->settings (); settings->setFontSize (QWebSettings::DefaultFontSize, std::max (6, settings->fontSize (QWebSettings::DefaultFontSize) + steps)); auto frame = view->page ()->mainFrame (); frame->evaluateJavaScript ("setTimeout(ScrollToBottom,0);"); } return true; }
void MainWindow::updateWindowTitle(const QString &title) { QWebSettings *settings = QWebSettings::globalSettings(); if (title.isEmpty()) { if (settings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) { setWindowTitle(i18nc("Window title when private browsing is activated", "rekonq (Private Browsing)")); } else { setWindowTitle("rekonq"); } } else { if (settings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) { setWindowTitle(i18nc("window title, %1 = title of the active website", "%1 – rekonq (Private Browsing)", title)); } else { setWindowTitle(i18nc("window title, %1 = title of the active website", "%1 – rekonq", title)); } } }
int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setApplicationName(app.translate("main", "Matrix Quiz")); #ifdef Q_WS_MAC app.setCursorFlashTime(0); #endif qsrand(static_cast<uint>(time(0))); QWebSettings *webSettings = QWebSettings::globalSettings(); webSettings->setAttribute(QWebSettings::AutoLoadImages, true); webSettings->setAttribute(QWebSettings::JavascriptEnabled, true); webSettings->setAttribute(QWebSettings::PluginsEnabled, true); QString url = QUrl::fromLocalFile(AQP::applicationPathOf() + "/matrixquiz.html").toString(); BrowserWindow *browser = new BrowserWindow(url, new WebPage); browser->showToolBar(false); browser->enableActions(false); QDialogButtonBox *buttonBox = new QDialogButtonBox; QPushButton *quitButton = buttonBox->addButton( app.translate("main", "&Quit"), QDialogButtonBox::AcceptRole); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(browser, 1); layout->addWidget(buttonBox); QDialog dialog; dialog.setLayout(layout); QObject::connect(quitButton, SIGNAL(clicked()), &dialog, SLOT(accept())); dialog.setWindowTitle(app.applicationName()); dialog.show(); return app.exec(); }
LoginForm::LoginForm(QUrl url, QWidget *parent) : QMainWindow(parent), ui(new Ui::LoginForm) { url.addEncodedQueryItem(OAUTH_CALLBACK,QByteArray(REDIRECT_URL).toPercentEncoding()); qDebug() << url; #ifdef Q_WS_MAEMO_5 setAttribute(Qt::WA_Maemo5AutoOrientation); setAttribute(Qt::WA_Maemo5StackedWindow); #endif QWebSettings* defaultSettings = QWebSettings::globalSettings(); defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, true); defaultSettings->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true); ui->setupUi(this); // defaultSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled,true); page = new JsConsoleWebPage(this); ui->webView->setPage(page); QWebViewSelectionSuppressor *suppressor = new QWebViewSelectionSuppressor(ui->webView); suppressor->enable(); ui->webView->setInputMethodHints(Qt::ImhNoAutoUppercase|Qt::ImhNoPredictiveText); connect(page,SIGNAL(consoleMessage(QString)),this,SLOT(consoleMessage(QString))); connect(ui->webView, SIGNAL(urlChanged(QUrl)), this, SLOT(handleChange(QUrl))); ui->webView->load(url); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), config_(kimai::paths::dataFolder() + "Config.ini") { ui->setupUi(this); configDialog_ = NULL; setWindowTitle("Kimai"); QWebSettings* webSettings = QWebSettings::globalSettings(); webSettings->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true); webSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); jsBridge_ = new KimaiJavaScriptBridge(this); connect(ui->webView, SIGNAL(loadFinished(bool)), this, SLOT(webView_loadFinished(bool))); connect(ui->webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(mainFrame_javaScriptWindowObjectCleared())); connect(ui->actionConfiguration, SIGNAL(triggered()), this, SLOT(menuBar_configuration_triggered())); connect(&config_, SIGNAL(valueChanged(QString)), this, SLOT(config_valueChanged(QString))); QVariant kimaiUrl = config_.value("kimaiUrl"); if (kimaiUrl.isNull() || kimaiUrl.toString().trimmed().isEmpty()) { QMessageBox::information(this, "Kimai URL not set", "No Kimai URL set. Please set it in the configuration dialog."); showConfigDialog(); } else { ui->webView->load(QUrl(kimaiUrl.toString())); } QSettings settings("Kimai", "Kimai Desktop Client"); QVariant geometry = settings.value("kimai/windowGeometry"); if (!geometry.isNull()) restoreGeometry(geometry.toByteArray()); }
void LayoutTestController::overridePreference(const QString& name, const QVariant& value) { QWebSettings* settings = m_topLoadingFrame->page()->settings(); if (name == "WebKitJavaScriptEnabled") settings->setAttribute(QWebSettings::JavascriptEnabled, value.toBool()); else if (name == "WebKitTabToLinksPreferenceKey") settings->setAttribute(QWebSettings::LinksIncludedInFocusChain, value.toBool()); else if (name == "WebKitOfflineWebApplicationCacheEnabled") settings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, value.toBool()); else if (name == "WebKitDefaultFontSize") settings->setFontSize(QWebSettings::DefaultFontSize, value.toInt()); else if (name == "WebKitUsesPageCachePreferenceKey") QWebSettings::setMaximumPagesInCache(value.toInt()); else if (name == "WebKitEnableCaretBrowsing") setCaretBrowsingEnabled(value.toBool()); else if (name == "WebKitPluginsEnabled") settings->setAttribute(QWebSettings::PluginsEnabled, value.toBool()); else if (name == "WebKitWebGLEnabled") settings->setAttribute(QWebSettings::WebGLEnabled, value.toBool()); else if (name == "WebKitCSSRegionsEnabled") settings->setAttribute(QWebSettings::CSSRegionsEnabled, value.toBool()); else if (name == "WebKitHyperlinkAuditingEnabled") settings->setAttribute(QWebSettings::HyperlinkAuditingEnabled, value.toBool()); else if (name == "WebKitHixie76WebSocketProtocolEnabled") DumpRenderTreeSupportQt::setHixie76WebSocketProtocolEnabled(m_topLoadingFrame->page(), value.toBool()); else if (name == "WebKitAcceleratedCompositingEnabled") settings->setAttribute(QWebSettings::AcceleratedCompositingEnabled, value.toBool()); else printf("ERROR: LayoutTestController::overridePreference() does not support the '%s' preference\n", name.toLatin1().data()); }
void SettingsDialog::loadDefaults() { QWebSettings *defaultSettings = QWebSettings::globalSettings(); QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont); int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize); m_standardFont = QFont(standardFontFamily, standardFontSize); standardLabel->setText(QString(QLatin1String("%1 %2")).arg(m_standardFont.family()).arg(m_standardFont.pointSize())); QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont); int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize); m_fixedFont = QFont(fixedFontFamily, fixedFontSize); fixedLabel->setText(QString(QLatin1String("%1 %2")).arg(m_fixedFont.family()).arg(m_fixedFont.pointSize())); downloadsLocation->setText(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)); blockPopupWindows->setChecked(!defaultSettings->testAttribute(QWebSettings::JavascriptCanOpenWindows)); enableJavascript->setChecked(defaultSettings->testAttribute(QWebSettings::JavascriptEnabled)); enablePlugins->setChecked(defaultSettings->testAttribute(QWebSettings::PluginsEnabled)); enableImages->setChecked(defaultSettings->testAttribute(QWebSettings::AutoLoadImages)); enableLocalStorage->setChecked(defaultSettings->testAttribute(QWebSettings::LocalStorageEnabled)); clickToFlash->setChecked(false); cookieSessionCombo->setCurrentIndex(0); filterTrackingCookiesCheckbox->setChecked(false); autoFillPasswordFormsCheckBox->setChecked(false); minimFontSizeCheckBox->setChecked(false); minimumFontSizeSpinBox->setValue(9); }
void DownloadManager::updateRow() { DownloadItem *item = qobject_cast<DownloadItem*>(sender()); int row = m_downloads.indexOf(item); if (-1 == row) return; if (!m_iconProvider) m_iconProvider = new QFileIconProvider(); QIcon icon = m_iconProvider->icon(item->m_output.fileName()); if (icon.isNull()) icon = style()->standardIcon(QStyle::SP_FileIcon); item->fileIcon->setPixmap(icon.pixmap(48, 48)); downloadsView->setRowHeight(row, item->minimumSizeHint().height()); bool remove = false; QWebSettings *globalSettings = QWebSettings::globalSettings(); if (!item->downloading() && globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) remove = true; if (item->downloadedSuccessfully() && removePolicy() == DownloadManager::SuccessFullDownload) { remove = true; } if (remove) m_model->removeRow(row); cleanupButton->setEnabled(m_downloads.count() - activeDownloads() > 0); }
void BrowserApplication::saveSession() { if (quiting) return; QSettings settings; settings.beginGroup(QLatin1String("MainWindow")); settings.setValue(QLatin1String("restoring"), false); settings.endGroup(); QWebSettings *globalSettings = QWebSettings::globalSettings(); if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) return; clean(); settings.beginGroup(QLatin1String("sessions")); int version = 2; QByteArray data; QBuffer buffer(&data); QDataStream stream(&buffer); buffer.open(QIODevice::WriteOnly); stream << qint32(BrowserApplicationMagic); stream << qint32(version); stream << qint32(m_mainWindows.count()); for (int i = 0; i < m_mainWindows.count(); ++i) stream << m_mainWindows.at(i)->saveState(); settings.setValue(QLatin1String("lastSession"), data); settings.endGroup(); }
void ToolbarSearch::searchNow() { QString searchText = lineEdit()->text(); QStringList newList = m_stringListModel->stringList(); if (newList.contains(searchText)) newList.removeAt(newList.indexOf(searchText)); newList.prepend(searchText); if (newList.size() >= m_maxSavedSearches) newList.removeLast(); QWebSettings *globalSettings = QWebSettings::globalSettings(); if (!globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) { m_stringListModel->setStringList(newList); m_autosaver->changeOccurred(); } QUrl url(QLatin1String("http://www.google.com/search")); QUrlQuery urlQuery; urlQuery.addQueryItem(QLatin1String("q"), searchText); urlQuery.addQueryItem(QLatin1String("ie"), QLatin1String("UTF-8")); urlQuery.addQueryItem(QLatin1String("oe"), QLatin1String("UTF-8")); urlQuery.addQueryItem(QLatin1String("client"), QLatin1String("qtdemobrowser")); url.setQuery(urlQuery); emit search(url); }
itsBrowser::itsBrowser( QWidget *parent ) : QWebView( parent ){ //This is needed in Ubuntu under QT 5 for SSL to work //Still need to test in Windows7 QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration(); sslConfig.setProtocol( QSsl::SslV3 ); //Seems under ubuntu we need to specify the version QSslConfiguration::setDefaultConfiguration( sslConfig ); QWebSettings *Tsettings = settings(); Tsettings->setAttribute( QWebSettings::JavascriptEnabled , true ); Tsettings->setAttribute( QWebSettings::PluginsEnabled , true ); Tsettings->setAttribute( QWebSettings::AutoLoadImages , true ); Tsettings->setAttribute( QWebSettings::JavaEnabled , true ); Tsettings->setAttribute( QWebSettings::JavascriptCanOpenWindows , true); QNetworkCookieJar *myjar = new QNetworkCookieJar(); this->page()->networkAccessManager()->setCookieJar(myjar); connect( page()->networkAccessManager(), SIGNAL( sslErrors( QNetworkReply*, const QList<QSslError> & ) ) ,this,SLOT( handleSslErrors( QNetworkReply*, const QList<QSslError> & ) ) ); connect( page()->networkAccessManager(), SIGNAL( authenticationRequired( QNetworkReply*,QAuthenticator* ) ) , this,SLOT( ProvideAuthentication(QNetworkReply*,QAuthenticator* ) ) ); connect( page()->networkAccessManager(), SIGNAL( proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *)) , this , SLOT( ProvideProxAuthentication( const QNetworkProxy&, QAuthenticator*) ) ); connect( page()->networkAccessManager(), SIGNAL( finished ( QNetworkReply *)),this,SLOT(NetworkTaskfinished (QNetworkReply *))); }
static PyObject *meth_QWebSettings_setFontFamily(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; { QWebSettings::FontFamily a0; const QString* a1; int a1State = 0; QWebSettings *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "BEJ1", &sipSelf, sipType_QWebSettings, &sipCpp, sipType_QWebSettings_FontFamily, &a0, sipType_QString,&a1, &a1State)) { sipCpp->setFontFamily(a0,*a1); sipReleaseType(const_cast<QString *>(a1),sipType_QString,a1State); Py_INCREF(Py_None); return Py_None; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QWebSettings, sipName_setFontFamily, doc_QWebSettings_setFontFamily); return NULL; }
WBBrowserWindow::WBBrowserWindow(QWidget *parent, Ui::MainWindow* uniboardMainWindow, bool isViewerWebInstance) : QWidget(parent) , mWebToolBar(0) , mSearchToolBar(0) , mTabWidget(new WBTabWidget(this)) , mSearchAction(0) , mUniboardMainWindow(uniboardMainWindow) { QWebSettings *defaultSettings = QWebSettings::globalSettings(); defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, true); defaultSettings->setAttribute(QWebSettings::PluginsEnabled, true); setupMenu(); if(!isViewerWebInstance) setupToolBar(); else{ setupToolBarForTutorial(); } QVBoxLayout *layout = new QVBoxLayout; layout->setSpacing(0); layout->setMargin(0); layout->addWidget(mTabWidget); this->setLayout(layout); connect(mTabWidget, SIGNAL(loadPage(const QString &)), this, SLOT(loadPage(const QString &))); connect(mTabWidget, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(slotUpdateWindowTitle(const QString &))); if (!isViewerWebInstance) { connect(mTabWidget, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int))); }
GeneralSettingsPage::GeneralSettingsPage() { m_font = qApp->font(); #if !defined(QT_NO_WEBKIT) QWebSettings* webSettings = QWebSettings::globalSettings(); m_font.setPointSize(webSettings->fontSize(QWebSettings::DefaultFontSize)); #endif }
void QHFWebView::load(const QUrl &url) { QWebView::load(url); QWebSettings *sets = this->page()->settings(); sets->setAttribute(QWebSettings::JavascriptEnabled,true); sets->setAttribute(QWebSettings::LocalContentCanAccessFileUrls,true); connect(page()->mainFrame(),SIGNAL(javaScriptWindowObjectCleared()),this,SLOT(registerObject())); }
void MyWebView::SetHighlightStyleClass(QString strClassName, QString &strTmpStyle) { QByteArray strComposedStyle("." + strClassName.toUtf8() + " { " + strTmpStyle.toUtf8() + " }"); QWebSettings *settings = QWebSettings::globalSettings(); settings->setUserStyleSheetUrl(QUrl("data:text/css;charset=utf-8;base64," + strComposedStyle.toBase64())); }
void TestRunner::setAlwaysBlockCookies(bool block) { QWebSettings* globalSettings = QWebSettings::globalSettings(); if (block) globalSettings->setThirdPartyCookiePolicy(QWebSettings::AlwaysBlockThirdPartyCookies); else globalSettings->setThirdPartyCookiePolicy(QWebSettings::AlwaysAllowThirdPartyCookies); }
SimplePartWidget::SimplePartWidget(QWidget *parent, Imap::Network::MsgPartNetAccessManager *manager, const QModelIndex &partIndex, MessageView *messageView): EmbeddedWebView(parent, manager), m_partIndex(partIndex), m_messageView(messageView), m_netAccessManager(manager) { Q_ASSERT(partIndex.isValid()); if (m_messageView) { connect(this, &QWebView::loadStarted, m_messageView, &MessageView::onWebViewLoadStarted); connect(this, &QWebView::loadFinished, m_messageView, &MessageView::onWebViewLoadFinished); } QUrl url; url.setScheme(QStringLiteral("trojita-imap")); url.setHost(QStringLiteral("msg")); url.setPath(partIndex.data(Imap::Mailbox::RolePartPathToPart).toString()); if (partIndex.data(Imap::Mailbox::RolePartMimeType).toString() == QLatin1String("text/plain")) { if (partIndex.data(Imap::Mailbox::RolePartOctets).toULongLong() < 100 * 1024) { connect(this, &QWebView::loadFinished, this, &SimplePartWidget::slotMarkupPlainText); } else { QFont font(QFontDatabase::systemFont(QFontDatabase::FixedFont)); setStaticWidth(QFontMetrics(font).maxWidth()*90); addCustomStylesheet(QStringLiteral("pre{word-wrap:normal !important;white-space:pre !important;}")); QWebSettings *s = settings(); s->setFontFamily(QWebSettings::StandardFont, font.family()); } } load(url); m_savePart = new QAction(UiUtils::loadIcon(QStringLiteral("document-save")), tr("Save this message part..."), this); connect(m_savePart, &QAction::triggered, this, &SimplePartWidget::slotDownloadPart); this->addAction(m_savePart); m_saveMessage = new QAction(UiUtils::loadIcon(QStringLiteral("document-save-all")), tr("Save whole message..."), this); connect(m_saveMessage, &QAction::triggered, this, &SimplePartWidget::slotDownloadMessage); this->addAction(m_saveMessage); m_findAction = new QAction(UiUtils::loadIcon(QStringLiteral("edit-find")), tr("Search..."), this); m_findAction->setShortcut(tr("Ctrl+F")); connect(m_findAction, &QAction::triggered, this, &SimplePartWidget::searchDialogRequested); addAction(m_findAction); setContextMenuPolicy(Qt::CustomContextMenu); // It is actually OK to construct this widget without any connection to a messageView -- this is often used when // displaying message source or message headers. Let's silence the QObject::connect warning. if (m_messageView) { connect(this, &QWidget::customContextMenuRequested, m_messageView, &MessageView::partContextMenuRequested); connect(this, &SimplePartWidget::searchDialogRequested, m_messageView, &MessageView::triggerSearchDialog); // The targets expect the sender() of the signal to be a SimplePartWidget, not a QWebPage, // which means we have to do this indirection connect(page(), &QWebPage::linkHovered, this, &SimplePartWidget::linkHovered); connect(this, &SimplePartWidget::linkHovered, m_messageView, &MessageView::partLinkHovered); connect(page(), &QWebPage::downloadRequested, this, &SimplePartWidget::slotDownloadImage); installEventFilter(m_messageView); } }
QFont HelpViewer::viewerFont() const { QWebSettings* webSettings = QWebSettings::globalSettings(); QFont font(QApplication::font().family(), webSettings->fontSize(QWebSettings::DefaultFontSize)); const QHelpEngineCore &engine = LocalHelpManager::helpEngine(); return qvariant_cast<QFont>(engine.customValue(QLatin1String("font"), font)); }
void TestRunner::setXSSAuditorEnabled(bool enable) { // Set XSSAuditingEnabled globally so that windows created by the test inherit it too. // resetSettings() will call this to reset the page and global setting to false again. // Needed by http/tests/security/xssAuditor/link-opens-new-window.html QWebSettings* globalSettings = QWebSettings::globalSettings(); globalSettings->setAttribute(QWebSettings::XSSAuditingEnabled, enable); m_drt->webPage()->settings()->setAttribute(QWebSettings::XSSAuditingEnabled, enable); }
QtMainWindow::QtMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::QtMainWindow), webInspectorWindow(new QtWebInspector()), mainWindowCallback(NULL), cur_tbrp(0), m_alertDialog(0), m_LogicalDpiX(0), m_LogicalDpiY(0), firstShow(true) //TODO: m_SyncStatusDlg { #ifdef OS_WINDOWS_DESKTOP QPixmap icon(":/images/rho.png"); QApplication::setWindowIcon(icon); #endif ui->setupUi(this); #ifdef RHODES_WIN32 ui->menuSimulate->clear(); ui->menuSimulate->setTitle("Navigate"); ui->menuSimulate->insertAction(0, ui->actionBack); #endif QWebSettings* qs = QWebSettings::globalSettings(); qs->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); qs->setOfflineStorageDefaultQuota(1024*1024*1024); rho::String rs_dir = RHODESAPP().getRhoRootPath()+RHO_EMULATOR_DIR; qs->enablePersistentStorage(rs_dir.c_str()); this->ui->webView->setContextMenuPolicy(Qt::NoContextMenu); this->ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); this->ui->webView->page()->mainFrame()->securityOrigin().setDatabaseQuota(1024*1024*1024); this->main_webView = this->ui->webView; this->main_webInspector = webInspectorWindow->webInspector(); this->cur_webInspector = this->main_webInspector; this->move(0,0); this->ui->toolBar->hide(); this->ui->toolBarRight->hide(); // connecting WebInspector main_webInspector->setPage(ui->webView->page()); #ifdef OS_SYMBIAN QWebViewKineticScroller *newScroller = new QWebViewKineticScroller(); newScroller->setWidget(this->ui->webView); QWebViewSelectionSuppressor* suppressor = new QWebViewSelectionSuppressor(this->ui->webView); #endif #if defined(RHODES_EMULATOR) webInspectorWindow->show(); #endif }
void TestRunner::setAlwaysAcceptCookies(bool accept) { QWebSettings* globalSettings = QWebSettings::globalSettings(); if (accept) globalSettings->setThirdPartyCookiePolicy(QWebSettings::AlwaysAllowThirdPartyCookies); else { // This matches the Safari third-party cookie blocking policy tested in third-party-cookie-relaxing.html globalSettings->setThirdPartyCookiePolicy(QWebSettings::AllowThirdPartyWithExistingCookies); } }
BrowserWidget::BrowserWidget(QWidget *parent, QSettings *settings, QObject *jsProxy): QGraphicsView(parent), scene(0), jsProxy(jsProxy), zoomStepFactor (settings->value("browser/zoom_step_factor").toFloat()), homePageUrl (settings->value("browser/home_page_url").toString()), errorPageUrl (settings->value("browser/error_url").toString()), unsupportedPageUrl (settings->value("browser/unsupported_url").toString()), pagesInFastHistory (settings->value("browser/pages_in_fast_history").toInt()), freezeForMsecsWhenZooming (settings->value("browser/freeze_time_when_zoom_ms").toInt()), freezeForMsecsWhenDragging (settings->value("browser/freeze_time_when_drag_ms").toInt()), maxDragDistanceToEmitClick (settings->value("browser/click_if_drag_at_most_px").toInt()), dragDistance(maxDragDistanceToEmitClick) { webView = new QGraphicsWebView(); webPage = new BrowserWebPage(); webView->setPage(webPage); newScene(); // visual settings setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setFrameShape(QFrame::NoFrame); setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); webView->setResizesToContents(true); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QPalette pal(palette()); pal.setColor(QPalette::Base, Qt::white); setPalette(pal); // web settings QWebSettings *globalSettings = QWebSettings::globalSettings(); globalSettings->setAttribute(QWebSettings::PluginsEnabled, true); globalSettings->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); globalSettings->setMaximumPagesInCache(pagesInFastHistory); webView->page()->history()->setMaximumItemCount(pagesInFastHistory); webView->page()->setForwardUnsupportedContent(true); // connects connect(webView, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanging(QUrl))); connect(webView, SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString))); connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(newScene())); connect(webView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); connect(webView->page(), SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(unsupportedContent(QNetworkReply*))); connect(webView->page()->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), this, SLOT(sslErrors(QNetworkReply*, const QList<QSslError>&)) ); connect(&unfreezeTimer, SIGNAL(timeout()), this, SLOT(unfreezeTiles())); unfreezeTimer.setSingleShot(true); connect(webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJavaScriptBinding())); addJavaScriptBinding(); }
void HistoryManager::addHistoryItem(const HistoryItem &item) { QWebSettings *globalSettings = QWebSettings::globalSettings(); if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) return; m_history.prepend(item); emit entryAdded(item); if (m_history.count() == 1) checkForExpired(); }
EmbeddedWebView::EmbeddedWebView(QWidget *parent, QNetworkAccessManager *networkManager) : QWebView(parent) , m_scrollParent(nullptr) , m_resizeInProgress(0) , m_staticWidth(0) , m_colorScheme(ColorScheme::System) { // set to expanding, ie. "freely" - this is important so the widget will attempt to shrink below the sizehint! setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setFocusPolicy(Qt::StrongFocus); // not by the wheel setPage(new ErrorCheckingPage(this)); page()->setNetworkAccessManager(networkManager); QWebSettings *s = settings(); s->setAttribute(QWebSettings::JavascriptEnabled, false); s->setAttribute(QWebSettings::JavaEnabled, false); s->setAttribute(QWebSettings::PluginsEnabled, false); s->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); s->setAttribute(QWebSettings::JavaEnabled, false); s->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, false); s->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, false); s->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, false); s->clearMemoryCaches(); page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); connect(this, &QWebView::linkClicked, this, &EmbeddedWebView::slotLinkClicked); connect(this, &QWebView::loadFinished, this, &EmbeddedWebView::handlePageLoadFinished); connect(page()->mainFrame(), &QWebFrame::contentsSizeChanged, this, &EmbeddedWebView::handlePageLoadFinished); // Scrolling is implemented on upper layers page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); // Setup shortcuts for standard actions QAction *copyAction = page()->action(QWebPage::Copy); copyAction->setShortcut(tr("Ctrl+C")); addAction(copyAction); m_autoScrollTimer = new QTimer(this); m_autoScrollTimer->setInterval(50); connect(m_autoScrollTimer, &QTimer::timeout, this, &EmbeddedWebView::autoScroll); m_sizeContrainTimer = new QTimer(this); m_sizeContrainTimer->setInterval(50); m_sizeContrainTimer->setSingleShot(true); connect(m_sizeContrainTimer, &QTimer::timeout, this, &EmbeddedWebView::constrainSize); setContextMenuPolicy(Qt::NoContextMenu); findScrollParent(); addCustomStylesheet(QString()); }
GeneralSettingsPage::GeneralSettingsPage() : m_ui(0) { m_font = qApp->font(); #if !defined(QT_NO_WEBKIT) QWebSettings* webSettings = QWebSettings::globalSettings(); m_font.setPointSize(webSettings->fontSize(QWebSettings::DefaultFontSize)); #endif setId("A.General settings"); setDisplayName(tr("General")); setCategory(Help::Constants::HELP_CATEGORY); setDisplayCategory(QCoreApplication::translate("Help", Help::Constants::HELP_TR_CATEGORY)); setCategoryIcon(QLatin1String(Help::Constants::HELP_CATEGORY_ICON)); }
void Editor::fullConstructor(const Theme &theme) { m_jsToCppProxy = new JsToCppProxy(this); connect(m_jsToCppProxy, &JsToCppProxy::messageReceived, this, &Editor::on_proxyMessageReceived); m_webView = new CustomQWebView(this); QUrlQuery query; query.addQueryItem("themePath", theme.path); query.addQueryItem("themeName", theme.name); QUrl url = QUrl("file://" + Notepadqq::editorPath()); url.setQuery(query); m_webView->setUrl(url); // To load the page in the background (http://stackoverflow.com/a/10520029): // (however, no noticeable improvement here on an i5, september 2014) //QString content = QString("<html><body onload='setTimeout(function() { window.location=\"%1\"; }, 1);'>Loading...</body></html>").arg("file://" + Notepadqq::editorPath()); //m_webView->setContent(content.toUtf8()); m_webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); QWebSettings *pageSettings = m_webView->page()->settings(); #ifdef QT_DEBUG pageSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); #endif pageSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); m_layout = new QVBoxLayout(this); m_layout->setContentsMargins(0, 0, 0, 0); m_layout->setSpacing(0); m_layout->addWidget(m_webView, 1); setLayout(m_layout); connect(m_webView->page()->mainFrame(), &QWebFrame::javaScriptWindowObjectCleared, this, &Editor::on_javaScriptWindowObjectCleared); connect(m_webView, &CustomQWebView::mouseWheel, this, &Editor::mouseWheel); connect(m_webView, &CustomQWebView::urlsDropped, this, &Editor::urlsDropped); // TODO Display a message if a javascript error gets triggered. // Right now, if there's an error in the javascript code, we // get stuck waiting a J_EVT_READY that will never come. }
QWidget* ManPageDocumentation::documentationWidget(KDevelop::DocumentationFindWidget* findWidget, QWidget* parent ) { KDevelop::StandardDocumentationView* view = new KDevelop::StandardDocumentationView(findWidget, parent); view->setDocumentation(IDocumentation::Ptr(this)); // apply custom style-sheet to normalize look of the page const QString cssFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kdevmanpage/manpagedocumentation.css"); QWebSettings* settings = view->settings(); settings->setUserStyleSheetUrl(QUrl::fromLocalFile(cssFile)); view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); QObject::connect(view, &KDevelop::StandardDocumentationView::linkClicked, ManPageDocumentation::s_provider->model(), &ManPageModel::showItemFromUrl); return view; }
QtMainWindow::QtMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::QtMainWindow), webInspectorWindow(new QtWebInspector()), cb(NULL), cur_tbrp(0), m_alertDialog(0), m_LogicalDpiX(0), m_LogicalDpiY(0) //TODO: m_SyncStatusDlg { #ifdef OS_WINDOWS_DESKTOP QPixmap icon(":/images/rho.png"); QApplication::setWindowIcon(icon); #endif ui->setupUi(this); QWebSettings* qs = QWebSettings::globalSettings(); //this->ui->webView->settings(); qs->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); qs->setAttribute(QWebSettings::LocalStorageEnabled, true); qs->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); qs->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); qs->setOfflineStorageDefaultQuota(1024*1024*1024); rho::String rs_dir = RHODESAPP().getRhoRootPath()+RHO_EMULATOR_DIR; qs->setOfflineWebApplicationCachePath(rs_dir.c_str()); qs->setLocalStoragePath(rs_dir.c_str()); qs->setOfflineStoragePath(rs_dir.c_str()); this->ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); this->ui->webView->page()->mainFrame()->securityOrigin().setDatabaseQuota(1024*1024*1024); this->main_webView = this->ui->webView; this->main_webInspector = webInspectorWindow->webInspector(); this->cur_webInspector = this->main_webInspector; this->move(0,0); this->ui->toolBar->hide(); this->ui->toolBarRight->hide(); // connecting WebInspector main_webInspector->setPage(ui->webView->page()); #ifdef OS_SYMBIAN QWebViewKineticScroller *newScroller = new QWebViewKineticScroller(); newScroller->setWidget(this->ui->webView); QWebViewSelectionSuppressor* suppressor = new QWebViewSelectionSuppressor(this->ui->webView); #endif webInspectorWindow->show(); }