From c9f52b7223685d2e7fca925594171f94dd8c6e3b Mon Sep 17 00:00:00 2001 From: TrickyLeifa Date: Wed, 15 May 2024 00:00:17 +0200 Subject: Ported to CMake, ... * Ported the project to CMake * Android and Mac support dropped for the time being. * Tests, BASS and Discord-RPC are now options * Restructured and reformated the project. * Merged `include` and `src` * Renamed `resource` to `data` * Renamed various files * External libraries headers are no longer included in `src` * Replaced header guards with #pragma once * Multiple refactors (keywords, headers) * Added Qt6 compatibility * Removed various unused functions and headers * Reworked AOPacket * When content is passed to AOPacket, it should be ensured that the content is already decoded. * Encoding/decoding are now static methods. * Fixed various memory leaks * Removed animation code for AOImage * AOImage is always using static images * Simplified ChatLogPiece --- src/eventfilters.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/eventfilters.cpp (limited to 'src/eventfilters.cpp') diff --git a/src/eventfilters.cpp b/src/eventfilters.cpp new file mode 100644 index 00000000..2e11b587 --- /dev/null +++ b/src/eventfilters.cpp @@ -0,0 +1,21 @@ +#include "eventfilters.h" + +bool AOLineEditFilter::eventFilter(QObject *obj, QEvent *event) +{ + QLineEdit *lineEdit = qobject_cast(obj); + if (event->type() == QEvent::FocusOut && lineEdit != nullptr && preserve_selection) + { // lost focus + int start = lineEdit->selectionStart(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) + int len = lineEdit->selectionLength(); +#else + int len = lineEdit->selectedText().length(); +#endif + if (start != -1 && len != -1) + { + lineEdit->setSelection(start, len); + return true; + } + } + return false; +} -- cgit From 657145035cd66c18ae777e1272fd5221dddca0ef Mon Sep 17 00:00:00 2001 From: TrickyLeifa Date: Fri, 17 May 2024 23:54:41 +0200 Subject: Reimplemented unit tests, ... * Reimplemented unit tests and simplified addition of new tests * Minimal support of Qt is now 5.15 --- src/eventfilters.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/eventfilters.cpp') diff --git a/src/eventfilters.cpp b/src/eventfilters.cpp index 2e11b587..6f0b0f12 100644 --- a/src/eventfilters.cpp +++ b/src/eventfilters.cpp @@ -6,11 +6,8 @@ bool AOLineEditFilter::eventFilter(QObject *obj, QEvent *event) if (event->type() == QEvent::FocusOut && lineEdit != nullptr && preserve_selection) { // lost focus int start = lineEdit->selectionStart(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) int len = lineEdit->selectionLength(); -#else - int len = lineEdit->selectedText().length(); -#endif + if (start != -1 && len != -1) { lineEdit->setSelection(start, len); -- cgit