[kde-doc-english] [trojita] src/Gui: GUI: Implement message zooming via Ctrl+Wheel scrolling
Jan Kundrát
jkt at kde.org
Thu May 26 09:52:06 UTC 2016
Git commit d3a4b236bfd36052adf437ec3f624b20bea33995 by Jan Kundrát.
Committed on 21/05/2016 at 15:26.
Pushed by gerrit into branch 'master'.
GUI: Implement message zooming via Ctrl+Wheel scrolling
Change-Id: Id1b00c11ed56cb5c273f3d5a6051d1be6236f030
M +14 -0 src/Gui/EmbeddedWebView.cpp
M +1 -0 src/Gui/EmbeddedWebView.h
M +1 -1 src/Gui/MessageView.cpp
http://commits.kde.org/trojita/d3a4b236bfd36052adf437ec3f624b20bea33995
diff --git a/src/Gui/EmbeddedWebView.cpp b/src/Gui/EmbeddedWebView.cpp
index 283042d..9e0128e 100644
--- a/src/Gui/EmbeddedWebView.cpp
+++ b/src/Gui/EmbeddedWebView.cpp
@@ -234,6 +234,20 @@ void EmbeddedWebView::mouseReleaseEvent(QMouseEvent *e)
QWebView::mouseReleaseEvent(e);
}
+void EmbeddedWebView::wheelEvent(QWheelEvent *e)
+{
+ if (e->modifiers() == Qt::ControlModifier) {
+ if (e->delta() > 0) {
+ zoomIn();
+ } else {
+ zoomOut();
+ }
+ e->accept();
+ } else {
+ e->ignore();
+ }
+}
+
const auto zoomConstant = 1.1;
void EmbeddedWebView::zoomIn()
diff --git a/src/Gui/EmbeddedWebView.h b/src/Gui/EmbeddedWebView.h
index 2c0b091..283a6e9 100644
--- a/src/Gui/EmbeddedWebView.h
+++ b/src/Gui/EmbeddedWebView.h
@@ -69,6 +69,7 @@ protected:
bool eventFilter(QObject *o, QEvent *e);
void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
+ void wheelEvent(QWheelEvent *e);
void showEvent(QShowEvent *se);
void addCustomStylesheet(const QString &css);
protected slots:
diff --git a/src/Gui/MessageView.cpp b/src/Gui/MessageView.cpp
index bac957b..829164c 100644
--- a/src/Gui/MessageView.cpp
+++ b/src/Gui/MessageView.cpp
@@ -302,7 +302,7 @@ void MessageView::stopAutoMarkAsRead()
bool MessageView::eventFilter(QObject *object, QEvent *event)
{
- if (event->type() == QEvent::Wheel) {
+ if (event->type() == QEvent::Wheel && static_cast<QWheelEvent*>(event)->modifiers() == Qt::NoModifier) {
// while the containing scrollview has Qt::StrongFocus, the event forwarding breaks that
// -> completely disable focus for the following wheel event ...
parentWidget()->setFocusPolicy(Qt::NoFocus);
More information about the kde-doc-english
mailing list