From 0bca0d3b271c35d02999354d2ee003cd7226b6a0 Mon Sep 17 00:00:00 2001 From: jolavillette Date: Wed, 31 Dec 2025 07:23:22 +0100 Subject: [PATCH] override the keyPressEvent function, enabling the statistics window to close when the Escape key is pressed --- retroshare-gui/src/gui/statistics/StatisticsWindow.cpp | 10 ++++++++++ retroshare-gui/src/gui/statistics/StatisticsWindow.h | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp b/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp index 684fdc69d..ff15eed31 100644 --- a/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp +++ b/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -228,3 +229,12 @@ void StatisticsWindow::setNewPage(int page) ui->stackPages->setCurrentIndex(page); } } + +void StatisticsWindow::keyPressEvent(QKeyEvent *event) +{ + if (event->key() == Qt::Key_Escape) { + close(); // Close window is escape is pressed + } else { + QMainWindow::keyPressEvent(event); + } +} diff --git a/retroshare-gui/src/gui/statistics/StatisticsWindow.h b/retroshare-gui/src/gui/statistics/StatisticsWindow.h index 2450812d7..47635377f 100644 --- a/retroshare-gui/src/gui/statistics/StatisticsWindow.h +++ b/retroshare-gui/src/gui/statistics/StatisticsWindow.h @@ -66,7 +66,8 @@ public slots: protected: void changeEvent(QEvent *e); - void closeEvent (QCloseEvent * event); + void closeEvent (QCloseEvent * event); + void keyPressEvent(QKeyEvent *event) override; private: void initStackedPage();