From ff6034574d984f2d201c033efc00faeae055691e Mon Sep 17 00:00:00 2001
From: Tobias Markmann <tm@ayena.de>
Date: Mon, 22 Aug 2016 21:12:45 +0200
Subject: Add shortcuts to change chat view font size

Test-Information:

Tested on OS X 10.11.6 with Qt 5.5.1.

Change-Id: Ie96bae26e4001b3955007064313ae76cb47c0a7e

diff --git a/Swift/QtUI/QtTextEdit.cpp b/Swift/QtUI/QtTextEdit.cpp
index 3143192..4ffd32a 100644
--- a/Swift/QtUI/QtTextEdit.cpp
+++ b/Swift/QtUI/QtTextEdit.cpp
@@ -12,6 +12,7 @@
 
 #include <QApplication>
 #include <QKeyEvent>
+#include <QKeySequence>
 #include <QMenu>
 #include <QTextDocument>
 
@@ -60,6 +61,8 @@ void QtTextEdit::keyPressEvent(QKeyEvent* event) {
                || (key == Qt::Key_Tab && modifiers == Qt::ControlModifier)
                || (key == Qt::Key_A && modifiers == Qt::AltModifier)
                || (key == Qt::Key_Tab)
+               || (event->matches(QKeySequence::ZoomIn))
+               || (event->matches(QKeySequence::ZoomOut))
     ) {
         emit unhandledKeyPressEvent(event);
     }
diff --git a/Swift/QtUI/QtWebView.cpp b/Swift/QtUI/QtWebView.cpp
index b8eb7a5..abdc17a 100644
--- a/Swift/QtUI/QtWebView.cpp
+++ b/Swift/QtUI/QtWebView.cpp
@@ -11,6 +11,7 @@
 
 #include <QFocusEvent>
 #include <QKeyEvent>
+#include <QKeySequence>
 #include <QMenu>
 
 #include <Swiften/Base/Log.h>
@@ -29,6 +30,16 @@ QtWebView::QtWebView(QWidget* parent) : QWebView(parent), fontSizeIsMinimal(fals
 void QtWebView::keyPressEvent(QKeyEvent* event) {
     Qt::KeyboardModifiers modifiers = event->modifiers();
     int key = event->key();
+    if (event->matches(QKeySequence::ZoomIn)) {
+        event->accept();
+        emit fontGrowRequested();
+        return;
+    }
+    if (event->matches(QKeySequence::ZoomOut)) {
+        event->accept();
+        emit fontShrinkRequested();
+        return;
+    }
     if (modifiers == Qt::ShiftModifier && (key == Qt::Key_PageUp || key == Qt::Key_PageDown)) {
         modifiers = Qt::NoModifier;
     }
@@ -70,8 +81,9 @@ void QtWebView::contextMenuEvent(QContextMenuEvent* ev) {
 
     // Add our own custom actions
     menu->addAction(tr("Clear"), this, SIGNAL(clearRequested()));
-    menu->addAction(tr("Increase font size"), this, SIGNAL(fontGrowRequested()));
+    menu->addAction(tr("Increase font size"), this, SIGNAL(fontGrowRequested()), QKeySequence(QKeySequence::ZoomIn));
     QAction* shrink = new QAction(tr("Decrease font size"), this);
+    shrink->setShortcut(QKeySequence(QKeySequence::ZoomOut));
     shrink->setEnabled(!fontSizeIsMinimal);
     connect(shrink, SIGNAL(triggered()), this, SIGNAL(fontShrinkRequested()));
     menu->addAction(shrink);
-- 
cgit v0.10.2-6-g49f6