From e5461500b554422d9333b5749c1d22980e70aa2d Mon Sep 17 00:00:00 2001 From: Tsu Jan Date: Sat, 11 Dec 2021 10:31:15 +0330 Subject: [PATCH] Prevent unnecessary scroll jumps on undoing/redoing --- ChangeLog | 1 + NEWS | 2 +- feathernotes/about.ui | 2 ++ .../data/translations/feathernotes.ts | 2 +- .../data/translations/feathernotes_ar_DZ.ts | 2 +- .../data/translations/feathernotes_be.ts | 2 +- .../data/translations/feathernotes_bg.ts | 2 +- .../data/translations/feathernotes_ca.ts | 8 ++++---- .../data/translations/feathernotes_cs.ts | 2 +- .../data/translations/feathernotes_cy.ts | 2 +- .../data/translations/feathernotes_da.ts | 2 +- .../data/translations/feathernotes_de.ts | 2 +- .../data/translations/feathernotes_el.ts | 2 +- .../data/translations/feathernotes_eo.ts | 2 +- .../data/translations/feathernotes_es.ts | 2 +- .../data/translations/feathernotes_et.ts | 2 +- .../data/translations/feathernotes_fa.ts | 2 +- .../data/translations/feathernotes_fi.ts | 2 +- .../data/translations/feathernotes_fr.ts | 2 +- .../data/translations/feathernotes_he.ts | 2 +- .../data/translations/feathernotes_hr.ts | 2 +- .../data/translations/feathernotes_hu.ts | 2 +- .../data/translations/feathernotes_id.ts | 2 +- .../data/translations/feathernotes_it.ts | 2 +- .../data/translations/feathernotes_ja.ts | 2 +- .../data/translations/feathernotes_ko.ts | 2 +- .../data/translations/feathernotes_lt.ts | 2 +- .../data/translations/feathernotes_nb_NO.ts | 2 +- .../data/translations/feathernotes_nl.ts | 2 +- .../data/translations/feathernotes_pl.ts | 2 +- .../data/translations/feathernotes_pt.ts | 2 +- .../data/translations/feathernotes_pt_BR.ts | 2 +- .../data/translations/feathernotes_ru.ts | 2 +- .../data/translations/feathernotes_si.ts | 2 +- .../data/translations/feathernotes_sk_SK.ts | 2 +- .../data/translations/feathernotes_tr.ts | 2 +- .../data/translations/feathernotes_uk.ts | 2 +- .../data/translations/feathernotes_zh_CN.ts | 2 +- .../data/translations/feathernotes_zh_HANT.ts | 2 +- feathernotes/textedit.cpp | 19 +++++++++++++++++++ 40 files changed, 62 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index c8503865..604939b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ V0.10.0 * Scroll one page per wheel turn when the cursor is on the vertical scrollbar and half the page when Shift is also pressed. * Scroll the view up/down by a single step without moving text cursor with Ctrl+Up/Down. Also, scroll the view up/down by one page without moving text cursor with Ctrl+PageUp/PageDown. * Don't try to save or restore window position under Wayland because, otherwise, menus might appear at wrong positions. + * Don't let QTextEdit's built-in undo/redo shortcuts cause a scroll jump when there's nothing to undo/redo. V0.9.0 --------- diff --git a/NEWS b/NEWS index 0fb19681..5eb4999f 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,5 @@ Latest version: - 23 Nov 2021, V0.10.0 + 11 Dec 2021, V0.10.0 See "ChangeLog" for changes. diff --git a/feathernotes/about.ui b/feathernotes/about.ui index 5cb9b15c..e9cf1f89 100644 --- a/feathernotes/about.ui +++ b/feathernotes/about.ui @@ -97,6 +97,8 @@ <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Catalan:</span> Joan Miró</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Chinese:</span> You-Sheng Yang <a href="https://github.com/vicamo">(vicamo at GitHub)</a>, <a href="https://github.com/BavonChao">BavonChao at GitHub</a>, <a href="https://github.com/theyearthewas">theyearthewas at GitHub</a>, <a href="https://github.com/Python-37">Python-37 at GitHub</a></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Czech:</span> <a href="https://github.com/p-bo">p-bo at GitHub</a>, <a href="https://github.com/pafri">pafri at GitHub</a></p> diff --git a/feathernotes/data/translations/feathernotes.ts b/feathernotes/data/translations/feathernotes.ts index 24d06ffa..2d45c345 100644 --- a/feathernotes/data/translations/feathernotes.ts +++ b/feathernotes/data/translations/feathernotes.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License diff --git a/feathernotes/data/translations/feathernotes_ar_DZ.ts b/feathernotes/data/translations/feathernotes_ar_DZ.ts index 53e6bfd4..b5deac49 100644 --- a/feathernotes/data/translations/feathernotes_ar_DZ.ts +++ b/feathernotes/data/translations/feathernotes_ar_DZ.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License diff --git a/feathernotes/data/translations/feathernotes_be.ts b/feathernotes/data/translations/feathernotes_be.ts index 1fdbb2b2..ecf623e4 100644 --- a/feathernotes/data/translations/feathernotes_be.ts +++ b/feathernotes/data/translations/feathernotes_be.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License diff --git a/feathernotes/data/translations/feathernotes_bg.ts b/feathernotes/data/translations/feathernotes_bg.ts index 4f6148b9..0a785237 100644 --- a/feathernotes/data/translations/feathernotes_bg.ts +++ b/feathernotes/data/translations/feathernotes_bg.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Лиценз diff --git a/feathernotes/data/translations/feathernotes_ca.ts b/feathernotes/data/translations/feathernotes_ca.ts index a0f5cf6b..4348d4fd 100644 --- a/feathernotes/data/translations/feathernotes_ca.ts +++ b/feathernotes/data/translations/feathernotes_ca.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Llicència @@ -1783,7 +1783,7 @@ Takes effect after closing this dialog. Spell Checking - + Comprovació ortogràfica @@ -1881,7 +1881,7 @@ name but ending with ".aff". Replace with: - + Reemplaça per: @@ -1918,7 +1918,7 @@ name but ending with ".aff". New Node - + Nou node diff --git a/feathernotes/data/translations/feathernotes_cs.ts b/feathernotes/data/translations/feathernotes_cs.ts index 52a58d90..bcb43cc8 100644 --- a/feathernotes/data/translations/feathernotes_cs.ts +++ b/feathernotes/data/translations/feathernotes_cs.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Licence diff --git a/feathernotes/data/translations/feathernotes_cy.ts b/feathernotes/data/translations/feathernotes_cy.ts index b66765da..81334152 100644 --- a/feathernotes/data/translations/feathernotes_cy.ts +++ b/feathernotes/data/translations/feathernotes_cy.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License diff --git a/feathernotes/data/translations/feathernotes_da.ts b/feathernotes/data/translations/feathernotes_da.ts index 2f149629..eb8e6cc4 100644 --- a/feathernotes/data/translations/feathernotes_da.ts +++ b/feathernotes/data/translations/feathernotes_da.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License diff --git a/feathernotes/data/translations/feathernotes_de.ts b/feathernotes/data/translations/feathernotes_de.ts index 1424d699..b34f0c90 100644 --- a/feathernotes/data/translations/feathernotes_de.ts +++ b/feathernotes/data/translations/feathernotes_de.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Lizenz diff --git a/feathernotes/data/translations/feathernotes_el.ts b/feathernotes/data/translations/feathernotes_el.ts index a25ebfdd..1e72c2ac 100644 --- a/feathernotes/data/translations/feathernotes_el.ts +++ b/feathernotes/data/translations/feathernotes_el.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Άδεια χρήσης diff --git a/feathernotes/data/translations/feathernotes_eo.ts b/feathernotes/data/translations/feathernotes_eo.ts index 4c6e0de5..07feb8b0 100644 --- a/feathernotes/data/translations/feathernotes_eo.ts +++ b/feathernotes/data/translations/feathernotes_eo.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Licenco diff --git a/feathernotes/data/translations/feathernotes_es.ts b/feathernotes/data/translations/feathernotes_es.ts index 98ae9435..cef1e482 100644 --- a/feathernotes/data/translations/feathernotes_es.ts +++ b/feathernotes/data/translations/feathernotes_es.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Licencia diff --git a/feathernotes/data/translations/feathernotes_et.ts b/feathernotes/data/translations/feathernotes_et.ts index 5a41587e..4d721985 100644 --- a/feathernotes/data/translations/feathernotes_et.ts +++ b/feathernotes/data/translations/feathernotes_et.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Litsents diff --git a/feathernotes/data/translations/feathernotes_fa.ts b/feathernotes/data/translations/feathernotes_fa.ts index 4222048b..b28df2e9 100644 --- a/feathernotes/data/translations/feathernotes_fa.ts +++ b/feathernotes/data/translations/feathernotes_fa.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License مجوز diff --git a/feathernotes/data/translations/feathernotes_fi.ts b/feathernotes/data/translations/feathernotes_fi.ts index 2e076d59..a40ec025 100644 --- a/feathernotes/data/translations/feathernotes_fi.ts +++ b/feathernotes/data/translations/feathernotes_fi.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Lisenssi diff --git a/feathernotes/data/translations/feathernotes_fr.ts b/feathernotes/data/translations/feathernotes_fr.ts index 882da8a0..9f4fce17 100644 --- a/feathernotes/data/translations/feathernotes_fr.ts +++ b/feathernotes/data/translations/feathernotes_fr.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Licence diff --git a/feathernotes/data/translations/feathernotes_he.ts b/feathernotes/data/translations/feathernotes_he.ts index 3bd784dd..71bcaf5d 100644 --- a/feathernotes/data/translations/feathernotes_he.ts +++ b/feathernotes/data/translations/feathernotes_he.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License רישיון diff --git a/feathernotes/data/translations/feathernotes_hr.ts b/feathernotes/data/translations/feathernotes_hr.ts index 36f34b97..768c61ed 100644 --- a/feathernotes/data/translations/feathernotes_hr.ts +++ b/feathernotes/data/translations/feathernotes_hr.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License diff --git a/feathernotes/data/translations/feathernotes_hu.ts b/feathernotes/data/translations/feathernotes_hu.ts index 79f3e896..6e0d6e02 100644 --- a/feathernotes/data/translations/feathernotes_hu.ts +++ b/feathernotes/data/translations/feathernotes_hu.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Licenc diff --git a/feathernotes/data/translations/feathernotes_id.ts b/feathernotes/data/translations/feathernotes_id.ts index 83c9ba5a..5b4abef2 100644 --- a/feathernotes/data/translations/feathernotes_id.ts +++ b/feathernotes/data/translations/feathernotes_id.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Lisensi diff --git a/feathernotes/data/translations/feathernotes_it.ts b/feathernotes/data/translations/feathernotes_it.ts index 55b1f1fc..893ce61c 100644 --- a/feathernotes/data/translations/feathernotes_it.ts +++ b/feathernotes/data/translations/feathernotes_it.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Licenza diff --git a/feathernotes/data/translations/feathernotes_ja.ts b/feathernotes/data/translations/feathernotes_ja.ts index a442f65b..9e358db3 100644 --- a/feathernotes/data/translations/feathernotes_ja.ts +++ b/feathernotes/data/translations/feathernotes_ja.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License ライセンス diff --git a/feathernotes/data/translations/feathernotes_ko.ts b/feathernotes/data/translations/feathernotes_ko.ts index 39b78791..ad0aa57a 100644 --- a/feathernotes/data/translations/feathernotes_ko.ts +++ b/feathernotes/data/translations/feathernotes_ko.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License 라이센스 diff --git a/feathernotes/data/translations/feathernotes_lt.ts b/feathernotes/data/translations/feathernotes_lt.ts index 08f62da9..7ac81eae 100644 --- a/feathernotes/data/translations/feathernotes_lt.ts +++ b/feathernotes/data/translations/feathernotes_lt.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Licencija diff --git a/feathernotes/data/translations/feathernotes_nb_NO.ts b/feathernotes/data/translations/feathernotes_nb_NO.ts index adfee10d..b71ba41f 100644 --- a/feathernotes/data/translations/feathernotes_nb_NO.ts +++ b/feathernotes/data/translations/feathernotes_nb_NO.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Lisens diff --git a/feathernotes/data/translations/feathernotes_nl.ts b/feathernotes/data/translations/feathernotes_nl.ts index d5179506..5dc8583e 100644 --- a/feathernotes/data/translations/feathernotes_nl.ts +++ b/feathernotes/data/translations/feathernotes_nl.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Licentie diff --git a/feathernotes/data/translations/feathernotes_pl.ts b/feathernotes/data/translations/feathernotes_pl.ts index 81f05da8..a2775d69 100644 --- a/feathernotes/data/translations/feathernotes_pl.ts +++ b/feathernotes/data/translations/feathernotes_pl.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Licencja diff --git a/feathernotes/data/translations/feathernotes_pt.ts b/feathernotes/data/translations/feathernotes_pt.ts index ea2f94ff..4489f679 100644 --- a/feathernotes/data/translations/feathernotes_pt.ts +++ b/feathernotes/data/translations/feathernotes_pt.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Licença diff --git a/feathernotes/data/translations/feathernotes_pt_BR.ts b/feathernotes/data/translations/feathernotes_pt_BR.ts index 3789fd3b..0859642d 100644 --- a/feathernotes/data/translations/feathernotes_pt_BR.ts +++ b/feathernotes/data/translations/feathernotes_pt_BR.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Licença diff --git a/feathernotes/data/translations/feathernotes_ru.ts b/feathernotes/data/translations/feathernotes_ru.ts index 2a97dca7..eed770ad 100644 --- a/feathernotes/data/translations/feathernotes_ru.ts +++ b/feathernotes/data/translations/feathernotes_ru.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Лицензия diff --git a/feathernotes/data/translations/feathernotes_si.ts b/feathernotes/data/translations/feathernotes_si.ts index b427ce3a..b83acd52 100644 --- a/feathernotes/data/translations/feathernotes_si.ts +++ b/feathernotes/data/translations/feathernotes_si.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License diff --git a/feathernotes/data/translations/feathernotes_sk_SK.ts b/feathernotes/data/translations/feathernotes_sk_SK.ts index a29b60ab..9c5807d7 100644 --- a/feathernotes/data/translations/feathernotes_sk_SK.ts +++ b/feathernotes/data/translations/feathernotes_sk_SK.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Licencia diff --git a/feathernotes/data/translations/feathernotes_tr.ts b/feathernotes/data/translations/feathernotes_tr.ts index d9ab9331..73381bdc 100644 --- a/feathernotes/data/translations/feathernotes_tr.ts +++ b/feathernotes/data/translations/feathernotes_tr.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Lisans diff --git a/feathernotes/data/translations/feathernotes_uk.ts b/feathernotes/data/translations/feathernotes_uk.ts index 83b65a68..e04b8941 100644 --- a/feathernotes/data/translations/feathernotes_uk.ts +++ b/feathernotes/data/translations/feathernotes_uk.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License Ліцензія diff --git a/feathernotes/data/translations/feathernotes_zh_CN.ts b/feathernotes/data/translations/feathernotes_zh_CN.ts index 3a524d0d..76385099 100644 --- a/feathernotes/data/translations/feathernotes_zh_CN.ts +++ b/feathernotes/data/translations/feathernotes_zh_CN.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License 许可证 diff --git a/feathernotes/data/translations/feathernotes_zh_HANT.ts b/feathernotes/data/translations/feathernotes_zh_HANT.ts index 17767d73..3b11b4f3 100644 --- a/feathernotes/data/translations/feathernotes_zh_HANT.ts +++ b/feathernotes/data/translations/feathernotes_zh_HANT.ts @@ -4,7 +4,7 @@ FeatherNotes::AboutDialog - + License 許可證 diff --git a/feathernotes/textedit.cpp b/feathernotes/textedit.cpp index fb8a2954..a46c5d7e 100644 --- a/feathernotes/textedit.cpp +++ b/feathernotes/textedit.cpp @@ -164,6 +164,25 @@ void TextEdit::keyPressEvent (QKeyEvent *event) return; } + /* QWidgetTextControl::undo() and QWidgetTextControl::redo() call ensureCursorVisible() + even when there's nothing to undo/redo. Users may press the undo/redo shortcut keys + just to make sure of the state of a document and a scroll jump can confuse them when + there's nothing to undo/redo. */ + if (event == QKeySequence::Undo) + { + if (document()->isUndoAvailable()) + undo(); + event->accept(); + return; + } + if (event == QKeySequence::Redo) + { + if (document()->isRedoAvailable()) + redo(); + event->accept(); + return; + } + if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) { QTextCursor cur = textCursor();