mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 04:24:09 +00:00
fix: mouse scroll zoom in out
This commit is contained in:
parent
b9d364e861
commit
f81ac16fa6
|
@ -925,6 +925,21 @@ bool ArticleView::eventFilter( QObject * obj, QEvent * ev )
|
||||||
return true;
|
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
|
else
|
||||||
return QFrame::eventFilter( obj, ev );
|
return QFrame::eventFilter( obj, ev );
|
||||||
|
|
|
@ -182,8 +182,9 @@ public:
|
||||||
|
|
||||||
void setZoomFactor( qreal factor )
|
void setZoomFactor( qreal factor )
|
||||||
{
|
{
|
||||||
if(ui.definition->zoomFactor()!=factor){
|
qreal existedFactor = ui.definition->zoomFactor();
|
||||||
qDebug()<<"set zoom factor:"<<factor;
|
if(!qFuzzyCompare(existedFactor,factor)){
|
||||||
|
qDebug()<<"zoom factor ,existed:"<<existedFactor<<"set:"<<factor;
|
||||||
ui.definition->setZoomFactor( factor );
|
ui.definition->setZoomFactor( factor );
|
||||||
ui.definition->page()->setZoomFactor(factor);
|
ui.definition->page()->setZoomFactor(factor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ ArticleWebView::~ArticleWebView()
|
||||||
void ArticleWebView::setUp( Config::Class * cfg )
|
void ArticleWebView::setUp( Config::Class * cfg )
|
||||||
{
|
{
|
||||||
this->cfg = cfg;
|
this->cfg = cfg;
|
||||||
|
setZoomFactor(cfg->preferences.zoomFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArticleWebView::triggerPageAction( QWebEnginePage::WebAction action, bool checked )
|
void ArticleWebView::triggerPageAction( QWebEnginePage::WebAction action, bool checked )
|
||||||
|
@ -87,6 +88,11 @@ bool ArticleWebView::eventFilter(QObject *obj, QEvent *ev) {
|
||||||
if (ev->type() == QEvent::Wheel) {
|
if (ev->type() == QEvent::Wheel) {
|
||||||
QWheelEvent *pe = static_cast<QWheelEvent *>(ev);
|
QWheelEvent *pe = static_cast<QWheelEvent *>(ev);
|
||||||
wheelEvent(pe);
|
wheelEvent(pe);
|
||||||
|
|
||||||
|
if ( pe->modifiers().testFlag( Qt::ControlModifier ) )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ev->type() == QEvent::FocusIn) {
|
if (ev->type() == QEvent::FocusIn) {
|
||||||
QFocusEvent *pe = static_cast<QFocusEvent *>(ev);
|
QFocusEvent *pe = static_cast<QFocusEvent *>(ev);
|
||||||
|
|
Loading…
Reference in a new issue