fix webengine reslist which had stopped working at some point in qt revs. Now working with 5.9-5.12 at least

This commit is contained in:
Jean-Francois Dockes 2019-05-27 17:04:28 +02:00
parent c1553029b9
commit 2c9bc17587
2 changed files with 27 additions and 16 deletions

View File

@ -101,7 +101,23 @@ function saveLoc(ev)
} }
} }
)raw"); )raw");
#endif // webengine
bool RclWebPage::acceptNavigationRequest(const QUrl& url,
NavigationType tp,
bool isMainFrame)
{
Q_UNUSED(isMainFrame);
LOGDEB0("QWebEnginePage::acceptNavigationRequest. Type: " <<
tp << " isMainFrame " << isMainFrame << std::endl);
if (tp == QWebEnginePage::NavigationTypeLinkClicked) {
m_reslist->onLinkClicked(url);
return false;
} else {
return true;
}
}
#endif // WEBENGINE
// Decide if we set font family and style with a css section in the // Decide if we set font family and style with a css section in the
// html <head> or with qwebsettings setfont... calls. We currently do // html <head> or with qwebsettings setfont... calls. We currently do
@ -268,8 +284,8 @@ void QtGuiResListPager::suggest(const vector<string>uterms,
// Set up the links as a <href="Sold|new">. // Set up the links as a <href="Sold|new">.
for (auto& it : sugg[uit]) { for (auto& it : sugg[uit]) {
if (issimple) { if (issimple) {
it = string("<a href=\"S") + uit + "|" + it + "\">" + it = string("<a href=\"") + linkPrefix() + "S" + uit +
it + "</a>"; "|" + it + "\">" + it + "</a>";
} }
} }
} }
@ -445,9 +461,9 @@ void ResList::setFont()
// For some reason there is (12-2014) an offset of 3 between what // For some reason there is (12-2014) an offset of 3 between what
// we request from webkit and what we get. // we request from webkit and what we get.
settings()->setFontSize(QWEBSETTINGS::DefaultFontSize, settings()->setFontSize(QWEBSETTINGS::DefaultFontSize,
prefs.reslistfontsize + 3); prefs.reslistfontsize + 3);
settings()->setFontFamily(QWEBSETTINGS::StandardFont, settings()->setFontFamily(QWEBSETTINGS::StandardFont,
prefs.reslistfontfamily); prefs.reslistfontfamily);
} else { } else {
settings()->resetFontSize(QWEBSETTINGS::DefaultFontSize); settings()->resetFontSize(QWEBSETTINGS::DefaultFontSize);
settings()->resetFontFamily(QWEBSETTINGS::StandardFont); settings()->resetFontFamily(QWEBSETTINGS::StandardFont);
@ -664,7 +680,7 @@ void ResList::highlighted(const QString& )
// fair enough, else we go to next/previous result page. // fair enough, else we go to next/previous result page.
void ResList::resPageUpOrBack() void ResList::resPageUpOrBack()
{ {
#if defined(USING_WEBKIT) #if defined(USING_WEBKIT)
if (scrollIsAtTop()) { if (scrollIsAtTop()) {
resultPageBack(); resultPageBack();
} else { } else {
@ -1095,7 +1111,7 @@ void ResList::onLinkClicked(const QUrl &qurl)
break; break;
default: default:
LOGERR("ResList::onLinkClicked: bad link [" << strurl << "]\n"); LOGERR("ResList::onLinkClicked: bad link [" << strurl.substr(0,20) << "]\n");
break;// ?? break;// ??
} }
} }

View File

@ -157,21 +157,16 @@ private:
#ifdef USING_WEBENGINE #ifdef USING_WEBENGINE
// Subclass the page to hijack the link clicks // Subclass the page to hijack the link clicks
class RclWebPage: public QWebEnginePage { class RclWebPage : public QWebEnginePage {
Q_OBJECT Q_OBJECT
public: public:
RclWebPage(ResList *parent) RclWebPage(ResList *parent)
: QWebEnginePage((QWidget *)parent), m_reslist(parent) {} : QWebEnginePage((QWidget *)parent), m_reslist(parent) {}
protected: protected:
virtual bool acceptNavigationRequest(const QUrl& url, virtual bool acceptNavigationRequest(
NavigationType, const QUrl& url, NavigationType tp, bool isMainFrame);
bool) {
m_reslist->onLinkClicked(url);
return false;
}
private: private:
ResList *m_reslist; ResList *m_reslist;
}; };