diff options
author | 2023-03-07 23:12:12 +0600 | |
---|---|---|
committer | 2023-03-07 23:12:12 +0600 | |
commit | 8130e7616ca9260b2bafd7cc1a0d066bfa442997 (patch) | |
tree | 196b6ca40e43c79299d781ebd767eb7e2ac65c8f /src/webview.cpp | |
parent | b6fd8414a4387cac5c03d2a9e9529086acb484c9 (diff) | |
parent | 594d9515ac0bc0adf50ae288b85e31c10bd90d27 (diff) | |
download | whatsie-8130e7616ca9260b2bafd7cc1a0d066bfa442997.tar.gz whatsie-8130e7616ca9260b2bafd7cc1a0d066bfa442997.zip |
Update upstream source from tag 'upstream/4.12.1'
Update to upstream version '4.12.1'
with Debian dir 20fc3fb6707b619235ac02b06cb881c2422626d2
Diffstat (limited to '')
-rw-r--r-- | src/webview.cpp | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/webview.cpp b/src/webview.cpp index cfd9af9..8029ffd 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -8,7 +8,7 @@ WebView::WebView(QWidget *parent, QStringList dictionaries) : QWebEngineView(parent) { - m_dictionaries = dictionaries; + dictionaries = dictionaries; QObject *parentMainWindow = this->parent(); while (!parentMainWindow->objectName().contains("MainWindow")) { @@ -49,18 +49,23 @@ WebView::WebView(QWidget *parent, QStringList dictionaries) } void WebView::wheelEvent(QWheelEvent *event) { - if (event->modifiers().testFlag(Qt::ControlModifier)) { + bool controlKeyIsHeld = + QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier); + // this doesn't work, (even after checking the global QApplication keyboard + // modifiers) as expected, the Ctrl+wheel is managed by Chromium + // WebenginePage directly. So, we manage it by injecting js to page using + // WebEnginePage::injectPreventScrollWheelZoomHelper + if ((event->modifiers() & Qt::ControlModifier) != 0 || controlKeyIsHeld) { qDebug() << "skipped ctrl + m_wheel event on webengineview"; - // do nothing + event->ignore(); } else { - qDebug() << "wheel event on webengine view"; QWebEngineView::wheelEvent(event); } } void WebView::contextMenuEvent(QContextMenuEvent *event) { - QMenu *menu = page()->createStandardContextMenu(); + auto menu = page()->createStandardContextMenu(); menu->setAttribute(Qt::WA_DeleteOnClose, true); // hide reload, back, forward, savepage, copyimagelink menus foreach (auto *action, menu->actions()) { @@ -87,29 +92,27 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) { return; } - QWebEngineProfile *profile = page()->profile(); - const QStringList &languages = profile->spellCheckLanguages(); - + auto pageWebengineProfile = page()->profile(); + const QStringList &languages = pageWebengineProfile->spellCheckLanguages(); menu->addSeparator(); - - QAction *spellcheckAction = new QAction(tr("Check Spelling"), menu); + auto *spellcheckAction = new QAction(tr("Check Spelling"), menu); spellcheckAction->setCheckable(true); - spellcheckAction->setChecked(profile->isSpellCheckEnabled()); + spellcheckAction->setChecked(pageWebengineProfile->isSpellCheckEnabled()); connect(spellcheckAction, &QAction::toggled, this, - [profile, this](bool toogled) { - profile->setSpellCheckEnabled(toogled); + [pageWebengineProfile, this](bool toogled) { + pageWebengineProfile->setSpellCheckEnabled(toogled); settings.setValue("sc_enabled", toogled); }); menu->addAction(spellcheckAction); - if (profile->isSpellCheckEnabled()) { - QMenu *subMenu = menu->addMenu(tr("Select Language")); - for (const QString &dict : qAsConst(m_dictionaries)) { - QAction *action = subMenu->addAction(dict); + if (pageWebengineProfile->isSpellCheckEnabled()) { + auto subMenu = menu->addMenu(tr("Select Language")); + for (const QString &dict : qAsConst(dictionaries)) { + auto action = subMenu->addAction(dict); action->setCheckable(true); action->setChecked(languages.contains(dict)); - connect(action, &QAction::triggered, this, [profile, dict, this]() { - profile->setSpellCheckLanguages(QStringList() << dict); + connect(action, &QAction::triggered, this, [pageWebengineProfile, dict, this]() { + pageWebengineProfile->setSpellCheckLanguages(QStringList() << dict); settings.setValue("sc_dict", dict); }); } |