本文整理汇总了C++中QWebSettings::setFontFamily方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebSettings::setFontFamily方法的具体用法?C++ QWebSettings::setFontFamily怎么用?C++ QWebSettings::setFontFamily使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebSettings
的用法示例。
在下文中一共展示了QWebSettings::setFontFamily方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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);
});
}
示例3: sipReleaseType
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;
}
示例4: font
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);
}
}
示例5: 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);
}
示例6: QWidget
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
QWebSettings *settings = QWebSettings::globalSettings();
settings->setAttribute(QWebSettings::PluginsEnabled, true);//允许插件
settings->setAttribute(QWebSettings::JavascriptEnabled, true);//JavaScript
settings->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);//
settings->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
settings->setFontFamily(QWebSettings::FixedFont,"幼圆");
ui->webView->setStyle(new CustomStyle());
ui->webView->load(QUrl("file:///D:/BigData/Qt-Tools/Demo/testwebview/map.html"));
// ui->webView->load(QUrl("http://www.yicai.com/video/"));
connect(ui->webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScriptWindowObject()));
}
示例7: setViewerFont
void HelpViewer::setViewerFont(const QFont &font)
{
QWebSettings *webSettings = settings();
webSettings->setFontFamily(QWebSettings::StandardFont, font.family());
webSettings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
}
示例8: 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;
}
示例9: 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();
//.........这里部分代码省略.........