Commit 84bc0573 authored by Simon Depiets's avatar Simon Depiets
Browse files

Link zoom in source and target panels

BUG:413497
Linking the zoom in source and target panels by setting the same fontPointSize.
parent 2356fdcc
......@@ -131,6 +131,8 @@ EditorView::EditorView(QWidget *parent, Catalog* catalog/*,keyEventHandler* kh*/
connect(m_targetTextEdit, &TranslationUnitTextEdit::findNextRequested, this, &EditorView::findNextRequested);
connect(m_sourceTextEdit, &TranslationUnitTextEdit::replaceRequested, this, &EditorView::replaceRequested);
connect(m_targetTextEdit, &TranslationUnitTextEdit::replaceRequested, this, &EditorView::replaceRequested);
connect(m_sourceTextEdit, &TranslationUnitTextEdit::zoomRequested, m_targetTextEdit, &TranslationUnitTextEdit::zoomRequestedSlot);
connect(m_targetTextEdit, &TranslationUnitTextEdit::zoomRequested, m_sourceTextEdit, &TranslationUnitTextEdit::zoomRequestedSlot);
connect(this, &EditorView::doExplicitCompletion, m_targetTextEdit, &TranslationUnitTextEdit::doExplicitCompletion);
......
......@@ -1019,17 +1019,35 @@ void insertContent(QTextCursor& cursor, const CatalogString& catStr, const Catal
// QAction* spellchecking=menu.addAction();
// event->accept();
}
void TranslationUnitTextEdit::zoomRequestedSlot(qreal fontSize)
{
QFont curFont = font();
curFont.setPointSizeF(fontSize);
setFont(curFont);
}
void TranslationUnitTextEdit::wheelEvent(QWheelEvent * event) {
//Override default KTextEdit behavior which ignores Ctrl+wheelEvent when the field is not ReadOnly (i/o zooming)
if (m_part == DocPosition::Target && !Settings::mouseWheelGo() && (event->modifiers() == Qt::ControlModifier)) {
float delta = event->angleDelta().y() / 120.f;
zoomInF(delta);
//Also zoom in the source
emit zoomRequested(font().pointSizeF());
return;
}
if (m_part == DocPosition::Source || !Settings::mouseWheelGo())
{
if (event->modifiers() == Qt::ControlModifier)
{
float delta = event->angleDelta().y() / 120.f;
zoomInF(delta);
//Also zoom in the target
emit zoomRequested(font().pointSizeF());
return;
}
return KTextEdit::wheelEvent(event);
}
switch (event->modifiers()) {
case Qt::ControlModifier:
......
......@@ -82,6 +82,7 @@ public slots:
void emitCursorPositionChanged();//for leds
void doExplicitCompletion();
void zoomRequestedSlot(qreal fontSize);
protected:
void keyPressEvent(QKeyEvent *keyEvent) override;
......@@ -132,6 +133,7 @@ signals:
void gotoPrevFuzzyUntrRequested();
void gotoNextFuzzyUntrRequested();
void gotoEntryRequested(const DocPosition&);
void zoomRequested(qreal);
void tagInsertRequested(const InlineTag& tag);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment