App: Use more local methods to trigger memory trim timer

The global event filter function is executed often, for events
originating deep in the widget hierarchy even multiple times.

Triggering the timer only by mouse and key presses on the main
application and on texteditor is less intrusive and still happens
often enough (TM).

Change-Id: I848d55a347bd62d12e8523965d1750c59da33116
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2022-08-02 11:04:10 +02:00
parent 9177649cab
commit df4155f617
6 changed files with 45 additions and 31 deletions

View File

@@ -2372,6 +2372,8 @@ static inline bool isPrintableText(const QString &text)
void TextEditorWidget::keyPressEvent(QKeyEvent *e)
{
ICore::restartTrimmer();
ExecuteOnDestruction eod([&]() { d->clearBlockSelection(); });
if (!isModifier(e) && mouseHidingEnabled())
@@ -5460,6 +5462,8 @@ static bool handleForwardBackwardMouseButtons(QMouseEvent *e)
void TextEditorWidget::mousePressEvent(QMouseEvent *e)
{
ICore::restartTrimmer();
if (e->button() == Qt::LeftButton) {
MultiTextCursor multiCursor = multiTextCursor();
const QTextCursor &cursor = cursorForPosition(e->pos());