Changeset View
Changeset View
Standalone View
Standalone View
documentation/standarddocumentationview.cpp
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | 113 | { | |||
---|---|---|---|---|---|
114 | auto mainLayout = new QVBoxLayout(this); | 114 | auto mainLayout = new QVBoxLayout(this); | ||
115 | mainLayout->setMargin(0); | 115 | mainLayout->setMargin(0); | ||
116 | setLayout(mainLayout); | 116 | setLayout(mainLayout); | ||
117 | 117 | | |||
118 | d->init(this); | 118 | d->init(this); | ||
119 | layout()->addWidget(d->m_view); | 119 | layout()->addWidget(d->m_view); | ||
120 | 120 | | |||
121 | findWidget->setEnabled(true); | 121 | findWidget->setEnabled(true); | ||
122 | connect(findWidget, &DocumentationFindWidget::newSearch, this, &StandardDocumentationView::search); | 122 | connect(findWidget, &DocumentationFindWidget::searchRequested, this, &StandardDocumentationView::search); | ||
123 | connect(findWidget, &DocumentationFindWidget::searchDataChanged, this, &StandardDocumentationView::searchIncremental); | ||||
123 | connect(findWidget, &DocumentationFindWidget::searchFinished, this, &StandardDocumentationView::finishSearch); | 124 | connect(findWidget, &DocumentationFindWidget::searchFinished, this, &StandardDocumentationView::finishSearch); | ||
124 | 125 | | |||
125 | #ifdef USE_QTWEBKIT | 126 | #ifdef USE_QTWEBKIT | ||
126 | QFont sansSerifFont = QFontDatabase::systemFont(QFontDatabase::GeneralFont); | 127 | QFont sansSerifFont = QFontDatabase::systemFont(QFontDatabase::GeneralFont); | ||
127 | QFont monospaceFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); | 128 | QFont monospaceFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); | ||
128 | 129 | | |||
129 | QWebSettings* s = d->m_view->settings(); | 130 | QWebSettings* s = d->m_view->settings(); | ||
130 | 131 | | |||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 178 | if(options & DocumentationFindWidget::Previous) | |||
178 | ff |= WebkitThing::FindBackward; | 179 | ff |= WebkitThing::FindBackward; | ||
179 | 180 | | |||
180 | if(options & DocumentationFindWidget::MatchCase) | 181 | if(options & DocumentationFindWidget::MatchCase) | ||
181 | ff |= WebkitThing::FindCaseSensitively; | 182 | ff |= WebkitThing::FindCaseSensitively; | ||
182 | 183 | | |||
183 | d->m_view->page()->findText(text, ff); | 184 | d->m_view->page()->findText(text, ff); | ||
184 | } | 185 | } | ||
185 | 186 | | |||
187 | void StandardDocumentationView::searchIncremental(const QString& text, DocumentationFindWidget::FindOptions options) | ||||
brauch: a bit unconventional naming, I'd simply go for something like "updateSearchPattern" | |||||
Changed it at least to "searchIncremental" which seems more like commonly used lingo, cmp. https://en.wikipedia.org/wiki/Incremental_search Idea with the naming was to describe the action that is done here. Would agree it still can be improved, but have no clear concept of the whole logic pattern, so lousy at naming, agreed. kossebau: Changed it at least to "searchIncremental" which seems more like commonly used lingo, cmp. | |||||
188 | { | ||||
189 | #ifdef USE_QTWEBKIT | ||||
190 | typedef QWebPage WebkitThing; | ||||
191 | #else | ||||
192 | typedef QWebEnginePage WebkitThing; | ||||
193 | #endif | ||||
194 | WebkitThing::FindFlags findFlags; | ||||
195 | | ||||
196 | if (options & DocumentationFindWidget::MatchCase) | ||||
197 | findFlags |= WebkitThing::FindCaseSensitively; | ||||
198 | | ||||
199 | // calling with changed text with added or removed chars at end will result in current | ||||
200 | // selection kept, if also matching new text | ||||
201 | // behaviour on changed case sensitivity though is advancing to next match even if current | ||||
202 | // would be still matching. as there is no control about currently shown match, nothing | ||||
203 | // we can do about it. thankfully case sensitivity does not happen too often, so should | ||||
204 | // not be too grave UX | ||||
205 | // at least with webengine 5.9.1 there is a bug when switching from no-casesensitivy to | ||||
206 | // casesensitivity, that global matches are not updated and the ones with non-matching casing | ||||
207 | // still active. no workaround so far. | ||||
208 | d->m_view->page()->findText(text, findFlags); | ||||
209 | } | ||||
210 | | ||||
186 | void StandardDocumentationView::finishSearch() | 211 | void StandardDocumentationView::finishSearch() | ||
187 | { | 212 | { | ||
188 | // passing emptry string to reset search, as told in API docs | 213 | // passing emptry string to reset search, as told in API docs | ||
189 | d->m_view->page()->findText(QString()); | 214 | d->m_view->page()->findText(QString()); | ||
190 | } | 215 | } | ||
191 | 216 | | |||
192 | void StandardDocumentationView::initZoom(const QString& configSubGroup) | 217 | void StandardDocumentationView::initZoom(const QString& configSubGroup) | ||
193 | { | 218 | { | ||
▲ Show 20 Lines • Show All 130 Lines • Show Last 20 Lines |
a bit unconventional naming, I'd simply go for something like "updateSearchPattern"