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;
|
||||
}
|
||||
}
|
||||
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 );
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue