From f4246a23eb76cb09c1a603d54891f80ec1e54eb5 Mon Sep 17 00:00:00 2001
From: Tobias Markmann <tm@ayena.de>
Date: Mon, 20 Feb 2017 17:23:59 +0100
Subject: Add alternative zoom shortcuts on macOS and workaround Qt bug

This adds the Ctrl + Minus and Ctrl + Equal shortcuts for
zoom out and zoom in respectively.

In addition, this commit provides a workaround for QTBUG-56571.

Test-Information:

Tested on macOS 10.12.3 with Qt 5.7.1. Tested with German
and UK keyboard layout. On UK layout both shortcuts,
Ctrl + (+/-) and Ctrl + (=/-) work. On German layout only
Ctrl + (+/-) works.

Change-Id: Ifbcab308c9a8f4c88b51978969c73c3c1138a9ba

diff --git a/Swift/QtUI/QtTextEdit.cpp b/Swift/QtUI/QtTextEdit.cpp
index e9708bf..1b4d76d 100644
--- a/Swift/QtUI/QtTextEdit.cpp
+++ b/Swift/QtUI/QtTextEdit.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2017 Isode Limited.
  * All rights reserved.
  * See the COPYING file for more information.
  */
@@ -59,6 +59,10 @@ void QtTextEdit::keyPressEvent(QKeyEvent* event) {
                || (key == Qt::Key_Tab && modifiers == Qt::ControlModifier)
                || (key == Qt::Key_A && modifiers == Qt::AltModifier)
                || (key == Qt::Key_Tab)
+#ifdef SWIFTEN_PLATFORM_MACOSX
+               || (key == Qt::Key_Minus && (modifiers & Qt::ControlModifier))
+               || (key == Qt::Key_Equal && (modifiers & Qt::ControlModifier))
+#endif
                || (event->matches(QKeySequence::ZoomIn))
                || (event->matches(QKeySequence::ZoomOut))
     ) {
diff --git a/Swift/QtUI/QtWebView.cpp b/Swift/QtUI/QtWebView.cpp
index abdc17a..967be1a 100644
--- a/Swift/QtUI/QtWebView.cpp
+++ b/Swift/QtUI/QtWebView.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2017 Isode Limited.
  * All rights reserved.
  * See the COPYING file for more information.
  */
@@ -30,12 +30,12 @@ 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)) {
+    if (event->matches(QKeySequence::ZoomIn) || (key == Qt::Key_Equal && (modifiers & Qt::ControlModifier))) {
         event->accept();
         emit fontGrowRequested();
         return;
     }
-    if (event->matches(QKeySequence::ZoomOut)) {
+    if (event->matches(QKeySequence::ZoomOut) || (key == Qt::Key_Minus && (modifiers & Qt::ControlModifier))) {
         event->accept();
         emit fontShrinkRequested();
         return;
-- 
cgit v0.10.2-6-g49f6