Changeset View
Changeset View
Standalone View
Standalone View
documentation/standarddocumentationview.cpp
Show All 16 Lines | |||||
17 | * Free Software Foundation, Inc., | 17 | * Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "standarddocumentationview.h" | 21 | #include "standarddocumentationview.h" | ||
22 | #include "documentationfindwidget.h" | 22 | #include "documentationfindwidget.h" | ||
23 | #include "debug.h" | 23 | #include "debug.h" | ||
24 | 24 | | |||
25 | #include <QFontDatabase> | ||||
26 | | ||||
25 | using namespace KDevelop; | 27 | using namespace KDevelop; | ||
26 | 28 | | |||
27 | StandardDocumentationView::StandardDocumentationView(DocumentationFindWidget* findWidget, QWidget* parent) | 29 | StandardDocumentationView::StandardDocumentationView(DocumentationFindWidget* findWidget, QWidget* parent) | ||
28 | : QWebView (parent) | 30 | : QWebView (parent) | ||
29 | { | 31 | { | ||
30 | findWidget->setEnabled(true); | 32 | findWidget->setEnabled(true); | ||
31 | connect(findWidget, &DocumentationFindWidget::newSearch, this, &StandardDocumentationView::search); | 33 | connect(findWidget, &DocumentationFindWidget::newSearch, this, &StandardDocumentationView::search); | ||
34 | | ||||
35 | QFont sansSerifFont = QFontDatabase::systemFont(QFontDatabase::GeneralFont); | ||||
36 | QFont monospaceFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); | ||||
37 | QFont minimalFont = QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont); | ||||
38 | | ||||
39 | QWebSettings* s = settings(); | ||||
40 | | ||||
41 | s->setFontFamily(QWebSettings::StandardFont, sansSerifFont.family()); | ||||
42 | s->setFontFamily(QWebSettings::SerifFont, "Serif"); | ||||
43 | s->setFontFamily(QWebSettings::SansSerifFont, sansSerifFont.family()); | ||||
44 | s->setFontFamily(QWebSettings::FixedFont, monospaceFont.family()); | ||||
45 | | ||||
46 | s->setFontSize(QWebSettings::DefaultFontSize, QFontInfo(sansSerifFont).pixelSize()); | ||||
apol: why `+ 4`?
Also just now I realize that they don't use QFont there... | |||||
+4 is "heuristic" value, ensure that the HTML-font size be close to system font size. If we pass original size to QWebView the resulting font size will be too small. antonanikin: `+4` is "heuristic" value, ensure that the HTML-font size be close to system font size. If we… | |||||
47 | s->setFontSize(QWebSettings::DefaultFixedFontSize, QFontInfo(monospaceFont).pixelSize()); | ||||
48 | s->setFontSize(QWebSettings::MinimumFontSize, QFontInfo(minimalFont).pixelSize()); | ||||
32 | } | 49 | } | ||
33 | 50 | | |||
34 | void StandardDocumentationView::search ( const QString& text, DocumentationFindWidget::FindOptions options ) | 51 | void StandardDocumentationView::search ( const QString& text, DocumentationFindWidget::FindOptions options ) | ||
35 | { | 52 | { | ||
36 | //Highlighting has been commented because it doesn't let me jump around all occurrences | 53 | //Highlighting has been commented because it doesn't let me jump around all occurrences | ||
37 | // page()->findText(QString(), QWebPage::HighlightAllOccurrences); | 54 | // page()->findText(QString(), QWebPage::HighlightAllOccurrences); | ||
38 | 55 | | |||
39 | QWebPage::FindFlags ff=QWebPage::FindWrapsAroundDocument /*| QWebPage::HighlightAllOccurrences*/; | 56 | QWebPage::FindFlags ff=QWebPage::FindWrapsAroundDocument /*| QWebPage::HighlightAllOccurrences*/; | ||
Show All 26 Lines |
why + 4?
Also just now I realize that they don't use QFont there...