本文整理汇总了C++中QWebSettings::setFontSize方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebSettings::setFontSize方法的具体用法?C++ QWebSettings::setFontSize怎么用?C++ QWebSettings::setFontSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebSettings
的用法示例。
在下文中一共展示了QWebSettings::setFontSize方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWebPage
WebPage::WebPage(QObject* parent, DumpRenderTree* drt)
: QWebPage(parent)
, m_webInspector(0)
, m_drt(drt)
{
QWebSettings* globalSettings = QWebSettings::globalSettings();
globalSettings->setFontSize(QWebSettings::MinimumFontSize, 0);
globalSettings->setFontSize(QWebSettings::MinimumLogicalFontSize, 5);
globalSettings->setFontSize(QWebSettings::DefaultFontSize, 16);
globalSettings->setFontSize(QWebSettings::DefaultFixedFontSize, 13);
globalSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
globalSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true);
globalSettings->setAttribute(QWebSettings::LinksIncludedInFocusChain, false);
globalSettings->setAttribute(QWebSettings::PluginsEnabled, true);
globalSettings->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
globalSettings->setAttribute(QWebSettings::JavascriptEnabled, true);
globalSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false);
globalSettings->setAttribute(QWebSettings::SpatialNavigationEnabled, false);
connect(this, SIGNAL(geometryChangeRequested(const QRect &)),
this, SLOT(setViewGeometry(const QRect & )));
setNetworkAccessManager(m_drt->networkAccessManager());
setPluginFactory(new TestPlugin(this));
connect(this, SIGNAL(featurePermissionRequested(QWebFrame*, QWebPage::Feature)), this, SLOT(requestPermission(QWebFrame*, QWebPage::Feature)));
connect(this, SIGNAL(featurePermissionRequestCanceled(QWebFrame*, QWebPage::Feature)), this, SLOT(cancelPermission(QWebFrame*, QWebPage::Feature)));
}
示例2: loadSettings
void BrowserApplication::loadSettings()
{
QSettings settings;
settings.beginGroup(QLatin1String("websettings"));
QWebSettings *defaultSettings = QWebSettings::globalSettings();
QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont);
int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize);
QFont standardFont = QFont(standardFontFamily, standardFontSize);
standardFont = qVariantValue<QFont>(settings.value(QLatin1String("standardFont"), standardFont));
defaultSettings->setFontFamily(QWebSettings::StandardFont, standardFont.family());
defaultSettings->setFontSize(QWebSettings::DefaultFontSize, standardFont.pointSize());
int minimumFontSize = settings.value(QLatin1String("minimumFontSize"),
defaultSettings->fontSize(QWebSettings::MinimumFontSize)).toInt();
defaultSettings->setFontSize(QWebSettings::MinimumFontSize, minimumFontSize);
QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont);
int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize);
QFont fixedFont = QFont(fixedFontFamily, fixedFontSize);
fixedFont = qVariantValue<QFont>(settings.value(QLatin1String("fixedFont"), fixedFont));
defaultSettings->setFontFamily(QWebSettings::FixedFont, fixedFont.family());
defaultSettings->setFontSize(QWebSettings::DefaultFixedFontSize, fixedFont.pointSize());
defaultSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, !(settings.value(QLatin1String("blockPopupWindows"), true).toBool()));
defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, settings.value(QLatin1String("enableJavascript"), true).toBool());
defaultSettings->setAttribute(QWebSettings::PluginsEnabled, settings.value(QLatin1String("enablePlugins"), true).toBool());
defaultSettings->setAttribute(QWebSettings::AutoLoadImages, settings.value(QLatin1String("enableImages"), true).toBool());
defaultSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled, settings.value(QLatin1String("enableInspector"), false).toBool());
QUrl url = settings.value(QLatin1String("userStyleSheet")).toUrl();
defaultSettings->setUserStyleSheetUrl(url);
settings.endGroup();
}
示例3: QWebView
StandardDocumentationView::StandardDocumentationView(DocumentationFindWidget* findWidget, QWidget* parent)
: QWebView(parent)
{
findWidget->setEnabled(true);
connect(findWidget, &DocumentationFindWidget::newSearch, this, &StandardDocumentationView::search);
QFont sansSerifFont = QFontDatabase::systemFont(QFontDatabase::GeneralFont);
QFont monospaceFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
QFont minimalFont = QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont);
QWebSettings* s = settings();
s->setFontFamily(QWebSettings::StandardFont, sansSerifFont.family());
s->setFontFamily(QWebSettings::SerifFont, "Serif");
s->setFontFamily(QWebSettings::SansSerifFont, sansSerifFont.family());
s->setFontFamily(QWebSettings::FixedFont, monospaceFont.family());
s->setFontSize(QWebSettings::DefaultFontSize, QFontInfo(sansSerifFont).pixelSize());
s->setFontSize(QWebSettings::DefaultFixedFontSize, QFontInfo(monospaceFont).pixelSize());
s->setFontSize(QWebSettings::MinimumFontSize, QFontInfo(minimalFont).pixelSize());
// Fixes for correct positioning. The problem looks like the following:
//
// 1) Some page is loaded and loadFinished() signal is emitted,
// after this QWebView set right position inside page.
//
// 2) After loadFinished() emitting, page JS code finishes it's work and changes
// font settings (size). This leads to page contents "moving" inside view widget
// and as a result we have wrong position.
//
// Such behavior occurs for example with QtHelp pages.
//
// To fix the problem, first, we disable view painter updates during load to avoid content
// "flickering" and also to hide font size "jumping". Secondly, we reset position inside page
// after loading with using standard QWebFrame method scrollToAnchor().
connect(this, &QWebView::loadStarted, this, [this]() {
setUpdatesEnabled(false);
});
connect(this, &QWebView::loadFinished, this, [this](bool) {
if (url().isValid()) {
page()->mainFrame()->scrollToAnchor(url().fragment());
}
setUpdatesEnabled(true);
});
}
示例4: overridePreference
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());
}
示例5: eventFilter
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;
}
示例6: optionChanged
void QtWebKitWebBackend::optionChanged(const QString &option)
{
if (option == QLatin1String("Cache/PagesInMemoryLimit"))
{
QWebSettings::setMaximumPagesInCache(SettingsManager::getValue(QLatin1String("Cache/PagesInMemoryLimit")).toInt());
}
if (!(option.startsWith(QLatin1String("Browser/")) || option.startsWith(QLatin1String("Content/"))))
{
return;
}
QWebSettings *globalSettings = QWebSettings::globalSettings();
globalSettings->setAttribute(QWebSettings::DnsPrefetchEnabled, true);
globalSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
globalSettings->setAttribute(QWebSettings::AutoLoadImages, SettingsManager::getValue(QLatin1String("Browser/EnableImages")).toBool());
globalSettings->setAttribute(QWebSettings::PluginsEnabled, SettingsManager::getValue(QLatin1String("Browser/EnablePlugins")).toString() != QLatin1String("disabled"));
globalSettings->setAttribute(QWebSettings::JavaEnabled, SettingsManager::getValue(QLatin1String("Browser/EnableJava")).toBool());
globalSettings->setAttribute(QWebSettings::JavascriptEnabled, SettingsManager::getValue(QLatin1String("Browser/EnableJavaScript")).toBool());
globalSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, SettingsManager::getValue(QLatin1String("Browser/JavaScriptCanAccessClipboard")).toBool());
globalSettings->setAttribute(QWebSettings::JavascriptCanCloseWindows, true);
globalSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, SettingsManager::getValue(QLatin1String("Browser/JavaScriptCanOpenWindows")).toBool());
globalSettings->setAttribute(QWebSettings::LocalStorageEnabled, SettingsManager::getValue(QLatin1String("Browser/EnableLocalStorage")).toBool());
globalSettings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, SettingsManager::getValue(QLatin1String("Browser/EnableOfflineStorageDatabase")).toBool());
globalSettings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, SettingsManager::getValue(QLatin1String("Browser/EnableOfflineWebApplicationCache")).toBool());
globalSettings->setAttribute(QWebSettings::ZoomTextOnly, SettingsManager::getValue(QLatin1String("Content/ZoomTextOnly")).toBool());
globalSettings->setFontSize(QWebSettings::DefaultFontSize, SettingsManager::getValue(QLatin1String("Content/DefaultFontSize")).toInt());
globalSettings->setFontSize(QWebSettings::DefaultFixedFontSize, SettingsManager::getValue(QLatin1String("Content/DefaultFixedFontSize")).toInt());
globalSettings->setFontSize(QWebSettings::MinimumFontSize, SettingsManager::getValue(QLatin1String("Content/MinimumFontSize")).toInt());
globalSettings->setFontFamily(QWebSettings::StandardFont, SettingsManager::getValue(QLatin1String("Content/StandardFont")).toString());
globalSettings->setFontFamily(QWebSettings::FixedFont, SettingsManager::getValue(QLatin1String("Content/FixedFont")).toString());
globalSettings->setFontFamily(QWebSettings::SerifFont, SettingsManager::getValue(QLatin1String("Content/SerifFont")).toString());
globalSettings->setFontFamily(QWebSettings::SansSerifFont, SettingsManager::getValue(QLatin1String("Content/SansSerifFont")).toString());
globalSettings->setFontFamily(QWebSettings::CursiveFont, SettingsManager::getValue(QLatin1String("Content/CursiveFont")).toString());
globalSettings->setFontFamily(QWebSettings::FantasyFont, SettingsManager::getValue(QLatin1String("Content/FantasyFont")).toString());
globalSettings->setOfflineStorageDefaultQuota(SettingsManager::getValue(QLatin1String("Browser/OfflineStorageLimit")).toInt() * 1024);
globalSettings->setOfflineWebApplicationCacheQuota(SettingsManager::getValue(QLatin1String("Content/OfflineWebApplicationCacheLimit")).toInt() * 1024);
}
示例7: sipNoMethod
static PyObject *meth_QWebSettings_setFontSize(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QWebSettings::FontSize a0;
int a1;
QWebSettings *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "BEi", &sipSelf, sipType_QWebSettings, &sipCpp, sipType_QWebSettings_FontSize, &a0, &a1))
{
sipCpp->setFontSize(a0,a1);
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QWebSettings, sipName_setFontSize, doc_QWebSettings_setFontSize);
return NULL;
}
示例8: setViewerFont
void HelpViewer::setViewerFont(const QFont &font)
{
QWebSettings *webSettings = settings();
webSettings->setFontFamily(QWebSettings::StandardFont, font.family());
webSettings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
}
示例9: setup
//Initial global settings setup
void Global::setup(StartupConfig startupConfig) {
fileManager.setup(startupConfig.homeDirPath, startupConfig.programDirPath, startupConfig.accountId);
shortcutKeys = new ShortcutKeys();
QString settingsFile = fileManager.getHomeDirPath("") + "nixnote.conf";
globalSettings = new QSettings(settingsFile, QSettings::IniFormat);
int accountId = startupConfig.accountId;
if (accountId <=0) {
globalSettings->beginGroup("SaveState");
accountId = globalSettings->value("lastAccessedAccount", 1).toInt();
globalSettings->endGroup();
}
QString key = "1b73cc55-9a2f-441b-877a-ca1d0131cd2"+
QString::number(accountId);
QLOG_DEBUG() << "Shared memory key: " << key;
sharedMemory = new QSharedMemory(key);
settingsFile = fileManager.getHomeDirPath("") + "nixnote-"+QString::number(accountId)+".conf";
settings = new QSettings(settingsFile, QSettings::IniFormat);
this->forceNoStartMimized = startupConfig.forceNoStartMinimized;
this->forceSystemTrayAvailable = startupConfig.forceSystemTrayAvailable;
this->startupNewNote = startupConfig.startupNewNote;
this->syncAndExit = startupConfig.syncAndExit;
this->forceStartMinimized = startupConfig.forceStartMinimized;
this->startupNote = startupConfig.startupNoteLid;
startupConfig.accountId = accountId;
accountsManager = new AccountsManager(startupConfig.accountId);
enableIndexing = startupConfig.enableIndexing;
cryptCounter = 0;
attachmentNameDelimeter = "------";
username = "";
password = "";
connected = false;
server = accountsManager->getServer();
// Cleanup any temporary files from the last time
QDir myDir(fileManager.getTmpDirPath());
QStringList list = myDir.entryList();
for (int i=0; i<list.size(); i++) {
if (list[i] != "." && list[i] != "..") {
QString file = fileManager.getTmpDirPath()+ list[i];
myDir.remove(file);
}
}
settings->beginGroup("Debugging");
disableUploads = settings->value("disableUploads", false).toBool();
nonAsciiSortBug = settings->value("nonAsciiSortBug", false).toBool();
settings->endGroup();
setupDateTimeFormat();
settings->beginGroup("Appearance");
int countbehavior = settings->value("countBehavior", CountAll).toInt();
if (countbehavior==1)
countBehavior = CountAll;
if (countbehavior==2)
countBehavior = CountNone;
pdfPreview = settings->value("showPDFs", true).toBool();
defaultFont = settings->value("defaultFont","").toString();
defaultFontSize = settings->value("defaultFontSize",0).toInt();
defaultGuiFontSize = settings->value("defaultGuiFontSize", 0).toInt();
defaultGuiFont = settings->value("defaultGuiFont","").toString();
disableEditing = false;
if (settings->value("disableEditingOnStartup",false).toBool() || startupConfig.disableEditing)
disableEditing = true;
settings->endGroup();
if (defaultFont != "" && defaultFontSize > 0) {
QWebSettings *settings = QWebSettings::globalSettings();
settings->setFontFamily(QWebSettings::StandardFont, defaultFont);
// QWebkit DPI is hard coded to 96. Hence, we calculate the correct
// font size based on desktop logical DPI.
settings->setFontSize(QWebSettings::DefaultFontSize,
defaultFontSize * (QApplication::desktop()->logicalDpiX() / 96.0)
);
}
settings->beginGroup("Appearance");
QString theme = settings->value("themeName", "").toString();
loadTheme(resourceList,theme);
autoHideEditorToolbar = settings->value("autoHideEditorToolbar", true).toBool();
settings->endGroup();
minIndexInterval = 5000;
maxIndexInterval = 120000;
indexResourceCountPause=2;
indexNoteCountPause=100;
}
示例10: saveValues
void AppearancePreferences::saveValues() {
global.settings->beginGroup("Appearance");
global.settings->setValue("disableEditingOnStartup", disableEditingOnStartup->isChecked());
global.settings->setValue("showTrayIcon", showTrayIcon->isChecked());
global.settings->setValue("showPDFs", showPDFs->isChecked());
global.autoHideEditorToolbar = this->autoHideEditorButtonbar->isChecked();
global.settings->setValue("autoHideEditorToolbar", global.autoHideEditorToolbar);
global.settings->setValue("mouseMiddleClickOpen", mouseMiddleClickAction->currentIndex());
global.settings->setValue("traySingleClickAction", traySingleClickAction->currentIndex());
global.settings->setValue("trayMiddleClickAction", trayMiddleClickAction->currentIndex());
global.settings->remove("trayDoubleClickAction");
global.pdfPreview = showPDFs->isChecked();
if (minimizeToTray!= NULL)
global.settings->setValue("minimizeToTray", minimizeToTray->isChecked());
else
global.settings->remove("minimizeToTray");
if (closeToTray != NULL)
global.settings->setValue("closeToTray", closeToTray->isChecked());
else
global.settings->remove("closeToTray");
global.settings->setValue("showSplashScreen", showSplashScreen->isChecked());
global.settings->setValue("startMinimized", startMinimized->isChecked());
global.settings->setValue("showMissedReminders", showMissedReminders->isChecked());
if (dynamicTotals->isChecked()) {
global.settings->setValue("countBehavior", 1);
global.countBehavior = Global::CountAll;
} else {
global.settings->setValue("countBehavior", 2);
global.countBehavior = Global::CountNone;
}
int index = defaultNotebookOnStartup->currentIndex();
int value = defaultNotebookOnStartup->itemData(index).toInt();
global.settings->setValue("startupNotebook", value);
// Save default font & size
if (webSettingsChanged) {
int idx = defaultFontChooser->currentIndex();
global.defaultFont = defaultFontChooser->itemData(idx, Qt::UserRole).toString();
idx = defaultFontSizeChooser->currentIndex();
global.defaultFontSize = defaultFontSizeChooser->itemData(idx, Qt::UserRole).toInt();
idx = defaultGuiFontSizeChooser->currentIndex();
global.defaultGuiFontSize = defaultGuiFontSizeChooser->itemData(idx, Qt::UserRole).toInt();
idx = defaultGuiFontChooser->currentIndex();
global.defaultGuiFont = defaultGuiFontChooser->itemData(idx, Qt::UserRole).toString();
if (global.defaultGuiFont == "System Default")
global.defaultGuiFont = "";
if (global.defaultFont == "System Default")
global.defaultFont = "";
global.settings->setValue("defaultFont", global.defaultFont);
global.settings->setValue("defaultFontSize", global.defaultFontSize);
global.settings->setValue("defaultGuiFont", global.defaultGuiFont);
global.settings->setValue("defaultGuiFontSize", global.defaultGuiFontSize);
QWebSettings *settings = QWebSettings::globalSettings();
settings->setFontFamily(QWebSettings::StandardFont, global.defaultFont);
// QWebkit DPI is hard coded to 96. Hence, we calculate the correct
// font size based on desktop logical DPI.
if (global.defaultFontSize > 0) {
settings->setFontSize(QWebSettings::DefaultFontSize, global.defaultFontSize * (QApplication::desktop()->logicalDpiX() / 96.0));
}
}
// See if the user has overridden the window icon
// index = windowThemeChooser->currentIndex();
// QString userIcon = windowThemeChooser->itemData(index).toString();
// if (userIcon != global.getResourceFileName(userIcon)) {
//global.settings->setValue("windowIcon", userIcon);
//Copy the nixnote2.desktop so we can override the app icon
// Ideally, we could use QSettings since it is ini format, but
// it puts [Desktop Entry] as [Desktop%20Enry], which screws
// things up.
QString systemFile = "/usr/share/applications/nixnote2.desktop";
QFile systemIni(systemFile);
QStringList desktopData;
if (systemIni.open(QIODevice::ReadOnly)) {
QTextStream data(&systemIni);
QString line = data.readLine();
while (!line.isNull()) {
if (line.startsWith("Icon=")) {
line = "Icon=" +global.getResourceFileName(global.resourceList,":windowIcon.png");
}
desktopData.append(line);
line = data.readLine();
}
}
systemIni.close();
// Now, write it back out
QString userFile = QDir::homePath()+"/.local/share/applications/nixnote2.desktop";
QFile userIni(userFile);
if (userIni.open(QIODevice::WriteOnly)) {
QTextStream data(&userIni);
for (int i=0; i<desktopData.size(); i++) {
data << desktopData[i] << "\n";
}
}
userIni.close();
//.........这里部分代码省略.........