aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlessandro Portale <[email protected]>2025-07-02 13:55:57 +0200
committerAlessandro Portale <[email protected]>2025-07-02 13:32:24 +0000
commit8dc8e771d05f69d143ef38e2bec65c7577ca71c1 (patch)
treefbd28a40123e6fc6f74e65c8ff9dd69c6b237af4
parentb017ceeed924715c7ea94ddb92317a0d252eefc2 (diff)
Learning: Use Utils::OverlayWidget as mouse catcher
Change-Id: I406d1cad40dd48a0889585779e6c281325767864 Reviewed-by: Marcus Tillmanns <[email protected]>
-rw-r--r--src/plugins/learning/qtacademywelcomepage.cpp38
1 files changed, 6 insertions, 32 deletions
diff --git a/src/plugins/learning/qtacademywelcomepage.cpp b/src/plugins/learning/qtacademywelcomepage.cpp
index dfc34552e5a..34f6076a0f7 100644
--- a/src/plugins/learning/qtacademywelcomepage.cpp
+++ b/src/plugins/learning/qtacademywelcomepage.cpp
@@ -5,6 +5,7 @@
#include "learningtr.h"
#include "utils/algorithm.h"
+#include "utils/overlaywidget.h"
#include <coreplugin/welcomepagehelper.h>
@@ -405,34 +406,6 @@ static Layouting::Grid createDetailWidget(const CourseItem *course)
// clang-format on
}
-class MouseCatcher : public QWidget
-{
- Q_OBJECT
-public:
- MouseCatcher() { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); }
-
- void mousePressEvent(QMouseEvent *event) override
- {
- if (event->type() == QEvent::MouseButtonPress) {
- QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
- if (mouseEvent->button() == Qt::LeftButton) {
- event->accept();
- emit clicked();
- }
- }
- }
-
- void paintEvent(QPaintEvent *event) override
- {
- Q_UNUSED(event);
- QPainter painter(this);
- painter.fillRect(rect(), QColor(0, 0, 0, 128));
- }
-
-signals:
- void clicked();
-};
-
class QtAcademyWelcomePageWidget final : public QWidget
{
Q_OBJECT
@@ -475,9 +448,11 @@ public:
}.emerge();
// clang-format on
- auto mouseCatcher = new MouseCatcher;
- connect(mouseCatcher, &MouseCatcher::clicked, this, [this]() {
- setSelectedCourse(nullptr);
+ auto mouseCatcher = new OverlayWidget(this);
+ mouseCatcher->attachToWidget(m_view);
+ mouseCatcher->setAttribute(Qt::WA_TransparentForMouseEvents, false);
+ mouseCatcher->setPaintFunction([](QWidget *that, QPainter &p, QPaintEvent *) {
+ p.fillRect(that->rect(), QColor(0, 0, 0, 128));
});
mouseCatcher->setVisible(false);
@@ -503,7 +478,6 @@ public:
Grid {
GridCell({
m_view,
- mouseCatcher,
Align(Qt::AlignCenter, detailWdgt),
}),
},