fix: mouse scroll zoom in out

This commit is contained in:
yifang 2022-02-18 00:39:24 +08:00
parent b9d364e861
commit f81ac16fa6
3 changed files with 24 additions and 2 deletions

View file

@ -925,6 +925,21 @@ bool ArticleView::eventFilter( QObject * obj, QEvent * ev )
return true;
}
}
else if( ev->type() == QEvent::Wheel )
{
QWheelEvent * pe = static_cast< QWheelEvent * >( ev );
if( pe->modifiers().testFlag( Qt::ControlModifier ) )
{
if( pe->angleDelta().y() > 0 )
{
zoomIn();
}
else
{
zoomOut();
}
}
}
}
else
return QFrame::eventFilter( obj, ev );

View file

@ -182,8 +182,9 @@ public:
void setZoomFactor( qreal factor )
{
if(ui.definition->zoomFactor()!=factor){
qDebug()<<"set zoom factor:"<<factor;
qreal existedFactor = ui.definition->zoomFactor();
if(!qFuzzyCompare(existedFactor,factor)){
qDebug()<<"zoom factor ,existed:"<<existedFactor<<"set:"<<factor;
ui.definition->setZoomFactor( factor );
ui.definition->page()->setZoomFactor(factor);
}

View file

@ -26,6 +26,7 @@ ArticleWebView::~ArticleWebView()
void ArticleWebView::setUp( Config::Class * cfg )
{
this->cfg = cfg;
setZoomFactor(cfg->preferences.zoomFactor);
}
void ArticleWebView::triggerPageAction( QWebEnginePage::WebAction action, bool checked )
@ -87,6 +88,11 @@ bool ArticleWebView::eventFilter(QObject *obj, QEvent *ev) {
if (ev->type() == QEvent::Wheel) {
QWheelEvent *pe = static_cast<QWheelEvent *>(ev);
wheelEvent(pe);
if ( pe->modifiers().testFlag( Qt::ControlModifier ) )
{
return true;
}
}
if (ev->type() == QEvent::FocusIn) {
QFocusEvent *pe = static_cast<QFocusEvent *>(ev);