summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-08-22 19:12:45 (GMT)
committerTobias Markmann <tm@ayena.de>2016-08-22 19:12:45 (GMT)
commitff6034574d984f2d201c033efc00faeae055691e (patch)
tree5f3ea2dff15515b61e92384edf0fc8a02d7c8f1c
parentec40ba1c1ff258bfe24bc5e7b024cf2e6eaed810 (diff)
downloadswift-ff6034574d984f2d201c033efc00faeae055691e.zip
swift-ff6034574d984f2d201c033efc00faeae055691e.tar.bz2
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
-rw-r--r--Swift/QtUI/QtTextEdit.cpp3
-rw-r--r--Swift/QtUI/QtWebView.cpp14
2 files changed, 16 insertions, 1 deletions
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);